@@ -130,6 +130,15 @@ enum {
130130};
131131#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
132132
133+ typedef union {
134+ struct {
135+ uint32_t rtc_freq :20 ;
136+ uint32_t rsv :11 ;
137+ uint32_t bt_wakeup :1 ;
138+ };
139+ uint32_t val ;
140+ } bt_wakeup_params_t ;
141+
133142/* External functions or variables
134143 ************************************************************************
135144 */
@@ -220,6 +229,9 @@ static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void);
220229#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
221230#endif /* !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
222231#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
232+ #if CONFIG_FREERTOS_USE_TICKLESS_IDLE
233+ static bool esp_bt_check_wakeup_by_bt (void );
234+ #endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
223235/* Local variable definition
224236 ***************************************************************************
225237 */
@@ -712,6 +724,7 @@ void controller_sleep_cb(uint32_t enable_tick, void *arg)
712724
713725void controller_wakeup_cb (void * arg )
714726{
727+ bt_wakeup_params_t * params ;
715728 if (s_ble_active ) {
716729 return ;
717730 }
@@ -721,15 +734,25 @@ void controller_wakeup_cb(void *arg)
721734 esp_pm_get_configuration (& pm_config );
722735 assert (esp_rom_get_cpu_ticks_per_us () == pm_config .max_freq_mhz );
723736#endif //CONFIG_PM_ENABLE
737+ params = (bt_wakeup_params_t * )arg ;
724738 esp_phy_enable (PHY_MODEM_BT );
725739 if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_RC_SLOW ) {
726- uint32_t * clk_freq = (uint32_t * )arg ;
727- * clk_freq = esp_clk_tree_lp_slow_get_freq_hz (ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED ) / 5 ;
740+ params -> rtc_freq = esp_clk_tree_lp_slow_get_freq_hz (ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED ) / 5 ;
728741 }
742+ #if CONFIG_FREERTOS_USE_TICKLESS_IDLE
743+ params -> bt_wakeup = esp_bt_check_wakeup_by_bt ();
744+ #endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
729745 // need to check if need to call pm lock here
730746 s_ble_active = true;
731747}
732748
749+ #if CONFIG_FREERTOS_USE_TICKLESS_IDLE
750+ static bool esp_bt_check_wakeup_by_bt (void )
751+ {
752+ return (esp_sleep_get_wakeup_causes () & ESP_SLEEP_WAKEUP_BT );
753+ }
754+ #endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
755+
733756esp_err_t controller_sleep_init (modem_clock_lpclk_src_t slow_clk_src )
734757{
735758 esp_err_t rc = 0 ;
0 commit comments