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