STM32L486xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_ll_gpio.h 00004 * @author MCD Application Team 00005 * @brief Header file of GPIO LL module. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> 00010 * 00011 * Redistribution and use in source and binary forms, with or without modification, 00012 * are permitted provided that the following conditions are met: 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00019 * may be used to endorse or promote products derived from this software 00020 * without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00023 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00024 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00025 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00026 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00027 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00028 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00030 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00031 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00032 * 00033 ****************************************************************************** 00034 */ 00035 00036 /* Define to prevent recursive inclusion -------------------------------------*/ 00037 #ifndef __STM32L4xx_LL_GPIO_H 00038 #define __STM32L4xx_LL_GPIO_H 00039 00040 #ifdef __cplusplus 00041 extern "C" { 00042 #endif 00043 00044 /* Includes ------------------------------------------------------------------*/ 00045 #include "stm32l4xx.h" 00046 00047 /** @addtogroup STM32L4xx_LL_Driver 00048 * @{ 00049 */ 00050 00051 #if defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOF) || defined (GPIOG) || defined (GPIOH) || defined (GPIOI) 00052 00053 /** @defgroup GPIO_LL GPIO 00054 * @{ 00055 */ 00056 00057 /* Private types -------------------------------------------------------------*/ 00058 /* Private variables ---------------------------------------------------------*/ 00059 /* Private constants ---------------------------------------------------------*/ 00060 /* Private macros ------------------------------------------------------------*/ 00061 #if defined(USE_FULL_LL_DRIVER) 00062 /** @defgroup GPIO_LL_Private_Macros GPIO Private Macros 00063 * @{ 00064 */ 00065 00066 /** 00067 * @} 00068 */ 00069 #endif /*USE_FULL_LL_DRIVER*/ 00070 00071 /* Exported types ------------------------------------------------------------*/ 00072 #if defined(USE_FULL_LL_DRIVER) 00073 /** @defgroup GPIO_LL_ES_INIT GPIO Exported Init structures 00074 * @{ 00075 */ 00076 00077 /** 00078 * @brief LL GPIO Init Structure definition 00079 */ 00080 typedef struct 00081 { 00082 uint32_t Pin; /*!< Specifies the GPIO pins to be configured. 00083 This parameter can be any value of @ref GPIO_LL_EC_PIN */ 00084 00085 uint32_t Mode; /*!< Specifies the operating mode for the selected pins. 00086 This parameter can be a value of @ref GPIO_LL_EC_MODE. 00087 00088 GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinMode().*/ 00089 00090 uint32_t Speed; /*!< Specifies the speed for the selected pins. 00091 This parameter can be a value of @ref GPIO_LL_EC_SPEED. 00092 00093 GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinSpeed().*/ 00094 00095 uint32_t OutputType; /*!< Specifies the operating output type for the selected pins. 00096 This parameter can be a value of @ref GPIO_LL_EC_OUTPUT. 00097 00098 GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinOutputType().*/ 00099 00100 uint32_t Pull; /*!< Specifies the operating Pull-up/Pull down for the selected pins. 00101 This parameter can be a value of @ref GPIO_LL_EC_PULL. 00102 00103 GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinPull().*/ 00104 00105 uint32_t Alternate; /*!< Specifies the Peripheral to be connected to the selected pins. 00106 This parameter can be a value of @ref GPIO_LL_EC_AF. 00107 00108 GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetAFPin_0_7() and LL_GPIO_SetAFPin_8_15().*/ 00109 } LL_GPIO_InitTypeDef; 00110 00111 /** 00112 * @} 00113 */ 00114 #endif /* USE_FULL_LL_DRIVER */ 00115 00116 /* Exported constants --------------------------------------------------------*/ 00117 /** @defgroup GPIO_LL_Exported_Constants GPIO Exported Constants 00118 * @{ 00119 */ 00120 00121 /** @defgroup GPIO_LL_EC_PIN PIN 00122 * @{ 00123 */ 00124 #define LL_GPIO_PIN_0 GPIO_BSRR_BS0 /*!< Select pin 0 */ 00125 #define LL_GPIO_PIN_1 GPIO_BSRR_BS1 /*!< Select pin 1 */ 00126 #define LL_GPIO_PIN_2 GPIO_BSRR_BS2 /*!< Select pin 2 */ 00127 #define LL_GPIO_PIN_3 GPIO_BSRR_BS3 /*!< Select pin 3 */ 00128 #define LL_GPIO_PIN_4 GPIO_BSRR_BS4 /*!< Select pin 4 */ 00129 #define LL_GPIO_PIN_5 GPIO_BSRR_BS5 /*!< Select pin 5 */ 00130 #define LL_GPIO_PIN_6 GPIO_BSRR_BS6 /*!< Select pin 6 */ 00131 #define LL_GPIO_PIN_7 GPIO_BSRR_BS7 /*!< Select pin 7 */ 00132 #define LL_GPIO_PIN_8 GPIO_BSRR_BS8 /*!< Select pin 8 */ 00133 #define LL_GPIO_PIN_9 GPIO_BSRR_BS9 /*!< Select pin 9 */ 00134 #define LL_GPIO_PIN_10 GPIO_BSRR_BS10 /*!< Select pin 10 */ 00135 #define LL_GPIO_PIN_11 GPIO_BSRR_BS11 /*!< Select pin 11 */ 00136 #define LL_GPIO_PIN_12 GPIO_BSRR_BS12 /*!< Select pin 12 */ 00137 #define LL_GPIO_PIN_13 GPIO_BSRR_BS13 /*!< Select pin 13 */ 00138 #define LL_GPIO_PIN_14 GPIO_BSRR_BS14 /*!< Select pin 14 */ 00139 #define LL_GPIO_PIN_15 GPIO_BSRR_BS15 /*!< Select pin 15 */ 00140 #define LL_GPIO_PIN_ALL (GPIO_BSRR_BS0 | GPIO_BSRR_BS1 | GPIO_BSRR_BS2 | \ 00141 GPIO_BSRR_BS3 | GPIO_BSRR_BS4 | GPIO_BSRR_BS5 | \ 00142 GPIO_BSRR_BS6 | GPIO_BSRR_BS7 | GPIO_BSRR_BS8 | \ 00143 GPIO_BSRR_BS9 | GPIO_BSRR_BS10 | GPIO_BSRR_BS11 | \ 00144 GPIO_BSRR_BS12 | GPIO_BSRR_BS13 | GPIO_BSRR_BS14 | \ 00145 GPIO_BSRR_BS15) /*!< Select all pins */ 00146 /** 00147 * @} 00148 */ 00149 00150 /** @defgroup GPIO_LL_EC_MODE Mode 00151 * @{ 00152 */ 00153 #define LL_GPIO_MODE_INPUT (0x00000000U) /*!< Select input mode */ 00154 #define LL_GPIO_MODE_OUTPUT GPIO_MODER_MODE0_0 /*!< Select output mode */ 00155 #define LL_GPIO_MODE_ALTERNATE GPIO_MODER_MODE0_1 /*!< Select alternate function mode */ 00156 #define LL_GPIO_MODE_ANALOG GPIO_MODER_MODE0 /*!< Select analog mode */ 00157 /** 00158 * @} 00159 */ 00160 00161 /** @defgroup GPIO_LL_EC_OUTPUT Output Type 00162 * @{ 00163 */ 00164 #define LL_GPIO_OUTPUT_PUSHPULL (0x00000000U) /*!< Select push-pull as output type */ 00165 #define LL_GPIO_OUTPUT_OPENDRAIN GPIO_OTYPER_OT0 /*!< Select open-drain as output type */ 00166 /** 00167 * @} 00168 */ 00169 00170 /** @defgroup GPIO_LL_EC_SPEED Output Speed 00171 * @{ 00172 */ 00173 #define LL_GPIO_SPEED_FREQ_LOW (0x00000000U) /*!< Select I/O low output speed */ 00174 #define LL_GPIO_SPEED_FREQ_MEDIUM GPIO_OSPEEDR_OSPEED0_0 /*!< Select I/O medium output speed */ 00175 #define LL_GPIO_SPEED_FREQ_HIGH GPIO_OSPEEDR_OSPEED0_1 /*!< Select I/O fast output speed */ 00176 #define LL_GPIO_SPEED_FREQ_VERY_HIGH GPIO_OSPEEDR_OSPEED0 /*!< Select I/O high output speed */ 00177 /** 00178 * @} 00179 */ 00180 #define LL_GPIO_SPEED_LOW LL_GPIO_SPEED_FREQ_LOW 00181 #define LL_GPIO_SPEED_MEDIUM LL_GPIO_SPEED_FREQ_MEDIUM 00182 #define LL_GPIO_SPEED_FAST LL_GPIO_SPEED_FREQ_HIGH 00183 #define LL_GPIO_SPEED_HIGH LL_GPIO_SPEED_FREQ_VERY_HIGH 00184 00185 /** @defgroup GPIO_LL_EC_PULL Pull Up Pull Down 00186 * @{ 00187 */ 00188 #define LL_GPIO_PULL_NO (0x00000000U) /*!< Select I/O no pull */ 00189 #define LL_GPIO_PULL_UP GPIO_PUPDR_PUPD0_0 /*!< Select I/O pull up */ 00190 #define LL_GPIO_PULL_DOWN GPIO_PUPDR_PUPD0_1 /*!< Select I/O pull down */ 00191 /** 00192 * @} 00193 */ 00194 00195 /** @defgroup GPIO_LL_EC_AF Alternate Function 00196 * @{ 00197 */ 00198 #define LL_GPIO_AF_0 (0x0000000U) /*!< Select alternate function 0 */ 00199 #define LL_GPIO_AF_1 (0x0000001U) /*!< Select alternate function 1 */ 00200 #define LL_GPIO_AF_2 (0x0000002U) /*!< Select alternate function 2 */ 00201 #define LL_GPIO_AF_3 (0x0000003U) /*!< Select alternate function 3 */ 00202 #define LL_GPIO_AF_4 (0x0000004U) /*!< Select alternate function 4 */ 00203 #define LL_GPIO_AF_5 (0x0000005U) /*!< Select alternate function 5 */ 00204 #define LL_GPIO_AF_6 (0x0000006U) /*!< Select alternate function 6 */ 00205 #define LL_GPIO_AF_7 (0x0000007U) /*!< Select alternate function 7 */ 00206 #define LL_GPIO_AF_8 (0x0000008U) /*!< Select alternate function 8 */ 00207 #define LL_GPIO_AF_9 (0x0000009U) /*!< Select alternate function 9 */ 00208 #define LL_GPIO_AF_10 (0x000000AU) /*!< Select alternate function 10 */ 00209 #define LL_GPIO_AF_11 (0x000000BU) /*!< Select alternate function 11 */ 00210 #define LL_GPIO_AF_12 (0x000000CU) /*!< Select alternate function 12 */ 00211 #define LL_GPIO_AF_13 (0x000000DU) /*!< Select alternate function 13 */ 00212 #define LL_GPIO_AF_14 (0x000000EU) /*!< Select alternate function 14 */ 00213 #define LL_GPIO_AF_15 (0x000000FU) /*!< Select alternate function 15 */ 00214 /** 00215 * @} 00216 */ 00217 00218 /** 00219 * @} 00220 */ 00221 00222 /* Exported macro ------------------------------------------------------------*/ 00223 /** @defgroup GPIO_LL_Exported_Macros GPIO Exported Macros 00224 * @{ 00225 */ 00226 00227 /** @defgroup GPIO_LL_EM_WRITE_READ Common Write and read registers Macros 00228 * @{ 00229 */ 00230 00231 /** 00232 * @brief Write a value in GPIO register 00233 * @param __INSTANCE__ GPIO Instance 00234 * @param __REG__ Register to be written 00235 * @param __VALUE__ Value to be written in the register 00236 * @retval None 00237 */ 00238 #define LL_GPIO_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) 00239 00240 /** 00241 * @brief Read a value in GPIO register 00242 * @param __INSTANCE__ GPIO Instance 00243 * @param __REG__ Register to be read 00244 * @retval Register value 00245 */ 00246 #define LL_GPIO_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) 00247 /** 00248 * @} 00249 */ 00250 00251 /** 00252 * @} 00253 */ 00254 00255 /* Exported functions --------------------------------------------------------*/ 00256 /** @defgroup GPIO_LL_Exported_Functions GPIO Exported Functions 00257 * @{ 00258 */ 00259 00260 /** @defgroup GPIO_LL_EF_Port_Configuration Port Configuration 00261 * @{ 00262 */ 00263 00264 /** 00265 * @brief Configure gpio mode for a dedicated pin on dedicated port. 00266 * @note I/O mode can be Input mode, General purpose output, Alternate function mode or Analog. 00267 * @note Warning: only one pin can be passed as parameter. 00268 * @rmtoll MODER MODEy LL_GPIO_SetPinMode 00269 * @param GPIOx GPIO Port 00270 * @param Pin This parameter can be one of the following values: 00271 * @arg @ref LL_GPIO_PIN_0 00272 * @arg @ref LL_GPIO_PIN_1 00273 * @arg @ref LL_GPIO_PIN_2 00274 * @arg @ref LL_GPIO_PIN_3 00275 * @arg @ref LL_GPIO_PIN_4 00276 * @arg @ref LL_GPIO_PIN_5 00277 * @arg @ref LL_GPIO_PIN_6 00278 * @arg @ref LL_GPIO_PIN_7 00279 * @arg @ref LL_GPIO_PIN_8 00280 * @arg @ref LL_GPIO_PIN_9 00281 * @arg @ref LL_GPIO_PIN_10 00282 * @arg @ref LL_GPIO_PIN_11 00283 * @arg @ref LL_GPIO_PIN_12 00284 * @arg @ref LL_GPIO_PIN_13 00285 * @arg @ref LL_GPIO_PIN_14 00286 * @arg @ref LL_GPIO_PIN_15 00287 * @param Mode This parameter can be one of the following values: 00288 * @arg @ref LL_GPIO_MODE_INPUT 00289 * @arg @ref LL_GPIO_MODE_OUTPUT 00290 * @arg @ref LL_GPIO_MODE_ALTERNATE 00291 * @arg @ref LL_GPIO_MODE_ANALOG 00292 * @retval None 00293 */ 00294 __STATIC_INLINE void LL_GPIO_SetPinMode(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Mode) 00295 { 00296 MODIFY_REG(GPIOx->MODER, (GPIO_MODER_MODE0 << (POSITION_VAL(Pin) * 2U)), (Mode << (POSITION_VAL(Pin) * 2U))); 00297 } 00298 00299 /** 00300 * @brief Return gpio mode for a dedicated pin on dedicated port. 00301 * @note I/O mode can be Input mode, General purpose output, Alternate function mode or Analog. 00302 * @note Warning: only one pin can be passed as parameter. 00303 * @rmtoll MODER MODEy LL_GPIO_GetPinMode 00304 * @param GPIOx GPIO Port 00305 * @param Pin This parameter can be one of the following values: 00306 * @arg @ref LL_GPIO_PIN_0 00307 * @arg @ref LL_GPIO_PIN_1 00308 * @arg @ref LL_GPIO_PIN_2 00309 * @arg @ref LL_GPIO_PIN_3 00310 * @arg @ref LL_GPIO_PIN_4 00311 * @arg @ref LL_GPIO_PIN_5 00312 * @arg @ref LL_GPIO_PIN_6 00313 * @arg @ref LL_GPIO_PIN_7 00314 * @arg @ref LL_GPIO_PIN_8 00315 * @arg @ref LL_GPIO_PIN_9 00316 * @arg @ref LL_GPIO_PIN_10 00317 * @arg @ref LL_GPIO_PIN_11 00318 * @arg @ref LL_GPIO_PIN_12 00319 * @arg @ref LL_GPIO_PIN_13 00320 * @arg @ref LL_GPIO_PIN_14 00321 * @arg @ref LL_GPIO_PIN_15 00322 * @retval Returned value can be one of the following values: 00323 * @arg @ref LL_GPIO_MODE_INPUT 00324 * @arg @ref LL_GPIO_MODE_OUTPUT 00325 * @arg @ref LL_GPIO_MODE_ALTERNATE 00326 * @arg @ref LL_GPIO_MODE_ANALOG 00327 */ 00328 __STATIC_INLINE uint32_t LL_GPIO_GetPinMode(GPIO_TypeDef *GPIOx, uint32_t Pin) 00329 { 00330 return (uint32_t)(READ_BIT(GPIOx->MODER, 00331 (GPIO_MODER_MODE0 << (POSITION_VAL(Pin) * 2U))) >> (POSITION_VAL(Pin) * 2U)); 00332 } 00333 00334 /** 00335 * @brief Configure gpio output type for several pins on dedicated port. 00336 * @note Output type as to be set when gpio pin is in output or 00337 * alternate modes. Possible type are Push-pull or Open-drain. 00338 * @rmtoll OTYPER OTy LL_GPIO_SetPinOutputType 00339 * @param GPIOx GPIO Port 00340 * @param PinMask This parameter can be a combination of the following values: 00341 * @arg @ref LL_GPIO_PIN_0 00342 * @arg @ref LL_GPIO_PIN_1 00343 * @arg @ref LL_GPIO_PIN_2 00344 * @arg @ref LL_GPIO_PIN_3 00345 * @arg @ref LL_GPIO_PIN_4 00346 * @arg @ref LL_GPIO_PIN_5 00347 * @arg @ref LL_GPIO_PIN_6 00348 * @arg @ref LL_GPIO_PIN_7 00349 * @arg @ref LL_GPIO_PIN_8 00350 * @arg @ref LL_GPIO_PIN_9 00351 * @arg @ref LL_GPIO_PIN_10 00352 * @arg @ref LL_GPIO_PIN_11 00353 * @arg @ref LL_GPIO_PIN_12 00354 * @arg @ref LL_GPIO_PIN_13 00355 * @arg @ref LL_GPIO_PIN_14 00356 * @arg @ref LL_GPIO_PIN_15 00357 * @arg @ref LL_GPIO_PIN_ALL 00358 * @param OutputType This parameter can be one of the following values: 00359 * @arg @ref LL_GPIO_OUTPUT_PUSHPULL 00360 * @arg @ref LL_GPIO_OUTPUT_OPENDRAIN 00361 * @retval None 00362 */ 00363 __STATIC_INLINE void LL_GPIO_SetPinOutputType(GPIO_TypeDef *GPIOx, uint32_t PinMask, uint32_t OutputType) 00364 { 00365 MODIFY_REG(GPIOx->OTYPER, PinMask, (PinMask * OutputType)); 00366 } 00367 00368 /** 00369 * @brief Return gpio output type for several pins on dedicated port. 00370 * @note Output type as to be set when gpio pin is in output or 00371 * alternate modes. Possible type are Push-pull or Open-drain. 00372 * @note Warning: only one pin can be passed as parameter. 00373 * @rmtoll OTYPER OTy LL_GPIO_GetPinOutputType 00374 * @param GPIOx GPIO Port 00375 * @param Pin This parameter can be one of the following values: 00376 * @arg @ref LL_GPIO_PIN_0 00377 * @arg @ref LL_GPIO_PIN_1 00378 * @arg @ref LL_GPIO_PIN_2 00379 * @arg @ref LL_GPIO_PIN_3 00380 * @arg @ref LL_GPIO_PIN_4 00381 * @arg @ref LL_GPIO_PIN_5 00382 * @arg @ref LL_GPIO_PIN_6 00383 * @arg @ref LL_GPIO_PIN_7 00384 * @arg @ref LL_GPIO_PIN_8 00385 * @arg @ref LL_GPIO_PIN_9 00386 * @arg @ref LL_GPIO_PIN_10 00387 * @arg @ref LL_GPIO_PIN_11 00388 * @arg @ref LL_GPIO_PIN_12 00389 * @arg @ref LL_GPIO_PIN_13 00390 * @arg @ref LL_GPIO_PIN_14 00391 * @arg @ref LL_GPIO_PIN_15 00392 * @arg @ref LL_GPIO_PIN_ALL 00393 * @retval Returned value can be one of the following values: 00394 * @arg @ref LL_GPIO_OUTPUT_PUSHPULL 00395 * @arg @ref LL_GPIO_OUTPUT_OPENDRAIN 00396 */ 00397 __STATIC_INLINE uint32_t LL_GPIO_GetPinOutputType(GPIO_TypeDef *GPIOx, uint32_t Pin) 00398 { 00399 return (uint32_t)(READ_BIT(GPIOx->OTYPER, Pin) >> POSITION_VAL(Pin)); 00400 } 00401 00402 /** 00403 * @brief Configure gpio speed for a dedicated pin on dedicated port. 00404 * @note I/O speed can be Low, Medium, Fast or High speed. 00405 * @note Warning: only one pin can be passed as parameter. 00406 * @note Refer to datasheet for frequency specifications and the power 00407 * supply and load conditions for each speed. 00408 * @rmtoll OSPEEDR OSPEEDy LL_GPIO_SetPinSpeed 00409 * @param GPIOx GPIO Port 00410 * @param Pin This parameter can be one of the following values: 00411 * @arg @ref LL_GPIO_PIN_0 00412 * @arg @ref LL_GPIO_PIN_1 00413 * @arg @ref LL_GPIO_PIN_2 00414 * @arg @ref LL_GPIO_PIN_3 00415 * @arg @ref LL_GPIO_PIN_4 00416 * @arg @ref LL_GPIO_PIN_5 00417 * @arg @ref LL_GPIO_PIN_6 00418 * @arg @ref LL_GPIO_PIN_7 00419 * @arg @ref LL_GPIO_PIN_8 00420 * @arg @ref LL_GPIO_PIN_9 00421 * @arg @ref LL_GPIO_PIN_10 00422 * @arg @ref LL_GPIO_PIN_11 00423 * @arg @ref LL_GPIO_PIN_12 00424 * @arg @ref LL_GPIO_PIN_13 00425 * @arg @ref LL_GPIO_PIN_14 00426 * @arg @ref LL_GPIO_PIN_15 00427 * @param Speed This parameter can be one of the following values: 00428 * @arg @ref LL_GPIO_SPEED_FREQ_LOW 00429 * @arg @ref LL_GPIO_SPEED_FREQ_MEDIUM 00430 * @arg @ref LL_GPIO_SPEED_FREQ_HIGH 00431 * @arg @ref LL_GPIO_SPEED_FREQ_VERY_HIGH 00432 * @retval None 00433 */ 00434 __STATIC_INLINE void LL_GPIO_SetPinSpeed(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Speed) 00435 { 00436 MODIFY_REG(GPIOx->OSPEEDR, (GPIO_OSPEEDR_OSPEED0 << (POSITION_VAL(Pin) * 2U)), 00437 (Speed << (POSITION_VAL(Pin) * 2U))); 00438 } 00439 00440 /** 00441 * @brief Return gpio speed for a dedicated pin on dedicated port. 00442 * @note I/O speed can be Low, Medium, Fast or High speed. 00443 * @note Warning: only one pin can be passed as parameter. 00444 * @note Refer to datasheet for frequency specifications and the power 00445 * supply and load conditions for each speed. 00446 * @rmtoll OSPEEDR OSPEEDy LL_GPIO_GetPinSpeed 00447 * @param GPIOx GPIO Port 00448 * @param Pin This parameter can be one of the following values: 00449 * @arg @ref LL_GPIO_PIN_0 00450 * @arg @ref LL_GPIO_PIN_1 00451 * @arg @ref LL_GPIO_PIN_2 00452 * @arg @ref LL_GPIO_PIN_3 00453 * @arg @ref LL_GPIO_PIN_4 00454 * @arg @ref LL_GPIO_PIN_5 00455 * @arg @ref LL_GPIO_PIN_6 00456 * @arg @ref LL_GPIO_PIN_7 00457 * @arg @ref LL_GPIO_PIN_8 00458 * @arg @ref LL_GPIO_PIN_9 00459 * @arg @ref LL_GPIO_PIN_10 00460 * @arg @ref LL_GPIO_PIN_11 00461 * @arg @ref LL_GPIO_PIN_12 00462 * @arg @ref LL_GPIO_PIN_13 00463 * @arg @ref LL_GPIO_PIN_14 00464 * @arg @ref LL_GPIO_PIN_15 00465 * @retval Returned value can be one of the following values: 00466 * @arg @ref LL_GPIO_SPEED_FREQ_LOW 00467 * @arg @ref LL_GPIO_SPEED_FREQ_MEDIUM 00468 * @arg @ref LL_GPIO_SPEED_FREQ_HIGH 00469 * @arg @ref LL_GPIO_SPEED_FREQ_VERY_HIGH 00470 */ 00471 __STATIC_INLINE uint32_t LL_GPIO_GetPinSpeed(GPIO_TypeDef *GPIOx, uint32_t Pin) 00472 { 00473 return (uint32_t)(READ_BIT(GPIOx->OSPEEDR, 00474 (GPIO_OSPEEDR_OSPEED0 << (POSITION_VAL(Pin) * 2U))) >> (POSITION_VAL(Pin) * 2U)); 00475 } 00476 00477 /** 00478 * @brief Configure gpio pull-up or pull-down for a dedicated pin on a dedicated port. 00479 * @note Warning: only one pin can be passed as parameter. 00480 * @rmtoll PUPDR PUPDy LL_GPIO_SetPinPull 00481 * @param GPIOx GPIO Port 00482 * @param Pin This parameter can be one of the following values: 00483 * @arg @ref LL_GPIO_PIN_0 00484 * @arg @ref LL_GPIO_PIN_1 00485 * @arg @ref LL_GPIO_PIN_2 00486 * @arg @ref LL_GPIO_PIN_3 00487 * @arg @ref LL_GPIO_PIN_4 00488 * @arg @ref LL_GPIO_PIN_5 00489 * @arg @ref LL_GPIO_PIN_6 00490 * @arg @ref LL_GPIO_PIN_7 00491 * @arg @ref LL_GPIO_PIN_8 00492 * @arg @ref LL_GPIO_PIN_9 00493 * @arg @ref LL_GPIO_PIN_10 00494 * @arg @ref LL_GPIO_PIN_11 00495 * @arg @ref LL_GPIO_PIN_12 00496 * @arg @ref LL_GPIO_PIN_13 00497 * @arg @ref LL_GPIO_PIN_14 00498 * @arg @ref LL_GPIO_PIN_15 00499 * @param Pull This parameter can be one of the following values: 00500 * @arg @ref LL_GPIO_PULL_NO 00501 * @arg @ref LL_GPIO_PULL_UP 00502 * @arg @ref LL_GPIO_PULL_DOWN 00503 * @retval None 00504 */ 00505 __STATIC_INLINE void LL_GPIO_SetPinPull(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Pull) 00506 { 00507 MODIFY_REG(GPIOx->PUPDR, (GPIO_PUPDR_PUPD0 << (POSITION_VAL(Pin) * 2U)), (Pull << (POSITION_VAL(Pin) * 2U))); 00508 } 00509 00510 /** 00511 * @brief Return gpio pull-up or pull-down for a dedicated pin on a dedicated port 00512 * @note Warning: only one pin can be passed as parameter. 00513 * @rmtoll PUPDR PUPDy LL_GPIO_GetPinPull 00514 * @param GPIOx GPIO Port 00515 * @param Pin This parameter can be one of the following values: 00516 * @arg @ref LL_GPIO_PIN_0 00517 * @arg @ref LL_GPIO_PIN_1 00518 * @arg @ref LL_GPIO_PIN_2 00519 * @arg @ref LL_GPIO_PIN_3 00520 * @arg @ref LL_GPIO_PIN_4 00521 * @arg @ref LL_GPIO_PIN_5 00522 * @arg @ref LL_GPIO_PIN_6 00523 * @arg @ref LL_GPIO_PIN_7 00524 * @arg @ref LL_GPIO_PIN_8 00525 * @arg @ref LL_GPIO_PIN_9 00526 * @arg @ref LL_GPIO_PIN_10 00527 * @arg @ref LL_GPIO_PIN_11 00528 * @arg @ref LL_GPIO_PIN_12 00529 * @arg @ref LL_GPIO_PIN_13 00530 * @arg @ref LL_GPIO_PIN_14 00531 * @arg @ref LL_GPIO_PIN_15 00532 * @retval Returned value can be one of the following values: 00533 * @arg @ref LL_GPIO_PULL_NO 00534 * @arg @ref LL_GPIO_PULL_UP 00535 * @arg @ref LL_GPIO_PULL_DOWN 00536 */ 00537 __STATIC_INLINE uint32_t LL_GPIO_GetPinPull(GPIO_TypeDef *GPIOx, uint32_t Pin) 00538 { 00539 return (uint32_t)(READ_BIT(GPIOx->PUPDR, 00540 (GPIO_PUPDR_PUPD0 << (POSITION_VAL(Pin) * 2U))) >> (POSITION_VAL(Pin) * 2U)); 00541 } 00542 00543 /** 00544 * @brief Configure gpio alternate function of a dedicated pin from 0 to 7 for a dedicated port. 00545 * @note Possible values are from AF0 to AF15 depending on target. 00546 * @note Warning: only one pin can be passed as parameter. 00547 * @rmtoll AFRL AFSELy LL_GPIO_SetAFPin_0_7 00548 * @param GPIOx GPIO Port 00549 * @param Pin This parameter can be one of the following values: 00550 * @arg @ref LL_GPIO_PIN_0 00551 * @arg @ref LL_GPIO_PIN_1 00552 * @arg @ref LL_GPIO_PIN_2 00553 * @arg @ref LL_GPIO_PIN_3 00554 * @arg @ref LL_GPIO_PIN_4 00555 * @arg @ref LL_GPIO_PIN_5 00556 * @arg @ref LL_GPIO_PIN_6 00557 * @arg @ref LL_GPIO_PIN_7 00558 * @param Alternate This parameter can be one of the following values: 00559 * @arg @ref LL_GPIO_AF_0 00560 * @arg @ref LL_GPIO_AF_1 00561 * @arg @ref LL_GPIO_AF_2 00562 * @arg @ref LL_GPIO_AF_3 00563 * @arg @ref LL_GPIO_AF_4 00564 * @arg @ref LL_GPIO_AF_5 00565 * @arg @ref LL_GPIO_AF_6 00566 * @arg @ref LL_GPIO_AF_7 00567 * @arg @ref LL_GPIO_AF_8 00568 * @arg @ref LL_GPIO_AF_9 00569 * @arg @ref LL_GPIO_AF_10 00570 * @arg @ref LL_GPIO_AF_11 00571 * @arg @ref LL_GPIO_AF_12 00572 * @arg @ref LL_GPIO_AF_13 00573 * @arg @ref LL_GPIO_AF_14 00574 * @arg @ref LL_GPIO_AF_15 00575 * @retval None 00576 */ 00577 __STATIC_INLINE void LL_GPIO_SetAFPin_0_7(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Alternate) 00578 { 00579 MODIFY_REG(GPIOx->AFR[0], (GPIO_AFRL_AFSEL0 << (POSITION_VAL(Pin) * 4U)), 00580 (Alternate << (POSITION_VAL(Pin) * 4U))); 00581 } 00582 00583 /** 00584 * @brief Return gpio alternate function of a dedicated pin from 0 to 7 for a dedicated port. 00585 * @rmtoll AFRL AFSELy LL_GPIO_GetAFPin_0_7 00586 * @param GPIOx GPIO Port 00587 * @param Pin This parameter can be one of the following values: 00588 * @arg @ref LL_GPIO_PIN_0 00589 * @arg @ref LL_GPIO_PIN_1 00590 * @arg @ref LL_GPIO_PIN_2 00591 * @arg @ref LL_GPIO_PIN_3 00592 * @arg @ref LL_GPIO_PIN_4 00593 * @arg @ref LL_GPIO_PIN_5 00594 * @arg @ref LL_GPIO_PIN_6 00595 * @arg @ref LL_GPIO_PIN_7 00596 * @retval Returned value can be one of the following values: 00597 * @arg @ref LL_GPIO_AF_0 00598 * @arg @ref LL_GPIO_AF_1 00599 * @arg @ref LL_GPIO_AF_2 00600 * @arg @ref LL_GPIO_AF_3 00601 * @arg @ref LL_GPIO_AF_4 00602 * @arg @ref LL_GPIO_AF_5 00603 * @arg @ref LL_GPIO_AF_6 00604 * @arg @ref LL_GPIO_AF_7 00605 * @arg @ref LL_GPIO_AF_8 00606 * @arg @ref LL_GPIO_AF_9 00607 * @arg @ref LL_GPIO_AF_10 00608 * @arg @ref LL_GPIO_AF_11 00609 * @arg @ref LL_GPIO_AF_12 00610 * @arg @ref LL_GPIO_AF_13 00611 * @arg @ref LL_GPIO_AF_14 00612 * @arg @ref LL_GPIO_AF_15 00613 */ 00614 __STATIC_INLINE uint32_t LL_GPIO_GetAFPin_0_7(GPIO_TypeDef *GPIOx, uint32_t Pin) 00615 { 00616 return (uint32_t)(READ_BIT(GPIOx->AFR[0], 00617 (GPIO_AFRL_AFSEL0 << (POSITION_VAL(Pin) * 4U))) >> (POSITION_VAL(Pin) * 4U)); 00618 } 00619 00620 /** 00621 * @brief Configure gpio alternate function of a dedicated pin from 8 to 15 for a dedicated port. 00622 * @note Possible values are from AF0 to AF15 depending on target. 00623 * @note Warning: only one pin can be passed as parameter. 00624 * @rmtoll AFRH AFSELy LL_GPIO_SetAFPin_8_15 00625 * @param GPIOx GPIO Port 00626 * @param Pin This parameter can be one of the following values: 00627 * @arg @ref LL_GPIO_PIN_8 00628 * @arg @ref LL_GPIO_PIN_9 00629 * @arg @ref LL_GPIO_PIN_10 00630 * @arg @ref LL_GPIO_PIN_11 00631 * @arg @ref LL_GPIO_PIN_12 00632 * @arg @ref LL_GPIO_PIN_13 00633 * @arg @ref LL_GPIO_PIN_14 00634 * @arg @ref LL_GPIO_PIN_15 00635 * @param Alternate This parameter can be one of the following values: 00636 * @arg @ref LL_GPIO_AF_0 00637 * @arg @ref LL_GPIO_AF_1 00638 * @arg @ref LL_GPIO_AF_2 00639 * @arg @ref LL_GPIO_AF_3 00640 * @arg @ref LL_GPIO_AF_4 00641 * @arg @ref LL_GPIO_AF_5 00642 * @arg @ref LL_GPIO_AF_6 00643 * @arg @ref LL_GPIO_AF_7 00644 * @arg @ref LL_GPIO_AF_8 00645 * @arg @ref LL_GPIO_AF_9 00646 * @arg @ref LL_GPIO_AF_10 00647 * @arg @ref LL_GPIO_AF_11 00648 * @arg @ref LL_GPIO_AF_12 00649 * @arg @ref LL_GPIO_AF_13 00650 * @arg @ref LL_GPIO_AF_14 00651 * @arg @ref LL_GPIO_AF_15 00652 * @retval None 00653 */ 00654 __STATIC_INLINE void LL_GPIO_SetAFPin_8_15(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Alternate) 00655 { 00656 MODIFY_REG(GPIOx->AFR[1], (GPIO_AFRH_AFSEL8 << (POSITION_VAL(Pin >> 8U) * 4U)), 00657 (Alternate << (POSITION_VAL(Pin >> 8U) * 4U))); 00658 } 00659 00660 /** 00661 * @brief Return gpio alternate function of a dedicated pin from 8 to 15 for a dedicated port. 00662 * @note Possible values are from AF0 to AF15 depending on target. 00663 * @rmtoll AFRH AFSELy LL_GPIO_GetAFPin_8_15 00664 * @param GPIOx GPIO Port 00665 * @param Pin This parameter can be one of the following values: 00666 * @arg @ref LL_GPIO_PIN_8 00667 * @arg @ref LL_GPIO_PIN_9 00668 * @arg @ref LL_GPIO_PIN_10 00669 * @arg @ref LL_GPIO_PIN_11 00670 * @arg @ref LL_GPIO_PIN_12 00671 * @arg @ref LL_GPIO_PIN_13 00672 * @arg @ref LL_GPIO_PIN_14 00673 * @arg @ref LL_GPIO_PIN_15 00674 * @retval Returned value can be one of the following values: 00675 * @arg @ref LL_GPIO_AF_0 00676 * @arg @ref LL_GPIO_AF_1 00677 * @arg @ref LL_GPIO_AF_2 00678 * @arg @ref LL_GPIO_AF_3 00679 * @arg @ref LL_GPIO_AF_4 00680 * @arg @ref LL_GPIO_AF_5 00681 * @arg @ref LL_GPIO_AF_6 00682 * @arg @ref LL_GPIO_AF_7 00683 * @arg @ref LL_GPIO_AF_8 00684 * @arg @ref LL_GPIO_AF_9 00685 * @arg @ref LL_GPIO_AF_10 00686 * @arg @ref LL_GPIO_AF_11 00687 * @arg @ref LL_GPIO_AF_12 00688 * @arg @ref LL_GPIO_AF_13 00689 * @arg @ref LL_GPIO_AF_14 00690 * @arg @ref LL_GPIO_AF_15 00691 */ 00692 __STATIC_INLINE uint32_t LL_GPIO_GetAFPin_8_15(GPIO_TypeDef *GPIOx, uint32_t Pin) 00693 { 00694 return (uint32_t)(READ_BIT(GPIOx->AFR[1], 00695 (GPIO_AFRH_AFSEL8 << (POSITION_VAL(Pin >> 8U) * 4U))) >> (POSITION_VAL(Pin >> 8U) * 4U)); 00696 } 00697 00698 #if defined(GPIO_ASCR_ASC0) 00699 /** 00700 * @brief Connect analog switch to ADC input of several pins for a dedicated port. 00701 * @note This bit must be set prior to the ADC conversion. 00702 * Only the IO which connected to the ADC input are effective. 00703 * Other IO must be kept reset value 00704 * @rmtoll ASCR ASCy LL_GPIO_EnablePinAnalogControl 00705 * @param GPIOx GPIO Port 00706 * @param PinMask This parameter can be a combination of the following values: 00707 * @arg @ref LL_GPIO_PIN_0 00708 * @arg @ref LL_GPIO_PIN_1 00709 * @arg @ref LL_GPIO_PIN_2 00710 * @arg @ref LL_GPIO_PIN_3 00711 * @arg @ref LL_GPIO_PIN_4 00712 * @arg @ref LL_GPIO_PIN_5 00713 * @arg @ref LL_GPIO_PIN_6 00714 * @arg @ref LL_GPIO_PIN_7 00715 * @arg @ref LL_GPIO_PIN_8 00716 * @arg @ref LL_GPIO_PIN_9 00717 * @arg @ref LL_GPIO_PIN_10 00718 * @arg @ref LL_GPIO_PIN_11 00719 * @arg @ref LL_GPIO_PIN_12 00720 * @arg @ref LL_GPIO_PIN_13 00721 * @arg @ref LL_GPIO_PIN_14 00722 * @arg @ref LL_GPIO_PIN_15 00723 * @arg @ref LL_GPIO_PIN_ALL 00724 * @retval None 00725 */ 00726 __STATIC_INLINE void LL_GPIO_EnablePinAnalogControl(GPIO_TypeDef *GPIOx, uint32_t PinMask) 00727 { 00728 SET_BIT(GPIOx->ASCR, PinMask); 00729 } 00730 00731 /** 00732 * @brief Disconnect analog switch to ADC input of several pins for a dedicated port. 00733 * @rmtoll ASCR ASCy LL_GPIO_DisablePinAnalogControl 00734 * @param GPIOx GPIO Port 00735 * @param PinMask This parameter can be a combination of the following values: 00736 * @arg @ref LL_GPIO_PIN_0 00737 * @arg @ref LL_GPIO_PIN_1 00738 * @arg @ref LL_GPIO_PIN_2 00739 * @arg @ref LL_GPIO_PIN_3 00740 * @arg @ref LL_GPIO_PIN_4 00741 * @arg @ref LL_GPIO_PIN_5 00742 * @arg @ref LL_GPIO_PIN_6 00743 * @arg @ref LL_GPIO_PIN_7 00744 * @arg @ref LL_GPIO_PIN_8 00745 * @arg @ref LL_GPIO_PIN_9 00746 * @arg @ref LL_GPIO_PIN_10 00747 * @arg @ref LL_GPIO_PIN_11 00748 * @arg @ref LL_GPIO_PIN_12 00749 * @arg @ref LL_GPIO_PIN_13 00750 * @arg @ref LL_GPIO_PIN_14 00751 * @arg @ref LL_GPIO_PIN_15 00752 * @arg @ref LL_GPIO_PIN_ALL 00753 * @retval None 00754 */ 00755 __STATIC_INLINE void LL_GPIO_DisablePinAnalogControl(GPIO_TypeDef *GPIOx, uint32_t PinMask) 00756 { 00757 CLEAR_BIT(GPIOx->ASCR, PinMask); 00758 } 00759 #endif /* GPIO_ASCR_ASC0 */ 00760 00761 /** 00762 * @brief Lock configuration of several pins for a dedicated port. 00763 * @note When the lock sequence has been applied on a port bit, the 00764 * value of this port bit can no longer be modified until the 00765 * next reset. 00766 * @note Each lock bit freezes a specific configuration register 00767 * (control and alternate function registers). 00768 * @rmtoll LCKR LCKK LL_GPIO_LockPin 00769 * @param GPIOx GPIO Port 00770 * @param PinMask This parameter can be a combination of the following values: 00771 * @arg @ref LL_GPIO_PIN_0 00772 * @arg @ref LL_GPIO_PIN_1 00773 * @arg @ref LL_GPIO_PIN_2 00774 * @arg @ref LL_GPIO_PIN_3 00775 * @arg @ref LL_GPIO_PIN_4 00776 * @arg @ref LL_GPIO_PIN_5 00777 * @arg @ref LL_GPIO_PIN_6 00778 * @arg @ref LL_GPIO_PIN_7 00779 * @arg @ref LL_GPIO_PIN_8 00780 * @arg @ref LL_GPIO_PIN_9 00781 * @arg @ref LL_GPIO_PIN_10 00782 * @arg @ref LL_GPIO_PIN_11 00783 * @arg @ref LL_GPIO_PIN_12 00784 * @arg @ref LL_GPIO_PIN_13 00785 * @arg @ref LL_GPIO_PIN_14 00786 * @arg @ref LL_GPIO_PIN_15 00787 * @arg @ref LL_GPIO_PIN_ALL 00788 * @retval None 00789 */ 00790 __STATIC_INLINE void LL_GPIO_LockPin(GPIO_TypeDef *GPIOx, uint32_t PinMask) 00791 { 00792 __IO uint32_t temp; 00793 WRITE_REG(GPIOx->LCKR, GPIO_LCKR_LCKK | PinMask); 00794 WRITE_REG(GPIOx->LCKR, PinMask); 00795 WRITE_REG(GPIOx->LCKR, GPIO_LCKR_LCKK | PinMask); 00796 temp = READ_REG(GPIOx->LCKR); 00797 (void) temp; 00798 } 00799 00800 /** 00801 * @brief Return 1 if all pins passed as parameter, of a dedicated port, are locked. else Return 0. 00802 * @rmtoll LCKR LCKy LL_GPIO_IsPinLocked 00803 * @param GPIOx GPIO Port 00804 * @param PinMask This parameter can be a combination of the following values: 00805 * @arg @ref LL_GPIO_PIN_0 00806 * @arg @ref LL_GPIO_PIN_1 00807 * @arg @ref LL_GPIO_PIN_2 00808 * @arg @ref LL_GPIO_PIN_3 00809 * @arg @ref LL_GPIO_PIN_4 00810 * @arg @ref LL_GPIO_PIN_5 00811 * @arg @ref LL_GPIO_PIN_6 00812 * @arg @ref LL_GPIO_PIN_7 00813 * @arg @ref LL_GPIO_PIN_8 00814 * @arg @ref LL_GPIO_PIN_9 00815 * @arg @ref LL_GPIO_PIN_10 00816 * @arg @ref LL_GPIO_PIN_11 00817 * @arg @ref LL_GPIO_PIN_12 00818 * @arg @ref LL_GPIO_PIN_13 00819 * @arg @ref LL_GPIO_PIN_14 00820 * @arg @ref LL_GPIO_PIN_15 00821 * @arg @ref LL_GPIO_PIN_ALL 00822 * @retval State of bit (1 or 0). 00823 */ 00824 __STATIC_INLINE uint32_t LL_GPIO_IsPinLocked(GPIO_TypeDef *GPIOx, uint32_t PinMask) 00825 { 00826 return (READ_BIT(GPIOx->LCKR, PinMask) == (PinMask)); 00827 } 00828 00829 /** 00830 * @brief Return 1 if one of the pin of a dedicated port is locked. else return 0. 00831 * @rmtoll LCKR LCKK LL_GPIO_IsAnyPinLocked 00832 * @param GPIOx GPIO Port 00833 * @retval State of bit (1 or 0). 00834 */ 00835 __STATIC_INLINE uint32_t LL_GPIO_IsAnyPinLocked(GPIO_TypeDef *GPIOx) 00836 { 00837 return (READ_BIT(GPIOx->LCKR, GPIO_LCKR_LCKK) == (GPIO_LCKR_LCKK)); 00838 } 00839 00840 /** 00841 * @} 00842 */ 00843 00844 /** @defgroup GPIO_LL_EF_Data_Access Data Access 00845 * @{ 00846 */ 00847 00848 /** 00849 * @brief Return full input data register value for a dedicated port. 00850 * @rmtoll IDR IDy LL_GPIO_ReadInputPort 00851 * @param GPIOx GPIO Port 00852 * @retval Input data register value of port 00853 */ 00854 __STATIC_INLINE uint32_t LL_GPIO_ReadInputPort(GPIO_TypeDef *GPIOx) 00855 { 00856 return (uint32_t)(READ_REG(GPIOx->IDR)); 00857 } 00858 00859 /** 00860 * @brief Return if input data level for several pins of dedicated port is high or low. 00861 * @rmtoll IDR IDy LL_GPIO_IsInputPinSet 00862 * @param GPIOx GPIO Port 00863 * @param PinMask This parameter can be a combination of the following values: 00864 * @arg @ref LL_GPIO_PIN_0 00865 * @arg @ref LL_GPIO_PIN_1 00866 * @arg @ref LL_GPIO_PIN_2 00867 * @arg @ref LL_GPIO_PIN_3 00868 * @arg @ref LL_GPIO_PIN_4 00869 * @arg @ref LL_GPIO_PIN_5 00870 * @arg @ref LL_GPIO_PIN_6 00871 * @arg @ref LL_GPIO_PIN_7 00872 * @arg @ref LL_GPIO_PIN_8 00873 * @arg @ref LL_GPIO_PIN_9 00874 * @arg @ref LL_GPIO_PIN_10 00875 * @arg @ref LL_GPIO_PIN_11 00876 * @arg @ref LL_GPIO_PIN_12 00877 * @arg @ref LL_GPIO_PIN_13 00878 * @arg @ref LL_GPIO_PIN_14 00879 * @arg @ref LL_GPIO_PIN_15 00880 * @arg @ref LL_GPIO_PIN_ALL 00881 * @retval State of bit (1 or 0). 00882 */ 00883 __STATIC_INLINE uint32_t LL_GPIO_IsInputPinSet(GPIO_TypeDef *GPIOx, uint32_t PinMask) 00884 { 00885 return (READ_BIT(GPIOx->IDR, PinMask) == (PinMask)); 00886 } 00887 00888 /** 00889 * @brief Write output data register for the port. 00890 * @rmtoll ODR ODy LL_GPIO_WriteOutputPort 00891 * @param GPIOx GPIO Port 00892 * @param PortValue Level value for each pin of the port 00893 * @retval None 00894 */ 00895 __STATIC_INLINE void LL_GPIO_WriteOutputPort(GPIO_TypeDef *GPIOx, uint32_t PortValue) 00896 { 00897 WRITE_REG(GPIOx->ODR, PortValue); 00898 } 00899 00900 /** 00901 * @brief Return full output data register value for a dedicated port. 00902 * @rmtoll ODR ODy LL_GPIO_ReadOutputPort 00903 * @param GPIOx GPIO Port 00904 * @retval Output data register value of port 00905 */ 00906 __STATIC_INLINE uint32_t LL_GPIO_ReadOutputPort(GPIO_TypeDef *GPIOx) 00907 { 00908 return (uint32_t)(READ_REG(GPIOx->ODR)); 00909 } 00910 00911 /** 00912 * @brief Return if input data level for several pins of dedicated port is high or low. 00913 * @rmtoll ODR ODy LL_GPIO_IsOutputPinSet 00914 * @param GPIOx GPIO Port 00915 * @param PinMask This parameter can be a combination of the following values: 00916 * @arg @ref LL_GPIO_PIN_0 00917 * @arg @ref LL_GPIO_PIN_1 00918 * @arg @ref LL_GPIO_PIN_2 00919 * @arg @ref LL_GPIO_PIN_3 00920 * @arg @ref LL_GPIO_PIN_4 00921 * @arg @ref LL_GPIO_PIN_5 00922 * @arg @ref LL_GPIO_PIN_6 00923 * @arg @ref LL_GPIO_PIN_7 00924 * @arg @ref LL_GPIO_PIN_8 00925 * @arg @ref LL_GPIO_PIN_9 00926 * @arg @ref LL_GPIO_PIN_10 00927 * @arg @ref LL_GPIO_PIN_11 00928 * @arg @ref LL_GPIO_PIN_12 00929 * @arg @ref LL_GPIO_PIN_13 00930 * @arg @ref LL_GPIO_PIN_14 00931 * @arg @ref LL_GPIO_PIN_15 00932 * @arg @ref LL_GPIO_PIN_ALL 00933 * @retval State of bit (1 or 0). 00934 */ 00935 __STATIC_INLINE uint32_t LL_GPIO_IsOutputPinSet(GPIO_TypeDef *GPIOx, uint32_t PinMask) 00936 { 00937 return (READ_BIT(GPIOx->ODR, PinMask) == (PinMask)); 00938 } 00939 00940 /** 00941 * @brief Set several pins to high level on dedicated gpio port. 00942 * @rmtoll BSRR BSy LL_GPIO_SetOutputPin 00943 * @param GPIOx GPIO Port 00944 * @param PinMask This parameter can be a combination of the following values: 00945 * @arg @ref LL_GPIO_PIN_0 00946 * @arg @ref LL_GPIO_PIN_1 00947 * @arg @ref LL_GPIO_PIN_2 00948 * @arg @ref LL_GPIO_PIN_3 00949 * @arg @ref LL_GPIO_PIN_4 00950 * @arg @ref LL_GPIO_PIN_5 00951 * @arg @ref LL_GPIO_PIN_6 00952 * @arg @ref LL_GPIO_PIN_7 00953 * @arg @ref LL_GPIO_PIN_8 00954 * @arg @ref LL_GPIO_PIN_9 00955 * @arg @ref LL_GPIO_PIN_10 00956 * @arg @ref LL_GPIO_PIN_11 00957 * @arg @ref LL_GPIO_PIN_12 00958 * @arg @ref LL_GPIO_PIN_13 00959 * @arg @ref LL_GPIO_PIN_14 00960 * @arg @ref LL_GPIO_PIN_15 00961 * @arg @ref LL_GPIO_PIN_ALL 00962 * @retval None 00963 */ 00964 __STATIC_INLINE void LL_GPIO_SetOutputPin(GPIO_TypeDef *GPIOx, uint32_t PinMask) 00965 { 00966 WRITE_REG(GPIOx->BSRR, PinMask); 00967 } 00968 00969 /** 00970 * @brief Set several pins to low level on dedicated gpio port. 00971 * @rmtoll BRR BRy LL_GPIO_ResetOutputPin 00972 * @param GPIOx GPIO Port 00973 * @param PinMask This parameter can be a combination of the following values: 00974 * @arg @ref LL_GPIO_PIN_0 00975 * @arg @ref LL_GPIO_PIN_1 00976 * @arg @ref LL_GPIO_PIN_2 00977 * @arg @ref LL_GPIO_PIN_3 00978 * @arg @ref LL_GPIO_PIN_4 00979 * @arg @ref LL_GPIO_PIN_5 00980 * @arg @ref LL_GPIO_PIN_6 00981 * @arg @ref LL_GPIO_PIN_7 00982 * @arg @ref LL_GPIO_PIN_8 00983 * @arg @ref LL_GPIO_PIN_9 00984 * @arg @ref LL_GPIO_PIN_10 00985 * @arg @ref LL_GPIO_PIN_11 00986 * @arg @ref LL_GPIO_PIN_12 00987 * @arg @ref LL_GPIO_PIN_13 00988 * @arg @ref LL_GPIO_PIN_14 00989 * @arg @ref LL_GPIO_PIN_15 00990 * @arg @ref LL_GPIO_PIN_ALL 00991 * @retval None 00992 */ 00993 __STATIC_INLINE void LL_GPIO_ResetOutputPin(GPIO_TypeDef *GPIOx, uint32_t PinMask) 00994 { 00995 WRITE_REG(GPIOx->BRR, PinMask); 00996 } 00997 00998 /** 00999 * @brief Toggle data value for several pin of dedicated port. 01000 * @rmtoll ODR ODy LL_GPIO_TogglePin 01001 * @param GPIOx GPIO Port 01002 * @param PinMask This parameter can be a combination of the following values: 01003 * @arg @ref LL_GPIO_PIN_0 01004 * @arg @ref LL_GPIO_PIN_1 01005 * @arg @ref LL_GPIO_PIN_2 01006 * @arg @ref LL_GPIO_PIN_3 01007 * @arg @ref LL_GPIO_PIN_4 01008 * @arg @ref LL_GPIO_PIN_5 01009 * @arg @ref LL_GPIO_PIN_6 01010 * @arg @ref LL_GPIO_PIN_7 01011 * @arg @ref LL_GPIO_PIN_8 01012 * @arg @ref LL_GPIO_PIN_9 01013 * @arg @ref LL_GPIO_PIN_10 01014 * @arg @ref LL_GPIO_PIN_11 01015 * @arg @ref LL_GPIO_PIN_12 01016 * @arg @ref LL_GPIO_PIN_13 01017 * @arg @ref LL_GPIO_PIN_14 01018 * @arg @ref LL_GPIO_PIN_15 01019 * @arg @ref LL_GPIO_PIN_ALL 01020 * @retval None 01021 */ 01022 __STATIC_INLINE void LL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint32_t PinMask) 01023 { 01024 WRITE_REG(GPIOx->ODR, READ_REG(GPIOx->ODR) ^ PinMask); 01025 } 01026 01027 /** 01028 * @} 01029 */ 01030 01031 #if defined(USE_FULL_LL_DRIVER) 01032 /** @defgroup GPIO_LL_EF_Init Initialization and de-initialization functions 01033 * @{ 01034 */ 01035 01036 ErrorStatus LL_GPIO_DeInit(GPIO_TypeDef *GPIOx); 01037 ErrorStatus LL_GPIO_Init(GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct); 01038 void LL_GPIO_StructInit(LL_GPIO_InitTypeDef *GPIO_InitStruct); 01039 01040 /** 01041 * @} 01042 */ 01043 #endif /* USE_FULL_LL_DRIVER */ 01044 01045 /** 01046 * @} 01047 */ 01048 01049 /** 01050 * @} 01051 */ 01052 01053 #endif /* defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOF) || defined (GPIOG) || defined (GPIOH) || defined (GPIOI) */ 01054 /** 01055 * @} 01056 */ 01057 01058 #ifdef __cplusplus 01059 } 01060 #endif 01061 01062 #endif /* __STM32L4xx_LL_GPIO_H */ 01063 01064 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/