stm32l0xx_ll_gpio.h 36 KB

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