Firmware SDK
twr_gpio.h
1 #ifndef _TWR_GPIO_H
2 #define _TWR_GPIO_H
3 
4 #include <twr_common.h>
5 
9 
11 
12 typedef enum
13 {
16 
19 
22 
25 
28 
31 
34 
37 
40 
43 
46 
49 
52 
55 
58 
61 
64 
67 
70 
73 
76 
79 
81  TWR_GPIO_SDA0 = 22
82 
84 
86 
87 typedef enum
88 {
91 
94 
97 
99 
101 
102 typedef enum
103 {
106 
109 
112 
115 
118 
121 
124 
127 
130 
133 
136 
139 
141  TWR_GPIO_MODE_ALTERNATE_7 = (7 << 4) | 2
142 
144 
147 
148 void twr_gpio_init(twr_gpio_channel_t channel);
149 
153 
155 
159 
161 
165 
167 
171 
173 
177 
179 
183 
184 void twr_gpio_set_output(twr_gpio_channel_t channel, int state);
185 
189 
191 
194 
196 
198 
199 #endif // _TWR_GPIO_H
twr_gpio_pull_t twr_gpio_get_pull(twr_gpio_channel_t channel)
Get pull-up/pull-down configuration for GPIO channel.
Definition: twr_gpio.c:361
void twr_gpio_set_output(twr_gpio_channel_t channel, int state)
Set output state for GPIO channel.
Definition: twr_gpio.c:471
void twr_gpio_set_pull(twr_gpio_channel_t channel, twr_gpio_pull_t pull)
Set pull-up/pull-down configuration for GPIO channel.
Definition: twr_gpio.c:340
void twr_gpio_init(twr_gpio_channel_t channel)
Initialize GPIO channel.
Definition: twr_gpio.c:325
twr_gpio_mode_t
GPIO mode of operation.
Definition: twr_gpio.h:103
twr_gpio_channel_t
GPIO channels.
Definition: twr_gpio.h:13
void twr_gpio_toggle_output(twr_gpio_channel_t channel)
Toggle output state for GPIO channel.
Definition: twr_gpio.c:483
int twr_gpio_get_output(twr_gpio_channel_t channel)
Get output state for GPIO channel.
Definition: twr_gpio.c:477
twr_gpio_mode_t twr_gpio_get_mode(twr_gpio_channel_t channel)
Get mode of operation for GPIO channel.
Definition: twr_gpio.c:428
twr_gpio_pull_t
GPIO pull-up/pull-down setting.
Definition: twr_gpio.h:88
int twr_gpio_get_input(twr_gpio_channel_t channel)
Get input state for GPIO channel.
Definition: twr_gpio.c:465
void twr_gpio_set_mode(twr_gpio_channel_t channel, twr_gpio_mode_t mode)
Set mode of operation for GPIO channel.
Definition: twr_gpio.c:367
@ TWR_GPIO_MODE_INPUT
GPIO channel operates as input.
Definition: twr_gpio.h:105
@ TWR_GPIO_MODE_OUTPUT
GPIO channel operates as output.
Definition: twr_gpio.h:108
@ TWR_GPIO_MODE_ALTERNATE_2
GPIO channel operates in alternate mode AF2.
Definition: twr_gpio.h:126
@ TWR_GPIO_MODE_ALTERNATE_5
GPIO channel operates in alternate mode AF5.
Definition: twr_gpio.h:135
@ TWR_GPIO_MODE_ALTERNATE_6
GPIO channel operates in alternate mode AF6.
Definition: twr_gpio.h:138
@ TWR_GPIO_MODE_ALTERNATE_0
GPIO channel operates in alternate mode AF0.
Definition: twr_gpio.h:120
@ TWR_GPIO_MODE_ALTERNATE_3
GPIO channel operates in alternate mode AF3.
Definition: twr_gpio.h:129
@ TWR_GPIO_MODE_ALTERNATE
GPIO channel operates in alternate mode.
Definition: twr_gpio.h:111
@ TWR_GPIO_MODE_ALTERNATE_4
GPIO channel operates in alternate mode AF4.
Definition: twr_gpio.h:132
@ TWR_GPIO_MODE_ALTERNATE_7
GPIO channel operates in alternate mode AF7.
Definition: twr_gpio.h:141
@ TWR_GPIO_MODE_ANALOG
GPIO channel operates in analog mode.
Definition: twr_gpio.h:114
@ TWR_GPIO_MODE_OUTPUT_OD
GPIO channel operates as open-drain output.
Definition: twr_gpio.h:117
@ TWR_GPIO_MODE_ALTERNATE_1
GPIO channel operates in alternate mode AF1.
Definition: twr_gpio.h:123
@ TWR_GPIO_P11
GPIO channel P11, TXD2.
Definition: twr_gpio.h:48
@ TWR_GPIO_P12
GPIO channel P12, MISO.
Definition: twr_gpio.h:51
@ TWR_GPIO_P1
GPIO channel P1, A1, RXD0.
Definition: twr_gpio.h:18
@ TWR_GPIO_P8
GPIO channel P8.
Definition: twr_gpio.h:39
@ TWR_GPIO_P3
GPIO channel P3, A3, RXD1.
Definition: twr_gpio.h:24
@ TWR_GPIO_P13
GPIO channel P13, MOSI.
Definition: twr_gpio.h:54
@ TWR_GPIO_P5
GPIO channel P5, A5, DAC1.
Definition: twr_gpio.h:30
@ TWR_GPIO_P9
GPIO channel P9.
Definition: twr_gpio.h:42
@ TWR_GPIO_SDA0
GPIO channel SDA0.
Definition: twr_gpio.h:81
@ TWR_GPIO_INT
GPIO channel INT.
Definition: twr_gpio.h:75
@ TWR_GPIO_P17
GPIO channel P17, SDA1.
Definition: twr_gpio.h:66
@ TWR_GPIO_P6
GPIO channel P6.
Definition: twr_gpio.h:33
@ TWR_GPIO_P15
GPIO channel P15, CS.
Definition: twr_gpio.h:60
@ TWR_GPIO_BUTTON
GPIO channel BUTTON.
Definition: twr_gpio.h:72
@ TWR_GPIO_SCL0
GPIO channel SCL0.
Definition: twr_gpio.h:78
@ TWR_GPIO_LED
GPIO channel LED.
Definition: twr_gpio.h:69
@ TWR_GPIO_P10
GPIO channel P10, RXD2.
Definition: twr_gpio.h:45
@ TWR_GPIO_P2
GPIO channel P2, A2, TXD1.
Definition: twr_gpio.h:21
@ TWR_GPIO_P0
GPIO channel P0, A0, TXD0.
Definition: twr_gpio.h:15
@ TWR_GPIO_P14
GPIO channel P14, SCLK.
Definition: twr_gpio.h:57
@ TWR_GPIO_P4
GPIO channel P4, A4, DAC0.
Definition: twr_gpio.h:27
@ TWR_GPIO_P16
GPIO channel P16, SCL1.
Definition: twr_gpio.h:63
@ TWR_GPIO_P7
GPIO channel P7, A6.
Definition: twr_gpio.h:36
@ TWR_GPIO_PULL_NONE
GPIO channel has no pull-up/pull-down.
Definition: twr_gpio.h:90
@ TWR_GPIO_PULL_DOWN
GPIO channel has pull-down.
Definition: twr_gpio.h:96
@ TWR_GPIO_PULL_UP
GPIO channel has pull-up.
Definition: twr_gpio.h:93