[feat] add timer_delay_us function

This commit is contained in:
zhji 2025-06-02 21:34:05 +08:00
parent 35186111b8
commit ab88fa8455
2 changed files with 8 additions and 0 deletions

View File

@ -21,6 +21,7 @@ uint32_t timer_count_h_read_raw(void);
void timer_start(void);
void timer_stop(void);
int timer_is_stopped(void);
void timer_delay_us(uint32_t us);
void timer_alarm_set(uint8_t alarm_id, uint32_t alarm_count);
uint32_t timer_alarm_get(uint8_t alarm_id);

View File

@ -44,6 +44,13 @@ int timer_is_stopped(void)
}
}
void timer_delay_us(uint32_t us)
{
uint64_t time = timer_count_read();
time += us;
while (timer_count_read() < time);
}
void timer_alarm_set(uint8_t alarm_id, uint32_t alarm_count)
{
if (alarm_id >= TIMER_ALARM_MAX) {