diff --git a/subsys/bluetooth/controller/Kconfig.ll_sw_split b/subsys/bluetooth/controller/Kconfig.ll_sw_split index 15b1bc8dddd..278985bd7ed 100644 --- a/subsys/bluetooth/controller/Kconfig.ll_sw_split +++ b/subsys/bluetooth/controller/Kconfig.ll_sw_split @@ -786,6 +786,12 @@ config BT_TICKER_UPDATE help This option enables Ticker Update interface. +config BT_TICKER_REMAINDER + bool "Ticker Remainder" + help + This option enables Ticker Start interface remainder parameter for + first expire timeout. + config BT_TICKER_JOB_IDLE_GET bool "Ticker Job Idle Get" default y if BT_TICKER_LOW_LAT diff --git a/subsys/bluetooth/controller/ticker/ticker.c b/subsys/bluetooth/controller/ticker/ticker.c index afd0472608f..d1a13a0186c 100644 --- a/subsys/bluetooth/controller/ticker/ticker.c +++ b/subsys/bluetooth/controller/ticker/ticker.c @@ -157,11 +157,17 @@ struct ticker_user_op_start { uint16_t lazy; /* Periodic latency in number of * periods */ +#if defined(CONFIG_BT_TICKER_REMAINDER) + uint32_t remainder_first; /* Sub-microsecond tick remainder */ +#endif /* CONFIG_BT_TICKER_REMAINDER */ + #if !defined(CONFIG_BT_TICKER_SLOT_AGNOSTIC) uint32_t ticks_slot; /* Air-time reservation ticks */ #endif /* CONFIG_BT_TICKER_SLOT_AGNOSTIC */ + ticker_timeout_func fp_timeout_func; /* Timeout callback function */ void *context; /* Context passed in timeout callback */ + #if defined(CONFIG_BT_TICKER_EXT) struct ticker_ext *ext_data; /* Ticker extension data instance */ #endif /* CONFIG_BT_TICKER_EXT */ @@ -2235,7 +2241,11 @@ static inline uint32_t ticker_job_op_start(struct ticker_instance *instance, ticker->ticks_to_expire = start->ticks_first; ticker->ticks_to_expire_minus = 0U; ticks_to_expire_prep(ticker, ticks_current, start->ticks_at_start); +#if defined(CONFIG_BT_TICKER_REMAINDER) + ticker->remainder_current = start->remainder_first; +#else /* !CONFIG_BT_TICKER_REMAINDER */ ticker->remainder_current = 0U; +#endif /* !CONFIG_BT_TICKER_REMAINDER */ ticker->lazy_current = 0U; ticker->force = 1U; @@ -3312,6 +3322,32 @@ uint8_t ticker_start(uint8_t instance_index, uint8_t user_id, uint8_t ticker_id, NULL); } +static uint8_t start_us(uint8_t instance_index, uint8_t user_id, + uint8_t ticker_id, uint32_t ticks_anchor, + uint32_t ticks_first, uint32_t remainder_first, + uint32_t ticks_periodic, uint32_t remainder_periodic, + uint16_t lazy, uint32_t ticks_slot, + ticker_timeout_func fp_timeout_func, void *context, + ticker_op_func fp_op_func, void *op_context, + struct ticker_ext *ext_data); + +uint8_t ticker_start_us(uint8_t instance_index, uint8_t user_id, + uint8_t ticker_id, uint32_t ticks_anchor, + uint32_t ticks_first, uint32_t remainder_first, + uint32_t ticks_periodic, uint32_t remainder_periodic, + uint16_t lazy, uint32_t ticks_slot, + ticker_timeout_func fp_timeout_func, void *context, + ticker_op_func fp_op_func, void *op_context) +{ + return start_us(instance_index, user_id, ticker_id, ticks_anchor, + ticks_first, remainder_first, + ticks_periodic, remainder_periodic, + lazy, ticks_slot, + fp_timeout_func, context, + fp_op_func, op_context, + NULL); +} + uint8_t ticker_start_ext(uint8_t instance_index, uint8_t user_id, uint8_t ticker_id, uint32_t ticks_anchor, uint32_t ticks_first, uint32_t ticks_periodic, uint32_t remainder_periodic, @@ -3319,13 +3355,49 @@ uint8_t ticker_start_ext(uint8_t instance_index, uint8_t user_id, uint8_t ticker ticker_timeout_func fp_timeout_func, void *context, ticker_op_func fp_op_func, void *op_context, struct ticker_ext *ext_data) -#else +{ + return start_us(instance_index, user_id, ticker_id, ticks_anchor, + ticks_first, 0U, ticks_periodic, remainder_periodic, + lazy, ticks_slot, + fp_timeout_func, context, + fp_op_func, op_context, + ext_data); +} + +static uint8_t start_us(uint8_t instance_index, uint8_t user_id, + uint8_t ticker_id, uint32_t ticks_anchor, + uint32_t ticks_first, uint32_t remainder_first, + uint32_t ticks_periodic, uint32_t remainder_periodic, + uint16_t lazy, uint32_t ticks_slot, + ticker_timeout_func fp_timeout_func, void *context, + ticker_op_func fp_op_func, void *op_context, + struct ticker_ext *ext_data) + +#else /* !CONFIG_BT_TICKER_EXT */ uint8_t ticker_start(uint8_t instance_index, uint8_t user_id, uint8_t ticker_id, uint32_t ticks_anchor, uint32_t ticks_first, uint32_t ticks_periodic, uint32_t remainder_periodic, uint16_t lazy, uint32_t ticks_slot, ticker_timeout_func fp_timeout_func, void *context, ticker_op_func fp_op_func, void *op_context) -#endif +{ + return ticker_start_us(instance_index, user_id, + ticker_id, ticks_anchor, + ticks_first, 0U, + ticks_periodic, remainder_periodic, + lazy, ticks_slot, + fp_timeout_func, context, + fp_op_func, op_context); +} + +uint8_t ticker_start_us(uint8_t instance_index, uint8_t user_id, + uint8_t ticker_id, uint32_t ticks_anchor, + uint32_t ticks_first, uint32_t remainder_first, + uint32_t ticks_periodic, uint32_t remainder_periodic, + uint16_t lazy, uint32_t ticks_slot, + ticker_timeout_func fp_timeout_func, void *context, + ticker_op_func fp_op_func, void *op_context) +#endif /* !CONFIG_BT_TICKER_EXT */ + { struct ticker_instance *instance = &_instance[instance_index]; struct ticker_user_op *user_op; @@ -3348,6 +3420,9 @@ uint8_t ticker_start(uint8_t instance_index, uint8_t user_id, uint8_t ticker_id, user_op->id = ticker_id; user_op->params.start.ticks_at_start = ticks_anchor; user_op->params.start.ticks_first = ticks_first; +#if defined(CONFIG_BT_TICKER_REMAINDER) + user_op->params.start.remainder_first = remainder_first; +#endif /* !CONFIG_BT_TICKER_REMAINDER */ user_op->params.start.ticks_periodic = ticks_periodic; user_op->params.start.remainder_periodic = remainder_periodic; #if !defined(CONFIG_BT_TICKER_SLOT_AGNOSTIC) diff --git a/subsys/bluetooth/controller/ticker/ticker.h b/subsys/bluetooth/controller/ticker/ticker.h index fbff407e94c..aa19ecbff8f 100644 --- a/subsys/bluetooth/controller/ticker/ticker.h +++ b/subsys/bluetooth/controller/ticker/ticker.h @@ -64,16 +64,24 @@ #if defined(CONFIG_BT_TICKER_EXT) #if defined(CONFIG_BT_TICKER_SLOT_AGNOSTIC) #define TICKER_USER_OP_T_SIZE 44 -#else +#else /* !CONFIG_BT_TICKER_SLOT_AGNOSTIC */ +#if defined(CONFIG_BT_TICKER_REMAINDER) +#define TICKER_USER_OP_T_SIZE 52 +#else /* !CONFIG_BT_TICKER_REMAINDER */ #define TICKER_USER_OP_T_SIZE 48 -#endif /* CONFIG_BT_TICKER_SLOT_AGNOSTIC */ -#else +#endif /* !CONFIG_BT_TICKER_REMAINDER */ +#endif /* !CONFIG_BT_TICKER_SLOT_AGNOSTIC */ +#else /* !CONFIG_BT_TICKER_EXT */ #if defined(CONFIG_BT_TICKER_SLOT_AGNOSTIC) #define TICKER_USER_OP_T_SIZE 40 -#else +#else /* !CONFIG_BT_TICKER_SLOT_AGNOSTIC */ +#if defined(CONFIG_BT_TICKER_REMAINDER) +#define TICKER_USER_OP_T_SIZE 48 +#else /* !CONFIG_BT_TICKER_REMAINDER */ #define TICKER_USER_OP_T_SIZE 44 -#endif /* CONFIG_BT_TICKER_SLOT_AGNOSTIC */ -#endif /* CONFIG_BT_TICKER_EXT */ +#endif /* !CONFIG_BT_TICKER_REMAINDER */ +#endif /* !CONFIG_BT_TICKER_SLOT_AGNOSTIC */ +#endif /* !CONFIG_BT_TICKER_EXT */ #define TICKER_CALL_ID_NONE 0 #define TICKER_CALL_ID_ISR 1 @@ -158,6 +166,13 @@ uint8_t ticker_start(uint8_t instance_index, uint8_t user_id, uint32_t ticks_slot, ticker_timeout_func fp_timeout_func, void *context, ticker_op_func fp_op_func, void *op_context); +uint8_t ticker_start_us(uint8_t instance_index, uint8_t user_id, + uint8_t ticker_id, uint32_t ticks_anchor, + uint32_t ticks_first, uint32_t remainder_first, + uint32_t ticks_periodic, uint32_t remainder_periodic, + uint16_t lazy, uint32_t ticks_slot, + ticker_timeout_func fp_timeout_func, void *context, + ticker_op_func fp_op_func, void *op_context); uint8_t ticker_update(uint8_t instance_index, uint8_t user_id, uint8_t ticker_id, uint32_t ticks_drift_plus, uint32_t ticks_drift_minus, uint32_t ticks_slot_plus,