42 lines
665 B
C
Executable file
42 lines
665 B
C
Executable file
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include <sys/threads.h>
|
|
#include <util/list.h>
|
|
|
|
|
|
extern list_t sys_timers;
|
|
|
|
#define TF_REPEAT (1<<0)
|
|
|
|
|
|
struct sys_timer {
|
|
list_t list;
|
|
|
|
uint32_t id;
|
|
systick_t timeout;
|
|
systick_t elapse;
|
|
|
|
void (*handler)(void);
|
|
|
|
union {
|
|
uint8_t flags;
|
|
struct {
|
|
uint8_t repeat:1;
|
|
uint8_t res:7;
|
|
};
|
|
};
|
|
};
|
|
|
|
typedef struct sys_timer SYSTIMER;
|
|
#define SYSTIMER(ptr) ((SYSTIMER*)ptr)
|
|
|
|
|
|
SYSTIMER* timer_create(uint32_t id,uint32_t timeout);
|
|
SYSTIMER* timer_create_ex(uint32_t id,uint32_t timeout,void (*handler)(void),uint8_t flags);
|
|
|
|
|
|
void timer_start(SYSTIMER* timer,uint32_t timeout);
|
|
void timer_cancel(SYSTIMER* timer);
|
|
|