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.
This commit is contained in:
robert-hh 2022-06-09 13:44:22 +02:00 committed by Damien George
parent aa6dbbcffd
commit 7da7663902
1 changed files with 5 additions and 1 deletions

View File

@ -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