stm32f0xx_ll_gpio.h 35 KB

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