-
Notifications
You must be signed in to change notification settings - Fork 0
/
timer.c
43 lines (33 loc) · 765 Bytes
/
timer.c
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
32
33
34
35
36
37
38
39
40
41
42
43
#include "common.h"
#include "timer.h"
/**
* @file timer.c
* @brief Implement the 2-second Time frame for the main loop using a timer
*/
///@todo verify the timer code
void timer_reset_two_sec(void){
///@todo Confirm the configuration of the Timer
///* Clear Timer Compare Flag
sbi(TIFR, OCF1A);
///* Stop Timer
TCCR1B = 0x00;
///* Reset Count
TCNT1H = 0;
TCNT1L = 0;
///* Output compare match value 8 MHz clock
OCR1A = TIMER_TWO_SEC;
///* Start Timer
TCCR1A = 0x00;
TCCR1B = 0x05;
TCCR1C = 0x00;
}
void watch_dog(int time){
wdt_disable();
wdt_enable(time);
}
void timer_wait_reset(void){
///* Return when timer>2 seconds.
while(!(TIFR & _BV(OCF1A)));
///* Restart timer
timer_reset_two_sec();
}