stm32g0xx_ll_gpio.h 36 KB

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