Skip to content

Commit 7e90d36

Browse files
marcowidmerkartben
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]> (cherry picked from commit 0969148)
1 parent 5997163 commit 7e90d36

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
@@ -784,8 +784,18 @@ int ll_init(struct k_sem *sem_rx)
784784

785785
int ll_deinit(void)
786786
{
787+
int err;
788+
787789
ll_reset();
788-
return lll_deinit();
790+
791+
err = lll_deinit();
792+
if (err) {
793+
return err;
794+
}
795+
796+
err = ticker_deinit(TICKER_INSTANCE_ID_CTLR);
797+
798+
return err;
789799
}
790800

791801
void ll_reset(void)

subsys/bluetooth/controller/ticker/ticker.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3464,6 +3464,30 @@ uint8_t ticker_init(uint8_t instance_index, uint8_t count_node, void *node,
34643464
return TICKER_STATUS_SUCCESS;
34653465
}
34663466

3467+
/**
3468+
* @brief Deinitialize ticker instance
3469+
*
3470+
* @param instance_index Index of ticker instance
3471+
*/
3472+
int ticker_deinit(uint8_t instance_index)
3473+
{
3474+
struct ticker_instance *instance;
3475+
3476+
if (instance_index >= TICKER_INSTANCE_MAX) {
3477+
return -EINVAL;
3478+
}
3479+
3480+
instance = &_instance[instance_index];
3481+
3482+
if (instance->ticker_id_head != TICKER_NULL) {
3483+
return -EBUSY;
3484+
}
3485+
3486+
instance->count_node = 0U;
3487+
3488+
return 0;
3489+
}
3490+
34673491
/**
34683492
* @brief Check if ticker instance is initialized
34693493
*

subsys/bluetooth/controller/ticker/ticker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ uint8_t ticker_init(uint8_t instance_index, uint8_t count_node, void *node,
171171
void *user_op, ticker_caller_id_get_cb_t caller_id_get_cb,
172172
ticker_sched_cb_t sched_cb,
173173
ticker_trigger_set_cb_t trigger_set_cb);
174+
int ticker_deinit(uint8_t instance_index);
174175
bool ticker_is_initialized(uint8_t instance_index);
175176
void ticker_trigger(uint8_t instance_index);
176177
void ticker_worker(void *param);

0 commit comments

Comments
 (0)