Bluetooth: Controller: Use ceiling_fraction function
Use ceiling_fraction function instead of repeated explicit code to ceil calculations. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
parent
1d922038fb
commit
61eb655ab6
10 changed files with 24 additions and 26 deletions
|
@ -83,8 +83,8 @@ static inline bool isr_rx_ci_adva_check(uint8_t tx_addr, uint8_t *addr,
|
|||
struct pdu_adv *ci);
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_ADV_EXT)
|
||||
#define PAYLOAD_BASED_FRAG_COUNT ((CONFIG_BT_CTLR_ADV_DATA_LEN_MAX + \
|
||||
PDU_AC_PAYLOAD_SIZE_MAX - 1) / \
|
||||
#define PAYLOAD_BASED_FRAG_COUNT \
|
||||
ceiling_fraction(CONFIG_BT_CTLR_ADV_DATA_LEN_MAX, \
|
||||
PDU_AC_PAYLOAD_SIZE_MAX)
|
||||
#define PAYLOAD_FRAG_COUNT MAX(PAYLOAD_BASED_FRAG_COUNT, BT_CTLR_DF_PER_ADV_CTE_NUM_MAX)
|
||||
#define BT_CTLR_ADV_AUX_SET CONFIG_BT_CTLR_ADV_AUX_SET
|
||||
|
|
|
@ -106,8 +106,7 @@ static void isr_tx(void *param)
|
|||
|
||||
/* LE Test Packet Interval */
|
||||
l = radio_tmr_end_get() - radio_tmr_ready_get();
|
||||
i = ((l + 249 + (SCAN_INT_UNIT_US - 1)) / SCAN_INT_UNIT_US) *
|
||||
SCAN_INT_UNIT_US;
|
||||
i = ceiling_fraction((l + 249), SCAN_INT_UNIT_US) * SCAN_INT_UNIT_US;
|
||||
t = radio_tmr_end_get() - l + i;
|
||||
t -= radio_tx_ready_delay_get(test_phy, test_phy_flags);
|
||||
|
||||
|
|
|
@ -79,8 +79,8 @@ static inline bool isr_rx_ci_adva_check(struct pdu_adv *adv,
|
|||
struct pdu_adv *ci);
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_ADV_EXT)
|
||||
#define PAYLOAD_FRAG_COUNT ((CONFIG_BT_CTLR_ADV_DATA_LEN_MAX + \
|
||||
PDU_AC_PAYLOAD_SIZE_MAX - 1) / \
|
||||
#define PAYLOAD_BASED_FRAG_COUNT \
|
||||
ceiling_fraction(CONFIG_BT_CTLR_ADV_DATA_LEN_MAX, \
|
||||
PDU_AC_PAYLOAD_SIZE_MAX)
|
||||
#define BT_CTLR_ADV_AUX_SET CONFIG_BT_CTLR_ADV_AUX_SET
|
||||
#if defined(CONFIG_BT_CTLR_ADV_PERIODIC)
|
||||
|
|
|
@ -102,8 +102,7 @@ static void isr_tx(void *param)
|
|||
|
||||
/* LE Test Packet Interval */
|
||||
l = radio_tmr_end_get() - radio_tmr_ready_get();
|
||||
i = ((l + 249 + (SCAN_INT_UNIT_US - 1)) / SCAN_INT_UNIT_US) *
|
||||
SCAN_INT_UNIT_US;
|
||||
i = ceiling_fraction((l + 249), SCAN_INT_UNIT_US) * SCAN_INT_UNIT_US;
|
||||
t = radio_tmr_end_get() - l + i;
|
||||
t -= radio_tx_ready_delay_get(test_phy, test_phy_flags);
|
||||
|
||||
|
|
|
@ -1221,9 +1221,8 @@ uint8_t ll_adv_enable(uint8_t enable)
|
|||
interval_min_us = time_us +
|
||||
(scan_delay + scan_window) * USEC_PER_MSEC;
|
||||
if ((interval * SCAN_INT_UNIT_US) < interval_min_us) {
|
||||
interval = (interval_min_us +
|
||||
(SCAN_INT_UNIT_US - 1)) /
|
||||
SCAN_INT_UNIT_US;
|
||||
interval = ceiling_fraction(interval_min_us,
|
||||
SCAN_INT_UNIT_US);
|
||||
}
|
||||
|
||||
/* passive scanning */
|
||||
|
|
|
@ -183,11 +183,10 @@ uint8_t ll_big_create(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bis,
|
|||
lll_adv_iso->num_bis = num_bis;
|
||||
|
||||
/* BN (Burst Count), Mandatory BN = 1 */
|
||||
bn = (max_sdu + (lll_adv_iso->max_pdu - 1U)) / lll_adv_iso->max_pdu;
|
||||
bn = ceiling_fraction(max_sdu, lll_adv_iso->max_pdu);
|
||||
if (bn > PDU_BIG_BN_MAX) {
|
||||
lll_adv_iso->bn = PDU_BIG_BN_MAX;
|
||||
bn = ((bn + (PDU_BIG_BN_MAX - 1)) / PDU_BIG_BN_MAX) *
|
||||
PDU_BIG_BN_MAX;
|
||||
bn = ceiling_fraction(bn, PDU_BIG_BN_MAX) * PDU_BIG_BN_MAX;
|
||||
} else {
|
||||
lll_adv_iso->bn = bn;
|
||||
}
|
||||
|
|
|
@ -3126,9 +3126,9 @@ static inline int event_conn_upd_prep(struct ll_conn *conn, uint16_t lazy,
|
|||
instant_latency;
|
||||
|
||||
lll->periph.window_widening_periodic_us =
|
||||
(((lll_clock_ppm_local_get() +
|
||||
ceiling_fraction(((lll_clock_ppm_local_get() +
|
||||
lll_clock_ppm_get(conn->periph.sca)) *
|
||||
conn_interval_us) + (1000000 - 1)) / 1000000U;
|
||||
conn_interval_us), USEC_PER_SEC);
|
||||
lll->periph.window_widening_max_us =
|
||||
(conn_interval_us >> 1) - EVENT_IFS_US;
|
||||
lll->periph.window_size_prepare_us =
|
||||
|
|
|
@ -190,9 +190,9 @@ void ull_periph_setup(struct node_rx_hdr *rx, struct node_rx_ftr *ftr,
|
|||
/* calculate the window widening */
|
||||
conn->periph.sca = pdu_adv->connect_ind.sca;
|
||||
lll->periph.window_widening_periodic_us =
|
||||
(((lll_clock_ppm_local_get() +
|
||||
ceiling_fraction(((lll_clock_ppm_local_get() +
|
||||
lll_clock_ppm_get(conn->periph.sca)) *
|
||||
conn_interval_us) + (1000000 - 1)) / 1000000U;
|
||||
conn_interval_us), USEC_PER_SEC);
|
||||
lll->periph.window_widening_max_us = (conn_interval_us >> 1) -
|
||||
EVENT_IFS_US;
|
||||
lll->periph.window_size_event_us = pdu_adv->connect_ind.win_size *
|
||||
|
|
|
@ -579,8 +579,9 @@ void ull_sync_setup(struct ll_scan_set *scan, struct ll_scan_aux_set *aux,
|
|||
#endif /* CONFIG_BT_CTLR_SYNC_ISO */
|
||||
|
||||
lll->window_widening_periodic_us =
|
||||
(((lll_clock_ppm_local_get() + lll_clock_ppm_get(sca)) *
|
||||
interval_us) + (1000000 - 1)) / 1000000U;
|
||||
ceiling_fraction(((lll_clock_ppm_local_get() +
|
||||
lll_clock_ppm_get(sca)) *
|
||||
interval_us), USEC_PER_SEC);
|
||||
lll->window_widening_max_us = (interval_us >> 1) - EVENT_IFS_US;
|
||||
if (si->offs_units) {
|
||||
lll->window_size_event_us = OFFS_UNIT_300_US;
|
||||
|
|
|
@ -335,8 +335,9 @@ void ull_sync_iso_setup(struct ll_sync_iso_set *sync_iso,
|
|||
|
||||
sca = sync_iso->sync->lll.sca;
|
||||
lll->window_widening_periodic_us =
|
||||
(((lll_clock_ppm_local_get() + lll_clock_ppm_get(sca)) *
|
||||
interval_us) + (1000000 - 1)) / 1000000U;
|
||||
ceiling_fraction(((lll_clock_ppm_local_get() +
|
||||
lll_clock_ppm_get(sca)) *
|
||||
interval_us), USEC_PER_SEC);
|
||||
lll->window_widening_max_us = (interval_us >> 1) - EVENT_IFS_US;
|
||||
if (bi->offs_units) {
|
||||
lll->window_size_event_us = 300U;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue