samd/mphalport: Fix an execution order bug in mp_hal_ticks_us_64().
The upper 32 bit of the 64 bit ticks register was taken before disabling the interrupts. That may have caused a wrong return values. Besides that, the function may cause trouble when called in an IRQ context, because it unconditionally enables IRQ. Signed-off-by: robert-hh <robert@hammelrath.com>
This commit is contained in:
@@ -94,10 +94,10 @@ void mp_hal_delay_us(mp_uint_t us) {
|
||||
}
|
||||
|
||||
uint64_t mp_hal_ticks_us_64(void) {
|
||||
uint32_t us64_upper = ticks_us64_upper;
|
||||
uint32_t us64_lower;
|
||||
uint8_t intflag;
|
||||
__disable_irq();
|
||||
uint32_t us64_upper = ticks_us64_upper;
|
||||
#if defined(MCU_SAMD21)
|
||||
us64_lower = REG_TC4_COUNT32_COUNT;
|
||||
intflag = TC4->COUNT32.INTFLAG.reg;
|
||||
|
||||
Reference in New Issue
Block a user