mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(bt): fixed the npl callout stop issue
(cherry picked from commit bb4eeb8edc)
Co-authored-by: ShenWeilong <shenweilong@espressif.com>
This commit is contained in:
committed by
ShenWeilong
parent
47fee134d3
commit
213dca167e
@@ -19,7 +19,8 @@ extern "C" {
|
|||||||
/* Use esp timer instead of FreeRTOS timer to implement the callout. */
|
/* Use esp timer instead of FreeRTOS timer to implement the callout. */
|
||||||
#define BLE_NPL_USE_ESP_TIMER (1)
|
#define BLE_NPL_USE_ESP_TIMER (1)
|
||||||
#else
|
#else
|
||||||
#define BLE_NPL_USE_ESP_TIMER (0)
|
/* Always use esp timer */
|
||||||
|
#define BLE_NPL_USE_ESP_TIMER (1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
@@ -787,6 +787,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;
|
struct ble_npl_callout_freertos *callout = (struct ble_npl_callout_freertos *)co->co;
|
||||||
#if BLE_NPL_USE_ESP_TIMER
|
#if BLE_NPL_USE_ESP_TIMER
|
||||||
esp_timer_stop(callout->handle);
|
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));
|
return esp_err_to_npl_error(esp_timer_start_once(callout->handle, ticks*1000));
|
||||||
#else
|
#else
|
||||||
@@ -798,6 +801,9 @@ IRAM_ATTR npl_freertos_callout_reset(struct ble_npl_callout *co, ble_npl_time_t
|
|||||||
}
|
}
|
||||||
if (in_isr()) {
|
if (in_isr()) {
|
||||||
xTimerStopFromISR(callout->handle, &woken1);
|
xTimerStopFromISR(callout->handle, &woken1);
|
||||||
|
if (callout->evq) {
|
||||||
|
npl_freertos_eventq_remove(callout->evq, &callout->ev);
|
||||||
|
}
|
||||||
xTimerChangePeriodFromISR(callout->handle, ticks, &woken2);
|
xTimerChangePeriodFromISR(callout->handle, ticks, &woken2);
|
||||||
xTimerResetFromISR(callout->handle, &woken3);
|
xTimerResetFromISR(callout->handle, &woken3);
|
||||||
|
|
||||||
@@ -806,6 +812,9 @@ IRAM_ATTR npl_freertos_callout_reset(struct ble_npl_callout *co, ble_npl_time_t
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
xTimerStop(callout->handle, portMAX_DELAY);
|
xTimerStop(callout->handle, portMAX_DELAY);
|
||||||
|
if (callout->evq) {
|
||||||
|
npl_freertos_eventq_remove(callout->evq, &callout->ev);
|
||||||
|
}
|
||||||
xTimerChangePeriod(callout->handle, ticks, portMAX_DELAY);
|
xTimerChangePeriod(callout->handle, ticks, portMAX_DELAY);
|
||||||
xTimerReset(callout->handle, portMAX_DELAY);
|
xTimerReset(callout->handle, portMAX_DELAY);
|
||||||
}
|
}
|
||||||
@@ -828,6 +837,10 @@ IRAM_ATTR npl_freertos_callout_stop(struct ble_npl_callout *co)
|
|||||||
#else
|
#else
|
||||||
xTimerStop(callout->handle, portMAX_DELAY);
|
xTimerStop(callout->handle, portMAX_DELAY);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (callout->evq) {
|
||||||
|
npl_freertos_eventq_remove(callout->evq, &callout->ev);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ extern "C" {
|
|||||||
/* Use esp timer instead of FreeRTOS timer to implement the callout. */
|
/* Use esp timer instead of FreeRTOS timer to implement the callout. */
|
||||||
#define BTDM_OSAL_USE_ESP_TIMER (1)
|
#define BTDM_OSAL_USE_ESP_TIMER (1)
|
||||||
#else
|
#else
|
||||||
#define BTDM_OSAL_USE_ESP_TIMER (0)
|
/* Always use esp timer */
|
||||||
|
#define BTDM_OSAL_USE_ESP_TIMER (1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct btdm_osal_event_freertos {
|
struct btdm_osal_event_freertos {
|
||||||
|
|||||||
@@ -795,6 +795,9 @@ wr_btdm_osal_callout_reset(struct btdm_osal_callout *co, btdm_osal_time_t ticks)
|
|||||||
struct btdm_osal_callout_freertos *callout = (struct btdm_osal_callout_freertos *)co->co;
|
struct btdm_osal_callout_freertos *callout = (struct btdm_osal_callout_freertos *)co->co;
|
||||||
#if BTDM_OSAL_USE_ESP_TIMER
|
#if BTDM_OSAL_USE_ESP_TIMER
|
||||||
esp_timer_stop(callout->handle);
|
esp_timer_stop(callout->handle);
|
||||||
|
if (callout->evq) {
|
||||||
|
btdm_osal_eventq_remove(callout->evq, &callout->ev);
|
||||||
|
}
|
||||||
|
|
||||||
return esp_err_to_npl_error(esp_timer_start_once(callout->handle, ticks * 1000));
|
return esp_err_to_npl_error(esp_timer_start_once(callout->handle, ticks * 1000));
|
||||||
#else
|
#else
|
||||||
@@ -806,6 +809,9 @@ wr_btdm_osal_callout_reset(struct btdm_osal_callout *co, btdm_osal_time_t ticks)
|
|||||||
}
|
}
|
||||||
if (in_isr()) {
|
if (in_isr()) {
|
||||||
xTimerStopFromISR(callout->handle, &woken1);
|
xTimerStopFromISR(callout->handle, &woken1);
|
||||||
|
if (callout->evq) {
|
||||||
|
btdm_osal_eventq_remove(callout->evq, &callout->ev);
|
||||||
|
}
|
||||||
xTimerChangePeriodFromISR(callout->handle, ticks, &woken2);
|
xTimerChangePeriodFromISR(callout->handle, ticks, &woken2);
|
||||||
xTimerResetFromISR(callout->handle, &woken3);
|
xTimerResetFromISR(callout->handle, &woken3);
|
||||||
|
|
||||||
@@ -814,6 +820,9 @@ wr_btdm_osal_callout_reset(struct btdm_osal_callout *co, btdm_osal_time_t ticks)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
xTimerStop(callout->handle, portMAX_DELAY);
|
xTimerStop(callout->handle, portMAX_DELAY);
|
||||||
|
if (callout->evq) {
|
||||||
|
btdm_osal_eventq_remove(callout->evq, &callout->ev);
|
||||||
|
}
|
||||||
xTimerChangePeriod(callout->handle, ticks, portMAX_DELAY);
|
xTimerChangePeriod(callout->handle, ticks, portMAX_DELAY);
|
||||||
xTimerReset(callout->handle, portMAX_DELAY);
|
xTimerReset(callout->handle, portMAX_DELAY);
|
||||||
}
|
}
|
||||||
@@ -844,6 +853,10 @@ wr_btdm_osal_callout_stop(struct btdm_osal_callout *co)
|
|||||||
#else
|
#else
|
||||||
xTimerStop(callout->handle, portMAX_DELAY);
|
xTimerStop(callout->handle, portMAX_DELAY);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (callout->evq) {
|
||||||
|
btdm_osal_eventq_remove(callout->evq, &callout->ev);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IRAM_ATTR
|
bool IRAM_ATTR
|
||||||
|
|||||||
Reference in New Issue
Block a user