Skip to content

Commit 0969148

Browse files
marcowidmerdanieldegrasse
authored andcommitted
Bluetooth: Controller: Deinit ticker
ticker_is_initialized() should only return true when the ticker is running (triggered regularly). Users like nrf_flash_sync_is_required() depend on this behavior. When the bluetooth controller driver is closed, ll_deinit() calls lll_deinit(), which stops the ticker from being triggered. Also deinitialize the ticker to ensure that ticker_is_initialized() returns false. Signed-off-by: Marco Widmer <[email protected]>
1 parent 2b4f645 commit 0969148

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

subsys/bluetooth/controller/ll_sw/ull.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,18 @@ int ll_init(struct k_sem *sem_rx)
783783

784784
int ll_deinit(void)
785785
{
786+
int err;
787+
786788
ll_reset();
787-
return lll_deinit();
789+
790+
err = lll_deinit();
791+
if (err) {
792+
return err;
793+
}
794+
795+
err = ticker_deinit(TICKER_INSTANCE_ID_CTLR);
796+
797+
return err;
788798
}
789799

790800
void ll_reset(void)

subsys/bluetooth/controller/ticker/ticker.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3475,6 +3475,30 @@ uint8_t ticker_init(uint8_t instance_index, uint8_t count_node, void *node,
34753475
return TICKER_STATUS_SUCCESS;
34763476
}
34773477

3478+
/**
3479+
* @brief Deinitialize ticker instance
3480+
*
3481+
* @param instance_index Index of ticker instance
3482+
*/
3483+
int ticker_deinit(uint8_t instance_index)
3484+
{
3485+
struct ticker_instance *instance;
3486+
3487+
if (instance_index >= TICKER_INSTANCE_MAX) {
3488+
return -EINVAL;
3489+
}
3490+
3491+
instance = &_instance[instance_index];
3492+
3493+
if (instance->ticker_id_head != TICKER_NULL) {
3494+
return -EBUSY;
3495+
}
3496+
3497+
instance->count_node = 0U;
3498+
3499+
return 0;
3500+
}
3501+
34783502
/**
34793503
* @brief Check if ticker instance is initialized
34803504
*

subsys/bluetooth/controller/ticker/ticker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ uint8_t ticker_init(uint8_t instance_index, uint8_t count_node, void *node,
173173
void *user_op, ticker_caller_id_get_cb_t caller_id_get_cb,
174174
ticker_sched_cb_t sched_cb,
175175
ticker_trigger_set_cb_t trigger_set_cb);
176+
int ticker_deinit(uint8_t instance_index);
176177
bool ticker_is_initialized(uint8_t instance_index);
177178
void ticker_trigger(uint8_t instance_index);
178179
void ticker_worker(void *param);

0 commit comments

Comments
 (0)