gr55xx_hal_aon_gpio.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file gr55xx_hal_aon_gpio.h
5 * @author BLE Driver Team
6 * @brief Header file containing functions prototypes of AON GPIO HAL library.
7 *
8 ****************************************************************************************
9 * @attention
10 #####Copyright (c) 2019 GOODIX
11 All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
15 * Redistributions of source code must retain the above copyright
16 notice, this list of conditions and the following disclaimer.
17 * Redistributions in binary form must reproduce the above copyright
18 notice, this list of conditions and the following disclaimer in the
19 documentation and/or other materials provided with the distribution.
20 * Neither the name of GOODIX nor the names of its contributors may be used
21 to endorse or promote products derived from this software without
22 specific prior written permission.
23
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 POSSIBILITY OF SUCH DAMAGE.
35 ****************************************************************************************
36 */
37
38 /** @addtogroup PERIPHERAL Peripheral Driver
39 * @{
40 */
41
42 /** @addtogroup HAL_DRIVER HAL Driver
43 * @{
44 */
45
46 /** @defgroup HAL_AON_GPIO AON_GPIO
47 * @brief AON_GPIO HAL module driver.
48 * @{
49 */
50
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55xx_HAL_AON_GPIO_H__
53 #define __GR55xx_HAL_AON_GPIO_H__
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx_ll_aon_gpio.h"
61 #include "gr55xx_hal_def.h"
62
63 /* Exported types ------------------------------------------------------------*/
64 /** @addtogroup HAL_AON_GPIO_ENUMERATIONS Enumerations
65 * @{
66 */
67
68 /**
69 * @brief AON_GPIO Bit SET and Bit RESET enumerations
70 */
71 typedef enum
72 {
73 AON_GPIO_PIN_RESET = 0U, /**< AON GPIO pin low level.*/
74 AON_GPIO_PIN_SET /**< AON GPIO pin high level.*/
75 } aon_gpio_pin_state_t;
76
77 /** @} */
78
79 /** @addtogroup HAL_AON_GPIO_STRUCTURES Structures
80 * @{
81 */
82
83 /**
84 * @brief AON_GPIO init structure definition
85 */
86 typedef struct _aon_gpio_init
87 {
88 uint32_t pin; /**< Specifies the AON_GPIO pins to be configured.
89 This parameter can be any value of @ref AON_GPIO_Pins */
90
91 uint32_t mode; /**< Specifies the operating mode for the selected pins.
92 This parameter can be a value of @ref AON_GPIO_Mode */
93
94 uint32_t pull; /**< Specifies the Pull-up or Pull-Down activation for the selected pins.
95 This parameter can be a value of @ref AON_GPIO_Pull */
96
97 uint32_t mux; /**< Specifies the Peripheral to be connected to the selected pins.
98 This parameter can be a value of @ref GPIOEx_Mux_Function_Selection. */
99 } aon_gpio_init_t;
100
101 /** @} */
102
103 /** @addtogroup HAL_AON_GPIO_CALLBACK_STRUCTURES Callback Structures
104 * @{
105 */
106
107 /** @defgroup AON_GPIO_Callback AON_GPIO Callback
108 * @{
109 */
110
111 /**
112 * @brief HAL AON_GPIO Callback function definition
113 */
114 typedef struct _hal_aon_gpio_callback
115 {
116 void (*aon_gpio_callback)(uint16_t aon_gpio_pin); /**< AON GPIO pin detection callback */
117 } hal_aon_gpio_callback_t;
118
119 /** @} */
120
121 /** @} */
122
123 /**
124 * @defgroup HAL_AON_GPIO_MACRO Defines
125 * @{
126 */
127
128 /* Exported constants --------------------------------------------------------*/
129 /** @defgroup AON_GPIO_Exported_Constants AON_GPIO Exported Constants
130 * @{
131 */
132
133 /** @defgroup AON_GPIO_Pins AON_GPIO pins
134 * @{
135 */
136 #define AON_GPIO_PIN_0 ((uint16_t)0x0001U) /**< Pin 0 selected */
137 #define AON_GPIO_PIN_1 ((uint16_t)0x0002U) /**< Pin 1 selected */
138 #define AON_GPIO_PIN_2 ((uint16_t)0x0004U) /**< Pin 2 selected */
139 #define AON_GPIO_PIN_3 ((uint16_t)0x0008U) /**< Pin 3 selected */
140 #define AON_GPIO_PIN_4 ((uint16_t)0x0010U) /**< Pin 4 selected */
141 #define AON_GPIO_PIN_5 ((uint16_t)0x0020U) /**< Pin 5 selected */
142 #define AON_GPIO_PIN_6 ((uint16_t)0x0040U) /**< Pin 6 selected */
143 #define AON_GPIO_PIN_7 ((uint16_t)0x0080U) /**< Pin 7 selected */
144
145 #define AON_GPIO_PIN_ALL ((uint16_t)0x00FFU) /**< All pins selected */
146
147 #define AON_GPIO_PIN_MASK (0x000000FFU) /**< PIN mask for assert test */
148 /** @} */
149
150 /** @defgroup AON_GPIO_Mode AON_GPIO mode
151 * @brief AON_GPIO Configuration Mode
152 * Elements values convention: 0x000000YX
153 * - X : IO Direction mode (Input, Output, Mux)
154 * - Y : IT trigger detection
155 * @{
156 */
157 #define AON_GPIO_MODE_INPUT (LL_AON_GPIO_MODE_INPUT << 0) /**< Input Mode */
158 #define AON_GPIO_MODE_OUTPUT (LL_AON_GPIO_MODE_OUTPUT << 0) /**< Output Mode */
159 #define AON_GPIO_MODE_MUX (LL_GPIO_MODE_MUX << 0) /**< Mux Mode */
160 #define AON_GPIO_MODE_IT_RISING (LL_AON_GPIO_TRIGGER_RISING << 4) /**< Interrupt Mode with Rising edge trigger detection */
161 #define AON_GPIO_MODE_IT_FALLING (LL_AON_GPIO_TRIGGER_FALLING << 4) /**< Interrupt Mode with Falling edge trigger detection */
162 #define AON_GPIO_MODE_IT_HIGH (LL_AON_GPIO_TRIGGER_HIGH << 4) /**< Interrupt Mode with High-level trigger detection */
163 #define AON_GPIO_MODE_IT_LOW (LL_AON_GPIO_TRIGGER_LOW << 4) /**< Interrupt Mode with Low-level trigger detection */
164 #define AON_GPIO_MODE_IT_BOTH_EDGE (LL_AON_GPIO_TRIGGER_BOTH_EDGE << 4) /**< Interrupt Mode with Rising and Falling edge trigger detection */
165 /** @} */
166
167
168 /** @defgroup AON_GPIO_Pull AON_GPIO pull
169 * @brief AON_GPIO Pull-Up or Pull-Down activation
170 * @{
171 */
172 #define AON_GPIO_NOPULL LL_AON_GPIO_PULL_NO /**< No Pull-up or Pull-down activation */
173 #define AON_GPIO_PULLUP LL_AON_GPIO_PULL_UP /**< Pull-up activation */
174 #define AON_GPIO_PULLDOWN LL_AON_GPIO_PULL_DOWN /**< Pull-down activation */
175 /** @} */
176
177 /**
178 * @brief AON_GPIO_default_config initStruct default configuration
179 */
180 #define AON_GPIO_DEFAULT_CONFIG \
181 { \
182 .pin = AON_GPIO_PIN_ALL, \
183 .mode = AON_GPIO_MODE_INPUT, \
184 .pull = AON_GPIO_PULLDOWN, \
185 .mux = AON_GPIO_MUX_7, \
186 }
187 /** @} */
188
189 /* Exported macro ------------------------------------------------------------*/
190 /** @defgroup AON_GPIO_Exported_Macros AON_GPIO Exported Macros
191 * @{
192 */
193
194 /**
195 * @brief Check whether the specified AON_GPIO pin is asserted or not.
196 * @param __AON_GPIO_PIN__ specifies the AON_GPIO pin to be checked.
197 * This parameter can be AON_GPIO_PIN_x where x can be (0..7).
198 * @retval The new state of __AON_GPIO_PIN__ (SET or RESET).
199 */
200 #define __HAL_AON_GPIO_IT_GET_IT(__AON_GPIO_PIN__) ll_aon_gpio_read_flag_it(__AON_GPIO_PIN__)
201
202 /**
203 * @brief Clear the AON_GPIO pin pending bits.
204 * @param __AON_GPIO_PIN__ specifies the AON_GPIO pins to be cleared.
205 * This parameter can be any combination of AON_GPIO_PIN_x where x can be (0..7).
206 * @retval None
207 */
208 #define __HAL_AON_GPIO_IT_CLEAR_IT(__AON_GPIO_PIN__) ll_aon_gpio_clear_flag_it(__AON_GPIO_PIN__)
209
210 /** @} */
211
212 /* Private macros ------------------------------------------------------------*/
213 /** @addtogroup AON_GPIO_Private_Macros AON_GPIO Private Macros
214 * @{
215 */
216
217 /**
218 * @brief Check if AON GPIO pin action is valid.
219 * @param __ACTION__ AON GPIO pin action.
220 * @retval SET (__ACTION__ is valid) or RESET (__ACTION__ is invalid)
221 */
222 #define IS_AON_GPIO_PIN_ACTION(__ACTION__) (((__ACTION__) == AON_GPIO_PIN_RESET) || ((__ACTION__) == AON_GPIO_PIN_SET))
223
224 /**
225 * @brief Check if AON GPIO pins are valid.
226 * @param __PIN__ AON GPIO pins.
227 * @retval SET (__PIN__ is valid) or RESET (__PIN__ is invalid)
228 */
229 #define IS_AON_GPIO_PIN(__PIN__) ((((__PIN__) & AON_GPIO_PIN_MASK) != 0x00U) &&\
230 (((__PIN__) & ~AON_GPIO_PIN_MASK) == 0x00U))
231
232 /**
233 * @brief Check if AON GPIO mode is valid.
234 * @param __MODE__ AON GPIO mode.
235 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
236 */
237 #define IS_AON_GPIO_MODE(__MODE__) (((__MODE__) == AON_GPIO_MODE_INPUT) ||\
238 ((__MODE__) == AON_GPIO_MODE_OUTPUT) ||\
239 ((__MODE__) == AON_GPIO_MODE_MUX) ||\
240 ((__MODE__) == AON_GPIO_MODE_IT_RISING) ||\
241 ((__MODE__) == AON_GPIO_MODE_IT_FALLING) ||\
242 ((__MODE__) == AON_GPIO_MODE_IT_HIGH) ||\
243 ((__MODE__) == AON_GPIO_MODE_IT_LOW))
244
245 /**
246 * @brief Check if AON GPIO pull type is valid.
247 * @param __PULL__ AON GPIO pull type.
248 * @retval SET (__PULL__ is valid) or RESET (__PULL__ is invalid)
249 */
250 #define IS_AON_GPIO_PULL(__PULL__) (((__PULL__) == AON_GPIO_NOPULL) ||\
251 ((__PULL__) == AON_GPIO_PULLUP) || \
252 ((__PULL__) == AON_GPIO_PULLDOWN))
253
254 /** @} */
255
256 /** @} */
257
258 /* Include AON GPIO HAL Extended module */
259 #include "gr55xx_hal_aon_gpio_ex.h"
260
261 /* Exported functions --------------------------------------------------------*/
262 /** @addtogroup HAL_AON_GPIO_DRIVER_FUNCTIONS Functions
263 * @{
264 */
265
266 /** @addtogroup AON_GPIO_Exported_Functions_Group1 Initialization and de-initialization functions
267 * @brief Initialization and Configuration functions
268 * @{
269 */
270
271 /**
272 ****************************************************************************************
273 * @brief Initialize the AON_GPIOx peripheral according to the specified parameters in the @ref aon_gpio_init_t.
274 *
275 * @param[in] p_aon_gpio_init: Pointer to an @ref aon_gpio_init_t structure that contains
276 * the configuration information for the specified AON_GPIO peripheral port.
277 ****************************************************************************************
278 */
279 void hal_aon_gpio_init(aon_gpio_init_t *p_aon_gpio_init);
280
281 /**
282 ****************************************************************************************
283 * @brief De-initialize the AON_GPIOx peripheral registers to their default reset values.
284 *
285 * @param[in] aon_gpio_pin: Specifies the port bit to be written.
286 * This parameter can be a combination of the following values:
287 * @arg @ref AON_GPIO_PIN_0
288 * @arg @ref AON_GPIO_PIN_1
289 * @arg @ref AON_GPIO_PIN_2
290 * @arg @ref AON_GPIO_PIN_3
291 * @arg @ref AON_GPIO_PIN_4
292 * @arg @ref AON_GPIO_PIN_5
293 * @arg @ref AON_GPIO_PIN_6
294 * @arg @ref AON_GPIO_PIN_7
295 * @arg @ref AON_GPIO_PIN_ALL
296 ****************************************************************************************
297 */
298 void hal_aon_gpio_deinit(uint32_t aon_gpio_pin);
299
300 /** @} */
301
302 /** @addtogroup AON_GPIO_Exported_Functions_Group2 IO operation functions
303 * @brief AON_GPIO Read, Write, Toggle, Lock and EXTI management functions.
304 * @{
305 */
306
307 /**
308 ****************************************************************************************
309 * @brief Read the specified input port pin.
310 *
311 * @param[in] aon_gpio_pin: Specifies the port bit to be read.
312 * This parameter can be one of the following values:
313 * @arg @ref AON_GPIO_PIN_0
314 * @arg @ref AON_GPIO_PIN_1
315 * @arg @ref AON_GPIO_PIN_2
316 * @arg @ref AON_GPIO_PIN_3
317 * @arg @ref AON_GPIO_PIN_4
318 * @arg @ref AON_GPIO_PIN_5
319 * @arg @ref AON_GPIO_PIN_6
320 * @arg @ref AON_GPIO_PIN_7
321 *
322 * @return The input port pin value.
323 ****************************************************************************************
324 */
325 aon_gpio_pin_state_t hal_aon_gpio_read_pin(uint16_t aon_gpio_pin);
326
327 /**
328 ****************************************************************************************
329 * @brief Set or clear the selected data port bit.
330 *
331 * @param[in] aon_gpio_pin: Specifies the port bit to be written.
332 * This parameter can be a combination of the following values:
333 * @arg @ref AON_GPIO_PIN_0
334 * @arg @ref AON_GPIO_PIN_1
335 * @arg @ref AON_GPIO_PIN_2
336 * @arg @ref AON_GPIO_PIN_3
337 * @arg @ref AON_GPIO_PIN_4
338 * @arg @ref AON_GPIO_PIN_5
339 * @arg @ref AON_GPIO_PIN_6
340 * @arg @ref AON_GPIO_PIN_7
341 * @arg @ref AON_GPIO_PIN_ALL
342 * @param[in] pin_state: Specifies the value to be written to the selected bit.
343 * This parameter can be one of the AON_GPIO_PinState enum values:
344 * @arg AON_GPIO_PIN_RESET: to clear the port pin
345 * @arg AON_GPIO_PIN_SET: to set the port pin
346 ****************************************************************************************
347 */
348 void hal_aon_gpio_write_pin(uint16_t aon_gpio_pin, aon_gpio_pin_state_t pin_state);
349
350 /**
351 ****************************************************************************************
352 * @brief Toggle the specified AON_GPIO pin.
353 *
354 * @param[in] aon_gpio_pin: Specifies the pin to be toggled.
355 * This parameter can be a combination of the following values:
356 * @arg @ref AON_GPIO_PIN_0
357 * @arg @ref AON_GPIO_PIN_1
358 * @arg @ref AON_GPIO_PIN_2
359 * @arg @ref AON_GPIO_PIN_3
360 * @arg @ref AON_GPIO_PIN_4
361 * @arg @ref AON_GPIO_PIN_5
362 * @arg @ref AON_GPIO_PIN_6
363 * @arg @ref AON_GPIO_PIN_7
364 * @arg @ref AON_GPIO_PIN_ALL
365 ****************************************************************************************
366 */
367 void hal_aon_gpio_toggle_pin(uint16_t aon_gpio_pin);
368
369 /** @} */
370
371 /** @addtogroup AON_GPIO_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
372 * @brief IRQ Handler and Callbacks functions
373 * @{
374 */
375
376 /**
377 ****************************************************************************************
378 * @brief Handle AON_GPIO interrupt request.
379 ****************************************************************************************
380 */
381 void hal_aon_gpio_irq_handler(void);
382
383 /**
384 ****************************************************************************************
385 * @brief AON GPIO pin detection callback.
386 *
387 * @note This function should not be modified. When the callback is needed,
388 * the hal_aon_gpio_callback can be implemented in the user file.
389 *
390 * @param[in] aon_gpio_pin: Indicate the port pin whose interrupt was triggered.
391 * This parameter can be a combination of the following values:
392 * @arg @ref AON_GPIO_PIN_0
393 * @arg @ref AON_GPIO_PIN_1
394 * @arg @ref AON_GPIO_PIN_2
395 * @arg @ref AON_GPIO_PIN_3
396 * @arg @ref AON_GPIO_PIN_4
397 * @arg @ref AON_GPIO_PIN_5
398 * @arg @ref AON_GPIO_PIN_6
399 * @arg @ref AON_GPIO_PIN_7
400 * @arg @ref AON_GPIO_PIN_ALL
401 ****************************************************************************************
402 */
403 void hal_aon_gpio_callback(uint16_t aon_gpio_pin);
404
405 /** @} */
406
407 /** @} */
408
409
410 #ifdef __cplusplus
411 }
412 #endif
413
414 #endif /* __GR55xx_HAL_AON_GPIO_H__ */
415
416 /** @} */
417
418 /** @} */
419
420 /** @} */
aon_gpio_init_t
struct _aon_gpio_init aon_gpio_init_t
AON_GPIO init structure definition.
hal_aon_gpio_toggle_pin
void hal_aon_gpio_toggle_pin(uint16_t aon_gpio_pin)
Toggle the specified AON_GPIO pin.
hal_aon_gpio_deinit
void hal_aon_gpio_deinit(uint32_t aon_gpio_pin)
De-initialize the AON_GPIOx peripheral registers to their default reset values.
gr55xx_ll_aon_gpio.h
Header file containing functions prototypes of AON GPIO LL library.
aon_gpio_pin_state_t
aon_gpio_pin_state_t
AON_GPIO Bit SET and Bit RESET enumerations.
Definition: gr55xx_hal_aon_gpio.h:72
AON_GPIO_PIN_RESET
@ AON_GPIO_PIN_RESET
AON GPIO pin low level.
Definition: gr55xx_hal_aon_gpio.h:73
hal_aon_gpio_write_pin
void hal_aon_gpio_write_pin(uint16_t aon_gpio_pin, aon_gpio_pin_state_t pin_state)
Set or clear the selected data port bit.
_hal_aon_gpio_callback::aon_gpio_callback
void(* aon_gpio_callback)(uint16_t aon_gpio_pin)
AON GPIO pin detection callback
Definition: gr55xx_hal_aon_gpio.h:116
_aon_gpio_init::pin
uint32_t pin
Specifies the AON_GPIO pins to be configured.
Definition: gr55xx_hal_aon_gpio.h:88
_hal_aon_gpio_callback
HAL AON_GPIO Callback function definition.
Definition: gr55xx_hal_aon_gpio.h:115
hal_aon_gpio_callback_t
struct _hal_aon_gpio_callback hal_aon_gpio_callback_t
HAL AON_GPIO Callback function definition.
hal_aon_gpio_callback
void hal_aon_gpio_callback(uint16_t aon_gpio_pin)
AON GPIO pin detection callback.
AON_GPIO_PIN_SET
@ AON_GPIO_PIN_SET
AON GPIO pin high level.
Definition: gr55xx_hal_aon_gpio.h:74
_aon_gpio_init::mux
uint32_t mux
Specifies the Peripheral to be connected to the selected pins.
Definition: gr55xx_hal_aon_gpio.h:97
_aon_gpio_init::pull
uint32_t pull
Specifies the Pull-up or Pull-Down activation for the selected pins.
Definition: gr55xx_hal_aon_gpio.h:94
_aon_gpio_init::mode
uint32_t mode
Specifies the operating mode for the selected pins.
Definition: gr55xx_hal_aon_gpio.h:91
hal_aon_gpio_init
void hal_aon_gpio_init(aon_gpio_init_t *p_aon_gpio_init)
Initialize the AON_GPIOx peripheral according to the specified parameters in the aon_gpio_init_t.
_aon_gpio_init
AON_GPIO init structure definition.
Definition: gr55xx_hal_aon_gpio.h:87
hal_aon_gpio_irq_handler
void hal_aon_gpio_irq_handler(void)
Handle AON_GPIO interrupt request.
hal_aon_gpio_read_pin
aon_gpio_pin_state_t hal_aon_gpio_read_pin(uint16_t aon_gpio_pin)
Read the specified input port pin.
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
gr55xx_hal_aon_gpio_ex.h
Header file containing extended macro of AON GPIO HAL library.