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
|
#ifndef GPIO_H
#define GPIO_H
#include "types.h"
/* GPIO pins used for the LCD display */
#define PIN_DISPLAY_SPI_CLOCK PIN_2
#define PIN_DISPLAY_SPI_MOSI PIN_3
#define PIN_DISPLAY_COMMAND_DATA PIN_18
#define PIN_DISPLAY_CHIP_SELECT PIN_25
#define PIN_DISPLAY_RESET PIN_26
/* GPIO pins used for the touch panel */
#define PIN_TOUCH_PANEL_RESET PIN_10
#define PIN_TOUCH_PANEL_IRQ PIN_28
#define PIN_TOUCH_PANEL_I2C_SDA PIN_06
#define PIN_TOUCH_PANEL_I2C_SCL PIN_07
/* GPIO pins used for the battery management */
#define PIN_BATTERY_CHARGE_INDICATOR PIN_12
#define PIN_BATTERY_VOLTAGE PIN_31
/* GPIO pins used for the button */
#define PIN_BUTTON_ENABLE PIN_15
#define PIN_BUTTON_PRESS PIN_13
/* GPIO pins used for the accelerometer */
#define PIN_ACCEL_I2C_SDA PIN_06
#define PIN_ACCEL_I2C_SCL PIN_07
#define PIN_ACCEL_IRQ PIN_08
/**
* The signal level of a GPIO line.
*/
enum gpio_level {
LOW = 0,
HIGH = 1,
};
/**
* The availables GPIO pins on the NRF82832.
*/
enum gpio_pin {
PIN_0 = 0,
PIN_1 = 1,
PIN_2 = 2,
PIN_3 = 3,
PIN_4 = 4,
PIN_5 = 5,
PIN_6 = 6,
PIN_7 = 7,
PIN_8 = 8,
PIN_9 = 9,
PIN_10 = 10,
PIN_11 = 11,
PIN_12 = 12,
PIN_13 = 13,
PIN_14 = 14,
PIN_15 = 15,
PIN_16 = 16,
PIN_17 = 17,
PIN_18 = 18,
PIN_19 = 19,
PIN_20 = 20,
PIN_21 = 21,
PIN_22 = 22,
PIN_23 = 23,
PIN_24 = 24,
PIN_25 = 25,
PIN_26 = 26,
PIN_27 = 27,
PIN_28 = 28,
PIN_29 = 29,
PIN_30 = 30,
PIN_31 = 31,
};
/**
* Init the given pin.
* Note that each pin configuration is hardcoded to fit the peripheral it is connected to.
*/
void gpio_init_pin(enum gpio_pin pin);
/**
* Disable a GPIO pin.
*/
u8 gpio_disable_pin(enum gpio_pin pin);
/**
* Read the current signal level of the given GPIO pin.
*/
enum gpio_level gpio_read_pin(enum gpio_pin pin);
/**
* Set the given GPIO pin to the given level.
* Returns 0 if the given pin is not an output pin.
* Returns 1 if written successfully
*/
u8 gpio_write_pin(enum gpio_pin pin, enum gpio_level level);
#endif
|