Skip to content

Commit bfdfe0e

Browse files
committed
stm32: fix uses of ticks_ms global
1 parent 77b78d7 commit bfdfe0e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

ports/stm32f4/common-hal/busio/UART.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,10 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t
250250
}
251251

252252
size_t rx_bytes = 0;
253-
uint64_t start_ticks = ticks_ms;
253+
uint64_t start_ticks = supervisor_ticks_ms64();
254254

255255
// Wait for all bytes received or timeout, same as nrf
256-
while ( (ringbuf_count(&self->rbuf) < len) && (ticks_ms - start_ticks < self->timeout_ms) ) {
256+
while ( (ringbuf_count(&self->rbuf) < len) && (supervisor_ticks_ms64() - start_ticks < self->timeout_ms) ) {
257257
RUN_BACKGROUND_TASKS;
258258
//restart if it failed in the callback
259259
if (errflag != HAL_OK) {

ports/stm32f4/common-hal/microcontroller/__init__.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ STATIC uint32_t get_us(void) {
4848
uint32_t ticks_per_us = HAL_RCC_GetSysClockFreq()/1000000;
4949
uint32_t micros, sys_cycles;
5050
do {
51-
micros = ticks_ms;
51+
micros = supervisor_ticks_ms32();
5252
sys_cycles = SysTick->VAL; //counts backwards
53-
} while (micros != ticks_ms); //try again if ticks_ms rolled over
53+
} while (micros != supervisor_ticks_ms32()); //try again if ticks_ms rolled over
5454
return (micros * 1000) + (ticks_per_us * 1000 - sys_cycles) / ticks_per_us;
5555
}
5656

0 commit comments

Comments
 (0)