From 7da76639027057245cfee043733193b3265e7a54 Mon Sep 17 00:00:00 2001 From: robert-hh Date: Thu, 9 Jun 2022 13:44:22 +0200 Subject: [PATCH] samd/mphalport: Add a mp_hal_ticks_ms_64() function. Returning a 64 bit number. This will be used by the utime module and the machine.UART module for timeout avoiding overflow. --- ports/samd/mphalport.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ports/samd/mphalport.h b/ports/samd/mphalport.h index 2eb4ce7ca6..c2aca8b0e2 100644 --- a/ports/samd/mphalport.h +++ b/ports/samd/mphalport.h @@ -50,6 +50,10 @@ static inline mp_uint_t mp_hal_ticks_ms(void) { return systick_ms; } +static inline uint64_t mp_hal_ticks_ms_64(void) { + return ((uint64_t)systick_ms_upper << 32) + systick_ms; +} + static inline mp_uint_t mp_hal_ticks_us(void) { #if defined(MCU_SAMD21) @@ -74,7 +78,7 @@ static inline mp_uint_t mp_hal_ticks_cpu(void) { } static inline uint64_t mp_hal_time_ns(void) { - return ((uint64_t)systick_ms + (uint64_t)systick_ms_upper * 0x100000000) * 1000000; + return mp_hal_ticks_ms_64() * 1000000; } // C-level pin HAL