blob: 7ac3ba361ee7dfc4af5d5195795f33cfb4e6e7e6 (
plain)
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
|
#ifndef GPIO_H
#define GPIO_H
#include <msp430.h>
class GPIO {
private:
GPIO(const GPIO ©);
public:
GPIO () {}
inline void setup() {
P1OUT = 0;
P2OUT = 0;
P3OUT = 0;
P4OUT = 0;
P1DIR = BIT0;
P2DIR = 0;
P3DIR = 0;
P4DIR = BIT6;
}
inline void led_on(unsigned char id) {
if (id == 0) {
P1OUT |= BIT0;
} else {
P4OUT |= BIT6;
}
}
inline void led_off(unsigned char id) {
if (id == 0) {
P1OUT &= ~BIT0;
} else {
P4OUT &= ~BIT6;
}
}
inline void led_toggle(unsigned char id) {
if (id == 0) {
P1OUT ^= BIT0;
} else {
P4OUT ^= BIT6;
}
}
};
extern GPIO gpio;
#endif
|