|
13 | 13 | /* Macro defining the max. counter update latency in ticks */
|
14 | 14 | #define HAL_TICKER_CNTR_SET_LATENCY 0
|
15 | 15 |
|
| 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 | + |
16 | 22 | /* Macro to translate microseconds to tick units.
|
17 | 23 | * NOTE: This returns the floor value.
|
18 | 24 | */
|
|
22 | 28 | & HAL_TICKER_CNTR_MASK \
|
23 | 29 | )
|
24 | 30 |
|
25 |
| -/* Macro returning remainder in nanoseconds */ |
| 31 | +/* Macro returning remainder in picoseconds */ |
26 | 32 | #define HAL_TICKER_REMAINDER(x) \
|
27 | 33 | ( \
|
28 | 34 | ( \
|
|
32 | 38 | / 1000UL \
|
33 | 39 | )
|
34 | 40 |
|
| 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 | + |
35 | 61 | /* Macro to translate tick units to microseconds. */
|
36 | 62 | #define HAL_TICKER_TICKS_TO_US(x) \
|
37 | 63 | ((uint32_t)(((uint64_t)(x) * 30517578125UL) / 1000000000UL))
|
38 | 64 |
|
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 |
| - |
45 | 65 | /* Macro defining the remainder resolution/range
|
46 | 66 | * ~ 1000000 * HAL_TICKER_TICKS_TO_US(1)
|
47 | 67 | */
|
|
0 commit comments