mirror of
https://github.com/raspberrypi/pico-sdk.git
synced 2025-12-10 07:14:36 +01:00
Crashes after calling btstack_cyw43_deinit (#2446)
You can deinitialise cyw43 and btstack by calling btstack_cyw43_deinit but its pending and timeout workers are not removed which means they can keep running, whcih causes a crash. Add a btstack_run_loop_async_context_deinit method and call this from btstack_cyw43_deinit.
This commit is contained in:
parent
31fadf42eb
commit
0de8847b99
3 changed files with 15 additions and 0 deletions
|
|
@ -129,6 +129,14 @@ const btstack_run_loop_t *btstack_run_loop_async_context_get_instance(async_cont
|
|||
return &btstack_run_loop_async_context;
|
||||
}
|
||||
|
||||
void btstack_run_loop_async_context_deinit(void) {
|
||||
if (btstack_async_context) {
|
||||
async_context_remove_at_time_worker(btstack_async_context, &btstack_timeout_worker);
|
||||
async_context_remove_when_pending_worker(btstack_async_context, &btstack_processing_worker);
|
||||
btstack_async_context = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void btstack_timeout_reached(__unused async_context_t *context, __unused async_at_time_worker_t *worker) {
|
||||
// simply wakeup worker
|
||||
async_context_set_work_pending(btstack_async_context, &btstack_processing_worker);
|
||||
|
|
|
|||
|
|
@ -23,6 +23,12 @@ extern "C" {
|
|||
*/
|
||||
const btstack_run_loop_t *btstack_run_loop_async_context_get_instance(async_context_t *context);
|
||||
|
||||
/**
|
||||
* \brief Deinitialize the BTstack state to stop it using the async_context API
|
||||
* \ingroup pico_btstack
|
||||
*/
|
||||
void btstack_run_loop_async_context_deinit(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ bool btstack_cyw43_init(async_context_t *context) {
|
|||
void btstack_cyw43_deinit(__unused async_context_t *context) {
|
||||
hci_power_control(HCI_POWER_OFF);
|
||||
hci_close();
|
||||
btstack_run_loop_async_context_deinit();
|
||||
btstack_run_loop_deinit();
|
||||
btstack_memory_deinit();
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue