stm32l1xx_ll_gpio.h 38 KB

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