Skip to content

Commit b3806c5

Browse files
committed
alif/system_tick: Add system_tick_get_ms_fast when SysTick is enabled.
This function gives direct access to the 32-bit SysTick millisecond counter. And then use it to implement `mp_hal_ticks_ms()`. Signed-off-by: Damien George <damien@micropython.org>
1 parent 953773c commit b3806c5

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

ports/alif/mphalport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ mp_uint_t mp_hal_ticks_us(void) {
133133
mp_uint_t mp_hal_ticks_ms(void) {
134134
// Convert system tick to millisecond counter.
135135
#if MICROPY_HW_SYSTEM_TICK_USE_SYSTICK
136-
return system_tick_get_u64() / 1000ULL;
136+
return system_tick_get_ms_fast();
137137
#elif MICROPY_HW_SYSTEM_TICK_USE_LPTIMER
138138
return system_tick_get_u64() * 1000ULL / system_tick_source_hz;
139139
#else

ports/alif/system_tick.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,11 @@ void system_tick_wfe_with_timeout_us(uint32_t timeout_us);
4141
void system_tick_schedule_after_us(uint32_t ticks_us);
4242
void system_tick_schedule_callback(void);
4343

44+
#if MICROPY_HW_SYSTEM_TICK_USE_SYSTICK
45+
static inline uint32_t system_tick_get_ms_fast(void) {
46+
extern volatile uint32_t system_tick_ms_counter;
47+
return system_tick_ms_counter;
48+
}
49+
#endif
50+
4451
#endif // MICROPY_INCLUDED_ALIF_SYSTEM_TICK_H

0 commit comments

Comments
 (0)