py32f0xx_ll_gpio.h 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120
  1. /**
  2. ******************************************************************************
  3. * @file py32f0xx_ll_gpio.h
  4. * @author MCU Application Team
  5. * @brief Header file of GPIO LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2023 Puya Semiconductor Co.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by Puya 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. * @attention
  19. *
  20. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  21. * All rights reserved.</center></h2>
  22. *
  23. * This software component is licensed by ST under BSD 3-Clause license,
  24. * the "License"; You may not use this file except in compliance with the
  25. * License. You may obtain a copy of the License at:
  26. * opensource.org/licenses/BSD-3-Clause
  27. *
  28. ******************************************************************************
  29. */
  30. /* Define to prevent recursive inclusion -------------------------------------*/
  31. #ifndef __PY32F0xx_LL_GPIO_H
  32. #define __PY32F0xx_LL_GPIO_H
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /* Includes ------------------------------------------------------------------*/
  37. #include "py32f0xx.h"
  38. /** @addtogroup PY32F0xx_LL_Driver
  39. * @{
  40. */
  41. #if defined (GPIOA) || defined (GPIOB) || defined (GPIOF)
  42. /** @defgroup GPIO_LL GPIO
  43. * @{
  44. */
  45. /** MISRA C:2012 deviation rule has been granted for following rules:
  46. * Rule-18.1_d - Medium: Array pointer `GPIOx' is accessed with index [..,..]
  47. * which may be out of array bounds [..,UNKNOWN] in following APIs:
  48. * LL_GPIO_GetAFPin_0_7
  49. * LL_GPIO_SetAFPin_0_7
  50. * LL_GPIO_SetAFPin_8_15
  51. * LL_GPIO_GetAFPin_8_15
  52. */
  53. /* Private types -------------------------------------------------------------*/
  54. /* Private variables ---------------------------------------------------------*/
  55. /* Private constants ---------------------------------------------------------*/
  56. /* Private macros ------------------------------------------------------------*/
  57. #if defined(USE_FULL_LL_DRIVER)
  58. /** @defgroup GPIO_LL_Private_Macros GPIO Private Macros
  59. * @{
  60. */
  61. /**
  62. * @}
  63. */
  64. #endif /*USE_FULL_LL_DRIVER*/
  65. /* Exported types ------------------------------------------------------------*/
  66. #if defined(USE_FULL_LL_DRIVER)
  67. /** @defgroup GPIO_LL_ES_INIT GPIO Exported Init structures
  68. * @{
  69. */
  70. /**
  71. * @brief LL GPIO Init Structure definition
  72. */
  73. typedef struct
  74. {
  75. uint32_t Pin; /*!< Specifies the GPIO pins to be configured.
  76. This parameter can be any value of @ref GPIO_LL_EC_PIN */
  77. uint32_t Mode; /*!< Specifies the operating mode for the selected pins.
  78. This parameter can be a value of @ref GPIO_LL_EC_MODE.
  79. GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinMode().*/
  80. uint32_t Speed; /*!< Specifies the speed for the selected pins.
  81. This parameter can be a value of @ref GPIO_LL_EC_SPEED.
  82. GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinSpeed().*/
  83. uint32_t OutputType; /*!< Specifies the operating output type for the selected pins.
  84. This parameter can be a value of @ref GPIO_LL_EC_OUTPUT.
  85. GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinOutputType().*/
  86. uint32_t Pull; /*!< Specifies the operating Pull-up/Pull down for the selected pins.
  87. This parameter can be a value of @ref GPIO_LL_EC_PULL.
  88. GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinPull().*/
  89. uint32_t Alternate; /*!< Specifies the Peripheral to be connected to the selected pins.
  90. This parameter can be a value of @ref GPIO_LL_EC_AF.
  91. GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetAFPin_0_7() and LL_GPIO_SetAFPin_8_15().*/
  92. } LL_GPIO_InitTypeDef;
  93. /**
  94. * @}
  95. */
  96. #endif /* USE_FULL_LL_DRIVER */
  97. /* Exported constants --------------------------------------------------------*/
  98. /** @defgroup GPIO_LL_Exported_Constants GPIO Exported Constants
  99. * @{
  100. */
  101. #define LL_GPIO_LCKR_LCKK 0x00030000U
  102. /** @defgroup GPIO_LL_EC_PIN PIN
  103. * @{
  104. */
  105. #define LL_GPIO_PIN_0 GPIO_BSRR_BS0 /*!< Select pin 0 */
  106. #define LL_GPIO_PIN_1 GPIO_BSRR_BS1 /*!< Select pin 1 */
  107. #define LL_GPIO_PIN_2 GPIO_BSRR_BS2 /*!< Select pin 2 */
  108. #define LL_GPIO_PIN_3 GPIO_BSRR_BS3 /*!< Select pin 3 */
  109. #define LL_GPIO_PIN_4 GPIO_BSRR_BS4 /*!< Select pin 4 */
  110. #define LL_GPIO_PIN_5 GPIO_BSRR_BS5 /*!< Select pin 5 */
  111. #define LL_GPIO_PIN_6 GPIO_BSRR_BS6 /*!< Select pin 6 */
  112. #define LL_GPIO_PIN_7 GPIO_BSRR_BS7 /*!< Select pin 7 */
  113. #define LL_GPIO_PIN_8 GPIO_BSRR_BS8 /*!< Select pin 8 */
  114. #define LL_GPIO_PIN_9 GPIO_BSRR_BS9 /*!< Select pin 9 */
  115. #define LL_GPIO_PIN_10 GPIO_BSRR_BS10 /*!< Select pin 10 */
  116. #define LL_GPIO_PIN_11 GPIO_BSRR_BS11 /*!< Select pin 11 */
  117. #define LL_GPIO_PIN_12 GPIO_BSRR_BS12 /*!< Select pin 12 */
  118. #define LL_GPIO_PIN_13 GPIO_BSRR_BS13 /*!< Select pin 13 */
  119. #define LL_GPIO_PIN_14 GPIO_BSRR_BS14 /*!< Select pin 14 */
  120. #define LL_GPIO_PIN_15 GPIO_BSRR_BS15 /*!< Select pin 15 */
  121. #define LL_GPIO_PIN_ALL (GPIO_BSRR_BS0 | GPIO_BSRR_BS1 | GPIO_BSRR_BS2 | \
  122. GPIO_BSRR_BS3 | GPIO_BSRR_BS4 | GPIO_BSRR_BS5 | \
  123. GPIO_BSRR_BS6 | GPIO_BSRR_BS7 | GPIO_BSRR_BS8 | \
  124. GPIO_BSRR_BS9 | GPIO_BSRR_BS10 | GPIO_BSRR_BS11 | \
  125. GPIO_BSRR_BS12 | GPIO_BSRR_BS13 | GPIO_BSRR_BS14 | \
  126. GPIO_BSRR_BS15) /*!< Select all pins */
  127. /**
  128. * @}
  129. */
  130. /** @defgroup GPIO_LL_EC_MODE Mode
  131. * @{
  132. */
  133. #define LL_GPIO_MODE_INPUT (0x00000000U) /*!< Select input mode */
  134. #define LL_GPIO_MODE_OUTPUT GPIO_MODER_MODE0_0 /*!< Select output mode */
  135. #define LL_GPIO_MODE_ALTERNATE GPIO_MODER_MODE0_1 /*!< Select alternate function mode */
  136. #define LL_GPIO_MODE_ANALOG GPIO_MODER_MODE0 /*!< Select analog mode */
  137. /**
  138. * @}
  139. */
  140. /** @defgroup GPIO_LL_EC_OUTPUT Output Type
  141. * @{
  142. */
  143. #define LL_GPIO_OUTPUT_PUSHPULL (0x00000000U) /*!< Select push-pull as output type */
  144. #define LL_GPIO_OUTPUT_OPENDRAIN GPIO_OTYPER_OT0 /*!< Select open-drain as output type */
  145. /**
  146. * @}
  147. */
  148. /** @defgroup GPIO_LL_EC_SPEED Output Speed
  149. * @{
  150. */
  151. #define LL_GPIO_SPEED_FREQ_LOW (0x00000000U) /*!< Select I/O low output speed */
  152. #define LL_GPIO_SPEED_FREQ_MEDIUM GPIO_OSPEEDR_OSPEED0_0 /*!< Select I/O medium output speed */
  153. #define LL_GPIO_SPEED_FREQ_HIGH GPIO_OSPEEDR_OSPEED0_1 /*!< Select I/O fast output speed */
  154. #define LL_GPIO_SPEED_FREQ_VERY_HIGH GPIO_OSPEEDR_OSPEED0 /*!< Select I/O high output speed */
  155. /**
  156. * @}
  157. */
  158. /** @defgroup GPIO_LL_EC_PULL Pull Up Pull Down
  159. * @{
  160. */
  161. #define LL_GPIO_PULL_NO (0x00000000U) /*!< Select I/O no pull */
  162. #define LL_GPIO_PULL_UP GPIO_PUPDR_PUPD0_0 /*!< Select I/O pull up */
  163. #define LL_GPIO_PULL_DOWN GPIO_PUPDR_PUPD0_1 /*!< Select I/O pull down */
  164. /**
  165. * @}
  166. */
  167. /** @defgroup GPIO_LL_EC_AF Alternate Function
  168. * @{
  169. */
  170. #define LL_GPIO_AF_0 (0x0000000U) /*!< Select alternate function 0 */
  171. #define LL_GPIO_AF_1 (0x0000001U) /*!< Select alternate function 1 */
  172. #define LL_GPIO_AF_2 (0x0000002U) /*!< Select alternate function 2 */
  173. #define LL_GPIO_AF_3 (0x0000003U) /*!< Select alternate function 3 */
  174. #define LL_GPIO_AF_4 (0x0000004U) /*!< Select alternate function 4 */
  175. #define LL_GPIO_AF_5 (0x0000005U) /*!< Select alternate function 5 */
  176. #define LL_GPIO_AF_6 (0x0000006U) /*!< Select alternate function 6 */
  177. #define LL_GPIO_AF_7 (0x0000007U) /*!< Select alternate function 7 */
  178. #define LL_GPIO_AF_8 (0x0000008U) /*!< Select alternate function 8 */
  179. #define LL_GPIO_AF_9 (0x0000009U) /*!< Select alternate function 9 */
  180. #define LL_GPIO_AF_10 (0x000000AU) /*!< Select alternate function 10 */
  181. #define LL_GPIO_AF_11 (0x000000BU) /*!< Select alternate function 11 */
  182. #define LL_GPIO_AF_12 (0x000000CU) /*!< Select alternate function 12 */
  183. #define LL_GPIO_AF_13 (0x000000DU) /*!< Select alternate function 13 */
  184. #define LL_GPIO_AF_14 (0x000000EU) /*!< Select alternate function 14 */
  185. #define LL_GPIO_AF_15 (0x000000FU) /*!< Select alternate function 15 */
  186. /**
  187. * @}
  188. */
  189. /** @defgroup GPIO_LL_Alternate_function_selection Alternate function selection
  190. * @{
  191. */
  192. /**
  193. * @brief AF 0 selection
  194. */
  195. #define LL_GPIO_AF0_SWJ LL_GPIO_AF_0 /*!< SWJ (SWD) Alternate Function mapping */
  196. #define LL_GPIO_AF0_SPI1 LL_GPIO_AF_0 /*!< SPI1 Alternate Function mapping */
  197. #define LL_GPIO_AF0_SPI2 LL_GPIO_AF_0 /*!< SPI2 Alternate Function mapping */
  198. #define LL_GPIO_AF0_TIM14 LL_GPIO_AF_0 /*!< TIM14 Alternate Function mapping */
  199. #define LL_GPIO_AF0_USART1 LL_GPIO_AF_0 /*!< USART1 Alternate Function mapping */
  200. /**
  201. * @brief AF 1 selection
  202. */
  203. #define LL_GPIO_AF1_IR LL_GPIO_AF_1 /*!< IR Alternate Function mapping */
  204. #define LL_GPIO_AF1_SPI2 LL_GPIO_AF_1 /*!< SPI2 Alternate Function mapping */
  205. #define LL_GPIO_AF1_TIM1 LL_GPIO_AF_1 /*!< TIM1 Alternate Function mapping */
  206. #define LL_GPIO_AF1_TIM3 LL_GPIO_AF_1 /*!< TIM3 Alternate Function mapping */
  207. #define LL_GPIO_AF1_USART1 LL_GPIO_AF_1 /*!< USART1 Alternate Function mapping */
  208. /**
  209. * @brief AF 2 selection
  210. */
  211. #define LL_GPIO_AF2_SPI2 LL_GPIO_AF_2 /*!< SPI2 Alternate Function mapping */
  212. #define LL_GPIO_AF2_TIM1 LL_GPIO_AF_2 /*!< TIM1 Alternate Function mapping */
  213. #define LL_GPIO_AF2_TIM14 LL_GPIO_AF_2 /*!< TIM14 Alternate Function mapping */
  214. #define LL_GPIO_AF2_TIM16 LL_GPIO_AF_2 /*!< TIM16 Alternate Function mapping */
  215. #define LL_GPIO_AF2_TIM17 LL_GPIO_AF_2 /*!< TIM17 Alternate Function mapping */
  216. /**
  217. * @brief AF 3 selection
  218. */
  219. #define LL_GPIO_AF3_LED LL_GPIO_AF_3 /*!< AF3: LED Alternate Function mapping*/
  220. #define LL_GPIO_AF3_USART1 LL_GPIO_AF_3 /*!< AF3: USART1 Alternate Function mapping*/
  221. #define LL_GPIO_AF3_USART2 LL_GPIO_AF_3 /*!< AF3: USART2 Alternate Function mapping*/
  222. #define LL_GPIO_AF3_SPI2 LL_GPIO_AF_3 /*!< AF3: SPI2 Alternate Function mapping*/
  223. /**
  224. * @brief AF 4 selection
  225. */
  226. #define LL_GPIO_AF4_TIM14 LL_GPIO_AF_4 /*!< TIM14 Alternate Function mapping*/
  227. #define LL_GPIO_AF4_USART2 LL_GPIO_AF_4 /*!< USART2 Alternate Function mapping*/
  228. /**
  229. * @brief AF 5 selection
  230. */
  231. #define LL_GPIO_AF5_LPTIM LL_GPIO_AF_5 /*!< LPTIM1 Alternate Function mapping*/
  232. #define LL_GPIO_AF5_USART2 LL_GPIO_AF_5 /*!< USART2 Alternate Function mapping*/
  233. #define LL_GPIO_AF5_EVENTOUT LL_GPIO_AF_5 /*!< EVENTOUT Alternate Function mapping*/
  234. #define LL_GPIO_AF5_TIM16 LL_GPIO_AF_5 /*!< TIM16 Alternate Function mapping*/
  235. #define LL_GPIO_AF5_TIM17 LL_GPIO_AF_5 /*!< TIM17 Alternate Function mapping*/
  236. #define LL_GPIO_AF5_MCO LL_GPIO_AF_5 /*!< MCO Alternate Function mapping*/
  237. /**
  238. * @brief AF 6 selection
  239. */
  240. #define LL_GPIO_AF6_I2C LL_GPIO_AF_6 /*!< I2C1 Alternate Function mapping */
  241. #define LL_GPIO_AF6_LED LL_GPIO_AF_6 /*!< AF6: LED Alternate Function mapping*/
  242. #define LL_GPIO_AF6_MCO LL_GPIO_AF_6 /*!< MCO Alternate Function mapping */
  243. #define LL_GPIO_AF6_EVENTOUT LL_GPIO_AF_6 /*!< AF6: EVENTOUT Alternate Function mapping*/
  244. /**
  245. * @brief AF 7 selection
  246. */
  247. #define LL_GPIO_AF7_EVENTOUT LL_GPIO_AF_7 /*!< EVENTOUT Alternate Function mapping */
  248. #define LL_GPIO_AF7_COMP1 LL_GPIO_AF_7 /*!< AF7: COMP1 Alternate Function mapping*/
  249. #define LL_GPIO_AF7_COMP2 LL_GPIO_AF_7 /*!< AF7: COMP2 Alternate Function mapping*/
  250. /**
  251. * @brief AF 8 selection
  252. */
  253. #define LL_GPIO_AF8_USART1 LL_GPIO_AF_8 /*!< AF8: USART1 Alternate Function mapping*/
  254. /**
  255. * @brief AF 9 selection
  256. */
  257. #define LL_GPIO_AF9_USART2 LL_GPIO_AF_9 /*!< USART2 Alternate Function mapping*/
  258. /**
  259. * @brief AF 10 selection
  260. */
  261. #define LL_GPIO_AF10_SPI1 LL_GPIO_AF_10 /*!< SPI2 Alternate Function mapping*/
  262. /**
  263. * @brief AF 11 selection
  264. */
  265. #define LL_GPIO_AF11_SPI2 LL_GPIO_AF_11 /*!< SPI2 Alternate Function mapping*/
  266. /**
  267. * @brief AF 12 selection
  268. */
  269. #define LL_GPIO_AF12_I2C LL_GPIO_AF_12 /*!< I2C1 Alternate Function mapping*/
  270. /**
  271. * @brief AF 13 selection
  272. */
  273. #define LL_GPIO_AF13_TIM1 LL_GPIO_AF_13 /*!< TIM1 Alternate Function mapping*/
  274. #define LL_GPIO_AF13_TIM3 LL_GPIO_AF_13 /*!< TIM3 Alternate Function mapping*/
  275. #define LL_GPIO_AF13_TIM14 LL_GPIO_AF_13 /*!< TIM14 Alternate Function mapping*/
  276. #define LL_GPIO_AF13_TIM17 LL_GPIO_AF_13 /*!< TIM17 Alternate Function mapping*/
  277. /**
  278. * @brief AF 14 selection
  279. */
  280. #define LL_GPIO_AF14_TIM1 LL_GPIO_AF_14 /*!< TIM1 Alternate Function mapping*/
  281. /**
  282. * @brief AF 15 selection
  283. */
  284. #define LL_GPIO_AF15_RTCOUT LL_GPIO_AF_15
  285. #define LL_GPIO_AF15_MCO LL_GPIO_AF_15 /*!< MCO Alternate Function mapping*/
  286. #define LL_GPIO_AF15_IR LL_GPIO_AF_15 /*!< IR Alternate Function mapping*/
  287. /**
  288. * @}
  289. */
  290. /**
  291. * @}
  292. */
  293. /* Exported macro ------------------------------------------------------------*/
  294. /** @defgroup GPIO_LL_Exported_Macros GPIO Exported Macros
  295. * @{
  296. */
  297. /** @defgroup GPIO_LL_EM_WRITE_READ Common Write and read registers Macros
  298. * @{
  299. */
  300. /**
  301. * @brief Write a value in GPIO register
  302. * @param __INSTANCE__ GPIO Instance
  303. * @param __REG__ Register to be written
  304. * @param __VALUE__ Value to be written in the register
  305. * @retval None
  306. */
  307. #define LL_GPIO_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  308. /**
  309. * @brief Read a value in GPIO register
  310. * @param __INSTANCE__ GPIO Instance
  311. * @param __REG__ Register to be read
  312. * @retval Register value
  313. */
  314. #define LL_GPIO_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  315. /**
  316. * @}
  317. */
  318. /**
  319. * @}
  320. */
  321. /* Exported functions --------------------------------------------------------*/
  322. /** @defgroup GPIO_LL_Exported_Functions GPIO Exported Functions
  323. * @{
  324. */
  325. /** @defgroup GPIO_LL_EF_Port_Configuration Port Configuration
  326. * @{
  327. */
  328. /**
  329. * @brief Configure gpio mode for a dedicated pin on dedicated port.
  330. * @note I/O mode can be Input mode, General purpose output, Alternate function mode or Analog.
  331. * @note Warning: only one pin can be passed as parameter.
  332. * @rmtoll MODER MODEy LL_GPIO_SetPinMode
  333. * @param GPIOx GPIO Port
  334. * @param Pin This parameter can be one of the following values:
  335. * @arg @ref LL_GPIO_PIN_0
  336. * @arg @ref LL_GPIO_PIN_1
  337. * @arg @ref LL_GPIO_PIN_2
  338. * @arg @ref LL_GPIO_PIN_3
  339. * @arg @ref LL_GPIO_PIN_4
  340. * @arg @ref LL_GPIO_PIN_5
  341. * @arg @ref LL_GPIO_PIN_6
  342. * @arg @ref LL_GPIO_PIN_7
  343. * @arg @ref LL_GPIO_PIN_8
  344. * @arg @ref LL_GPIO_PIN_9
  345. * @arg @ref LL_GPIO_PIN_10
  346. * @arg @ref LL_GPIO_PIN_11
  347. * @arg @ref LL_GPIO_PIN_12
  348. * @arg @ref LL_GPIO_PIN_13
  349. * @arg @ref LL_GPIO_PIN_14
  350. * @arg @ref LL_GPIO_PIN_15
  351. * @param Mode This parameter can be one of the following values:
  352. * @arg @ref LL_GPIO_MODE_INPUT
  353. * @arg @ref LL_GPIO_MODE_OUTPUT
  354. * @arg @ref LL_GPIO_MODE_ALTERNATE
  355. * @arg @ref LL_GPIO_MODE_ANALOG
  356. * @retval None
  357. */
  358. __STATIC_INLINE void LL_GPIO_SetPinMode(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Mode)
  359. {
  360. MODIFY_REG(GPIOx->MODER, ((Pin * Pin) * GPIO_MODER_MODE0), ((Pin * Pin) * Mode));
  361. }
  362. /**
  363. * @brief Return gpio mode for a dedicated pin on dedicated port.
  364. * @note I/O mode can be Input mode, General purpose output, Alternate function mode or Analog.
  365. * @note Warning: only one pin can be passed as parameter.
  366. * @rmtoll MODER MODEy LL_GPIO_GetPinMode
  367. * @param GPIOx GPIO Port
  368. * @param Pin This parameter can be one of the following values:
  369. * @arg @ref LL_GPIO_PIN_0
  370. * @arg @ref LL_GPIO_PIN_1
  371. * @arg @ref LL_GPIO_PIN_2
  372. * @arg @ref LL_GPIO_PIN_3
  373. * @arg @ref LL_GPIO_PIN_4
  374. * @arg @ref LL_GPIO_PIN_5
  375. * @arg @ref LL_GPIO_PIN_6
  376. * @arg @ref LL_GPIO_PIN_7
  377. * @arg @ref LL_GPIO_PIN_8
  378. * @arg @ref LL_GPIO_PIN_9
  379. * @arg @ref LL_GPIO_PIN_10
  380. * @arg @ref LL_GPIO_PIN_11
  381. * @arg @ref LL_GPIO_PIN_12
  382. * @arg @ref LL_GPIO_PIN_13
  383. * @arg @ref LL_GPIO_PIN_14
  384. * @arg @ref LL_GPIO_PIN_15
  385. * @retval Returned value can be one of the following values:
  386. * @arg @ref LL_GPIO_MODE_INPUT
  387. * @arg @ref LL_GPIO_MODE_OUTPUT
  388. * @arg @ref LL_GPIO_MODE_ALTERNATE
  389. * @arg @ref LL_GPIO_MODE_ANALOG
  390. */
  391. __STATIC_INLINE uint32_t LL_GPIO_GetPinMode(GPIO_TypeDef *GPIOx, uint32_t Pin)
  392. {
  393. return (uint32_t)(READ_BIT(GPIOx->MODER, ((Pin * Pin) * GPIO_MODER_MODE0)) / (Pin * Pin));
  394. }
  395. /**
  396. * @brief Configure gpio output type for several pins on dedicated port.
  397. * @note Output type as to be set when gpio pin is in output or
  398. * alternate modes. Possible type are Push-pull or Open-drain.
  399. * @rmtoll OTYPER OTy LL_GPIO_SetPinOutputType
  400. * @param GPIOx GPIO Port
  401. * @param PinMask This parameter can be a combination of the following values:
  402. * @arg @ref LL_GPIO_PIN_0
  403. * @arg @ref LL_GPIO_PIN_1
  404. * @arg @ref LL_GPIO_PIN_2
  405. * @arg @ref LL_GPIO_PIN_3
  406. * @arg @ref LL_GPIO_PIN_4
  407. * @arg @ref LL_GPIO_PIN_5
  408. * @arg @ref LL_GPIO_PIN_6
  409. * @arg @ref LL_GPIO_PIN_7
  410. * @arg @ref LL_GPIO_PIN_8
  411. * @arg @ref LL_GPIO_PIN_9
  412. * @arg @ref LL_GPIO_PIN_10
  413. * @arg @ref LL_GPIO_PIN_11
  414. * @arg @ref LL_GPIO_PIN_12
  415. * @arg @ref LL_GPIO_PIN_13
  416. * @arg @ref LL_GPIO_PIN_14
  417. * @arg @ref LL_GPIO_PIN_15
  418. * @arg @ref LL_GPIO_PIN_ALL
  419. * @param OutputType This parameter can be one of the following values:
  420. * @arg @ref LL_GPIO_OUTPUT_PUSHPULL
  421. * @arg @ref LL_GPIO_OUTPUT_OPENDRAIN
  422. * @retval None
  423. */
  424. __STATIC_INLINE void LL_GPIO_SetPinOutputType(GPIO_TypeDef *GPIOx, uint32_t PinMask, uint32_t OutputType)
  425. {
  426. MODIFY_REG(GPIOx->OTYPER, PinMask, (PinMask * OutputType));
  427. }
  428. /**
  429. * @brief Return gpio output type for several pins on dedicated port.
  430. * @note Output type as to be set when gpio pin is in output or
  431. * alternate modes. Possible type are Push-pull or Open-drain.
  432. * @note Warning: only one pin can be passed as parameter.
  433. * @rmtoll OTYPER OTy LL_GPIO_GetPinOutputType
  434. * @param GPIOx GPIO Port
  435. * @param Pin This parameter can be one of the following values:
  436. * @arg @ref LL_GPIO_PIN_0
  437. * @arg @ref LL_GPIO_PIN_1
  438. * @arg @ref LL_GPIO_PIN_2
  439. * @arg @ref LL_GPIO_PIN_3
  440. * @arg @ref LL_GPIO_PIN_4
  441. * @arg @ref LL_GPIO_PIN_5
  442. * @arg @ref LL_GPIO_PIN_6
  443. * @arg @ref LL_GPIO_PIN_7
  444. * @arg @ref LL_GPIO_PIN_8
  445. * @arg @ref LL_GPIO_PIN_9
  446. * @arg @ref LL_GPIO_PIN_10
  447. * @arg @ref LL_GPIO_PIN_11
  448. * @arg @ref LL_GPIO_PIN_12
  449. * @arg @ref LL_GPIO_PIN_13
  450. * @arg @ref LL_GPIO_PIN_14
  451. * @arg @ref LL_GPIO_PIN_15
  452. * @arg @ref LL_GPIO_PIN_ALL
  453. * @retval Returned value can be one of the following values:
  454. * @arg @ref LL_GPIO_OUTPUT_PUSHPULL
  455. * @arg @ref LL_GPIO_OUTPUT_OPENDRAIN
  456. */
  457. __STATIC_INLINE uint32_t LL_GPIO_GetPinOutputType(GPIO_TypeDef *GPIOx, uint32_t Pin)
  458. {
  459. return (uint32_t)(READ_BIT(GPIOx->OTYPER, Pin) / Pin);
  460. }
  461. /**
  462. * @brief Configure gpio speed for a dedicated pin on dedicated port.
  463. * @note I/O speed can be Low, Medium, High or Very High speed.
  464. * @note Warning: only one pin can be passed as parameter.
  465. * @note Refer to datasheet for frequency specifications and the power
  466. * supply and load conditions for each speed.
  467. * @rmtoll OSPEEDR OSPEEDy LL_GPIO_SetPinSpeed
  468. * @param GPIOx GPIO Port
  469. * @param Pin This parameter can be one of the following values:
  470. * @arg @ref LL_GPIO_PIN_0
  471. * @arg @ref LL_GPIO_PIN_1
  472. * @arg @ref LL_GPIO_PIN_2
  473. * @arg @ref LL_GPIO_PIN_3
  474. * @arg @ref LL_GPIO_PIN_4
  475. * @arg @ref LL_GPIO_PIN_5
  476. * @arg @ref LL_GPIO_PIN_6
  477. * @arg @ref LL_GPIO_PIN_7
  478. * @arg @ref LL_GPIO_PIN_8
  479. * @arg @ref LL_GPIO_PIN_9
  480. * @arg @ref LL_GPIO_PIN_10
  481. * @arg @ref LL_GPIO_PIN_11
  482. * @arg @ref LL_GPIO_PIN_12
  483. * @arg @ref LL_GPIO_PIN_13
  484. * @arg @ref LL_GPIO_PIN_14
  485. * @arg @ref LL_GPIO_PIN_15
  486. * @param Speed This parameter can be one of the following values:
  487. * @arg @ref LL_GPIO_SPEED_FREQ_LOW
  488. * @arg @ref LL_GPIO_SPEED_FREQ_MEDIUM
  489. * @arg @ref LL_GPIO_SPEED_FREQ_HIGH
  490. * @arg @ref LL_GPIO_SPEED_FREQ_VERY_HIGH
  491. * @retval None
  492. */
  493. __STATIC_INLINE void LL_GPIO_SetPinSpeed(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Speed)
  494. {
  495. MODIFY_REG(GPIOx->OSPEEDR, ((Pin * Pin) * GPIO_OSPEEDR_OSPEED0), ((Pin * Pin) * Speed));
  496. }
  497. /**
  498. * @brief Return gpio speed for a dedicated pin on dedicated port.
  499. * @note I/O speed can be Low, Medium, High or Very High speed.
  500. * @note Warning: only one pin can be passed as parameter.
  501. * @note Refer to datasheet for frequency specifications and the power
  502. * supply and load conditions for each speed.
  503. * @rmtoll OSPEEDR OSPEEDy LL_GPIO_GetPinSpeed
  504. * @param GPIOx GPIO Port
  505. * @param Pin This parameter can be one of the following values:
  506. * @arg @ref LL_GPIO_PIN_0
  507. * @arg @ref LL_GPIO_PIN_1
  508. * @arg @ref LL_GPIO_PIN_2
  509. * @arg @ref LL_GPIO_PIN_3
  510. * @arg @ref LL_GPIO_PIN_4
  511. * @arg @ref LL_GPIO_PIN_5
  512. * @arg @ref LL_GPIO_PIN_6
  513. * @arg @ref LL_GPIO_PIN_7
  514. * @arg @ref LL_GPIO_PIN_8
  515. * @arg @ref LL_GPIO_PIN_9
  516. * @arg @ref LL_GPIO_PIN_10
  517. * @arg @ref LL_GPIO_PIN_11
  518. * @arg @ref LL_GPIO_PIN_12
  519. * @arg @ref LL_GPIO_PIN_13
  520. * @arg @ref LL_GPIO_PIN_14
  521. * @arg @ref LL_GPIO_PIN_15
  522. * @retval Returned value can be one of the following values:
  523. * @arg @ref LL_GPIO_SPEED_FREQ_LOW
  524. * @arg @ref LL_GPIO_SPEED_FREQ_MEDIUM
  525. * @arg @ref LL_GPIO_SPEED_FREQ_HIGH
  526. * @arg @ref LL_GPIO_SPEED_FREQ_VERY_HIGH
  527. */
  528. __STATIC_INLINE uint32_t LL_GPIO_GetPinSpeed(GPIO_TypeDef *GPIOx, uint32_t Pin)
  529. {
  530. return (uint32_t)(READ_BIT(GPIOx->OSPEEDR, ((Pin * Pin) * GPIO_OSPEEDR_OSPEED0)) / (Pin * Pin));
  531. }
  532. /**
  533. * @brief Configure gpio pull-up or pull-down for a dedicated pin on a dedicated port.
  534. * @note Warning: only one pin can be passed as parameter.
  535. * @rmtoll PUPDR PUPDy LL_GPIO_SetPinPull
  536. * @param GPIOx GPIO Port
  537. * @param Pin This parameter can be one of the following values:
  538. * @arg @ref LL_GPIO_PIN_0
  539. * @arg @ref LL_GPIO_PIN_1
  540. * @arg @ref LL_GPIO_PIN_2
  541. * @arg @ref LL_GPIO_PIN_3
  542. * @arg @ref LL_GPIO_PIN_4
  543. * @arg @ref LL_GPIO_PIN_5
  544. * @arg @ref LL_GPIO_PIN_6
  545. * @arg @ref LL_GPIO_PIN_7
  546. * @arg @ref LL_GPIO_PIN_8
  547. * @arg @ref LL_GPIO_PIN_9
  548. * @arg @ref LL_GPIO_PIN_10
  549. * @arg @ref LL_GPIO_PIN_11
  550. * @arg @ref LL_GPIO_PIN_12
  551. * @arg @ref LL_GPIO_PIN_13
  552. * @arg @ref LL_GPIO_PIN_14
  553. * @arg @ref LL_GPIO_PIN_15
  554. * @param Pull This parameter can be one of the following values:
  555. * @arg @ref LL_GPIO_PULL_NO
  556. * @arg @ref LL_GPIO_PULL_UP
  557. * @arg @ref LL_GPIO_PULL_DOWN
  558. * @retval None
  559. */
  560. __STATIC_INLINE void LL_GPIO_SetPinPull(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Pull)
  561. {
  562. MODIFY_REG(GPIOx->PUPDR, ((Pin * Pin) * GPIO_PUPDR_PUPD0), ((Pin * Pin) * Pull));
  563. }
  564. /**
  565. * @brief Return gpio pull-up or pull-down for a dedicated pin on a dedicated port
  566. * @note Warning: only one pin can be passed as parameter.
  567. * @rmtoll PUPDR PUPDy LL_GPIO_GetPinPull
  568. * @param GPIOx GPIO Port
  569. * @param Pin This parameter can be one of the following values:
  570. * @arg @ref LL_GPIO_PIN_0
  571. * @arg @ref LL_GPIO_PIN_1
  572. * @arg @ref LL_GPIO_PIN_2
  573. * @arg @ref LL_GPIO_PIN_3
  574. * @arg @ref LL_GPIO_PIN_4
  575. * @arg @ref LL_GPIO_PIN_5
  576. * @arg @ref LL_GPIO_PIN_6
  577. * @arg @ref LL_GPIO_PIN_7
  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_PULL_NO
  588. * @arg @ref LL_GPIO_PULL_UP
  589. * @arg @ref LL_GPIO_PULL_DOWN
  590. */
  591. __STATIC_INLINE uint32_t LL_GPIO_GetPinPull(GPIO_TypeDef *GPIOx, uint32_t Pin)
  592. {
  593. return (uint32_t)(READ_BIT(GPIOx->PUPDR, ((Pin * Pin) * GPIO_PUPDR_PUPD0)) / (Pin * Pin));
  594. }
  595. /**
  596. * @brief Configure gpio alternate function of a dedicated pin from 0 to 7 for a dedicated port.
  597. * @note Possible values are from AF0 to AF7 depending on target.
  598. * @note Warning: only one pin can be passed as parameter.
  599. * @rmtoll AFRL AFSELy LL_GPIO_SetAFPin_0_7
  600. * @param GPIOx GPIO Port
  601. * @param Pin This parameter can be one of the following values:
  602. * @arg @ref LL_GPIO_PIN_0
  603. * @arg @ref LL_GPIO_PIN_1
  604. * @arg @ref LL_GPIO_PIN_2
  605. * @arg @ref LL_GPIO_PIN_3
  606. * @arg @ref LL_GPIO_PIN_4
  607. * @arg @ref LL_GPIO_PIN_5
  608. * @arg @ref LL_GPIO_PIN_6
  609. * @arg @ref LL_GPIO_PIN_7
  610. * @param Alternate This parameter can be one of the following values:
  611. * @arg @ref LL_GPIO_AF_0
  612. * @arg @ref LL_GPIO_AF_1
  613. * @arg @ref LL_GPIO_AF_2
  614. * @arg @ref LL_GPIO_AF_3
  615. * @arg @ref LL_GPIO_AF_4
  616. * @arg @ref LL_GPIO_AF_5
  617. * @arg @ref LL_GPIO_AF_6
  618. * @arg @ref LL_GPIO_AF_7
  619. * @arg @ref LL_GPIO_AF_8
  620. * @arg @ref LL_GPIO_AF_9
  621. * @arg @ref LL_GPIO_AF_10
  622. * @arg @ref LL_GPIO_AF_11
  623. * @arg @ref LL_GPIO_AF_12
  624. * @arg @ref LL_GPIO_AF_13
  625. * @arg @ref LL_GPIO_AF_14
  626. * @arg @ref LL_GPIO_AF_15
  627. * @retval None
  628. */
  629. __STATIC_INLINE void LL_GPIO_SetAFPin_0_7(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Alternate)
  630. {
  631. MODIFY_REG(GPIOx->AFR[0], ((((Pin * Pin) * Pin) * Pin) * GPIO_AFRL_AFSEL0),
  632. ((((Pin * Pin) * Pin) * Pin) * Alternate));
  633. }
  634. /**
  635. * @brief Return gpio alternate function of a dedicated pin from 0 to 7 for a dedicated port.
  636. * @rmtoll AFRL AFSELy LL_GPIO_GetAFPin_0_7
  637. * @param GPIOx GPIO Port
  638. * @param Pin This parameter can be one of the following values:
  639. * @arg @ref LL_GPIO_PIN_0
  640. * @arg @ref LL_GPIO_PIN_1
  641. * @arg @ref LL_GPIO_PIN_2
  642. * @arg @ref LL_GPIO_PIN_3
  643. * @arg @ref LL_GPIO_PIN_4
  644. * @arg @ref LL_GPIO_PIN_5
  645. * @arg @ref LL_GPIO_PIN_6
  646. * @arg @ref LL_GPIO_PIN_7
  647. * @retval Returned value can be one of the following values:
  648. * @arg @ref LL_GPIO_AF_0
  649. * @arg @ref LL_GPIO_AF_1
  650. * @arg @ref LL_GPIO_AF_2
  651. * @arg @ref LL_GPIO_AF_3
  652. * @arg @ref LL_GPIO_AF_4
  653. * @arg @ref LL_GPIO_AF_5
  654. * @arg @ref LL_GPIO_AF_6
  655. * @arg @ref LL_GPIO_AF_7
  656. * @arg @ref LL_GPIO_AF_8
  657. * @arg @ref LL_GPIO_AF_9
  658. * @arg @ref LL_GPIO_AF_10
  659. * @arg @ref LL_GPIO_AF_11
  660. * @arg @ref LL_GPIO_AF_12
  661. * @arg @ref LL_GPIO_AF_13
  662. * @arg @ref LL_GPIO_AF_14
  663. * @arg @ref LL_GPIO_AF_15
  664. */
  665. __STATIC_INLINE uint32_t LL_GPIO_GetAFPin_0_7(GPIO_TypeDef *GPIOx, uint32_t Pin)
  666. {
  667. return (uint32_t)(READ_BIT(GPIOx->AFR[0],
  668. ((((Pin * Pin) * Pin) * Pin) * GPIO_AFRL_AFSEL0)) / (((Pin * Pin) * Pin) * Pin));
  669. }
  670. /**
  671. * @brief Configure gpio alternate function of a dedicated pin from 8 to 15 for a dedicated port.
  672. * @note Possible values are from AF0 to AF7 depending on target.
  673. * @note Warning: only one pin can be passed as parameter.
  674. * @rmtoll AFRH AFSELy LL_GPIO_SetAFPin_8_15
  675. * @param GPIOx GPIO Port
  676. * @param Pin This parameter can be one of the following values:
  677. * @arg @ref LL_GPIO_PIN_8
  678. * @arg @ref LL_GPIO_PIN_9
  679. * @arg @ref LL_GPIO_PIN_10
  680. * @arg @ref LL_GPIO_PIN_11
  681. * @arg @ref LL_GPIO_PIN_12
  682. * @arg @ref LL_GPIO_PIN_13
  683. * @arg @ref LL_GPIO_PIN_14
  684. * @arg @ref LL_GPIO_PIN_15
  685. * @param Alternate This parameter can be one of the following values:
  686. * @arg @ref LL_GPIO_AF_0
  687. * @arg @ref LL_GPIO_AF_1
  688. * @arg @ref LL_GPIO_AF_2
  689. * @arg @ref LL_GPIO_AF_3
  690. * @arg @ref LL_GPIO_AF_4
  691. * @arg @ref LL_GPIO_AF_5
  692. * @arg @ref LL_GPIO_AF_6
  693. * @arg @ref LL_GPIO_AF_7
  694. * @arg @ref LL_GPIO_AF_8
  695. * @arg @ref LL_GPIO_AF_9
  696. * @arg @ref LL_GPIO_AF_10
  697. * @arg @ref LL_GPIO_AF_11
  698. * @arg @ref LL_GPIO_AF_12
  699. * @arg @ref LL_GPIO_AF_13
  700. * @arg @ref LL_GPIO_AF_14
  701. * @arg @ref LL_GPIO_AF_15
  702. * @retval None
  703. */
  704. __STATIC_INLINE void LL_GPIO_SetAFPin_8_15(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Alternate)
  705. {
  706. MODIFY_REG(GPIOx->AFR[1], (((((Pin >> 8U) * (Pin >> 8U)) * (Pin >> 8U)) * (Pin >> 8U)) * GPIO_AFRH_AFSEL8),
  707. (((((Pin >> 8U) * (Pin >> 8U)) * (Pin >> 8U)) * (Pin >> 8U)) * Alternate));
  708. }
  709. /**
  710. * @brief Return gpio alternate function of a dedicated pin from 8 to 15 for a dedicated port.
  711. * @note Possible values are from AF0 to AF7 depending on target.
  712. * @rmtoll AFRH AFSELy LL_GPIO_GetAFPin_8_15
  713. * @param GPIOx GPIO Port
  714. * @param Pin This parameter can be one of the following values:
  715. * @arg @ref LL_GPIO_PIN_8
  716. * @arg @ref LL_GPIO_PIN_9
  717. * @arg @ref LL_GPIO_PIN_10
  718. * @arg @ref LL_GPIO_PIN_11
  719. * @arg @ref LL_GPIO_PIN_12
  720. * @arg @ref LL_GPIO_PIN_13
  721. * @arg @ref LL_GPIO_PIN_14
  722. * @arg @ref LL_GPIO_PIN_15
  723. * @retval Returned value can be one of the following values:
  724. * @arg @ref LL_GPIO_AF_0
  725. * @arg @ref LL_GPIO_AF_1
  726. * @arg @ref LL_GPIO_AF_2
  727. * @arg @ref LL_GPIO_AF_3
  728. * @arg @ref LL_GPIO_AF_4
  729. * @arg @ref LL_GPIO_AF_5
  730. * @arg @ref LL_GPIO_AF_6
  731. * @arg @ref LL_GPIO_AF_7
  732. * @arg @ref LL_GPIO_AF_8
  733. * @arg @ref LL_GPIO_AF_9
  734. * @arg @ref LL_GPIO_AF_10
  735. * @arg @ref LL_GPIO_AF_11
  736. * @arg @ref LL_GPIO_AF_12
  737. * @arg @ref LL_GPIO_AF_13
  738. * @arg @ref LL_GPIO_AF_14
  739. * @arg @ref LL_GPIO_AF_15
  740. */
  741. __STATIC_INLINE uint32_t LL_GPIO_GetAFPin_8_15(GPIO_TypeDef *GPIOx, uint32_t Pin)
  742. {
  743. return (uint32_t)(READ_BIT(GPIOx->AFR[1],
  744. (((((Pin >> 8U) * (Pin >> 8U)) * (Pin >> 8U)) * (Pin >> 8U)) * GPIO_AFRH_AFSEL8)) /
  745. ((((Pin >> 8U) * (Pin >> 8U)) * (Pin >> 8U)) * (Pin >> 8U)));
  746. }
  747. /**
  748. * @brief Lock configuration of several pins for a dedicated port.
  749. * @note When the lock sequence has been applied on a port bit, the
  750. * value of this port bit can no longer be modified until the
  751. * next reset.
  752. * @note Each lock bit freezes a specific configuration register
  753. * (control and alternate function registers).
  754. * @rmtoll LCKR LCKK LL_GPIO_LockPin
  755. * @param GPIOx GPIO Port
  756. * @param PinMask This parameter can be a combination of the following values:
  757. * @arg @ref LL_GPIO_PIN_0
  758. * @arg @ref LL_GPIO_PIN_1
  759. * @arg @ref LL_GPIO_PIN_2
  760. * @arg @ref LL_GPIO_PIN_3
  761. * @arg @ref LL_GPIO_PIN_4
  762. * @arg @ref LL_GPIO_PIN_5
  763. * @arg @ref LL_GPIO_PIN_6
  764. * @arg @ref LL_GPIO_PIN_7
  765. * @arg @ref LL_GPIO_PIN_8
  766. * @arg @ref LL_GPIO_PIN_9
  767. * @arg @ref LL_GPIO_PIN_10
  768. * @arg @ref LL_GPIO_PIN_11
  769. * @arg @ref LL_GPIO_PIN_12
  770. * @arg @ref LL_GPIO_PIN_13
  771. * @arg @ref LL_GPIO_PIN_14
  772. * @arg @ref LL_GPIO_PIN_15
  773. * @arg @ref LL_GPIO_PIN_ALL
  774. * @retval None
  775. */
  776. __STATIC_INLINE void LL_GPIO_LockPin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
  777. {
  778. __IO uint32_t temp;
  779. WRITE_REG(GPIOx->LCKR, GPIO_LCKR_LCKK | PinMask);
  780. WRITE_REG(GPIOx->LCKR, PinMask);
  781. WRITE_REG(GPIOx->LCKR, GPIO_LCKR_LCKK | PinMask);
  782. /* Read LCKK register. This read is mandatory to complete key lock sequence */
  783. temp = READ_REG(GPIOx->LCKR);
  784. (void) temp;
  785. }
  786. /**
  787. * @brief Return 1 if all pins passed as parameter, of a dedicated port, are locked. else Return 0.
  788. * @rmtoll LCKR LCKy LL_GPIO_IsPinLocked
  789. * @param GPIOx GPIO Port
  790. * @param PinMask This parameter can be a combination of the following values:
  791. * @arg @ref LL_GPIO_PIN_0
  792. * @arg @ref LL_GPIO_PIN_1
  793. * @arg @ref LL_GPIO_PIN_2
  794. * @arg @ref LL_GPIO_PIN_3
  795. * @arg @ref LL_GPIO_PIN_4
  796. * @arg @ref LL_GPIO_PIN_5
  797. * @arg @ref LL_GPIO_PIN_6
  798. * @arg @ref LL_GPIO_PIN_7
  799. * @arg @ref LL_GPIO_PIN_8
  800. * @arg @ref LL_GPIO_PIN_9
  801. * @arg @ref LL_GPIO_PIN_10
  802. * @arg @ref LL_GPIO_PIN_11
  803. * @arg @ref LL_GPIO_PIN_12
  804. * @arg @ref LL_GPIO_PIN_13
  805. * @arg @ref LL_GPIO_PIN_14
  806. * @arg @ref LL_GPIO_PIN_15
  807. * @arg @ref LL_GPIO_PIN_ALL
  808. * @retval State of bit (1 or 0).
  809. */
  810. __STATIC_INLINE uint32_t LL_GPIO_IsPinLocked(GPIO_TypeDef *GPIOx, uint32_t PinMask)
  811. {
  812. return (READ_BIT(GPIOx->LCKR, PinMask) == (PinMask));
  813. }
  814. /**
  815. * @brief Return 1 if one of the pin of a dedicated port is locked. else return 0.
  816. * @rmtoll LCKR LCKK LL_GPIO_IsAnyPinLocked
  817. * @param GPIOx GPIO Port
  818. * @retval State of bit (1 or 0).
  819. */
  820. __STATIC_INLINE uint32_t LL_GPIO_IsAnyPinLocked(GPIO_TypeDef *GPIOx)
  821. {
  822. return (READ_BIT(GPIOx->LCKR, LL_GPIO_LCKR_LCKK) != 0U);
  823. }
  824. /**
  825. * @}
  826. */
  827. /** @defgroup GPIO_LL_EF_Data_Access Data Access
  828. * @{
  829. */
  830. /**
  831. * @brief Return full input data register value for a dedicated port.
  832. * @rmtoll IDR IDy LL_GPIO_ReadInputPort
  833. * @param GPIOx GPIO Port
  834. * @retval Input data register value of port
  835. */
  836. __STATIC_INLINE uint32_t LL_GPIO_ReadInputPort(GPIO_TypeDef *GPIOx)
  837. {
  838. return (uint32_t)(READ_REG(GPIOx->IDR));
  839. }
  840. /**
  841. * @brief Return if input data level for several pins of dedicated port is high or low.
  842. * @rmtoll IDR IDy LL_GPIO_IsInputPinSet
  843. * @param GPIOx GPIO Port
  844. * @param PinMask This parameter can be a combination of the following values:
  845. * @arg @ref LL_GPIO_PIN_0
  846. * @arg @ref LL_GPIO_PIN_1
  847. * @arg @ref LL_GPIO_PIN_2
  848. * @arg @ref LL_GPIO_PIN_3
  849. * @arg @ref LL_GPIO_PIN_4
  850. * @arg @ref LL_GPIO_PIN_5
  851. * @arg @ref LL_GPIO_PIN_6
  852. * @arg @ref LL_GPIO_PIN_7
  853. * @arg @ref LL_GPIO_PIN_8
  854. * @arg @ref LL_GPIO_PIN_9
  855. * @arg @ref LL_GPIO_PIN_10
  856. * @arg @ref LL_GPIO_PIN_11
  857. * @arg @ref LL_GPIO_PIN_12
  858. * @arg @ref LL_GPIO_PIN_13
  859. * @arg @ref LL_GPIO_PIN_14
  860. * @arg @ref LL_GPIO_PIN_15
  861. * @arg @ref LL_GPIO_PIN_ALL
  862. * @retval State of bit (1 or 0).
  863. */
  864. __STATIC_INLINE uint32_t LL_GPIO_IsInputPinSet(GPIO_TypeDef *GPIOx, uint32_t PinMask)
  865. {
  866. return (READ_BIT(GPIOx->IDR, PinMask) == (PinMask));
  867. }
  868. /**
  869. * @brief Write output data register for the port.
  870. * @rmtoll ODR ODy LL_GPIO_WriteOutputPort
  871. * @param GPIOx GPIO Port
  872. * @param PortValue Level value for each pin of the port
  873. * @retval None
  874. */
  875. __STATIC_INLINE void LL_GPIO_WriteOutputPort(GPIO_TypeDef *GPIOx, uint32_t PortValue)
  876. {
  877. WRITE_REG(GPIOx->ODR, PortValue);
  878. }
  879. /**
  880. * @brief Return full output data register value for a dedicated port.
  881. * @rmtoll ODR ODy LL_GPIO_ReadOutputPort
  882. * @param GPIOx GPIO Port
  883. * @retval Output data register value of port
  884. */
  885. __STATIC_INLINE uint32_t LL_GPIO_ReadOutputPort(GPIO_TypeDef *GPIOx)
  886. {
  887. return (uint32_t)(READ_REG(GPIOx->ODR));
  888. }
  889. /**
  890. * @brief Return if input data level for several pins of dedicated port is high or low.
  891. * @rmtoll ODR ODy LL_GPIO_IsOutputPinSet
  892. * @param GPIOx GPIO Port
  893. * @param PinMask This parameter can be a combination of the following values:
  894. * @arg @ref LL_GPIO_PIN_0
  895. * @arg @ref LL_GPIO_PIN_1
  896. * @arg @ref LL_GPIO_PIN_2
  897. * @arg @ref LL_GPIO_PIN_3
  898. * @arg @ref LL_GPIO_PIN_4
  899. * @arg @ref LL_GPIO_PIN_5
  900. * @arg @ref LL_GPIO_PIN_6
  901. * @arg @ref LL_GPIO_PIN_7
  902. * @arg @ref LL_GPIO_PIN_8
  903. * @arg @ref LL_GPIO_PIN_9
  904. * @arg @ref LL_GPIO_PIN_10
  905. * @arg @ref LL_GPIO_PIN_11
  906. * @arg @ref LL_GPIO_PIN_12
  907. * @arg @ref LL_GPIO_PIN_13
  908. * @arg @ref LL_GPIO_PIN_14
  909. * @arg @ref LL_GPIO_PIN_15
  910. * @arg @ref LL_GPIO_PIN_ALL
  911. * @retval State of bit (1 or 0).
  912. */
  913. __STATIC_INLINE uint32_t LL_GPIO_IsOutputPinSet(GPIO_TypeDef *GPIOx, uint32_t PinMask)
  914. {
  915. return (READ_BIT(GPIOx->ODR, PinMask) == (PinMask));
  916. }
  917. /**
  918. * @brief Set several pins to high level on dedicated gpio port.
  919. * @rmtoll BSRR BSy LL_GPIO_SetOutputPin
  920. * @param GPIOx GPIO Port
  921. * @param PinMask This parameter can be a combination of the following values:
  922. * @arg @ref LL_GPIO_PIN_0
  923. * @arg @ref LL_GPIO_PIN_1
  924. * @arg @ref LL_GPIO_PIN_2
  925. * @arg @ref LL_GPIO_PIN_3
  926. * @arg @ref LL_GPIO_PIN_4
  927. * @arg @ref LL_GPIO_PIN_5
  928. * @arg @ref LL_GPIO_PIN_6
  929. * @arg @ref LL_GPIO_PIN_7
  930. * @arg @ref LL_GPIO_PIN_8
  931. * @arg @ref LL_GPIO_PIN_9
  932. * @arg @ref LL_GPIO_PIN_10
  933. * @arg @ref LL_GPIO_PIN_11
  934. * @arg @ref LL_GPIO_PIN_12
  935. * @arg @ref LL_GPIO_PIN_13
  936. * @arg @ref LL_GPIO_PIN_14
  937. * @arg @ref LL_GPIO_PIN_15
  938. * @arg @ref LL_GPIO_PIN_ALL
  939. * @retval None
  940. */
  941. __STATIC_INLINE void LL_GPIO_SetOutputPin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
  942. {
  943. WRITE_REG(GPIOx->BSRR, PinMask);
  944. }
  945. /**
  946. * @brief Set several pins to low level on dedicated gpio port.
  947. * @rmtoll BRR BRy LL_GPIO_ResetOutputPin
  948. * @param GPIOx GPIO Port
  949. * @param PinMask This parameter can be a combination of the following values:
  950. * @arg @ref LL_GPIO_PIN_0
  951. * @arg @ref LL_GPIO_PIN_1
  952. * @arg @ref LL_GPIO_PIN_2
  953. * @arg @ref LL_GPIO_PIN_3
  954. * @arg @ref LL_GPIO_PIN_4
  955. * @arg @ref LL_GPIO_PIN_5
  956. * @arg @ref LL_GPIO_PIN_6
  957. * @arg @ref LL_GPIO_PIN_7
  958. * @arg @ref LL_GPIO_PIN_8
  959. * @arg @ref LL_GPIO_PIN_9
  960. * @arg @ref LL_GPIO_PIN_10
  961. * @arg @ref LL_GPIO_PIN_11
  962. * @arg @ref LL_GPIO_PIN_12
  963. * @arg @ref LL_GPIO_PIN_13
  964. * @arg @ref LL_GPIO_PIN_14
  965. * @arg @ref LL_GPIO_PIN_15
  966. * @arg @ref LL_GPIO_PIN_ALL
  967. * @retval None
  968. */
  969. __STATIC_INLINE void LL_GPIO_ResetOutputPin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
  970. {
  971. WRITE_REG(GPIOx->BRR, PinMask);
  972. }
  973. /**
  974. * @brief Toggle data value for several pin of dedicated port.
  975. * @rmtoll ODR ODy LL_GPIO_TogglePin
  976. * @param GPIOx GPIO Port
  977. * @param PinMask This parameter can be a combination of the following values:
  978. * @arg @ref LL_GPIO_PIN_0
  979. * @arg @ref LL_GPIO_PIN_1
  980. * @arg @ref LL_GPIO_PIN_2
  981. * @arg @ref LL_GPIO_PIN_3
  982. * @arg @ref LL_GPIO_PIN_4
  983. * @arg @ref LL_GPIO_PIN_5
  984. * @arg @ref LL_GPIO_PIN_6
  985. * @arg @ref LL_GPIO_PIN_7
  986. * @arg @ref LL_GPIO_PIN_8
  987. * @arg @ref LL_GPIO_PIN_9
  988. * @arg @ref LL_GPIO_PIN_10
  989. * @arg @ref LL_GPIO_PIN_11
  990. * @arg @ref LL_GPIO_PIN_12
  991. * @arg @ref LL_GPIO_PIN_13
  992. * @arg @ref LL_GPIO_PIN_14
  993. * @arg @ref LL_GPIO_PIN_15
  994. * @arg @ref LL_GPIO_PIN_ALL
  995. * @retval None
  996. */
  997. __STATIC_INLINE void LL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
  998. {
  999. WRITE_REG(GPIOx->ODR, READ_REG(GPIOx->ODR) ^ PinMask);
  1000. }
  1001. /**
  1002. * @}
  1003. */
  1004. #if defined(USE_FULL_LL_DRIVER)
  1005. /** @defgroup GPIO_LL_EF_Init Initialization and de-initialization functions
  1006. * @{
  1007. */
  1008. ErrorStatus LL_GPIO_DeInit(GPIO_TypeDef *GPIOx);
  1009. ErrorStatus LL_GPIO_Init(GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct);
  1010. void LL_GPIO_StructInit(LL_GPIO_InitTypeDef *GPIO_InitStruct);
  1011. /**
  1012. * @}
  1013. */
  1014. #endif /* USE_FULL_LL_DRIVER */
  1015. /**
  1016. * @}
  1017. */
  1018. /**
  1019. * @}
  1020. */
  1021. #endif /* defined (GPIOA) || defined (GPIOB) || defined (GPIOF) */
  1022. /**
  1023. * @}
  1024. */
  1025. #ifdef __cplusplus
  1026. }
  1027. #endif
  1028. #endif /* __PY32F0xx_LL_GPIO_H */
  1029. /************************ (C) COPYRIGHT Puya *****END OF FILE****/