stm32: fix uses of ticks_ms global
This commit is contained in:
parent
77b78d7fb9
commit
bfdfe0e681
@ -250,10 +250,10 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t
|
||||
}
|
||||
|
||||
size_t rx_bytes = 0;
|
||||
uint64_t start_ticks = ticks_ms;
|
||||
uint64_t start_ticks = supervisor_ticks_ms64();
|
||||
|
||||
// Wait for all bytes received or timeout, same as nrf
|
||||
while ( (ringbuf_count(&self->rbuf) < len) && (ticks_ms - start_ticks < self->timeout_ms) ) {
|
||||
while ( (ringbuf_count(&self->rbuf) < len) && (supervisor_ticks_ms64() - start_ticks < self->timeout_ms) ) {
|
||||
RUN_BACKGROUND_TASKS;
|
||||
//restart if it failed in the callback
|
||||
if (errflag != HAL_OK) {
|
||||
|
@ -48,9 +48,9 @@ STATIC uint32_t get_us(void) {
|
||||
uint32_t ticks_per_us = HAL_RCC_GetSysClockFreq()/1000000;
|
||||
uint32_t micros, sys_cycles;
|
||||
do {
|
||||
micros = ticks_ms;
|
||||
micros = supervisor_ticks_ms32();
|
||||
sys_cycles = SysTick->VAL; //counts backwards
|
||||
} while (micros != ticks_ms); //try again if ticks_ms rolled over
|
||||
} while (micros != supervisor_ticks_ms32()); //try again if ticks_ms rolled over
|
||||
return (micros * 1000) + (ticks_per_us * 1000 - sys_cycles) / ticks_per_us;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user