diff --git a/examples/bluetooth/nimble/power_save/README.md b/examples/bluetooth/nimble/power_save/README.md index 20c6d83c43..8b338c12d4 100644 --- a/examples/bluetooth/nimble/power_save/README.md +++ b/examples/bluetooth/nimble/power_save/README.md @@ -16,6 +16,7 @@ This example contains some build configurations. For each configuration, a few c - `sdkconfig.40m.esp32c3`: ESP32C3 uses main XTAL as low power clock in light sleep enabled. - `sdkconfig.defaults.esp32s3`: ESP32S3 uses 32kHz XTAL as low power clock in light sleep enabled. - `sdkconfig.40m.esp32s3`: ESP32S3 uses main XTAL as low power clock in light sleep enabled. +- `sdkconfig.defaults.esp32c2`: ESP32C2 uses main XTAL as low power clock in light sleep enabled. ## How to use example ### Hardware Required @@ -48,6 +49,15 @@ idf.py menuconfig 7. Enable power up main XTAL during light sleep: - `Component config > Bluetooth > Controller Options > MODEM SLEEP Options > [*] power up main XTAL during light sleep` +#### For Chip ESP32-C2 + +4. Enable bluetooth modem sleep: + - `Component config > Bluetooth > Controller Options` + - `[*] Enable BLE sleep` +5. Power down flash during light sleep: + - `Component config > Hardware Settings > Sleep Config` + - `[*] Power down flash in light sleep when there is no SPIRAM` + ### Build and Flash ``` @@ -107,8 +117,10 @@ I (463) NimBLE: | ESP32 | 231 mA | 14.1 mA | X | 1.9 mA | | ESP32C3 | 262 mA | 12 mA | 2.3 mA | 140 uA | | ESP32S3 | 240 mA | 17.9 mA | 3.3 mA | 230 uA | +| ESP32C2 | 130 mA | 18.0 mA | 2.5 mA | X | X: This feature is currently not supported. ## Example Breakdown -- ESP32 does not support the use of main XTAL in light sleep mode, so an external 32kHz crystal is required. \ No newline at end of file +- ESP32 does not support the use of main XTAL in light sleep mode, so an external 32kHz crystal is required. +- ESP32C2 does not support the use of 32KHz XTAL in light sleep mode, the XTAL frequency is set to 26MHz in default. \ No newline at end of file diff --git a/examples/bluetooth/nimble/power_save/main/Kconfig.projbuild b/examples/bluetooth/nimble/power_save/main/Kconfig.projbuild index 782afa509e..912236c456 100644 --- a/examples/bluetooth/nimble/power_save/main/Kconfig.projbuild +++ b/examples/bluetooth/nimble/power_save/main/Kconfig.projbuild @@ -2,7 +2,8 @@ menu "Example Configuration" choice EXAMPLE_MAX_CPU_FREQ prompt "Maximum CPU frequency" - default EXAMPLE_MAX_CPU_FREQ_160 + default EXAMPLE_MAX_CPU_FREQ_160 if !IDF_TARGET_ESP32C2 + default EXAMPLE_MAX_CPU_FREQ_120 if IDF_TARGET_ESP32C2 depends on PM_ENABLE help Maximum CPU frequency to use for dynamic frequency scaling. @@ -11,6 +12,9 @@ menu "Example Configuration" bool "80 MHz" config EXAMPLE_MAX_CPU_FREQ_160 bool "160 MHz" + config EXAMPLE_MAX_CPU_FREQ_120 + bool "120 MHz" + depends on IDF_TARGET_ESP32C2 config EXAMPLE_MAX_CPU_FREQ_240 bool "240 MHz" depends on IDF_TARGET_ESP32 || IDF_TARGET_ESP32S3 @@ -19,12 +23,14 @@ menu "Example Configuration" config EXAMPLE_MAX_CPU_FREQ_MHZ int default 80 if EXAMPLE_MAX_CPU_FREQ_80 + default 120 if EXAMPLE_MAX_CPU_FREQ_120 default 160 if EXAMPLE_MAX_CPU_FREQ_160 default 240 if EXAMPLE_MAX_CPU_FREQ_240 choice EXAMPLE_MIN_CPU_FREQ prompt "Minimum CPU frequency" - default EXAMPLE_MIN_CPU_FREQ_40M + default EXAMPLE_MIN_CPU_FREQ_40M if !IDF_TARGET_ESP32C2 + default EXAMPLE_MIN_CPU_FREQ_26M if IDF_TARGET_ESP32C2 depends on PM_ENABLE help Minimum CPU frequency to use for dynamic frequency scaling. @@ -42,6 +48,10 @@ menu "Example Configuration" config EXAMPLE_MIN_CPU_FREQ_40M bool "40 MHz (use with 40MHz XTAL)" depends on XTAL_FREQ_40 || XTAL_FREQ_AUTO + config EXAMPLE_MIN_CPU_FREQ_26M + bool "26 MHz (use with 26MHz XTAL)" + depends on IDF_TARGET_ESP32C2 + depends on XTAL_FREQ_26 || XTAL_FREQ_AUTO config EXAMPLE_MIN_CPU_FREQ_20M bool "20 MHz (use with 40MHz XTAL)" depends on XTAL_FREQ_40 || XTAL_FREQ_AUTO @@ -54,6 +64,7 @@ menu "Example Configuration" int default 80 if EXAMPLE_MIN_CPU_FREQ_80M default 40 if EXAMPLE_MIN_CPU_FREQ_40M + default 26 if EXAMPLE_MIN_CPU_FREQ_26M default 20 if EXAMPLE_MIN_CPU_FREQ_20M default 10 if EXAMPLE_MIN_CPU_FREQ_10M diff --git a/examples/bluetooth/nimble/power_save/main/main.c b/examples/bluetooth/nimble/power_save/main/main.c index 93b9392250..605651fd06 100644 --- a/examples/bluetooth/nimble/power_save/main/main.c +++ b/examples/bluetooth/nimble/power_save/main/main.c @@ -524,6 +524,8 @@ app_main(void) esp_pm_config_esp32c3_t pm_config = { #elif CONFIG_IDF_TARGET_ESP32S3 esp_pm_config_esp32s3_t pm_config = { +#elif CONFIG_IDF_TARGET_ESP32C2 + esp_pm_config_esp32c2_t pm_config = { #endif .max_freq_mhz = CONFIG_EXAMPLE_MAX_CPU_FREQ_MHZ, .min_freq_mhz = CONFIG_EXAMPLE_MIN_CPU_FREQ_MHZ, diff --git a/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32c2 b/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32c2 new file mode 100644 index 0000000000..9f941613f7 --- /dev/null +++ b/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32c2 @@ -0,0 +1,19 @@ +CONFIG_IDF_TARGET="esp32h2" + +# Bluetooth Low Power Config +CONFIG_BT_LE_SLEEP_ENABLE=y + +# +# Power Management +# +CONFIG_PM_ENABLE=y +CONFIG_PM_DFS_INIT_AUTO=y + +# XTAL Freq Config +CONFIG_XTAL_FREQ_26=y +CONFIG_XTAL_FREQ=26 + +# +# Sleep Config +# +CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y