diff --git a/components/bt/controller/esp32/bt.c b/components/bt/controller/esp32/bt.c index b046109d1a..8808618c81 100644 --- a/components/bt/controller/esp32/bt.c +++ b/components/bt/controller/esp32/bt.c @@ -1394,7 +1394,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) #if CONFIG_BTDM_CTRL_LPCLK_SEL_EXT_32K_XTAL // check whether or not EXT_CRYS is working if (rtc_clk_slow_freq_get() == RTC_SLOW_FREQ_32K_XTAL) { - btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL32K; // set default value + btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL32K; // External 32kHz XTAL #ifdef CONFIG_PM_ENABLE s_btdm_allow_light_sleep = true; #endif diff --git a/components/bt/controller/esp32c3/Kconfig.in b/components/bt/controller/esp32c3/Kconfig.in index 6f8fee6cd3..c30f80bc45 100644 --- a/components/bt/controller/esp32c3/Kconfig.in +++ b/components/bt/controller/esp32c3/Kconfig.in @@ -359,7 +359,8 @@ menu "MODEM SLEEP Options" bool "Internal 150kHz RC oscillator" depends on ESP32C3_RTC_CLK_SRC_INT_RC help - Internal 150kHz RC oscillator. + Internal 150kHz RC oscillator. The accuracy of this clock is a lot larger than 500ppm which is required + in Bluetooth communication, so don't select this option in scenarios such as BLE connection state. endchoice diff --git a/components/bt/controller/esp32c3/bt.c b/components/bt/controller/esp32c3/bt.c index c4cd255fc7..8c1b116343 100644 --- a/components/bt/controller/esp32c3/bt.c +++ b/components/bt/controller/esp32c3/bt.c @@ -992,7 +992,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) // configure and initialize resources s_lp_cntl.enable = (cfg->sleep_mode == ESP_BT_SLEEP_MODE_1) ? 1 : 0; - s_lp_cntl.no_light_sleep = 0; + s_lp_cntl.no_light_sleep = 1; if (s_lp_cntl.enable) { #if (CONFIG_MAC_BB_PD) @@ -1029,31 +1029,29 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT; btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac); - // // set default bluetooth sleep clock source - // s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL; + // set default bluetooth sleep clock source + s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value #if CONFIG_BT_CTRL_LPCLK_SEL_EXT_32K_XTAL // check whether or not EXT_CRYS is working if (rtc_clk_slow_freq_get() == RTC_SLOW_FREQ_32K_XTAL) { - s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL32K; // set default value -// #ifdef CONFIG_PM_ENABLE -// s_btdm_allow_light_sleep = true; -// #endif + s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL32K; // External 32 kHz XTAL + s_lp_cntl.no_light_sleep = 0; } else { ESP_LOGW(BTDM_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock\n" "light sleep mode will not be able to apply when bluetooth is enabled"); - s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value } #elif (CONFIG_BT_CTRL_LPCLK_SEL_RTC_SLOW) // check whether or not EXT_CRYS is working if (rtc_clk_slow_freq_get() == RTC_SLOW_FREQ_RTC) { - s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_RTC_SLOW; // set default value + s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_RTC_SLOW; // Internal 150 kHz RC oscillator + ESP_LOGW(BTDM_LOG_TAG, "Internal 150kHz RC osciallator. The accuracy of this clock is a lot larger than 500ppm which is " + "required in Bluetooth communication, so don't select this option in scenarios such as BLE connection state."); } else { - ESP_LOGW(BTDM_LOG_TAG, "Internal 150kHz RC oscillator not detected, fall back to main XTAL as Bluetooth sleep clock\n" - "light sleep mode will not be able to apply when bluetooth is enabled"); - s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value + ESP_LOGW(BT_LOG_TAG, "Internal 150kHz RC oscillator not detected."); + assert(0); } #else - s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value + s_lp_cntl.no_light_sleep = 1; #endif bool select_src_ret __attribute__((unused)); diff --git a/components/bt/controller/esp32s3/Kconfig.in b/components/bt/controller/esp32s3/Kconfig.in index 53ca7b0616..359dac7b54 100644 --- a/components/bt/controller/esp32s3/Kconfig.in +++ b/components/bt/controller/esp32s3/Kconfig.in @@ -373,10 +373,11 @@ menu "MODEM SLEEP Options" modem sleep to be used with both DFS and light sleep. config BT_CTRL_LPCLK_SEL_RTC_SLOW - bool "Internal 90kHz RC oscillator" + bool "Internal 150kHz RC oscillator" depends on ESP32S3_RTC_CLK_SRC_INT_RC help - Internal 90kHz RC oscillator. + Internal 150kHz RC oscillator. The accuracy of this clock is a lot larger than 500ppm which is required + in Bluetooth communication, so don't select this option in scenarios such as BLE connection state. endchoice diff --git a/components/bt/controller/esp32s3/bt.c b/components/bt/controller/esp32s3/bt.c index a4bacd2d3e..4190c7b05a 100644 --- a/components/bt/controller/esp32s3/bt.c +++ b/components/bt/controller/esp32s3/bt.c @@ -972,7 +972,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) // configure and initialize resources s_lp_cntl.enable = (cfg->sleep_mode == ESP_BT_SLEEP_MODE_1) ? 1 : 0; - s_lp_cntl.no_light_sleep = 0; + s_lp_cntl.no_light_sleep = 1; if (s_lp_cntl.enable) { #if (CONFIG_MAC_BB_PD) @@ -1009,31 +1009,29 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT; btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac); - // // set default bluetooth sleep clock source - // s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL; + // set default bluetooth sleep clock source + s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value #if CONFIG_BT_CTRL_LPCLK_SEL_EXT_32K_XTAL // check whether or not EXT_CRYS is working if (rtc_clk_slow_freq_get() == RTC_SLOW_FREQ_32K_XTAL) { - s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL32K; // set default value -// #ifdef CONFIG_PM_ENABLE -// s_btdm_allow_light_sleep = true; -// #endif + s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL32K; // External 32 kHz XTAL + s_lp_cntl.no_light_sleep = 0; } else { ESP_LOGW(BT_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock\n" "light sleep mode will not be able to apply when bluetooth is enabled"); - s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value } #elif (CONFIG_BT_CTRL_LPCLK_SEL_RTC_SLOW) // check whether or not EXT_CRYS is working if (rtc_clk_slow_freq_get() == RTC_SLOW_FREQ_RTC) { - s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_RTC_SLOW; // set default value + s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_RTC_SLOW; // Internal 150 kHz RC oscillator + ESP_LOGW(BTDM_LOG_TAG, "Internal 150kHz RC osciallator. The accuracy of this clock is a lot larger than 500ppm which is " + "required in Bluetooth communication, so don't select this option in scenarios such as BLE connection state."); } else { - ESP_LOGW(BT_LOG_TAG, "Internal 90kHz RC oscillator not detected, fall back to main XTAL as Bluetooth sleep clock\n" - "light sleep mode will not be able to apply when bluetooth is enabled"); - s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value + ESP_LOGW(BT_LOG_TAG, "Internal 150kHz RC oscillator not detected."); + assert(0); } #else - s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value + s_lp_cntl.no_light_sleep = 1; #endif bool select_src_ret __attribute__((unused));