1 /**
2 ******************************************************************************
3 * @file stm32wbaxx_ll_gpio.h
4 * @author MCD Application Team
5 * @brief Header file of GPIO LL module.
6 ******************************************************************************
7 * @attention
8 *
9 * Copyright (c) 2022 STMicroelectronics.
10 * All rights reserved.
11 *
12 * This software is licensed under terms that can be found in the LICENSE file
13 * in the root directory of this software component.
14 * If no LICENSE file comes with this software, it is provided AS-IS.
15 *
16 ******************************************************************************
17 */
18
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef __STM32WBAxx_LL_GPIO_H
21 #define __STM32WBAxx_LL_GPIO_H
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32wbaxx.h"
29
30 /** @addtogroup STM32WBAxx_LL_Driver
31 * @{
32 */
33
34 #if defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOH)
35
36 /** @defgroup GPIO_LL GPIO
37 * @{
38 */
39 /** MISRA C:2012 deviation rule has been granted for following rules:
40 * Rule-18.1_d - Medium: Array pointer `GPIOx' is accessed with index [..,..]
41 * which may be out of array bounds [..,UNKNOWN] in following APIs:
42 * LL_GPIO_GetAFPin_0_7
43 * LL_GPIO_SetAFPin_0_7
44 * LL_GPIO_SetAFPin_8_15
45 * LL_GPIO_GetAFPin_8_15
46 */
47
48 /* Private types -------------------------------------------------------------*/
49 /* Private variables ---------------------------------------------------------*/
50 /* Private constants ---------------------------------------------------------*/
51 /* Private macros ------------------------------------------------------------*/
52 #if defined(USE_FULL_LL_DRIVER)
53 /** @defgroup GPIO_LL_Private_Macros GPIO Private Macros
54 * @{
55 */
56
57 /**
58 * @}
59 */
60 #endif /*USE_FULL_LL_DRIVER*/
61
62 /* Exported types ------------------------------------------------------------*/
63 #if defined(USE_FULL_LL_DRIVER)
64 /** @defgroup GPIO_LL_ES_INIT GPIO Exported Init structures
65 * @{
66 */
67
68 /**
69 * @brief LL GPIO Init Structure definition
70 */
71 typedef struct
72 {
73 uint32_t Pin; /*!< Specifies the GPIO pins to be configured.
74 This parameter can be any value of @ref GPIO_LL_EC_PIN */
75
76 uint32_t Mode; /*!< Specifies the operating mode for the selected pins.
77 This parameter can be a value of @ref GPIO_LL_EC_MODE.
78
79 GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinMode().*/
80
81 uint32_t Speed; /*!< Specifies the speed for the selected pins.
82 This parameter can be a value of @ref GPIO_LL_EC_SPEED.
83
84 GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinSpeed().*/
85
86 uint32_t OutputType; /*!< Specifies the operating output type for the selected pins.
87 This parameter can be a value of @ref GPIO_LL_EC_OUTPUT.
88
89 GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinOutputType().*/
90
91 uint32_t Pull; /*!< Specifies the operating Pull-up/Pull down for the selected pins.
92 This parameter can be a value of @ref GPIO_LL_EC_PULL.
93
94 GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinPull().*/
95
96 uint32_t Alternate; /*!< Specifies the Peripheral to be connected to the selected pins.
97 This parameter can be a value of @ref GPIO_LL_EC_AF.
98
99 GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetAFPin_0_7() and LL_GPIO_SetAFPin_8_15().*/
100 } LL_GPIO_InitTypeDef;
101
102 /**
103 * @}
104 */
105 #endif /* USE_FULL_LL_DRIVER */
106
107 /* Exported constants --------------------------------------------------------*/
108 /** @defgroup GPIO_LL_Exported_Constants GPIO Exported Constants
109 * @{
110 */
111
112 /** @defgroup GPIO_LL_EC_PIN PIN
113 * @{
114 */
115 #define LL_GPIO_PIN_0 GPIO_BSRR_BS0 /*!< Select pin 0 */
116 #define LL_GPIO_PIN_1 GPIO_BSRR_BS1 /*!< Select pin 1 */
117 #define LL_GPIO_PIN_2 GPIO_BSRR_BS2 /*!< Select pin 2 */
118 #define LL_GPIO_PIN_3 GPIO_BSRR_BS3 /*!< Select pin 3 */
119 #define LL_GPIO_PIN_4 GPIO_BSRR_BS4 /*!< Select pin 4 */
120 #define LL_GPIO_PIN_5 GPIO_BSRR_BS5 /*!< Select pin 5 */
121 #define LL_GPIO_PIN_6 GPIO_BSRR_BS6 /*!< Select pin 6 */
122 #define LL_GPIO_PIN_7 GPIO_BSRR_BS7 /*!< Select pin 7 */
123 #define LL_GPIO_PIN_8 GPIO_BSRR_BS8 /*!< Select pin 8 */
124 #define LL_GPIO_PIN_9 GPIO_BSRR_BS9 /*!< Select pin 9 */
125 #define LL_GPIO_PIN_10 GPIO_BSRR_BS10 /*!< Select pin 10 */
126 #define LL_GPIO_PIN_11 GPIO_BSRR_BS11 /*!< Select pin 11 */
127 #define LL_GPIO_PIN_12 GPIO_BSRR_BS12 /*!< Select pin 12 */
128 #define LL_GPIO_PIN_13 GPIO_BSRR_BS13 /*!< Select pin 13 */
129 #define LL_GPIO_PIN_14 GPIO_BSRR_BS14 /*!< Select pin 14 */
130 #define LL_GPIO_PIN_15 GPIO_BSRR_BS15 /*!< Select pin 15 */
131 #define LL_GPIO_PIN_ALL (GPIO_BSRR_BS0 | GPIO_BSRR_BS1 | GPIO_BSRR_BS2 | \
132 GPIO_BSRR_BS3 | GPIO_BSRR_BS4 | GPIO_BSRR_BS5 | \
133 GPIO_BSRR_BS6 | GPIO_BSRR_BS7 | GPIO_BSRR_BS8 | \
134 GPIO_BSRR_BS9 | GPIO_BSRR_BS10 | GPIO_BSRR_BS11 | \
135 GPIO_BSRR_BS12 | GPIO_BSRR_BS13 | GPIO_BSRR_BS14 | \
136 GPIO_BSRR_BS15) /*!< Select all pins */
137 /**
138 * @}
139 */
140
141 /** @defgroup GPIO_LL_EC_MODE Mode
142 * @{
143 */
144 #define LL_GPIO_MODE_INPUT (0x00000000U) /*!< Select input mode */
145 #define LL_GPIO_MODE_OUTPUT GPIO_MODER_MODE0_0 /*!< Select output mode */
146 #define LL_GPIO_MODE_ALTERNATE GPIO_MODER_MODE0_1 /*!< Select alternate function mode */
147 #define LL_GPIO_MODE_ANALOG GPIO_MODER_MODE0 /*!< Select analog mode */
148 /**
149 * @}
150 */
151
152 /** @defgroup GPIO_LL_EC_OUTPUT Output Type
153 * @{
154 */
155 #define LL_GPIO_OUTPUT_PUSHPULL (0x00000000U) /*!< Select push-pull as output type */
156 #define LL_GPIO_OUTPUT_OPENDRAIN GPIO_OTYPER_OT0 /*!< Select open-drain as output type */
157 /**
158 * @}
159 */
160
161 /** @defgroup GPIO_LL_EC_SPEED Output Speed
162 * @{
163 */
164 #define LL_GPIO_SPEED_FREQ_LOW (0x00000000U) /*!< Select I/O low output speed */
165 #define LL_GPIO_SPEED_FREQ_MEDIUM GPIO_OSPEEDR_OSPEED0_0 /*!< Select I/O medium output speed */
166 #define LL_GPIO_SPEED_FREQ_HIGH GPIO_OSPEEDR_OSPEED0_1 /*!< Select I/O fast output speed */
167 /**
168 * @}
169 */
170 #define LL_GPIO_SPEED_LOW LL_GPIO_SPEED_FREQ_LOW
171 #define LL_GPIO_SPEED_MEDIUM LL_GPIO_SPEED_FREQ_MEDIUM
172 #define LL_GPIO_SPEED_FAST LL_GPIO_SPEED_FREQ_HIGH
173
174
175 /** @defgroup GPIO_LL_EC_PULL Pull Up Pull Down
176 * @{
177 */
178 #define LL_GPIO_PULL_NO (0x00000000U) /*!< Select I/O no pull */
179 #define LL_GPIO_PULL_UP GPIO_PUPDR_PUPD0_0 /*!< Select I/O pull up */
180 #define LL_GPIO_PULL_DOWN GPIO_PUPDR_PUPD0_1 /*!< Select I/O pull down */
181 /**
182 * @}
183 */
184
185 /** @defgroup GPIO_LL_EC_AF Alternate Function
186 * @{
187 */
188 #define LL_GPIO_AF_0 (0x0000000U) /*!< Select alternate function 0 */
189 #define LL_GPIO_AF_1 (0x0000001U) /*!< Select alternate function 1 */
190 #define LL_GPIO_AF_2 (0x0000002U) /*!< Select alternate function 2 */
191 #define LL_GPIO_AF_3 (0x0000003U) /*!< Select alternate function 3 */
192 #define LL_GPIO_AF_4 (0x0000004U) /*!< Select alternate function 4 */
193 #define LL_GPIO_AF_5 (0x0000005U) /*!< Select alternate function 5 */
194 #define LL_GPIO_AF_6 (0x0000006U) /*!< Select alternate function 6 */
195 #define LL_GPIO_AF_7 (0x0000007U) /*!< Select alternate function 7 */
196 #define LL_GPIO_AF_8 (0x0000008U) /*!< Select alternate function 8 */
197 #define LL_GPIO_AF_9 (0x0000009U) /*!< Select alternate function 9 */
198 #define LL_GPIO_AF_10 (0x000000AU) /*!< Select alternate function 10 */
199 #define LL_GPIO_AF_11 (0x000000BU) /*!< Select alternate function 11 */
200 #define LL_GPIO_AF_12 (0x000000CU) /*!< Select alternate function 12 */
201 #define LL_GPIO_AF_13 (0x000000DU) /*!< Select alternate function 13 */
202 #define LL_GPIO_AF_14 (0x000000EU) /*!< Select alternate function 14 */
203 #define LL_GPIO_AF_15 (0x000000FU) /*!< Select alternate function 15 */
204 /**
205 * @}
206 */
207
208 /**
209 * @}
210 */
211
212 /* Exported macro ------------------------------------------------------------*/
213 /** @defgroup GPIO_LL_Exported_Macros GPIO Exported Macros
214 * @{
215 */
216
217 /** @defgroup GPIO_LL_EM_WRITE_READ Common Write and read registers Macros
218 * @{
219 */
220
221 /**
222 * @brief Write a value in GPIO register
223 * @param __INSTANCE__ GPIO Instance
224 * @param __REG__ Register to be written
225 * @param __VALUE__ Value to be written in the register
226 * @retval None
227 */
228 #define LL_GPIO_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
229
230 /**
231 * @brief Read a value in GPIO register
232 * @param __INSTANCE__ GPIO Instance
233 * @param __REG__ Register to be read
234 * @retval Register value
235 */
236 #define LL_GPIO_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
237 /**
238 * @}
239 */
240
241 /**
242 * @}
243 */
244
245 /* Exported functions --------------------------------------------------------*/
246 /** @defgroup GPIO_LL_Exported_Functions GPIO Exported Functions
247 * @{
248 */
249
250 /** @defgroup GPIO_LL_EF_Port_Configuration Port Configuration
251 * @{
252 */
253
254 /**
255 * @brief Configure gpio mode for a dedicated pin on dedicated port.
256 * @note I/O mode can be Input mode, General purpose output, Alternate function mode or Analog.
257 * @note Warning: only one pin can be passed as parameter.
258 * @rmtoll MODER MODEy LL_GPIO_SetPinMode
259 * @param GPIOx GPIO Port
260 * @param Pin This parameter can be one of the following values:
261 * @arg @ref LL_GPIO_PIN_0
262 * @arg @ref LL_GPIO_PIN_1
263 * @arg @ref LL_GPIO_PIN_2
264 * @arg @ref LL_GPIO_PIN_3
265 * @arg @ref LL_GPIO_PIN_4
266 * @arg @ref LL_GPIO_PIN_5
267 * @arg @ref LL_GPIO_PIN_6
268 * @arg @ref LL_GPIO_PIN_7
269 * @arg @ref LL_GPIO_PIN_8
270 * @arg @ref LL_GPIO_PIN_9
271 * @arg @ref LL_GPIO_PIN_10
272 * @arg @ref LL_GPIO_PIN_11
273 * @arg @ref LL_GPIO_PIN_12
274 * @arg @ref LL_GPIO_PIN_13
275 * @arg @ref LL_GPIO_PIN_14
276 * @arg @ref LL_GPIO_PIN_15
277 * @param Mode This parameter can be one of the following values:
278 * @arg @ref LL_GPIO_MODE_INPUT
279 * @arg @ref LL_GPIO_MODE_OUTPUT
280 * @arg @ref LL_GPIO_MODE_ALTERNATE
281 * @arg @ref LL_GPIO_MODE_ANALOG
282 * @retval None
283 */
LL_GPIO_SetPinMode(GPIO_TypeDef * GPIOx,uint32_t Pin,uint32_t Mode)284 __STATIC_INLINE void LL_GPIO_SetPinMode(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Mode)
285 {
286 MODIFY_REG(GPIOx->MODER, (GPIO_MODER_MODE0 << (POSITION_VAL(Pin) * GPIO_MODER_MODE1_Pos)),
287 (Mode << (POSITION_VAL(Pin) * GPIO_MODER_MODE1_Pos)));
288 }
289
290 /**
291 * @brief Return gpio mode for a dedicated pin on dedicated port.
292 * @note I/O mode can be Input mode, General purpose output, Alternate function mode or Analog.
293 * @note Warning: only one pin can be passed as parameter.
294 * @rmtoll MODER MODEy LL_GPIO_GetPinMode
295 * @param GPIOx GPIO Port
296 * @param Pin This parameter can be one of the following values:
297 * @arg @ref LL_GPIO_PIN_0
298 * @arg @ref LL_GPIO_PIN_1
299 * @arg @ref LL_GPIO_PIN_2
300 * @arg @ref LL_GPIO_PIN_3
301 * @arg @ref LL_GPIO_PIN_4
302 * @arg @ref LL_GPIO_PIN_5
303 * @arg @ref LL_GPIO_PIN_6
304 * @arg @ref LL_GPIO_PIN_7
305 * @arg @ref LL_GPIO_PIN_8
306 * @arg @ref LL_GPIO_PIN_9
307 * @arg @ref LL_GPIO_PIN_10
308 * @arg @ref LL_GPIO_PIN_11
309 * @arg @ref LL_GPIO_PIN_12
310 * @arg @ref LL_GPIO_PIN_13
311 * @arg @ref LL_GPIO_PIN_14
312 * @arg @ref LL_GPIO_PIN_15
313 * @retval Returned value can be one of the following values:
314 * @arg @ref LL_GPIO_MODE_INPUT
315 * @arg @ref LL_GPIO_MODE_OUTPUT
316 * @arg @ref LL_GPIO_MODE_ALTERNATE
317 * @arg @ref LL_GPIO_MODE_ANALOG
318 */
LL_GPIO_GetPinMode(const GPIO_TypeDef * GPIOx,uint32_t Pin)319 __STATIC_INLINE uint32_t LL_GPIO_GetPinMode(const GPIO_TypeDef *GPIOx, uint32_t Pin)
320 {
321 return (uint32_t)(READ_BIT(GPIOx->MODER, (GPIO_MODER_MODE0 << (POSITION_VAL(Pin) * GPIO_MODER_MODE1_Pos)))
322 >> (POSITION_VAL(Pin) * GPIO_MODER_MODE1_Pos));
323 }
324
325 /**
326 * @brief Configure gpio output type for several pins on dedicated port.
327 * @note Output type as to be set when gpio pin is in output or
328 * alternate modes. Possible type are Push-pull or Open-drain.
329 * @rmtoll OTYPER OTy LL_GPIO_SetPinOutputType
330 * @param GPIOx GPIO Port
331 * @param PinMask This parameter can be a combination of the following values:
332 * @arg @ref LL_GPIO_PIN_0
333 * @arg @ref LL_GPIO_PIN_1
334 * @arg @ref LL_GPIO_PIN_2
335 * @arg @ref LL_GPIO_PIN_3
336 * @arg @ref LL_GPIO_PIN_4
337 * @arg @ref LL_GPIO_PIN_5
338 * @arg @ref LL_GPIO_PIN_6
339 * @arg @ref LL_GPIO_PIN_7
340 * @arg @ref LL_GPIO_PIN_8
341 * @arg @ref LL_GPIO_PIN_9
342 * @arg @ref LL_GPIO_PIN_10
343 * @arg @ref LL_GPIO_PIN_11
344 * @arg @ref LL_GPIO_PIN_12
345 * @arg @ref LL_GPIO_PIN_13
346 * @arg @ref LL_GPIO_PIN_14
347 * @arg @ref LL_GPIO_PIN_15
348 * @arg @ref LL_GPIO_PIN_ALL
349 * @param OutputType This parameter can be one of the following values:
350 * @arg @ref LL_GPIO_OUTPUT_PUSHPULL
351 * @arg @ref LL_GPIO_OUTPUT_OPENDRAIN
352 * @retval None
353 */
LL_GPIO_SetPinOutputType(GPIO_TypeDef * GPIOx,uint32_t PinMask,uint32_t OutputType)354 __STATIC_INLINE void LL_GPIO_SetPinOutputType(GPIO_TypeDef *GPIOx, uint32_t PinMask, uint32_t OutputType)
355 {
356 MODIFY_REG(GPIOx->OTYPER, PinMask, (PinMask * OutputType));
357 }
358
359 /**
360 * @brief Return gpio output type for several pins on dedicated port.
361 * @note Output type as to be set when gpio pin is in output or
362 * alternate modes. Possible type are Push-pull or Open-drain.
363 * @note Warning: only one pin can be passed as parameter.
364 * @rmtoll OTYPER OTy LL_GPIO_GetPinOutputType
365 * @param GPIOx GPIO Port
366 * @param Pin This parameter can be one of the following values:
367 * @arg @ref LL_GPIO_PIN_0
368 * @arg @ref LL_GPIO_PIN_1
369 * @arg @ref LL_GPIO_PIN_2
370 * @arg @ref LL_GPIO_PIN_3
371 * @arg @ref LL_GPIO_PIN_4
372 * @arg @ref LL_GPIO_PIN_5
373 * @arg @ref LL_GPIO_PIN_6
374 * @arg @ref LL_GPIO_PIN_7
375 * @arg @ref LL_GPIO_PIN_8
376 * @arg @ref LL_GPIO_PIN_9
377 * @arg @ref LL_GPIO_PIN_10
378 * @arg @ref LL_GPIO_PIN_11
379 * @arg @ref LL_GPIO_PIN_12
380 * @arg @ref LL_GPIO_PIN_13
381 * @arg @ref LL_GPIO_PIN_14
382 * @arg @ref LL_GPIO_PIN_15
383 * @arg @ref LL_GPIO_PIN_ALL
384 * @retval Returned value can be one of the following values:
385 * @arg @ref LL_GPIO_OUTPUT_PUSHPULL
386 * @arg @ref LL_GPIO_OUTPUT_OPENDRAIN
387 */
LL_GPIO_GetPinOutputType(const GPIO_TypeDef * GPIOx,uint32_t Pin)388 __STATIC_INLINE uint32_t LL_GPIO_GetPinOutputType(const GPIO_TypeDef *GPIOx, uint32_t Pin)
389 {
390 return (uint32_t)(READ_BIT(GPIOx->OTYPER, Pin) >> POSITION_VAL(Pin));
391 }
392
393 /**
394 * @brief Configure gpio speed for a dedicated pin on dedicated port.
395 * @note I/O speed can be Low, Medium, Fast or High speed.
396 * @note Warning: only one pin can be passed as parameter.
397 * @note Refer to datasheet for frequency specifications and the power
398 * supply and load conditions for each speed.
399 * @rmtoll OSPEEDR OSPEEDy LL_GPIO_SetPinSpeed
400 * @param GPIOx GPIO Port
401 * @param Pin This parameter can be one of the following values:
402 * @arg @ref LL_GPIO_PIN_0
403 * @arg @ref LL_GPIO_PIN_1
404 * @arg @ref LL_GPIO_PIN_2
405 * @arg @ref LL_GPIO_PIN_3
406 * @arg @ref LL_GPIO_PIN_4
407 * @arg @ref LL_GPIO_PIN_5
408 * @arg @ref LL_GPIO_PIN_6
409 * @arg @ref LL_GPIO_PIN_7
410 * @arg @ref LL_GPIO_PIN_8
411 * @arg @ref LL_GPIO_PIN_9
412 * @arg @ref LL_GPIO_PIN_10
413 * @arg @ref LL_GPIO_PIN_11
414 * @arg @ref LL_GPIO_PIN_12
415 * @arg @ref LL_GPIO_PIN_13
416 * @arg @ref LL_GPIO_PIN_14
417 * @arg @ref LL_GPIO_PIN_15
418 * @param Speed This parameter can be one of the following values:
419 * @arg @ref LL_GPIO_SPEED_FREQ_LOW
420 * @arg @ref LL_GPIO_SPEED_FREQ_MEDIUM
421 * @arg @ref LL_GPIO_SPEED_FREQ_HIGH
422 * @retval None
423 */
LL_GPIO_SetPinSpeed(GPIO_TypeDef * GPIOx,uint32_t Pin,uint32_t Speed)424 __STATIC_INLINE void LL_GPIO_SetPinSpeed(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Speed)
425 {
426 MODIFY_REG(GPIOx->OSPEEDR, (GPIO_OSPEEDR_OSPEED0 << (POSITION_VAL(Pin) * GPIO_OSPEEDR_OSPEED1_Pos)),
427 (Speed << (POSITION_VAL(Pin) * GPIO_OSPEEDR_OSPEED1_Pos)));
428 }
429
430 /**
431 * @brief Return gpio speed for a dedicated pin on dedicated port.
432 * @note I/O speed can be Low, Medium, Fast or High speed.
433 * @note Warning: only one pin can be passed as parameter.
434 * @note Refer to datasheet for frequency specifications and the power
435 * supply and load conditions for each speed.
436 * @rmtoll OSPEEDR OSPEEDy LL_GPIO_GetPinSpeed
437 * @param GPIOx GPIO Port
438 * @param Pin This parameter can be one of the following values:
439 * @arg @ref LL_GPIO_PIN_0
440 * @arg @ref LL_GPIO_PIN_1
441 * @arg @ref LL_GPIO_PIN_2
442 * @arg @ref LL_GPIO_PIN_3
443 * @arg @ref LL_GPIO_PIN_4
444 * @arg @ref LL_GPIO_PIN_5
445 * @arg @ref LL_GPIO_PIN_6
446 * @arg @ref LL_GPIO_PIN_7
447 * @arg @ref LL_GPIO_PIN_8
448 * @arg @ref LL_GPIO_PIN_9
449 * @arg @ref LL_GPIO_PIN_10
450 * @arg @ref LL_GPIO_PIN_11
451 * @arg @ref LL_GPIO_PIN_12
452 * @arg @ref LL_GPIO_PIN_13
453 * @arg @ref LL_GPIO_PIN_14
454 * @arg @ref LL_GPIO_PIN_15
455 * @retval Returned value can be one of the following values:
456 * @arg @ref LL_GPIO_SPEED_FREQ_LOW
457 * @arg @ref LL_GPIO_SPEED_FREQ_MEDIUM
458 * @arg @ref LL_GPIO_SPEED_FREQ_HIGH
459 */
LL_GPIO_GetPinSpeed(const GPIO_TypeDef * GPIOx,uint32_t Pin)460 __STATIC_INLINE uint32_t LL_GPIO_GetPinSpeed(const GPIO_TypeDef *GPIOx, uint32_t Pin)
461 {
462 return (uint32_t)(READ_BIT(GPIOx->OSPEEDR, (GPIO_OSPEEDR_OSPEED0 << (POSITION_VAL(Pin) * GPIO_OSPEEDR_OSPEED1_Pos)))
463 >> (POSITION_VAL(Pin) * GPIO_OSPEEDR_OSPEED1_Pos));
464 }
465
466 /**
467 * @brief Configure gpio pull-up or pull-down for a dedicated pin on a dedicated port.
468 * @note Warning: only one pin can be passed as parameter.
469 * @rmtoll PUPDR PUPDy LL_GPIO_SetPinPull
470 * @param GPIOx GPIO Port
471 * @param Pin This parameter can be one of the following values:
472 * @arg @ref LL_GPIO_PIN_0
473 * @arg @ref LL_GPIO_PIN_1
474 * @arg @ref LL_GPIO_PIN_2
475 * @arg @ref LL_GPIO_PIN_3
476 * @arg @ref LL_GPIO_PIN_4
477 * @arg @ref LL_GPIO_PIN_5
478 * @arg @ref LL_GPIO_PIN_6
479 * @arg @ref LL_GPIO_PIN_7
480 * @arg @ref LL_GPIO_PIN_8
481 * @arg @ref LL_GPIO_PIN_9
482 * @arg @ref LL_GPIO_PIN_10
483 * @arg @ref LL_GPIO_PIN_11
484 * @arg @ref LL_GPIO_PIN_12
485 * @arg @ref LL_GPIO_PIN_13
486 * @arg @ref LL_GPIO_PIN_14
487 * @arg @ref LL_GPIO_PIN_15
488 * @param Pull This parameter can be one of the following values:
489 * @arg @ref LL_GPIO_PULL_NO
490 * @arg @ref LL_GPIO_PULL_UP
491 * @arg @ref LL_GPIO_PULL_DOWN
492 * @retval None
493 */
LL_GPIO_SetPinPull(GPIO_TypeDef * GPIOx,uint32_t Pin,uint32_t Pull)494 __STATIC_INLINE void LL_GPIO_SetPinPull(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Pull)
495 {
496 MODIFY_REG(GPIOx->PUPDR, (GPIO_PUPDR_PUPD0 << (POSITION_VAL(Pin) * GPIO_PUPDR_PUPD1_Pos)),
497 (Pull << (POSITION_VAL(Pin) * GPIO_PUPDR_PUPD1_Pos)));
498 }
499
500 /**
501 * @brief Return gpio pull-up or pull-down for a dedicated pin on a dedicated port
502 * @note Warning: only one pin can be passed as parameter.
503 * @rmtoll PUPDR PUPDy LL_GPIO_GetPinPull
504 * @param GPIOx GPIO Port
505 * @param Pin This parameter can be one of the following values:
506 * @arg @ref LL_GPIO_PIN_0
507 * @arg @ref LL_GPIO_PIN_1
508 * @arg @ref LL_GPIO_PIN_2
509 * @arg @ref LL_GPIO_PIN_3
510 * @arg @ref LL_GPIO_PIN_4
511 * @arg @ref LL_GPIO_PIN_5
512 * @arg @ref LL_GPIO_PIN_6
513 * @arg @ref LL_GPIO_PIN_7
514 * @arg @ref LL_GPIO_PIN_8
515 * @arg @ref LL_GPIO_PIN_9
516 * @arg @ref LL_GPIO_PIN_10
517 * @arg @ref LL_GPIO_PIN_11
518 * @arg @ref LL_GPIO_PIN_12
519 * @arg @ref LL_GPIO_PIN_13
520 * @arg @ref LL_GPIO_PIN_14
521 * @arg @ref LL_GPIO_PIN_15
522 * @retval Returned value can be one of the following values:
523 * @arg @ref LL_GPIO_PULL_NO
524 * @arg @ref LL_GPIO_PULL_UP
525 * @arg @ref LL_GPIO_PULL_DOWN
526 */
LL_GPIO_GetPinPull(const GPIO_TypeDef * GPIOx,uint32_t Pin)527 __STATIC_INLINE uint32_t LL_GPIO_GetPinPull(const GPIO_TypeDef *GPIOx, uint32_t Pin)
528 {
529 return (uint32_t)(READ_BIT(GPIOx->PUPDR, (GPIO_PUPDR_PUPD0 << (POSITION_VAL(Pin) * GPIO_PUPDR_PUPD1_Pos)))
530 >> (POSITION_VAL(Pin) * GPIO_PUPDR_PUPD1_Pos));
531 }
532
533 /**
534 * @brief Configure gpio alternate function of a dedicated pin from 0 to 7 for a dedicated port.
535 * @note Possible values are from AF0 to AF15 depending on target.
536 * @note Warning: only one pin can be passed as parameter.
537 * @rmtoll AFRL AFSELy LL_GPIO_SetAFPin_0_7
538 * @param GPIOx GPIO Port
539 * @param Pin This parameter can be one of the following values:
540 * @arg @ref LL_GPIO_PIN_0
541 * @arg @ref LL_GPIO_PIN_1
542 * @arg @ref LL_GPIO_PIN_2
543 * @arg @ref LL_GPIO_PIN_3
544 * @arg @ref LL_GPIO_PIN_4
545 * @arg @ref LL_GPIO_PIN_5
546 * @arg @ref LL_GPIO_PIN_6
547 * @arg @ref LL_GPIO_PIN_7
548 * @param Alternate This parameter can be one of the following values:
549 * @arg @ref LL_GPIO_AF_0
550 * @arg @ref LL_GPIO_AF_1
551 * @arg @ref LL_GPIO_AF_2
552 * @arg @ref LL_GPIO_AF_3
553 * @arg @ref LL_GPIO_AF_4
554 * @arg @ref LL_GPIO_AF_5
555 * @arg @ref LL_GPIO_AF_6
556 * @arg @ref LL_GPIO_AF_7
557 * @arg @ref LL_GPIO_AF_8
558 * @arg @ref LL_GPIO_AF_9
559 * @arg @ref LL_GPIO_AF_10
560 * @arg @ref LL_GPIO_AF_11
561 * @arg @ref LL_GPIO_AF_12
562 * @arg @ref LL_GPIO_AF_13
563 * @arg @ref LL_GPIO_AF_14
564 * @arg @ref LL_GPIO_AF_15
565 * @retval None
566 */
LL_GPIO_SetAFPin_0_7(GPIO_TypeDef * GPIOx,uint32_t Pin,uint32_t Alternate)567 __STATIC_INLINE void LL_GPIO_SetAFPin_0_7(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Alternate)
568 {
569 MODIFY_REG(GPIOx->AFR[0], (GPIO_AFRL_AFSEL0 << (POSITION_VAL(Pin) * GPIO_AFRL_AFSEL1_Pos)),
570 (Alternate << (POSITION_VAL(Pin) * GPIO_AFRL_AFSEL1_Pos)));
571 }
572
573 /**
574 * @brief Return gpio alternate function of a dedicated pin from 0 to 7 for a dedicated port.
575 * @rmtoll AFRL AFSELy LL_GPIO_GetAFPin_0_7
576 * @param GPIOx GPIO Port
577 * @param Pin This parameter can be one of the following values:
578 * @arg @ref LL_GPIO_PIN_0
579 * @arg @ref LL_GPIO_PIN_1
580 * @arg @ref LL_GPIO_PIN_2
581 * @arg @ref LL_GPIO_PIN_3
582 * @arg @ref LL_GPIO_PIN_4
583 * @arg @ref LL_GPIO_PIN_5
584 * @arg @ref LL_GPIO_PIN_6
585 * @arg @ref LL_GPIO_PIN_7
586 * @retval Returned value can be one of the following values:
587 * @arg @ref LL_GPIO_AF_0
588 * @arg @ref LL_GPIO_AF_1
589 * @arg @ref LL_GPIO_AF_2
590 * @arg @ref LL_GPIO_AF_3
591 * @arg @ref LL_GPIO_AF_4
592 * @arg @ref LL_GPIO_AF_5
593 * @arg @ref LL_GPIO_AF_6
594 * @arg @ref LL_GPIO_AF_7
595 * @arg @ref LL_GPIO_AF_8
596 * @arg @ref LL_GPIO_AF_9
597 * @arg @ref LL_GPIO_AF_10
598 * @arg @ref LL_GPIO_AF_11
599 * @arg @ref LL_GPIO_AF_12
600 * @arg @ref LL_GPIO_AF_13
601 * @arg @ref LL_GPIO_AF_14
602 * @arg @ref LL_GPIO_AF_15
603 */
LL_GPIO_GetAFPin_0_7(const GPIO_TypeDef * GPIOx,uint32_t Pin)604 __STATIC_INLINE uint32_t LL_GPIO_GetAFPin_0_7(const GPIO_TypeDef *GPIOx, uint32_t Pin)
605 {
606 return (uint32_t)(READ_BIT(GPIOx->AFR[0], (GPIO_AFRL_AFSEL0 << (POSITION_VAL(Pin) * GPIO_AFRL_AFSEL1_Pos)))
607 >> (POSITION_VAL(Pin) * GPIO_AFRL_AFSEL1_Pos));
608 }
609
610 /**
611 * @brief Configure gpio alternate function of a dedicated pin from 8 to 15 for a dedicated port.
612 * @note Possible values are from AF0 to AF15 depending on target.
613 * @note Warning: only one pin can be passed as parameter.
614 * @rmtoll AFRH AFSELy LL_GPIO_SetAFPin_8_15
615 * @param GPIOx GPIO Port
616 * @param Pin This parameter can be one of the following values:
617 * @arg @ref LL_GPIO_PIN_8
618 * @arg @ref LL_GPIO_PIN_9
619 * @arg @ref LL_GPIO_PIN_10
620 * @arg @ref LL_GPIO_PIN_11
621 * @arg @ref LL_GPIO_PIN_12
622 * @arg @ref LL_GPIO_PIN_13
623 * @arg @ref LL_GPIO_PIN_14
624 * @arg @ref LL_GPIO_PIN_15
625 * @param Alternate This parameter can be one of the following values:
626 * @arg @ref LL_GPIO_AF_0
627 * @arg @ref LL_GPIO_AF_1
628 * @arg @ref LL_GPIO_AF_2
629 * @arg @ref LL_GPIO_AF_3
630 * @arg @ref LL_GPIO_AF_4
631 * @arg @ref LL_GPIO_AF_5
632 * @arg @ref LL_GPIO_AF_6
633 * @arg @ref LL_GPIO_AF_7
634 * @arg @ref LL_GPIO_AF_8
635 * @arg @ref LL_GPIO_AF_9
636 * @arg @ref LL_GPIO_AF_10
637 * @arg @ref LL_GPIO_AF_11
638 * @arg @ref LL_GPIO_AF_12
639 * @arg @ref LL_GPIO_AF_13
640 * @arg @ref LL_GPIO_AF_14
641 * @arg @ref LL_GPIO_AF_15
642 * @retval None
643 */
LL_GPIO_SetAFPin_8_15(GPIO_TypeDef * GPIOx,uint32_t Pin,uint32_t Alternate)644 __STATIC_INLINE void LL_GPIO_SetAFPin_8_15(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Alternate)
645 {
646 MODIFY_REG(GPIOx->AFR[1], (GPIO_AFRH_AFSEL8 << (POSITION_VAL(Pin >> 8U) * GPIO_AFRH_AFSEL9_Pos)),
647 (Alternate << (POSITION_VAL(Pin >> 8U) * GPIO_AFRH_AFSEL9_Pos)));
648 }
649
650 /**
651 * @brief Return gpio alternate function of a dedicated pin from 8 to 15 for a dedicated port.
652 * @note Possible values are from AF0 to AF15 depending on target.
653 * @rmtoll AFRH AFSELy LL_GPIO_GetAFPin_8_15
654 * @param GPIOx GPIO Port
655 * @param Pin This parameter can be one of the following values:
656 * @arg @ref LL_GPIO_PIN_8
657 * @arg @ref LL_GPIO_PIN_9
658 * @arg @ref LL_GPIO_PIN_10
659 * @arg @ref LL_GPIO_PIN_11
660 * @arg @ref LL_GPIO_PIN_12
661 * @arg @ref LL_GPIO_PIN_13
662 * @arg @ref LL_GPIO_PIN_14
663 * @arg @ref LL_GPIO_PIN_15
664 * @retval Returned value can be one of the following values:
665 * @arg @ref LL_GPIO_AF_0
666 * @arg @ref LL_GPIO_AF_1
667 * @arg @ref LL_GPIO_AF_2
668 * @arg @ref LL_GPIO_AF_3
669 * @arg @ref LL_GPIO_AF_4
670 * @arg @ref LL_GPIO_AF_5
671 * @arg @ref LL_GPIO_AF_6
672 * @arg @ref LL_GPIO_AF_7
673 * @arg @ref LL_GPIO_AF_8
674 * @arg @ref LL_GPIO_AF_9
675 * @arg @ref LL_GPIO_AF_10
676 * @arg @ref LL_GPIO_AF_11
677 * @arg @ref LL_GPIO_AF_12
678 * @arg @ref LL_GPIO_AF_13
679 * @arg @ref LL_GPIO_AF_14
680 * @arg @ref LL_GPIO_AF_15
681 */
LL_GPIO_GetAFPin_8_15(const GPIO_TypeDef * GPIOx,uint32_t Pin)682 __STATIC_INLINE uint32_t LL_GPIO_GetAFPin_8_15(const GPIO_TypeDef *GPIOx, uint32_t Pin)
683 {
684 return (uint32_t)(READ_BIT(GPIOx->AFR[1], (GPIO_AFRH_AFSEL8 << (POSITION_VAL(Pin >> 8U) * GPIO_AFRH_AFSEL9_Pos)))
685 >> (POSITION_VAL(Pin >> 8U) * GPIO_AFRH_AFSEL9_Pos));
686 }
687
688
689 /**
690 * @brief Lock configuration of several pins for a dedicated port.
691 * @note When the lock sequence has been applied on a port bit, the
692 * value of this port bit can no longer be modified until the
693 * next reset.
694 * @note Each lock bit freezes a specific configuration register
695 * (control and alternate function registers).
696 * @rmtoll LCKR LCKK LL_GPIO_LockPin
697 * @param GPIOx GPIO Port
698 * @param PinMask This parameter can be a combination of the following values:
699 * @arg @ref LL_GPIO_PIN_0
700 * @arg @ref LL_GPIO_PIN_1
701 * @arg @ref LL_GPIO_PIN_2
702 * @arg @ref LL_GPIO_PIN_3
703 * @arg @ref LL_GPIO_PIN_4
704 * @arg @ref LL_GPIO_PIN_5
705 * @arg @ref LL_GPIO_PIN_6
706 * @arg @ref LL_GPIO_PIN_7
707 * @arg @ref LL_GPIO_PIN_8
708 * @arg @ref LL_GPIO_PIN_9
709 * @arg @ref LL_GPIO_PIN_10
710 * @arg @ref LL_GPIO_PIN_11
711 * @arg @ref LL_GPIO_PIN_12
712 * @arg @ref LL_GPIO_PIN_13
713 * @arg @ref LL_GPIO_PIN_14
714 * @arg @ref LL_GPIO_PIN_15
715 * @arg @ref LL_GPIO_PIN_ALL
716 * @retval None
717 */
LL_GPIO_LockPin(GPIO_TypeDef * GPIOx,uint32_t PinMask)718 __STATIC_INLINE void LL_GPIO_LockPin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
719 {
720 __IO uint32_t temp;
721 WRITE_REG(GPIOx->LCKR, GPIO_LCKR_LCKK | PinMask);
722 WRITE_REG(GPIOx->LCKR, PinMask);
723 WRITE_REG(GPIOx->LCKR, GPIO_LCKR_LCKK | PinMask);
724 /* Read LCKK register. This read is mandatory to complete key lock sequence */
725 temp = READ_REG(GPIOx->LCKR);
726 (void) temp;
727 }
728
729 /**
730 * @brief Return 1 if all pins passed as parameter, of a dedicated port, are locked. else Return 0.
731 * @rmtoll LCKR LCKy LL_GPIO_IsPinLocked
732 * @param GPIOx GPIO Port
733 * @param PinMask This parameter can be a combination of the following values:
734 * @arg @ref LL_GPIO_PIN_0
735 * @arg @ref LL_GPIO_PIN_1
736 * @arg @ref LL_GPIO_PIN_2
737 * @arg @ref LL_GPIO_PIN_3
738 * @arg @ref LL_GPIO_PIN_4
739 * @arg @ref LL_GPIO_PIN_5
740 * @arg @ref LL_GPIO_PIN_6
741 * @arg @ref LL_GPIO_PIN_7
742 * @arg @ref LL_GPIO_PIN_8
743 * @arg @ref LL_GPIO_PIN_9
744 * @arg @ref LL_GPIO_PIN_10
745 * @arg @ref LL_GPIO_PIN_11
746 * @arg @ref LL_GPIO_PIN_12
747 * @arg @ref LL_GPIO_PIN_13
748 * @arg @ref LL_GPIO_PIN_14
749 * @arg @ref LL_GPIO_PIN_15
750 * @arg @ref LL_GPIO_PIN_ALL
751 * @retval State of bit (1 or 0).
752 */
LL_GPIO_IsPinLocked(const GPIO_TypeDef * GPIOx,uint32_t PinMask)753 __STATIC_INLINE uint32_t LL_GPIO_IsPinLocked(const GPIO_TypeDef *GPIOx, uint32_t PinMask)
754 {
755 return ((READ_BIT(GPIOx->LCKR, PinMask) == (PinMask)) ? 1UL : 0UL);
756 }
757
758 /**
759 * @brief Return 1 if one of the pin of a dedicated port is locked. else return 0.
760 * @rmtoll LCKR LCKK LL_GPIO_IsAnyPinLocked
761 * @param GPIOx GPIO Port
762 * @retval State of bit (1 or 0).
763 */
LL_GPIO_IsAnyPinLocked(const GPIO_TypeDef * GPIOx)764 __STATIC_INLINE uint32_t LL_GPIO_IsAnyPinLocked(const GPIO_TypeDef *GPIOx)
765 {
766 return ((READ_BIT(GPIOx->LCKR, GPIO_LCKR_LCKK) == (GPIO_LCKR_LCKK)) ? 1UL : 0UL);
767 }
768
769 /**
770 * @}
771 */
772
773 /** @defgroup GPIO_LL_EF_Data_Access Data Access
774 * @{
775 */
776
777 /**
778 * @brief Return full input data register value for a dedicated port.
779 * @rmtoll IDR IDy LL_GPIO_ReadInputPort
780 * @param GPIOx GPIO Port
781 * @retval Input data register value of port
782 */
LL_GPIO_ReadInputPort(const GPIO_TypeDef * GPIOx)783 __STATIC_INLINE uint32_t LL_GPIO_ReadInputPort(const GPIO_TypeDef *GPIOx)
784 {
785 return (uint32_t)(READ_REG(GPIOx->IDR));
786 }
787
788 /**
789 * @brief Return if input data level for several pins of dedicated port is high or low.
790 * @rmtoll IDR IDy LL_GPIO_IsInputPinSet
791 * @param GPIOx GPIO Port
792 * @param PinMask This parameter can be a combination of the following values:
793 * @arg @ref LL_GPIO_PIN_0
794 * @arg @ref LL_GPIO_PIN_1
795 * @arg @ref LL_GPIO_PIN_2
796 * @arg @ref LL_GPIO_PIN_3
797 * @arg @ref LL_GPIO_PIN_4
798 * @arg @ref LL_GPIO_PIN_5
799 * @arg @ref LL_GPIO_PIN_6
800 * @arg @ref LL_GPIO_PIN_7
801 * @arg @ref LL_GPIO_PIN_8
802 * @arg @ref LL_GPIO_PIN_9
803 * @arg @ref LL_GPIO_PIN_10
804 * @arg @ref LL_GPIO_PIN_11
805 * @arg @ref LL_GPIO_PIN_12
806 * @arg @ref LL_GPIO_PIN_13
807 * @arg @ref LL_GPIO_PIN_14
808 * @arg @ref LL_GPIO_PIN_15
809 * @arg @ref LL_GPIO_PIN_ALL
810 * @retval State of bit (1 or 0).
811 */
LL_GPIO_IsInputPinSet(const GPIO_TypeDef * GPIOx,uint32_t PinMask)812 __STATIC_INLINE uint32_t LL_GPIO_IsInputPinSet(const GPIO_TypeDef *GPIOx, uint32_t PinMask)
813 {
814 return ((READ_BIT(GPIOx->IDR, PinMask) == (PinMask)) ? 1UL : 0UL);
815 }
816
817 /**
818 * @brief Write output data register for the port.
819 * @rmtoll ODR ODy LL_GPIO_WriteOutputPort
820 * @param GPIOx GPIO Port
821 * @param PortValue Level value for each pin of the port
822 * @retval None
823 */
LL_GPIO_WriteOutputPort(GPIO_TypeDef * GPIOx,uint32_t PortValue)824 __STATIC_INLINE void LL_GPIO_WriteOutputPort(GPIO_TypeDef *GPIOx, uint32_t PortValue)
825 {
826 WRITE_REG(GPIOx->ODR, PortValue);
827 }
828
829 /**
830 * @brief Return full output data register value for a dedicated port.
831 * @rmtoll ODR ODy LL_GPIO_ReadOutputPort
832 * @param GPIOx GPIO Port
833 * @retval Output data register value of port
834 */
LL_GPIO_ReadOutputPort(const GPIO_TypeDef * GPIOx)835 __STATIC_INLINE uint32_t LL_GPIO_ReadOutputPort(const GPIO_TypeDef *GPIOx)
836 {
837 return (uint32_t)(READ_REG(GPIOx->ODR));
838 }
839
840 /**
841 * @brief Return if input data level for several pins of dedicated port is high or low.
842 * @rmtoll ODR ODy LL_GPIO_IsOutputPinSet
843 * @param GPIOx GPIO Port
844 * @param PinMask This parameter can be a combination of the following values:
845 * @arg @ref LL_GPIO_PIN_0
846 * @arg @ref LL_GPIO_PIN_1
847 * @arg @ref LL_GPIO_PIN_2
848 * @arg @ref LL_GPIO_PIN_3
849 * @arg @ref LL_GPIO_PIN_4
850 * @arg @ref LL_GPIO_PIN_5
851 * @arg @ref LL_GPIO_PIN_6
852 * @arg @ref LL_GPIO_PIN_7
853 * @arg @ref LL_GPIO_PIN_8
854 * @arg @ref LL_GPIO_PIN_9
855 * @arg @ref LL_GPIO_PIN_10
856 * @arg @ref LL_GPIO_PIN_11
857 * @arg @ref LL_GPIO_PIN_12
858 * @arg @ref LL_GPIO_PIN_13
859 * @arg @ref LL_GPIO_PIN_14
860 * @arg @ref LL_GPIO_PIN_15
861 * @arg @ref LL_GPIO_PIN_ALL
862 * @retval State of bit (1 or 0).
863 */
LL_GPIO_IsOutputPinSet(const GPIO_TypeDef * GPIOx,uint32_t PinMask)864 __STATIC_INLINE uint32_t LL_GPIO_IsOutputPinSet(const GPIO_TypeDef *GPIOx, uint32_t PinMask)
865 {
866 return ((READ_BIT(GPIOx->ODR, PinMask) == (PinMask)) ? 1UL : 0UL);
867 }
868
869 /**
870 * @brief Set several pins to high level on dedicated gpio port.
871 * @rmtoll BSRR BSy LL_GPIO_SetOutputPin
872 * @param GPIOx GPIO Port
873 * @param PinMask This parameter can be a combination of the following values:
874 * @arg @ref LL_GPIO_PIN_0
875 * @arg @ref LL_GPIO_PIN_1
876 * @arg @ref LL_GPIO_PIN_2
877 * @arg @ref LL_GPIO_PIN_3
878 * @arg @ref LL_GPIO_PIN_4
879 * @arg @ref LL_GPIO_PIN_5
880 * @arg @ref LL_GPIO_PIN_6
881 * @arg @ref LL_GPIO_PIN_7
882 * @arg @ref LL_GPIO_PIN_8
883 * @arg @ref LL_GPIO_PIN_9
884 * @arg @ref LL_GPIO_PIN_10
885 * @arg @ref LL_GPIO_PIN_11
886 * @arg @ref LL_GPIO_PIN_12
887 * @arg @ref LL_GPIO_PIN_13
888 * @arg @ref LL_GPIO_PIN_14
889 * @arg @ref LL_GPIO_PIN_15
890 * @arg @ref LL_GPIO_PIN_ALL
891 * @retval None
892 */
LL_GPIO_SetOutputPin(GPIO_TypeDef * GPIOx,uint32_t PinMask)893 __STATIC_INLINE void LL_GPIO_SetOutputPin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
894 {
895 WRITE_REG(GPIOx->BSRR, PinMask);
896 }
897
898 /**
899 * @brief Set several pins to low level on dedicated gpio port.
900 * @rmtoll BRR BRy LL_GPIO_ResetOutputPin
901 * @param GPIOx GPIO Port
902 * @param PinMask This parameter can be a combination of the following values:
903 * @arg @ref LL_GPIO_PIN_0
904 * @arg @ref LL_GPIO_PIN_1
905 * @arg @ref LL_GPIO_PIN_2
906 * @arg @ref LL_GPIO_PIN_3
907 * @arg @ref LL_GPIO_PIN_4
908 * @arg @ref LL_GPIO_PIN_5
909 * @arg @ref LL_GPIO_PIN_6
910 * @arg @ref LL_GPIO_PIN_7
911 * @arg @ref LL_GPIO_PIN_8
912 * @arg @ref LL_GPIO_PIN_9
913 * @arg @ref LL_GPIO_PIN_10
914 * @arg @ref LL_GPIO_PIN_11
915 * @arg @ref LL_GPIO_PIN_12
916 * @arg @ref LL_GPIO_PIN_13
917 * @arg @ref LL_GPIO_PIN_14
918 * @arg @ref LL_GPIO_PIN_15
919 * @arg @ref LL_GPIO_PIN_ALL
920 * @retval None
921 */
LL_GPIO_ResetOutputPin(GPIO_TypeDef * GPIOx,uint32_t PinMask)922 __STATIC_INLINE void LL_GPIO_ResetOutputPin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
923 {
924 WRITE_REG(GPIOx->BRR, PinMask);
925 }
926
927 /**
928 * @brief Toggle data value for several pin of dedicated port.
929 * @rmtoll ODR ODy LL_GPIO_TogglePin
930 * @param GPIOx GPIO Port
931 * @param PinMask This parameter can be a combination of the following values:
932 * @arg @ref LL_GPIO_PIN_0
933 * @arg @ref LL_GPIO_PIN_1
934 * @arg @ref LL_GPIO_PIN_2
935 * @arg @ref LL_GPIO_PIN_3
936 * @arg @ref LL_GPIO_PIN_4
937 * @arg @ref LL_GPIO_PIN_5
938 * @arg @ref LL_GPIO_PIN_6
939 * @arg @ref LL_GPIO_PIN_7
940 * @arg @ref LL_GPIO_PIN_8
941 * @arg @ref LL_GPIO_PIN_9
942 * @arg @ref LL_GPIO_PIN_10
943 * @arg @ref LL_GPIO_PIN_11
944 * @arg @ref LL_GPIO_PIN_12
945 * @arg @ref LL_GPIO_PIN_13
946 * @arg @ref LL_GPIO_PIN_14
947 * @arg @ref LL_GPIO_PIN_15
948 * @arg @ref LL_GPIO_PIN_ALL
949 * @retval None
950 */
LL_GPIO_TogglePin(GPIO_TypeDef * GPIOx,uint32_t PinMask)951 __STATIC_INLINE void LL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
952 {
953 uint32_t odr = READ_REG(GPIOx->ODR);
954 WRITE_REG(GPIOx->BSRR, ((odr & PinMask) << 16u) | (~odr & PinMask));
955 }
956
957 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
958
959 /**
960 * @brief Enable secure write only access for several pin of dedicated port.
961 * @rmtoll SECCFGR SECy LL_GPIO_EnablePinSecure
962 * @param GPIOx GPIO Port
963 * @param PinMask This parameter can be a combination of the following values:
964 * @arg @ref LL_GPIO_PIN_0
965 * @arg @ref LL_GPIO_PIN_1
966 * @arg @ref LL_GPIO_PIN_2
967 * @arg @ref LL_GPIO_PIN_3
968 * @arg @ref LL_GPIO_PIN_4
969 * @arg @ref LL_GPIO_PIN_5
970 * @arg @ref LL_GPIO_PIN_6
971 * @arg @ref LL_GPIO_PIN_7
972 * @arg @ref LL_GPIO_PIN_8
973 * @arg @ref LL_GPIO_PIN_9
974 * @arg @ref LL_GPIO_PIN_10
975 * @arg @ref LL_GPIO_PIN_11
976 * @arg @ref LL_GPIO_PIN_12
977 * @arg @ref LL_GPIO_PIN_13
978 * @arg @ref LL_GPIO_PIN_14
979 * @arg @ref LL_GPIO_PIN_15
980 * @arg @ref LL_GPIO_PIN_ALL
981 * @retval None
982 */
LL_GPIO_EnablePinSecure(GPIO_TypeDef * GPIOx,uint32_t PinMask)983 __STATIC_INLINE void LL_GPIO_EnablePinSecure(GPIO_TypeDef *GPIOx, uint32_t PinMask)
984 {
985 SET_BIT(GPIOx->SECCFGR, PinMask);
986 }
987
988
989 /**
990 * @brief Disable secure write only access for several pin of dedicated port.
991 * @rmtoll SECCFGR SECy LL_GPIO_DisablePinSecure
992 * @param GPIOx GPIO Port
993 * @param PinMask This parameter can be a combination of the following values:
994 * @arg @ref LL_GPIO_PIN_0
995 * @arg @ref LL_GPIO_PIN_1
996 * @arg @ref LL_GPIO_PIN_2
997 * @arg @ref LL_GPIO_PIN_3
998 * @arg @ref LL_GPIO_PIN_4
999 * @arg @ref LL_GPIO_PIN_5
1000 * @arg @ref LL_GPIO_PIN_6
1001 * @arg @ref LL_GPIO_PIN_7
1002 * @arg @ref LL_GPIO_PIN_8
1003 * @arg @ref LL_GPIO_PIN_9
1004 * @arg @ref LL_GPIO_PIN_10
1005 * @arg @ref LL_GPIO_PIN_11
1006 * @arg @ref LL_GPIO_PIN_12
1007 * @arg @ref LL_GPIO_PIN_13
1008 * @arg @ref LL_GPIO_PIN_14
1009 * @arg @ref LL_GPIO_PIN_15
1010 * @arg @ref LL_GPIO_PIN_ALL
1011 * @retval None
1012 */
LL_GPIO_DisablePinSecure(GPIO_TypeDef * GPIOx,uint32_t PinMask)1013 __STATIC_INLINE void LL_GPIO_DisablePinSecure(GPIO_TypeDef *GPIOx, uint32_t PinMask)
1014 {
1015 CLEAR_BIT(GPIOx->SECCFGR, PinMask);
1016 }
1017
1018
1019 /**
1020 * @brief Return if secure write only access for several pin of dedicated port is enabled or not.
1021 * @rmtoll SECCFGR SECy LL_GPIO_IsEnabledPinSecure
1022 * @param GPIOx GPIO Port
1023 * @param PinMask This parameter can be a combination of the following values:
1024 * @arg @ref LL_GPIO_PIN_0
1025 * @arg @ref LL_GPIO_PIN_1
1026 * @arg @ref LL_GPIO_PIN_2
1027 * @arg @ref LL_GPIO_PIN_3
1028 * @arg @ref LL_GPIO_PIN_4
1029 * @arg @ref LL_GPIO_PIN_5
1030 * @arg @ref LL_GPIO_PIN_6
1031 * @arg @ref LL_GPIO_PIN_7
1032 * @arg @ref LL_GPIO_PIN_8
1033 * @arg @ref LL_GPIO_PIN_9
1034 * @arg @ref LL_GPIO_PIN_10
1035 * @arg @ref LL_GPIO_PIN_11
1036 * @arg @ref LL_GPIO_PIN_12
1037 * @arg @ref LL_GPIO_PIN_13
1038 * @arg @ref LL_GPIO_PIN_14
1039 * @arg @ref LL_GPIO_PIN_15
1040 * @arg @ref LL_GPIO_PIN_ALL
1041 * @retval State of bit (1 or 0).
1042 */
LL_GPIO_IsEnabledPinSecure(const GPIO_TypeDef * GPIOx,uint32_t PinMask)1043 __STATIC_INLINE uint32_t LL_GPIO_IsEnabledPinSecure(const GPIO_TypeDef *GPIOx, uint32_t PinMask)
1044 {
1045 return ((READ_BIT(GPIOx->SECCFGR, PinMask) == (PinMask)) ? 1UL : 0UL);
1046 }
1047
1048 #endif /* __ARM_FEATURE_CMSE */
1049
1050 /**
1051 * @}
1052 */
1053
1054 #if defined(USE_FULL_LL_DRIVER)
1055 /** @defgroup GPIO_LL_EF_Init Initialization and de-initialization functions
1056 * @{
1057 */
1058
1059 ErrorStatus LL_GPIO_DeInit(const GPIO_TypeDef *GPIOx);
1060 ErrorStatus LL_GPIO_Init(GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct);
1061 void LL_GPIO_StructInit(LL_GPIO_InitTypeDef *GPIO_InitStruct);
1062
1063 /**
1064 * @}
1065 */
1066 #endif /* USE_FULL_LL_DRIVER */
1067
1068 /**
1069 * @}
1070 */
1071
1072 /**
1073 * @}
1074 */
1075
1076 #endif /* defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOH) */
1077 /**
1078 * @}
1079 */
1080
1081 #ifdef __cplusplus
1082 }
1083 #endif
1084
1085 #endif /* STM32WBAxx_LL_GPIO_H */
1086