Skip to content

Commit 308567f

Browse files
committed
Fix micros() for nano without breaking giga
The rollover fix for the giga used the 64 bit timer instead of 32 bits. The nano does not have a 64 bit timer, so you need to use the 32 bit instead. So I know check to see if the processor supports 64 bits if so use it else fall back to 32 bit.
1 parent c0b7ef0 commit 308567f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: cores/arduino/zephyrCommon.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,12 @@ void delay(unsigned long ms) { k_sleep(K_MSEC(ms)); }
293293
void delayMicroseconds(unsigned int us) { k_sleep(K_USEC(us)); }
294294

295295
unsigned long micros(void) {
296+
#ifdef CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER
296297
return k_cyc_to_us_floor32(k_cycle_get_64());
297-
}
298+
#else
299+
return k_cyc_to_us_floor32(k_cycle_get_32());
300+
#endif
301+
}
298302

299303
unsigned long millis(void) { return k_uptime_get_32(); }
300304

0 commit comments

Comments
 (0)