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 _aon_gpio_callback
115 {
116 void (*aon_gpio_callback)(uint16_t aon_gpio_pin); /**< AON GPIO pin detection callback */
117 } 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 /** @} */
165
166
167 /** @defgroup AON_GPIO_Pull AON_GPIO pull
168 * @brief AON_GPIO Pull-Up or Pull-Down activation
169 * @{
170 */
171 #define AON_GPIO_NOPULL LL_AON_GPIO_PULL_NO /**< No Pull-up or Pull-down activation */
172 #define AON_GPIO_PULLUP LL_AON_GPIO_PULL_UP /**< Pull-up activation */
173 #define AON_GPIO_PULLDOWN LL_AON_GPIO_PULL_DOWN /**< Pull-down activation */
174 /** @} */
175
176 /**
177 * @brief AON_GPIO_default_config initStruct default configuartion
178 */
179 #define AON_GPIO_DEFAULT_CONFIG \
180 { \
181 .pin = AON_GPIO_PIN_ALL, \
182 .mode = AON_GPIO_MODE_INPUT, \
183 .pull = AON_GPIO_PULLDOWN, \
184 .mux = AON_GPIO_MUX_7, \
185 }
186 /** @} */
187
188 /* Exported macro ------------------------------------------------------------*/
189 /** @defgroup AON_GPIO_Exported_Macros AON_GPIO Exported Macros
190 * @{
191 */
192
193 /**
194 * @brief Check whether the specified AON_GPIO pin is asserted or not.
195 * @param __AON_GPIO_PIN__ specifies the AON_GPIO pin to be checked.
196 * This parameter can be AON_GPIO_PIN_x where x can be (0..15).
197 * @retval The new state of __AON_GPIO_PIN__ (SET or RESET).
198 */
199 #define __HAL_AON_GPIO_IT_GET_IT(__AON_GPIO_PIN__) ll_aon_gpio_read_flag_it(__AON_GPIO_PIN__)
200
201 /**
202 * @brief Clear the AON_GPIO pin pending bits.
203 * @param __AON_GPIO_PIN__ specifies the AON_GPIO pins to be cleared.
204 * This parameter can be any combination of AON_GPIO_PIN_x where x can be (0..15).
205 * @retval None
206 */
207 #define __HAL_AON_GPIO_IT_CLEAR_IT(__AON_GPIO_PIN__) ll_aon_gpio_clear_flag_it(__AON_GPIO_PIN__)
208
209 /** @} */
210
211 /* Private macros ------------------------------------------------------------*/
212 /** @addtogroup AON_GPIO_Private_Macros AON_GPIO Private Macros
213 * @{
214 */
215
216 /**
217 * @brief Check if AON GPIO pin action is valid.
218 * @param __ACTION__ AON GPIO pin action.
219 * @retval SET (__ACTION__ is valid) or RESET (__ACTION__ is invalid)
220 */
221 #define IS_AON_GPIO_PIN_ACTION(__ACTION__) (((__ACTION__) == AON_GPIO_PIN_RESET) || ((__ACTION__) == AON_GPIO_PIN_SET))
222
223 /**
224 * @brief Check if AON GPIO pins are valid.
225 * @param __PIN__ AON GPIO pins.
226 * @retval SET (__PIN__ is valid) or RESET (__PIN__ is invalid)
227 */
228 #define IS_AON_GPIO_PIN(__PIN__) ((((__PIN__) & AON_GPIO_PIN_MASK) != 0x00U) &&\
229 (((__PIN__) & ~AON_GPIO_PIN_MASK) == 0x00U))
230
231 /**
232 * @brief Check if AON GPIO mode is valid.
233 * @param __MODE__ AON GPIO mode.
234 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
235 */
236 #define IS_AON_GPIO_MODE(__MODE__) (((__MODE__) == AON_GPIO_MODE_INPUT) ||\
237 ((__MODE__) == AON_GPIO_MODE_OUTPUT) ||\
238 ((__MODE__) == AON_GPIO_MODE_MUX) ||\
239 ((__MODE__) == AON_GPIO_MODE_IT_RISING) ||\
240 ((__MODE__) == AON_GPIO_MODE_IT_FALLING) ||\
241 ((__MODE__) == AON_GPIO_MODE_IT_HIGH) ||\
242 ((__MODE__) == AON_GPIO_MODE_IT_LOW))
243
244 /**
245 * @brief Check if AON GPIO pull type is valid.
246 * @param __PULL__ AON GPIO pull type.
247 * @retval SET (__PULL__ is valid) or RESET (__PULL__ is invalid)
248 */
249 #define IS_AON_GPIO_PULL(__PULL__) (((__PULL__) == AON_GPIO_NOPULL) ||\
250 ((__PULL__) == AON_GPIO_PULLUP) || \
251 ((__PULL__) == AON_GPIO_PULLDOWN))
252
253 /** @} */
254
255 /** @} */
256
257 /* Include AON GPIO HAL Extended module */
258 #include "gr55xx_hal_aon_gpio_ex.h"
259
260 /* Exported functions --------------------------------------------------------*/
261 /** @addtogroup HAL_AON_GPIO_DRIVER_FUNCTIONS Functions
262 * @{
263 */
264
265 /** @addtogroup AON_GPIO_Exported_Functions_Group1 Initialization and de-initialization functions
266 * @brief Initialization and Configuration functions
267 * @{
268 */
269
270 /**
271 ****************************************************************************************
272 * @brief Initialize the AON_GPIOx peripheral according to the specified parameters in the @ref aon_gpio_init_t.
273 *
274 * @param[in] p_aon_gpio_init: Pointer to an @ref aon_gpio_init_t structure that contains
275 * the configuration information for the specified AON_GPIO peripheral port.
276 ****************************************************************************************
277 */
278 void hal_aon_gpio_init(aon_gpio_init_t *p_aon_gpio_init);
279
280 /**
281 ****************************************************************************************
282 * @brief De-initialize the AON_GPIOx peripheral registers to their default reset values.
283 *
284 * @param[in] aon_gpio_pin: Specifies the port bit to be written.
285 * This parameter can be a combination of the following values:
286 * @arg @ref AON_GPIO_PIN_0
287 * @arg @ref AON_GPIO_PIN_1
288 * @arg @ref AON_GPIO_PIN_2
289 * @arg @ref AON_GPIO_PIN_3
290 * @arg @ref AON_GPIO_PIN_4
291 * @arg @ref AON_GPIO_PIN_5
292 * @arg @ref AON_GPIO_PIN_ALL
293 ****************************************************************************************
294 */
295 void hal_aon_gpio_deinit(uint32_t aon_gpio_pin);
296
297 /** @} */
298
299 /** @addtogroup AON_GPIO_Exported_Functions_Group2 IO operation functions
300 * @brief AON_GPIO Read, Write, Toggle, Lock and EXTI management functions.
301 * @{
302 */
303
304 /**
305 ****************************************************************************************
306 * @brief Read the specified input port pin.
307 *
308 * @param[in] aon_gpio_pin: Specifies the port bit to be read.
309 * This parameter can be one of the following values:
310 * @arg @ref AON_GPIO_PIN_0
311 * @arg @ref AON_GPIO_PIN_1
312 * @arg @ref AON_GPIO_PIN_2
313 * @arg @ref AON_GPIO_PIN_3
314 * @arg @ref AON_GPIO_PIN_4
315 * @arg @ref AON_GPIO_PIN_5
316 *
317 * @return The input port pin value.
318 ****************************************************************************************
319 */
320 aon_gpio_pin_state_t hal_aon_gpio_read_pin(uint16_t aon_gpio_pin);
321
322 /**
323 ****************************************************************************************
324 * @brief Set or clear the selected data port bit.
325 *
326 * @param[in] aon_gpio_pin: Specifies the port bit to be written.
327 * This parameter can be a combination of the following values:
328 * @arg @ref AON_GPIO_PIN_0
329 * @arg @ref AON_GPIO_PIN_1
330 * @arg @ref AON_GPIO_PIN_2
331 * @arg @ref AON_GPIO_PIN_3
332 * @arg @ref AON_GPIO_PIN_4
333 * @arg @ref AON_GPIO_PIN_5
334 * @arg @ref AON_GPIO_PIN_ALL
335 * @param[in] pin_state: Specifies the value to be written to the selected bit.
336 * This parameter can be one of the AON_GPIO_PinState enum values:
337 * @arg AON_GPIO_PIN_RESET: to clear the port pin
338 * @arg AON_GPIO_PIN_SET: to set the port pin
339 ****************************************************************************************
340 */
341 void hal_aon_gpio_write_pin(uint16_t aon_gpio_pin, aon_gpio_pin_state_t pin_state);
342
343 /**
344 ****************************************************************************************
345 * @brief Toggle the specified AON_GPIO pin.
346 *
347 * @param[in] aon_gpio_pin: Specifies the pin to be toggled.
348 * This parameter can be a combination of the following values:
349 * @arg @ref AON_GPIO_PIN_0
350 * @arg @ref AON_GPIO_PIN_1
351 * @arg @ref AON_GPIO_PIN_2
352 * @arg @ref AON_GPIO_PIN_3
353 * @arg @ref AON_GPIO_PIN_4
354 * @arg @ref AON_GPIO_PIN_5
355 * @arg @ref AON_GPIO_PIN_ALL
356 ****************************************************************************************
357 */
358 void hal_aon_gpio_toggle_pin(uint16_t aon_gpio_pin);
359
360 /** @} */
361
362 /** @addtogroup AON_GPIO_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
363 * @brief IRQ Handler and Callbacks functions
364 * @{
365 */
366
367 /**
368 ****************************************************************************************
369 * @brief Handle AON_GPIO interrupt request.
370 ****************************************************************************************
371 */
372 void hal_aon_gpio_irq_handler(void);
373
374 /**
375 ****************************************************************************************
376 * @brief AON GPIO pin detection callback.
377 *
378 * @note This function should not be modified. When the callback is needed,
379 * the hal_aon_gpio_callback can be implemented in the user file.
380 *
381 * @param[in] aon_gpio_pin: Indicate the port pin whose interrupt was triggered.
382 * This parameter can be a combination of the following values:
383 * @arg @ref AON_GPIO_PIN_0
384 * @arg @ref AON_GPIO_PIN_1
385 * @arg @ref AON_GPIO_PIN_2
386 * @arg @ref AON_GPIO_PIN_3
387 * @arg @ref AON_GPIO_PIN_4
388 * @arg @ref AON_GPIO_PIN_5
389 * @arg @ref AON_GPIO_PIN_ALL
390 ****************************************************************************************
391 */
392 void hal_aon_gpio_callback(uint16_t aon_gpio_pin);
393
394 /** @} */
395
396 /** @} */
397
398
399 #ifdef __cplusplus
400 }
401 #endif
402
403 #endif /* __GR55xx_HAL_AON_GPIO_H__ */
404
405 /** @} */
406
407 /** @} */
408
409 /** @} */
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
_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
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.
_aon_gpio_init::pin
uint32_t pin
Specifies the AON_GPIO pins to be configured.
Definition: gr55xx_hal_aon_gpio.h:88
_aon_gpio_callback
HAL AON_GPIO Callback function definition.
Definition: gr55xx_hal_aon_gpio.h:115
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_callback_t
struct _aon_gpio_callback aon_gpio_callback_t
HAL AON_GPIO Callback function definition.
_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.