forked from triffid/FiveD_on_Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimer.h
31 lines (22 loc) · 765 Bytes
/
timer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef _TIMER_H
#define _TIMER_H
#include <stdint.h>
#ifndef SIMULATION
#include <avr/io.h>
#endif
#include "simulation.h"
// time-related constants
#define US * (F_CPU / 1000000)
#define MS * (F_CPU / 1000)
// #define DEFAULT_TICK (100 US)
#define WAITING_DELAY (10 MS)
void setupTimerInterrupt(void) __attribute__ ((cold));
uint8_t getTimerResolution(const uint32_t delay);
void setTimerResolution(uint8_t r);
uint16_t getTimerCeiling(const uint32_t delay);
#define setTimerCeiling(c) OCR1A = c
void setTimer(uint32_t delay);
#define enableTimerInterrupt() do { TIMSK1 |= (1<<OCIE1A); } while (0)
#define disableTimerInterrupt() do { TIMSK1 &= ~(1<<OCIE1A); } while (0)
#define timerInterruptIsEnabled() (TIMSK1 & (1 << OCIE1A))
#endif /* _TIMER_H */