Skip to content

Commit aa73661

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: Controller: Use macro to adjust ticks based on remainder
Use macro to adjust ticks for jitter stored in remainder value. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent be7173a commit aa73661

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,11 +1050,7 @@ void radio_tmr_tifs_set(uint32_t tifs)
10501050

10511051
uint32_t radio_tmr_start(uint8_t trx, uint32_t ticks_start, uint32_t remainder)
10521052
{
1053-
if ((!(remainder / 1000000UL)) || (remainder & 0x80000000)) {
1054-
ticks_start--;
1055-
remainder += 30517578UL;
1056-
}
1057-
remainder /= 1000000UL;
1053+
HAL_TICKER_REMOVE_JITTER(ticks_start, remainder);
10581054

10591055
nrf_timer_task_trigger(EVENT_TIMER, NRF_TIMER_TASK_CLEAR);
10601056
EVENT_TIMER->MODE = 0;

subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/ticker.h

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
/* Macro defining the max. counter update latency in ticks */
1414
#define HAL_TICKER_CNTR_SET_LATENCY 0
1515

16+
/* Macro defines the h/w supported most significant bit */
17+
#define HAL_TICKER_CNTR_MSBIT 23
18+
19+
/* Macro defining the HW supported counter bits */
20+
#define HAL_TICKER_CNTR_MASK 0x00FFFFFF
21+
1622
/* Macro to translate microseconds to tick units.
1723
* NOTE: This returns the floor value.
1824
*/
@@ -22,7 +28,7 @@
2228
& HAL_TICKER_CNTR_MASK \
2329
)
2430

25-
/* Macro returning remainder in nanoseconds */
31+
/* Macro returning remainder in picoseconds */
2632
#define HAL_TICKER_REMAINDER(x) \
2733
( \
2834
( \
@@ -32,16 +38,30 @@
3238
/ 1000UL \
3339
)
3440

41+
/* Macro to remove ticks and return positive remainder value in microseconds */
42+
#define HAL_TICKER_REMOVE_JITTER(t, r) \
43+
{ \
44+
if ((!(r / 1000000UL)) || (r & BIT(31))) { \
45+
t--; \
46+
r += 30517578UL; \
47+
} \
48+
r /= 1000000UL; \
49+
}
50+
51+
/* Macro to add ticks and return positive remainder value in microseconds */
52+
#define HAL_TICKER_ADD_JITTER(t, r) \
53+
{ \
54+
if ((!(r / 1000000UL)) || (r & BIT(31))) { \
55+
t++; \
56+
r += 30517578UL; \
57+
} \
58+
r /= 1000000UL; \
59+
}
60+
3561
/* Macro to translate tick units to microseconds. */
3662
#define HAL_TICKER_TICKS_TO_US(x) \
3763
((uint32_t)(((uint64_t)(x) * 30517578125UL) / 1000000000UL))
3864

39-
/* Macro defines the h/w supported most significant bit */
40-
#define HAL_TICKER_CNTR_MSBIT 23
41-
42-
/* Macro defining the HW supported counter bits */
43-
#define HAL_TICKER_CNTR_MASK 0x00FFFFFF
44-
4565
/* Macro defining the remainder resolution/range
4666
* ~ 1000000 * HAL_TICKER_TICKS_TO_US(1)
4767
*/

0 commit comments

Comments
 (0)