soc: arm: nordic_nrf: timing: Fix wrapping

Fix wrapping case for SoC with 32 bit TIMER.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2021-09-24 08:09:36 +02:00 committed by Anas Nashif
commit cd3dae7c2c

View file

@ -47,14 +47,14 @@ uint64_t soc_timing_cycles_get(volatile timing_t *const start,
{ {
#if defined(CONFIG_SOC_SERIES_NRF51X) #if defined(CONFIG_SOC_SERIES_NRF51X)
#define COUNTER_SPAN BIT(16) #define COUNTER_SPAN BIT(16)
#else
#define COUNTER_SPAN BIT64(32)
#endif
if (*end >= *start) { if (*end >= *start) {
return (*end - *start); return (*end - *start);
} else { } else {
return COUNTER_SPAN + *end - *start; return COUNTER_SPAN + *end - *start;
} }
#else
return (*end - *start);
#endif
} }
uint64_t soc_timing_freq_get(void) uint64_t soc_timing_freq_get(void)