stm32f0xx_ll_gpio.h 34 KB

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