2012-10-04 13:57:18 +02:00
|
|
|
/* small timer library, uses timer2 */
|
|
|
|
|
|
|
|
#ifndef _UTIL_H
|
|
|
|
#define _UTIL_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
/* structures */
|
|
|
|
typedef struct {
|
2012-10-07 02:04:16 +02:00
|
|
|
uint8_t current;
|
|
|
|
uint8_t timeout;
|
2012-10-04 13:57:18 +02:00
|
|
|
} timer_t;
|
|
|
|
|
|
|
|
typedef struct {
|
2012-10-07 02:04:16 +02:00
|
|
|
uint16_t current;
|
|
|
|
uint16_t timeout;
|
2012-10-04 13:57:18 +02:00
|
|
|
} timerL_t;
|
|
|
|
|
|
|
|
/* functions */
|
|
|
|
void timer_init(void);
|
|
|
|
void timer_set(timer_t *t, uint8_t timeout);
|
|
|
|
bool timer_expired(timer_t *t);
|
|
|
|
void timerL_set(timerL_t *t, uint16_t timeout);
|
|
|
|
bool timerL_expired(timerL_t *t);
|
|
|
|
|
|
|
|
#endif
|