diff options
| author | robert-hh <robert@hammelrath.com> | 2022-06-09 13:44:22 +0200 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2022-10-06 22:56:58 +1100 |
| commit | 7da76639027057245cfee043733193b3265e7a54 (patch) | |
| tree | c04cd5686fc6b9c0f89f8ccb23d50965f3e9e453 | |
| parent | aa6dbbcffd4f0a5c7572b8aa1ef256794838f969 (diff) | |
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.
| -rw-r--r-- | ports/samd/mphalport.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ports/samd/mphalport.h b/ports/samd/mphalport.h index 2eb4ce7ca..c2aca8b0e 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 |
