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
|
/*
* Copyright 2021 Daniel Friesel
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#ifndef GPIO_H
#define GPIO_H
extern "C" {
#include "lm4f_cpp_wrapper.h"
}
class GPIO {
private:
GPIO(const GPIO ©);
public:
GPIO () {}
enum Pin : unsigned char {
pa_0 = 0, pa_1, pa_2, pa_3, pa_4, pa_5, pa_6, pa_7,
pb_0, pb_1, pb_2, pb_3, pb_4, pb_5, pb_6, pb_7,
pc_0, pc_1, pc_2, pc_3, pc_4, pc_5, pc_6, pc_7,
pd_0, pd_1, pd_2, pd_3, pd_4, pd_5, pd_6, pd_7,
pe_0, pe_1, pe_2, pe_3, pe_4, pe_5, pe_6, pe_7,
pf_0, pf_1, pf_2, pf_3, pf_4,
PIN_INVALID
};
inline void setup() {
mp_gpio_setup();
}
inline void led_on(unsigned char id = 0) {
mp_gpio_write(pf_1 + id, 1);
}
inline void led_off(unsigned char id = 0) {
mp_gpio_write(pf_1 + id, 0);
}
inline void led_toggle(unsigned char id = 0) {
mp_gpio_write(pf_1 + id, !mp_gpio_read(pf_1 + id));
}
inline void input(unsigned char const pin) {
mp_gpio_input(pin);
}
inline void input(unsigned char const pin, unsigned char const pull) {
}
inline void output(unsigned char const pin) {
mp_gpio_output(pin);
}
/*
inline void output(unsigned char const pin, unsigned char const value) {
}*/
inline unsigned int read(unsigned char const pin) {
return mp_gpio_read(pin);
}
inline void write(unsigned char const pin, unsigned char value) {
mp_gpio_write(pin, value);
}
};
extern GPIO gpio;
#endif
|