23 lines
436 B
C
23 lines
436 B
C
#ifndef MILIS_H
|
|
#define MILIS_H
|
|
|
|
#include "lib/mystd.h"
|
|
|
|
typedef uint32_t milis_t;
|
|
|
|
typedef struct {
|
|
milis_t until;
|
|
} timer_t;
|
|
|
|
milis_t milis(void);
|
|
void milis_init(void);
|
|
|
|
// return true if the timer is past the time set.
|
|
// YOU NEED TO RESET THE TIMER OTHERWISE IT WILL KEEP BEING PENDING
|
|
bool timer_wait(timer_t* timer, milis_t ms);
|
|
|
|
static inline timer_t timer_reset(void) {
|
|
return (timer_t){.until = 0};
|
|
}
|
|
|
|
#endif /* MILIS_H */
|