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