|
64 | 64 | #define WIDTH_TO_MAXVAL(width) (UINT32_MAX >> (32 - width)) |
65 | 65 |
|
66 | 66 | #define FREQ_1MHZ 1000000LU |
| 67 | +#define FREQ_500KHZ 500000LU |
67 | 68 | #define FREQ_250KHZ 250000LU |
68 | 69 | #define FREQ_1KHZ 1000LU |
69 | 70 | #define FREQ_1HZ 1LU |
@@ -219,6 +220,9 @@ ztimer_clock_t *const ZTIMER_USEC = &ZTIMER_TIMER_CLK; |
219 | 220 | # elif (ZTIMER_TIMER_FREQ == 250000LU) && !(CONFIG_ZTIMER_PERIPH_TIMER_FORCE_CONVERSION) |
220 | 221 | static ztimer_convert_shift_t _ztimer_convert_shift_usec; |
221 | 222 | ztimer_clock_t *const ZTIMER_USEC = &_ztimer_convert_shift_usec.super.super; |
| 223 | +# elif (ZTIMER_TIMER_FREQ == 500000LU) && !(CONFIG_ZTIMER_PERIPH_TIMER_FORCE_CONVERSION) |
| 224 | +static ztimer_convert_shift_t _ztimer_convert_shift_usec; |
| 225 | +ztimer_clock_t *const ZTIMER_USEC = &_ztimer_convert_shift_usec.super.super; |
222 | 226 | # else |
223 | 227 | static ztimer_convert_frac_t _ztimer_convert_frac_usec; |
224 | 228 | ztimer_clock_t *const ZTIMER_USEC = &_ztimer_convert_frac_usec.super.super; |
@@ -353,6 +357,15 @@ void ztimer_init(void) |
353 | 357 | periph_timer_freq); |
354 | 358 | ztimer_convert_shift_up_init(&_ztimer_convert_shift_usec, |
355 | 359 | ZTIMER_USEC_BASE, 2); |
| 360 | +# elif (ZTIMER_TIMER_FREQ == FREQ_500KHZ) && !(CONFIG_ZTIMER_PERIPH_TIMER_FORCE_CONVERSION) |
| 361 | + if (IS_ACTIVE(DEVELHELP) && ((periph_timer_freq < 487500) || (periph_timer_freq > 512500))) { |
| 362 | + LOG_WARNING("ZTIMER_USEC from %" PRIu32 " Hz clock with \"left-shift by 1\" frequency conversion\n", |
| 363 | + periph_timer_freq); |
| 364 | + } |
| 365 | + LOG_DEBUG("ztimer_init(): ZTIMER_USEC convert_shift %lu to 1000000\n", |
| 366 | + periph_timer_freq); |
| 367 | + ztimer_convert_shift_up_init(&_ztimer_convert_shift_usec, |
| 368 | + ZTIMER_USEC_BASE, 1); |
356 | 369 | # else |
357 | 370 | LOG_DEBUG("ztimer_init(): ZTIMER_USEC convert_frac %lu to 1000000\n", |
358 | 371 | ZTIMER_TIMER_FREQ); |
|
0 commit comments