gr55xx_hal_msio.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file gr55xx_hal_msio.h
5 * @author BLE Driver Team
6 * @brief Header file containing functions prototypes of MSIO 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_MSIO MSIO
47 * @brief MSIO HAL module driver.
48 * @{
49 */
50
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55xx_HAL_MSIO_H__
53 #define __GR55xx_HAL_MSIO_H__
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx_ll_msio.h"
61 #include "gr55xx_hal_def.h"
62
63 /* Exported types ------------------------------------------------------------*/
64 /** @addtogroup HAL_MSIO_ENUMERATIONS Enumerations
65 * @{
66 */
67
68 /**
69 * @brief MSIO Bit SET and Bit RESET enumerations
70 */
71 typedef enum
72 {
73 MSIO_PIN_RESET = 0U, /**< MSIO pin low level. */
74 MSIO_PIN_SET /**< MSIO pin high level.*/
75 } msio_pin_state_t;
76
77 /** @} */
78
79 /** @addtogroup HAL_MSIO_STRUCTURES Structures
80 * @{
81 */
82
83 /**
84 * @brief MSIO init structure definition
85 */
86 typedef struct _msio_init
87 {
88 uint32_t pin; /**< Specifies the MSIO pins to be configured.
89 This parameter can be any value of @ref MSIO_pins */
90
91 uint32_t direction; /**< Specifies the direction for the selected pins.
92 This parameter can be a value of @ref MSIO_direction */
93
94 uint32_t mode; /**< Specifies the operating mode for the selected pins.
95 This parameter can be a value of @ref MSIO_mode */
96
97 uint32_t pull; /**< Specifies the Pull-up or Pull-Down activation for the selected pins.
98 This parameter can be a value of @ref MSIO_pull */
99
100 uint32_t mux; /**< Specifies the Peripheral to be connected to the selected pins.
101 This parameter can be a value of @ref GPIOEx_Mux_Function_Selection. */
102 } msio_init_t;
103
104 /** @} */
105
106 /**
107 * @defgroup HAL_MSIO_MACRO Defines
108 * @{
109 */
110
111 /* Exported constants --------------------------------------------------------*/
112 /** @defgroup MSIO_Exported_Constants MSIO Exported Constants
113 * @{
114 */
115
116 /** @defgroup MSIO_pins MSIO pins
117 * @{
118 */
119 #define MSIO_PIN_0 ((uint16_t)0x0001U) /**< Pin 0 selected */
120 #define MSIO_PIN_1 ((uint16_t)0x0002U) /**< Pin 1 selected */
121 #define MSIO_PIN_2 ((uint16_t)0x0004U) /**< Pin 2 selected */
122 #define MSIO_PIN_3 ((uint16_t)0x0008U) /**< Pin 3 selected */
123 #define MSIO_PIN_4 ((uint16_t)0x0010U) /**< Pin 4 selected */
124
125 #define MSIO_PIN_ALL ((uint16_t)0x001FU) /**< All pins selected */
126
127 #define MSIO_PIN_MASK (0x0000001FU) /**< PIN mask for assert test */
128 /** @} */
129
130 /** @defgroup MSIO_direction MSIO direction
131 * @{
132 */
133 #define MSIO_DIRECTION_NONE LL_MSIO_DIRECTION_NONE /**< Disable input & output */
134 #define MSIO_DIRECTION_INPUT LL_MSIO_DIRECTION_INPUT /**< Only Input */
135 #define MSIO_DIRECTION_OUTPUT LL_MSIO_DIRECTION_OUTPUT /**< Only Output */
136 #define MSIO_DIRECTION_INOUT LL_MSIO_DIRECTION_INOUT /**< Input & Output */
137 /** @} */
138
139 /** @defgroup MSIO_mode MSIO mode
140 * @brief MSIO Analog or Digital mode
141 * @{
142 */
143 #define MSIO_MODE_ANALOG LL_MSIO_MODE_ANALOG /**< Analog IO */
144 #define MSIO_MODE_DIGITAL LL_MSIO_MODE_DIGITAL /**< Digital IO */
145 /** @} */
146
147 /** @defgroup MSIO_pull MSIO pull
148 * @brief MSIO Pull-Up or Pull-Down Activation
149 * @{
150 */
151 #define MSIO_NOPULL LL_MSIO_PULL_NO /**< No Pull-up or Pull-down activation */
152 #define MSIO_PULLUP LL_MSIO_PULL_UP /**< Pull-up activation */
153 #define MSIO_PULLDOWN LL_MSIO_PULL_DOWN /**< Pull-down activation */
154 /** @} */
155
156 /**
157 * @brief MSIO_default_config initStruct default configuartion
158 */
159 #define MSIO_DEFAULT_CONFIG \
160 { \
161 .pin = MSIO_PIN_ALL, \
162 .direction = MSIO_DIRECTION_INPUT, \
163 .mode = MSIO_MODE_DIGITAL, \
164 .pull = MSIO_PULLDOWN, \
165 .mux = GPIO_MUX_7, \
166 }
167 /** @} */
168
169 /* Exported macro ------------------------------------------------------------*/
170 /** @defgroup MSIO_Exported_Macros MSIO Exported Macros
171 * @{
172 */
173
174 /** @} */
175
176 /* Private macros ------------------------------------------------------------*/
177 /** @addtogroup MSIO_Private_Macros MSIO Private Macros
178 * @{
179 */
180
181 /**
182 * @brief Check if MSIO pin action is valid.
183 * @param __ACTION__ MSIO pin action.
184 * @retval SET (__ACTION__ is valid) or RESET (__ACTION__ is invalid)
185 */
186 #define IS_MSIO_PIN_ACTION(__ACTION__) (((__ACTION__) == MSIO_PIN_RESET) || ((__ACTION__) == MSIO_PIN_SET))
187
188 /**
189 * @brief Check if MSIO pins are valid.
190 * @param __PIN__ MSIO pins.
191 * @retval SET (__PIN__ is valid) or RESET (__PIN__ is invalid)
192 */
193 #define IS_MSIO_PIN(__PIN__) ((((__PIN__) & MSIO_PIN_MASK) != 0x00U) && \
194 (((__PIN__) & ~MSIO_PIN_MASK) == 0x00U))
195
196 /**
197 * @brief Check if MSIO direction is valid.
198 * @param __DIR__ MSIO direction.
199 * @retval SET (__DIR__ is valid) or RESET (__DIR__ is invalid)
200 */
201 #define IS_MSIO_DIRECTION(__DIR__) (((__DIR__) == MSIO_DIRECTION_NONE) || \
202 ((__DIR__) == MSIO_DIRECTION_INPUT) || \
203 ((__DIR__) == MSIO_DIRECTION_OUTPUT) || \
204 ((__DIR__) == MSIO_DIRECTION_INOUT))
205
206 /**
207 * @brief Check if MSIO mode is valid.
208 * @param __MODE__ MSIO mode.
209 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
210 */
211 #define IS_MSIO_MODE(__MODE__) (((__MODE__) == MSIO_MODE_ANALOG) || \
212 ((__MODE__) == MSIO_MODE_DIGITAL))
213
214 /**
215 * @brief Check if MSIO pull type is valid.
216 * @param __PULL__ MSIO pull type.
217 * @retval SET (__PULL__ is valid) or RESET (__PULL__ is invalid)
218 */
219 #define IS_MSIO_PULL(__PULL__) (((__PULL__) == MSIO_NOPULL) || \
220 ((__PULL__) == MSIO_PULLUP) || \
221 ((__PULL__) == MSIO_PULLDOWN))
222
223 /** @} */
224
225 /** @} */
226
227 /* Include MSIO HAL Extended module */
228 #include "gr55xx_hal_msio_ex.h"
229
230 /* Exported functions --------------------------------------------------------*/
231 /** @addtogroup HAL_MSIO_DRIVER_FUNCTIONS Functions
232 * @{
233 */
234
235 /** @addtogroup MSIO_Exported_Functions_Group1 Initialization and de-initialization functions
236 * @brief Initialization and Configuration functions
237 * @{
238 */
239
240 /**
241 ****************************************************************************************
242 * @brief Initialize the MSIOx peripheral according to the specified parameters in the @ref msio_init_t.
243 * @param[in] p_msio_init: Pointer to an @ref msio_init_t structure that contains
244 * the configuration information for the specified MSIO peripheral port.
245 ****************************************************************************************
246 */
247 void hal_msio_init(msio_init_t *p_msio_init);
248
249 /**
250 ****************************************************************************************
251 * @brief De-initialize the MSIOx peripheral registers to their default reset values.
252 * @param[in] msio_pin: Specifies the port bit to be written.
253 * This parameter can be a combination of the following values:
254 * @arg @ref MSIO_PIN_0
255 * @arg @ref MSIO_PIN_1
256 * @arg @ref MSIO_PIN_2
257 * @arg @ref MSIO_PIN_3
258 * @arg @ref MSIO_PIN_4
259 * @arg @ref MSIO_PIN_ALL
260 ****************************************************************************************
261 */
262 void hal_msio_deinit(uint32_t msio_pin);
263
264 /** @} */
265
266 /** @addtogroup MSIO_Exported_Functions_Group2 IO operation functions
267 * @brief MSIO Read, Write, and Toggle management functions.
268 * @{
269 */
270
271 /**
272 ****************************************************************************************
273 * @brief Read the specified input port pin.
274 * @param[in] msio_pin: Specifies the port bit to be read.
275 * This parameter can be one of the following values:
276 * @arg @ref MSIO_PIN_0
277 * @arg @ref MSIO_PIN_1
278 * @arg @ref MSIO_PIN_2
279 * @arg @ref MSIO_PIN_3
280 * @arg @ref MSIO_PIN_4
281 * @retval ::MSIO_PIN_RESET: MSIO pin low level.
282 * @retval ::MSIO_PIN_SET: MSIO pin high level.
283 ****************************************************************************************
284 */
285 msio_pin_state_t hal_msio_read_pin(uint16_t msio_pin);
286
287 /**
288 ****************************************************************************************
289 * @brief Set or clear the selected data port bit.
290 * @param[in] msio_pin: Specifies the port bit to be written.
291 * This parameter can be a combination of the following values:
292 * @arg @ref MSIO_PIN_0
293 * @arg @ref MSIO_PIN_1
294 * @arg @ref MSIO_PIN_2
295 * @arg @ref MSIO_PIN_3
296 * @arg @ref MSIO_PIN_4
297 * @arg @ref MSIO_PIN_ALL
298 * @param[in] pin_state: Specifies the value to be written to the selected bit.
299 * This parameter can be one of the MSIO_PinState enum values:
300 * @arg MSIO_PIN_RESET: to clear the port pin
301 * @arg MSIO_PIN_SET: to set the port pin
302 ****************************************************************************************
303 */
304 void hal_msio_write_pin(uint16_t msio_pin, msio_pin_state_t pin_state);
305
306 /**
307 ****************************************************************************************
308 * @brief Toggle the specified MSIO pin.
309 * @param[in] msio_pin: Specifies the pin to be toggled.
310 * This parameter can be a combination of the following values:
311 * @arg @ref MSIO_PIN_0
312 * @arg @ref MSIO_PIN_1
313 * @arg @ref MSIO_PIN_2
314 * @arg @ref MSIO_PIN_3
315 * @arg @ref MSIO_PIN_4
316 * @arg @ref MSIO_PIN_ALL
317 ****************************************************************************************
318 */
319 void hal_msio_toggle_pin(uint16_t msio_pin);
320
321 /** @} */
322
323 /** @} */
324
325
326 #ifdef __cplusplus
327 }
328 #endif
329
330 #endif /* __GR55xx_HAL_MSIO_H__ */
331
332 /** @} */
333
334 /** @} */
335
336 /** @} */
_msio_init::direction
uint32_t direction
Specifies the direction for the selected pins.
Definition: gr55xx_hal_msio.h:91
hal_msio_deinit
void hal_msio_deinit(uint32_t msio_pin)
De-initialize the MSIOx peripheral registers to their default reset values.
hal_msio_init
void hal_msio_init(msio_init_t *p_msio_init)
Initialize the MSIOx peripheral according to the specified parameters in the msio_init_t.
MSIO_PIN_RESET
@ MSIO_PIN_RESET
MSIO pin low level.
Definition: gr55xx_hal_msio.h:73
_msio_init
MSIO init structure definition.
Definition: gr55xx_hal_msio.h:87
gr55xx_ll_msio.h
Header file containing functions prototypes of MSIO LL library.
msio_init_t
struct _msio_init msio_init_t
MSIO init structure definition.
_msio_init::mode
uint32_t mode
Specifies the operating mode for the selected pins.
Definition: gr55xx_hal_msio.h:94
hal_msio_write_pin
void hal_msio_write_pin(uint16_t msio_pin, msio_pin_state_t pin_state)
Set or clear the selected data port bit.
hal_msio_toggle_pin
void hal_msio_toggle_pin(uint16_t msio_pin)
Toggle the specified MSIO pin.
_msio_init::mux
uint32_t mux
Specifies the Peripheral to be connected to the selected pins.
Definition: gr55xx_hal_msio.h:100
hal_msio_read_pin
msio_pin_state_t hal_msio_read_pin(uint16_t msio_pin)
Read the specified input port pin.
msio_pin_state_t
msio_pin_state_t
MSIO Bit SET and Bit RESET enumerations.
Definition: gr55xx_hal_msio.h:72
MSIO_PIN_SET
@ MSIO_PIN_SET
MSIO pin high level.
Definition: gr55xx_hal_msio.h:74
_msio_init::pull
uint32_t pull
Specifies the Pull-up or Pull-Down activation for the selected pins.
Definition: gr55xx_hal_msio.h:97
_msio_init::pin
uint32_t pin
Specifies the MSIO pins to be configured.
Definition: gr55xx_hal_msio.h:88
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
gr55xx_hal_msio_ex.h
Header file containing extended macro of MSIO HAL library.