-
Notifications
You must be signed in to change notification settings - Fork 0
/
status.c
114 lines (107 loc) · 2.55 KB
/
status.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
110
111
112
113
114
#include "status.h"
#include <avr/io.h>
void status_pin_init()
{
uint8_t portc_out = (1<<PC0)|(1<<PC1)|(1<<PC2)|(1<<PC3)|(1<<PC4)|(1<<PC5);
uint8_t portd_out = (1<<PD3)|(1<<PD4)|(1<<PD5);
PORTC &= ~portc_out;
DDRC |= portc_out;
PORTD &= ~portd_out;
DDRD |= portd_out;
}
// Toggle these pins. Don't touch other pins.
void status_toggle(uint8_t pins)
{
if (pins & STATUS0)
PORTC ^= 1 << PC0;
if (pins & STATUS1)
PORTC ^= 1 << PC1;
if (pins & STATUS2)
PORTC ^= 1 << PC2;
if (pins & STATUS3)
PORTC ^= 1 << PC3;
if (pins & STATUS4)
PORTC ^= 1 << PC4;
if (pins & STATUS5)
PORTC ^= 1 << PC5;
if (pins & STATUS6)
PORTD ^= 1 << PD4;
if (pins & STATUS7)
PORTD ^= 1 << PD3;
}
// Set these pins to high. Don't touch other pins.
void status_set(uint8_t pins)
{
if (pins & STATUS0)
PORTC |= 1 << PC0;
if (pins & STATUS1)
PORTC |= 1 << PC1;
if (pins & STATUS2)
PORTC |= 1 << PC2;
if (pins & STATUS3)
PORTC |= 1 << PC3;
if (pins & STATUS4)
PORTC |= 1 << PC4;
if (pins & STATUS5)
PORTC |= 1 << PC5;
if (pins & STATUS6)
PORTD |= 1 << PD4;
if (pins & STATUS7)
PORTD |= 1 << PD3;
}
// Set these pins to low. Don't touch other pins.
void status_clear(uint8_t pins)
{
if (pins & STATUS0)
PORTC &= ~(1 << PC0);
if (pins & STATUS1)
PORTC &= ~(1 << PC1);
if (pins & STATUS2)
PORTC &= ~(1 << PC2);
if (pins & STATUS3)
PORTC &= ~(1 << PC3);
if (pins & STATUS4)
PORTC &= ~(1 << PC4);
if (pins & STATUS5)
PORTC &= ~(1 << PC5);
if (pins & STATUS6)
PORTD &= ~(1 << PD4);
if (pins & STATUS7)
PORTD &= ~(1 << PD3);
}
// Set only these pins to high. Other pins to low.
void status(uint8_t pins)
{
if (pins & STATUS0)
PORTC |= 1 << PC0;
else
PORTC &= ~(1 << PC0);
if (pins & STATUS1)
PORTC |= 1 << PC1;
else
PORTC &= ~(1 << PC1);
if (pins & STATUS2)
PORTC |= 1 << PC2;
else
PORTC &= ~(1 << PC2);
if (pins & STATUS3)
PORTC |= 1 << PC3;
else
PORTC &= ~(1 << PC3);
if (pins & STATUS4)
PORTC |= 1 << PC4;
else
PORTC &= ~(1 << PC4);
if (pins & STATUS5)
PORTC |= 1 << PC5;
else
PORTC &= ~(1 << PC5);
if (pins & STATUS6)
PORTD |= 1 << PD4;
else
PORTD &= ~(1 << PD4);
if (pins & STATUS7)
PORTD |= 1 << PD3;
else
PORTD &= ~(1 << PD3);
}