Add initial esp32-P4 support (#208)

This commit is contained in:
chegewara 2024-11-01 02:06:57 +01:00 committed by GitHub
parent 8ca58f5a89
commit ed2c59d5de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 76 additions and 1 deletions

View file

@ -39,6 +39,7 @@ idf_component_register(
"esp32c3" "esp32c3"
"esp32c6" "esp32c6"
"esp32h2" "esp32h2"
"esp32p4"
INCLUDE_DIRS INCLUDE_DIRS
"src" "src"
SRCS SRCS

47
Kconfig
View file

@ -76,4 +76,51 @@ config NIMBLE_CPP_DEBUG_ASSERT_ENABLED
Enabling this option will add debug asserts to the NimBLE CPP library. Enabling this option will add debug asserts to the NimBLE CPP library.
This will use approximately 1kB of flash memory. This will use approximately 1kB of flash memory.
#
# BT config
#
config BT_ENABLED
bool "Bluetooth"
default "y"
help
Select this option to enable Bluetooth and show the submenu with Bluetooth configuration choices.
config BT_NIMBLE_ENABLED
bool "NimBLE - BLE only"
default "y"
help
This option is recommended for BLE only usecases to save on memory
if IDF_TARGET_ESP32P4
config BT_NIMBLE_TRANSPORT_UART
bool "Enable Uart Transport"
default "n"
#
# Enable ESP Hosted BT
# Used as VHCI transport between BT Host and Controller
#
config ESP_ENABLE_BT
bool "Enable Hosted Bluetooth support"
default "y"
help
Enable Bluetooth Support via Hosted
choice ESP_WIFI_REMOTE_LIBRARY
prompt "Choose WiFi-remote implementation"
default ESP_WIFI_REMOTE_LIBRARY_HOSTED
help
Select type of WiFi Remote implementation
ESP-HOSTED is the default and most versatile option.
It's also possible to use EPPP, which uses PPPoS link between micros and NAPT, so it's slower
and less universal.
config ESP_WIFI_REMOTE_LIBRARY_HOSTED
bool "ESP-HOSTED"
endchoice
endif
endmenu endmenu

16
idf_component.yml Normal file
View file

@ -0,0 +1,16 @@
## IDF Component Manager Manifest File
dependencies:
espressif/esp_hosted:
version: "*"
rules:
- if: "target in [esp32p4]"
espressif/esp_wifi_remote:
version: "*"
rules:
- if: "target in [esp32p4]"
## Required IDF version
idf:
version: ">=5.3.0"
rules:
- if: "target in [esp32p4]"

View file

@ -56,7 +56,9 @@ void NimBLEAdvertising::reset() {
m_advData.name = (uint8_t *)name; m_advData.name = (uint8_t *)name;
m_advData.name_len = strlen(name); m_advData.name_len = strlen(name);
m_advData.name_is_complete = 1; m_advData.name_is_complete = 1;
#ifndef CONFIG_IDF_TARGET_ESP32P4
m_advData.tx_pwr_lvl = NimBLEDevice::getPower(); m_advData.tx_pwr_lvl = NimBLEDevice::getPower();
#endif
m_advData.flags = (BLE_HS_ADV_F_DISC_GEN | BLE_HS_ADV_F_BREDR_UNSUP); m_advData.flags = (BLE_HS_ADV_F_DISC_GEN | BLE_HS_ADV_F_BREDR_UNSUP);
#if !defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL) #if !defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
@ -1018,7 +1020,9 @@ void NimBLEAdvertisementData::addTxPower() {
char cdata[3]; char cdata[3];
cdata[0] = BLE_HS_ADV_TX_PWR_LVL_LEN + 1; cdata[0] = BLE_HS_ADV_TX_PWR_LVL_LEN + 1;
cdata[1] = BLE_HS_ADV_TYPE_TX_PWR_LVL; cdata[1] = BLE_HS_ADV_TYPE_TX_PWR_LVL;
#ifndef CONFIG_IDF_TARGET_ESP32P4
cdata[2] = NimBLEDevice::getPower(); cdata[2] = NimBLEDevice::getPower();
#endif
addData(cdata, 3); addData(cdata, 3);
} // addTxPower } // addTxPower

View file

@ -20,7 +20,9 @@
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
# include "esp_err.h" # include "esp_err.h"
#ifndef CONFIG_IDF_TARGET_ESP32P4
# include "esp_bt.h" # include "esp_bt.h"
#endif
# include "nvs_flash.h" # include "nvs_flash.h"
# if defined(CONFIG_NIMBLE_CPP_IDF) # if defined(CONFIG_NIMBLE_CPP_IDF)
# if (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) || CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE) # if (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) || CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE)
@ -360,6 +362,7 @@ NimBLEClient* NimBLEDevice::getDisconnectedClient() {
#endif // #if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL) #endif // #if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
#ifndef CONFIG_IDF_TARGET_ESP32P4
/** /**
* @brief Set the transmission power. * @brief Set the transmission power.
* @param [in] powerLevel The power level to set, can be one of: * @param [in] powerLevel The power level to set, can be one of:
@ -438,7 +441,7 @@ int NimBLEDevice::getPower(esp_ble_power_type_t powerType) {
return BLE_HS_ADV_TX_PWR_LVL_AUTO; return BLE_HS_ADV_TX_PWR_LVL_AUTO;
} }
} // getPower } // getPower
#endif
#else #else
void NimBLEDevice::setPower(int dbm) { void NimBLEDevice::setPower(int dbm) {

View file

@ -42,8 +42,10 @@ class NimBLEClient;
#include "NimBLEAddress.h" #include "NimBLEAddress.h"
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
#ifndef CONFIG_IDF_TARGET_ESP32P4
# include "esp_bt.h" # include "esp_bt.h"
#endif #endif
#endif
#include <string> #include <string>
#include <array> #include <array>
@ -116,8 +118,10 @@ public:
#endif #endif
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
#ifndef CONFIG_IDF_TARGET_ESP32P4
static void setPower(esp_power_level_t powerLevel, esp_ble_power_type_t powerType=ESP_BLE_PWR_TYPE_DEFAULT); static void setPower(esp_power_level_t powerLevel, esp_ble_power_type_t powerType=ESP_BLE_PWR_TYPE_DEFAULT);
static int getPower(esp_ble_power_type_t powerType=ESP_BLE_PWR_TYPE_DEFAULT); static int getPower(esp_ble_power_type_t powerType=ESP_BLE_PWR_TYPE_DEFAULT);
#endif
static void setOwnAddrType(uint8_t own_addr_type, bool useNRPA=false); static void setOwnAddrType(uint8_t own_addr_type, bool useNRPA=false);
static void setScanDuplicateCacheSize(uint16_t cacheSize); static void setScanDuplicateCacheSize(uint16_t cacheSize);
static void setScanFilterMode(uint8_t type); static void setScanFilterMode(uint8_t type);