-
Notifications
You must be signed in to change notification settings - Fork 0
/
output.c
109 lines (86 loc) · 1.51 KB
/
output.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include "config.h"
#include "output.h"
#include "adc.h"
#include "display.h"
#include "input.h"
#include <avr/io.h>
#include <avr/interrupt.h>
static volatile char locked = 0;
static volatile char enabled = 0;
uint8_t canSendLcd() {
if(doCanSendLcd != NULL)
return doCanSendLcd();
return 1;
}
char isEnabled() {
return enabled;
}
void outputInit() {
OUTPUT_DDR |= (1 << OUTPUT_PIN);
}
void outputHandleDisp(lcd_t lcd) {
if (dispHandler != NULL)
dispHandler(lcd);
}
void outputHandleLoop() {
if (loopHandler != NULL)
loopHandler();
}
void mainLock() {
locked = 1;
}
void mainUnlock() {
locked = 0;
}
char *getOutputName() {
return outputName;
}
char isLocked() {
return locked;
}
inline void outputEnable() {
if(enabled)
return;
enabled = 1;
if (enableHandler != NULL)
enableHandler();
}
inline void outputDisable() {
enabled = 0;
}
ISR(TIMER0_OVF_vect) {
if(timer0Handler != NULL)
timer0Handler();
else if(!enabled || locked) {
OUTPUT_PORT &= ~(1 << OUTPUT_PIN);
TCCR0 = 0;
return;
}
}
ISR(TIMER1_OVF_vect) {
if(timer1Handler != NULL)
timer1Handler();
else if(!enabled || locked) {
OUTPUT_PORT &= ~(1 << OUTPUT_PIN);
TCCR1B = 0;
return;
}
}
ISR(TIMER2_OVF_vect) {
if(timer2Handler != NULL)
timer2Handler();
else if(!enabled || locked) {
OUTPUT_PORT &= ~(1 << OUTPUT_PIN);
TCCR2 = 0;
return;
}
}
ISR(TIMER3_OVF_vect) {
if(timer3Handler != NULL)
timer3Handler();
else if(!enabled || locked) {
OUTPUT_PORT &= ~(1 << OUTPUT_PIN);
TCCR3B = 0;
return;
}
}