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