diff --git a/components/bt/porting/npl/freertos/include/nimble/npl_freertos.h b/components/bt/porting/npl/freertos/include/nimble/npl_freertos.h index 57c2db43e20..6cec8d98228 100644 --- a/components/bt/porting/npl/freertos/include/nimble/npl_freertos.h +++ b/components/bt/porting/npl/freertos/include/nimble/npl_freertos.h @@ -19,7 +19,8 @@ extern "C" { /* Use esp timer instead of FreeRTOS timer to implement the callout. */ #define BLE_NPL_USE_ESP_TIMER (1) #else -#define BLE_NPL_USE_ESP_TIMER (0) +/* Always use esp timer */ +#define BLE_NPL_USE_ESP_TIMER (1) #endif typedef struct { diff --git a/components/bt/porting/npl/freertos/src/npl_os_freertos.c b/components/bt/porting/npl/freertos/src/npl_os_freertos.c index cf37b7dd531..be516ad85d1 100644 --- a/components/bt/porting/npl/freertos/src/npl_os_freertos.c +++ b/components/bt/porting/npl/freertos/src/npl_os_freertos.c @@ -1010,6 +1010,9 @@ IRAM_ATTR npl_freertos_callout_reset(struct ble_npl_callout *co, ble_npl_time_t struct ble_npl_callout_freertos *callout = (struct ble_npl_callout_freertos *)co->co; #if BLE_NPL_USE_ESP_TIMER esp_timer_stop(callout->handle); + if (callout->evq) { + npl_freertos_eventq_remove(callout->evq, &callout->ev); + } return esp_err_to_npl_error(esp_timer_start_once(callout->handle, ticks*1000)); #else @@ -1021,6 +1024,9 @@ IRAM_ATTR npl_freertos_callout_reset(struct ble_npl_callout *co, ble_npl_time_t } if (in_isr()) { xTimerStopFromISR(callout->handle, &woken1); + if (callout->evq) { + npl_freertos_eventq_remove(callout->evq, &callout->ev); + } xTimerChangePeriodFromISR(callout->handle, ticks, &woken2); xTimerResetFromISR(callout->handle, &woken3); @@ -1029,6 +1035,9 @@ IRAM_ATTR npl_freertos_callout_reset(struct ble_npl_callout *co, ble_npl_time_t } } else { xTimerStop(callout->handle, portMAX_DELAY); + if (callout->evq) { + npl_freertos_eventq_remove(callout->evq, &callout->ev); + } xTimerChangePeriod(callout->handle, ticks, portMAX_DELAY); xTimerReset(callout->handle, portMAX_DELAY); } @@ -1061,6 +1070,10 @@ IRAM_ATTR npl_freertos_callout_stop(struct ble_npl_callout *co) xTimerStop(callout->handle, portMAX_DELAY); } #endif + + if (callout->evq) { + npl_freertos_eventq_remove(callout->evq, &callout->ev); + } } bool