app_io.h
Go to the documentation of this file.
1
52 #ifndef _APP_IO_H_
53 #define _APP_IO_H_
54
55 #include "app_drv_error.h"
56 #include <stdint.h>
57
68 #define APP_IO_PIN_0 ((uint32_t)0x00000001U)
69 #define APP_IO_PIN_1 ((uint32_t)0x00000002U)
70 #define APP_IO_PIN_2 ((uint32_t)0x00000004U)
71 #define APP_IO_PIN_3 ((uint32_t)0x00000008U)
72 #define APP_IO_PIN_4 ((uint32_t)0x00000010U)
73 #define APP_IO_PIN_5 ((uint32_t)0x00000020U)
74 #define APP_IO_PIN_6 ((uint32_t)0x00000040U)
75 #define APP_IO_PIN_7 ((uint32_t)0x00000080U)
76 #define APP_IO_PIN_8 ((uint32_t)0x00000100U)
77 #define APP_IO_PIN_9 ((uint32_t)0x00000200U)
78 #define APP_IO_PIN_10 ((uint32_t)0x00000400U)
79 #define APP_IO_PIN_11 ((uint32_t)0x00000800U)
80 #define APP_IO_PIN_12 ((uint32_t)0x00001000U)
81 #define APP_IO_PIN_13 ((uint32_t)0x00002000U)
82 #define APP_IO_PIN_14 ((uint32_t)0x00004000U)
83 #define APP_IO_PIN_15 ((uint32_t)0x00008000U)
84 #define APP_IO_PIN_16 ((uint32_t)0x00010000U)
85 #define APP_IO_PIN_17 ((uint32_t)0x00020000U)
86 #define APP_IO_PIN_18 ((uint32_t)0x00040000U)
87 #define APP_IO_PIN_19 ((uint32_t)0x00080000U)
88 #define APP_IO_PIN_20 ((uint32_t)0x00100000U)
89 #define APP_IO_PIN_21 ((uint32_t)0x00200000U)
90 #define APP_IO_PIN_22 ((uint32_t)0x00400000U)
91 #define APP_IO_PIN_23 ((uint32_t)0x00800000U)
92 #define APP_IO_PIN_24 ((uint32_t)0x01000000U)
93 #define APP_IO_PIN_25 ((uint32_t)0x02000000U)
94 #define APP_IO_PIN_26 ((uint32_t)0x04000000U)
95 #define APP_IO_PIN_27 ((uint32_t)0x08000000U)
96 #define APP_IO_PIN_28 ((uint32_t)0x10000000U)
97 #define APP_IO_PIN_29 ((uint32_t)0x20000000U)
98 #define APP_IO_PIN_30 ((uint32_t)0x40000000U)
99 #define APP_IO_PIN_31 ((uint32_t)0x80000000U)
101 #define APP_IO_PINS_0_15 ((uint32_t)0x0000FFFFU)
102 #define APP_IO_PINS_16_31 ((uint32_t)0xFFFF0000U)
103 #define APP_IO_PIN_ALL ((uint32_t)0xFFFFFFFFU)
104 #define APP_MSIO_PIN_MASK ((uint32_t)0x0000001FU)
105 #define APP_MSIO_PIN_ALL ((uint32_t)0x001FU)
106 #define APP_AON_IO_PIN_MASK ((uint32_t)0x000000FFU)
107 #define APP_AON_IO_PIN_ALL ((uint32_t)0x00FFU)
109 #define APP_IO_PIN_MASK ((uint32_t)0xFFFFFFFFU)
114 #define APP_IO_DEFAULT_CONFIG \
115 { \
116 .pin = APP_IO_PIN_ALL, \
117 .mode = APP_IO_MODE_INPUT, \
118 .pull = APP_IO_PULLDOWN, \
119 .mux = APP_IO_MUX_7, \
120 }
121
131 typedef enum
132 {
133 APP_IO_PIN_RESET,
134 APP_IO_PIN_SET,
135 } app_io_pin_state_t;
136
140 typedef enum
141 {
142 APP_IO_TYPE_NORMAL,
143 APP_IO_TYPE_AON,
144 APP_IO_TYPE_MSIO,
145 APP_IO_TYPE_MAX,
146 }app_io_type_t;
147
151 typedef enum
152 {
153 APP_IO_MODE_INPUT,
154 APP_IO_MODE_OUT_PUT,
155 APP_IO_MODE_MUX,
156 APP_IO_MODE_IT_RISING,
157 APP_IO_MODE_IT_FALLING,
158 APP_IO_MODE_IT_HIGH,
159 APP_IO_MODE_IT_LOW,
160 APP_IO_MODE_ANALOG,
161 APP_IO_MODE_MAX,
162 }app_io_mode_t;
163
167 typedef enum
168 {
169 APP_IO_NONE_WAKEUP,
170 APP_IO_DISABLE_WAKEUP,
171 APP_IO_ENABLE_WAKEUP,
172 }app_handle_mode_t;
173
177 typedef enum
178 {
179 APP_IO_CTX_WAKEUP,
180 APP_IO_CTX_INT,
181 }app_ctx_type_t;
182
186 typedef enum
187 {
188 APP_IO_NOPULL,
189 APP_IO_PULLUP,
190 APP_IO_PULLDOWN,
191 APP_IO_PULL_MAX
192 }app_io_pull_t;
193
197 typedef enum
198 {
199 APP_IO_MUX_0,
200 APP_IO_MUX_1,
201 APP_IO_MUX_2,
202 APP_IO_MUX_3,
203 APP_IO_MUX_4,
204 APP_IO_MUX_5,
205 APP_IO_MUX_6,
206 APP_IO_MUX_7,
207 APP_IO_MUX_8,
208 APP_IO_MUX_MAX,
209 }app_io_mux_t;
218 typedef struct
219 {
220 uint32_t pin;
222 app_io_mode_t mode;
223 app_io_pull_t pull;
224 app_io_mux_t mux;
225 } app_io_init_t;
230 /* Exported functions --------------------------------------------------------*/
246 uint16_t app_io_init(app_io_type_t type, app_io_init_t *p_init);
247
258 uint16_t app_io_deinit(app_io_type_t type, uint32_t pin);
259
270 app_io_pin_state_t app_io_read_pin(app_io_type_t type, uint32_t pin);
271
283 uint16_t app_io_write_pin(app_io_type_t type, uint32_t pin, app_io_pin_state_t pin_state);
284
295 uint16_t app_io_toggle_pin(app_io_type_t type, uint32_t pin);
298 #endif
299
APP_IO_MUX_1
@ APP_IO_MUX_1
Definition: app_io.h:200
APP_IO_CTX_INT
@ APP_IO_CTX_INT
Definition: app_io.h:180
APP_IO_MUX_6
@ APP_IO_MUX_6
Definition: app_io.h:205
app_io_init_t::mode
app_io_mode_t mode
Definition: app_io.h:222
APP_IO_MODE_IT_HIGH
@ APP_IO_MODE_IT_HIGH
Definition: app_io.h:158
APP_IO_MODE_ANALOG
@ APP_IO_MODE_ANALOG
Definition: app_io.h:160
APP_IO_NOPULL
@ APP_IO_NOPULL
Definition: app_io.h:188
APP_IO_MUX_4
@ APP_IO_MUX_4
Definition: app_io.h:203
app_io_write_pin
uint16_t app_io_write_pin(app_io_type_t type, uint32_t pin, app_io_pin_state_t pin_state)
Set or clear the selected data port bit.
APP_IO_MODE_IT_RISING
@ APP_IO_MODE_IT_RISING
Definition: app_io.h:156
APP_IO_MODE_MAX
@ APP_IO_MODE_MAX
Definition: app_io.h:161
app_io_deinit
uint16_t app_io_deinit(app_io_type_t type, uint32_t pin)
De-initialize the GPIOx peripheral.
APP_IO_ENABLE_WAKEUP
@ APP_IO_ENABLE_WAKEUP
Definition: app_io.h:171
app_io_pull_t
app_io_pull_t
GPIO pull Enumerations definition.
Definition: app_io.h:187
app_io_type_t
app_io_type_t
GPIO type Enumerations definition.
Definition: app_io.h:141
APP_IO_MUX_7
@ APP_IO_MUX_7
Definition: app_io.h:206
app_ctx_type_t
app_ctx_type_t
GPIO handler context type Enumerations definition.
Definition: app_io.h:178
APP_IO_TYPE_AON
@ APP_IO_TYPE_AON
Definition: app_io.h:143
app_io_mode_t
app_io_mode_t
GPIO mode Enumerations definition.
Definition: app_io.h:152
APP_IO_MUX_8
@ APP_IO_MUX_8
Definition: app_io.h:207
app_io_init_t::pull
app_io_pull_t pull
Definition: app_io.h:223
APP_IO_PULL_MAX
@ APP_IO_PULL_MAX
Definition: app_io.h:191
APP_IO_PIN_RESET
@ APP_IO_PIN_RESET
Definition: app_io.h:133
APP_IO_MODE_IT_FALLING
@ APP_IO_MODE_IT_FALLING
Definition: app_io.h:157
APP_IO_TYPE_NORMAL
@ APP_IO_TYPE_NORMAL
Definition: app_io.h:142
APP_IO_PULLUP
@ APP_IO_PULLUP
Definition: app_io.h:189
APP_IO_TYPE_MSIO
@ APP_IO_TYPE_MSIO
Definition: app_io.h:144
APP_IO_MUX_MAX
@ APP_IO_MUX_MAX
Definition: app_io.h:208
APP_IO_MUX_3
@ APP_IO_MUX_3
Definition: app_io.h:202
APP_IO_MUX_5
@ APP_IO_MUX_5
Definition: app_io.h:204
APP_IO_MUX_0
@ APP_IO_MUX_0
Definition: app_io.h:199
APP_IO_MUX_2
@ APP_IO_MUX_2
Definition: app_io.h:201
APP_IO_MODE_INPUT
@ APP_IO_MODE_INPUT
Definition: app_io.h:153
APP_IO_PIN_SET
@ APP_IO_PIN_SET
Definition: app_io.h:134
APP_IO_PULLDOWN
@ APP_IO_PULLDOWN
Definition: app_io.h:190
APP_IO_TYPE_MAX
@ APP_IO_TYPE_MAX
Definition: app_io.h:145
app_io_read_pin
app_io_pin_state_t app_io_read_pin(app_io_type_t type, uint32_t pin)
Read the specified input port pin..
app_io_pin_state_t
app_io_pin_state_t
GPIO state Enumerations definition.
Definition: app_io.h:132
app_io_init
uint16_t app_io_init(app_io_type_t type, app_io_init_t *p_init)
Initialize the APP GPIO DRIVER according to the specified parameters in the app_io_type_t and app_io_...
APP_IO_DISABLE_WAKEUP
@ APP_IO_DISABLE_WAKEUP
Definition: app_io.h:170
app_handle_mode_t
app_handle_mode_t
GPIO wake-up mode Enumerations definition.
Definition: app_io.h:168
app_io_toggle_pin
uint16_t app_io_toggle_pin(app_io_type_t type, uint32_t pin)
Toggle the specified GPIO pin.
app_io_mux_t
app_io_mux_t
GPIO mux Enumerations definition.
Definition: app_io.h:198
app_io_init_t::mux
app_io_mux_t mux
Definition: app_io.h:224
APP_IO_MODE_MUX
@ APP_IO_MODE_MUX
Definition: app_io.h:155
app_drv_error.h
Header file of app driver error code.
APP_IO_MODE_OUT_PUT
@ APP_IO_MODE_OUT_PUT
Definition: app_io.h:154
APP_IO_MODE_IT_LOW
@ APP_IO_MODE_IT_LOW
Definition: app_io.h:159
app_io_init_t
GPIO parameter structure definition.
Definition: app_io.h:219
app_io_init_t::pin
uint32_t pin
Definition: app_io.h:220
APP_IO_NONE_WAKEUP
@ APP_IO_NONE_WAKEUP
Definition: app_io.h:169
APP_IO_CTX_WAKEUP
@ APP_IO_CTX_WAKEUP
Definition: app_io.h:179