stm32f4xx_ll_gpio.h 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_ll_gpio.h
  4. * @author MCD Application Team
  5. * @brief Header file of GPIO LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32F4xx_LL_GPIO_H
  37. #define __STM32F4xx_LL_GPIO_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32f4xx.h"
  43. /** @addtogroup STM32F4xx_LL_Driver
  44. * @{
  45. */
  46. #if defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOF) || defined (GPIOG) || defined (GPIOH) || defined (GPIOI) || defined (GPIOJ) || defined (GPIOK)
  47. /** @defgroup GPIO_LL GPIO
  48. * @{
  49. */
  50. /* Private types -------------------------------------------------------------*/
  51. /* Private variables ---------------------------------------------------------*/
  52. /* Private constants ---------------------------------------------------------*/
  53. /* Private macros ------------------------------------------------------------*/
  54. #if defined(USE_FULL_LL_DRIVER)
  55. /** @defgroup GPIO_LL_Private_Macros GPIO Private Macros
  56. * @{
  57. */
  58. /**
  59. * @}
  60. */
  61. #endif /*USE_FULL_LL_DRIVER*/
  62. /* Exported types ------------------------------------------------------------*/
  63. #if defined(USE_FULL_LL_DRIVER)
  64. /** @defgroup GPIO_LL_ES_INIT GPIO Exported Init structures
  65. * @{
  66. */
  67. /**
  68. * @brief LL GPIO Init Structure definition
  69. */
  70. typedef struct
  71. {
  72. uint32_t Pin; /*!< Specifies the GPIO pins to be configured.
  73. This parameter can be any value of @ref GPIO_LL_EC_PIN */
  74. uint32_t Mode; /*!< Specifies the operating mode for the selected pins.
  75. This parameter can be a value of @ref GPIO_LL_EC_MODE.
  76. GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinMode().*/
  77. uint32_t Speed; /*!< Specifies the speed for the selected pins.
  78. This parameter can be a value of @ref GPIO_LL_EC_SPEED.
  79. GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinSpeed().*/
  80. uint32_t OutputType; /*!< Specifies the operating output type for the selected pins.
  81. This parameter can be a value of @ref GPIO_LL_EC_OUTPUT.
  82. GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinOutputType().*/
  83. uint32_t Pull; /*!< Specifies the operating Pull-up/Pull down for the selected pins.
  84. This parameter can be a value of @ref GPIO_LL_EC_PULL.
  85. GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinPull().*/
  86. uint32_t Alternate; /*!< Specifies the Peripheral to be connected to the selected pins.
  87. This parameter can be a value of @ref GPIO_LL_EC_AF.
  88. GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetAFPin_0_7() and LL_GPIO_SetAFPin_8_15().*/
  89. } LL_GPIO_InitTypeDef;
  90. /**
  91. * @}
  92. */
  93. #endif /* USE_FULL_LL_DRIVER */
  94. /* Exported constants --------------------------------------------------------*/
  95. /** @defgroup GPIO_LL_Exported_Constants GPIO Exported Constants
  96. * @{
  97. */
  98. /** @defgroup GPIO_LL_EC_PIN PIN
  99. * @{
  100. */
  101. #define LL_GPIO_PIN_0 GPIO_BSRR_BS_0 /*!< Select pin 0 */
  102. #define LL_GPIO_PIN_1 GPIO_BSRR_BS_1 /*!< Select pin 1 */
  103. #define LL_GPIO_PIN_2 GPIO_BSRR_BS_2 /*!< Select pin 2 */
  104. #define LL_GPIO_PIN_3 GPIO_BSRR_BS_3 /*!< Select pin 3 */
  105. #define LL_GPIO_PIN_4 GPIO_BSRR_BS_4 /*!< Select pin 4 */
  106. #define LL_GPIO_PIN_5 GPIO_BSRR_BS_5 /*!< Select pin 5 */
  107. #define LL_GPIO_PIN_6 GPIO_BSRR_BS_6 /*!< Select pin 6 */
  108. #define LL_GPIO_PIN_7 GPIO_BSRR_BS_7 /*!< Select pin 7 */
  109. #define LL_GPIO_PIN_8 GPIO_BSRR_BS_8 /*!< Select pin 8 */
  110. #define LL_GPIO_PIN_9 GPIO_BSRR_BS_9 /*!< Select pin 9 */
  111. #define LL_GPIO_PIN_10 GPIO_BSRR_BS_10 /*!< Select pin 10 */
  112. #define LL_GPIO_PIN_11 GPIO_BSRR_BS_11 /*!< Select pin 11 */
  113. #define LL_GPIO_PIN_12 GPIO_BSRR_BS_12 /*!< Select pin 12 */
  114. #define LL_GPIO_PIN_13 GPIO_BSRR_BS_13 /*!< Select pin 13 */
  115. #define LL_GPIO_PIN_14 GPIO_BSRR_BS_14 /*!< Select pin 14 */
  116. #define LL_GPIO_PIN_15 GPIO_BSRR_BS_15 /*!< Select pin 15 */
  117. #define LL_GPIO_PIN_ALL (GPIO_BSRR_BS_0 | GPIO_BSRR_BS_1 | GPIO_BSRR_BS_2 | \
  118. GPIO_BSRR_BS_3 | GPIO_BSRR_BS_4 | GPIO_BSRR_BS_5 | \
  119. GPIO_BSRR_BS_6 | GPIO_BSRR_BS_7 | GPIO_BSRR_BS_8 | \
  120. GPIO_BSRR_BS_9 | GPIO_BSRR_BS_10 | GPIO_BSRR_BS_11 | \
  121. GPIO_BSRR_BS_12 | GPIO_BSRR_BS_13 | GPIO_BSRR_BS_14 | \
  122. GPIO_BSRR_BS_15) /*!< Select all pins */
  123. /**
  124. * @}
  125. */
  126. /** @defgroup GPIO_LL_EC_MODE Mode
  127. * @{
  128. */
  129. #define LL_GPIO_MODE_INPUT (0x00000000U) /*!< Select input mode */
  130. #define LL_GPIO_MODE_OUTPUT GPIO_MODER_MODER0_0 /*!< Select output mode */
  131. #define LL_GPIO_MODE_ALTERNATE GPIO_MODER_MODER0_1 /*!< Select alternate function mode */
  132. #define LL_GPIO_MODE_ANALOG GPIO_MODER_MODER0 /*!< Select analog mode */
  133. /**
  134. * @}
  135. */
  136. /** @defgroup GPIO_LL_EC_OUTPUT Output Type
  137. * @{
  138. */
  139. #define LL_GPIO_OUTPUT_PUSHPULL (0x00000000U) /*!< Select push-pull as output type */
  140. #define LL_GPIO_OUTPUT_OPENDRAIN GPIO_OTYPER_OT_0 /*!< Select open-drain as output type */
  141. /**
  142. * @}
  143. */
  144. /** @defgroup GPIO_LL_EC_SPEED Output Speed
  145. * @{
  146. */
  147. #define LL_GPIO_SPEED_FREQ_LOW (0x00000000U) /*!< Select I/O low output speed */
  148. #define LL_GPIO_SPEED_FREQ_MEDIUM GPIO_OSPEEDER_OSPEEDR0_0 /*!< Select I/O medium output speed */
  149. #define LL_GPIO_SPEED_FREQ_HIGH GPIO_OSPEEDER_OSPEEDR0_1 /*!< Select I/O fast output speed */
  150. #define LL_GPIO_SPEED_FREQ_VERY_HIGH GPIO_OSPEEDER_OSPEEDR0 /*!< Select I/O high output speed */
  151. /**
  152. * @}
  153. */
  154. /** @defgroup GPIO_LL_EC_PULL Pull Up Pull Down
  155. * @{
  156. */
  157. #define LL_GPIO_PULL_NO (0x00000000U) /*!< Select I/O no pull */
  158. #define LL_GPIO_PULL_UP GPIO_PUPDR_PUPDR0_0 /*!< Select I/O pull up */
  159. #define LL_GPIO_PULL_DOWN GPIO_PUPDR_PUPDR0_1 /*!< Select I/O pull down */
  160. /**
  161. * @}
  162. */
  163. /** @defgroup GPIO_LL_EC_AF Alternate Function
  164. * @{
  165. */
  166. #define LL_GPIO_AF_0 (0x0000000U) /*!< Select alternate function 0 */
  167. #define LL_GPIO_AF_1 (0x0000001U) /*!< Select alternate function 1 */
  168. #define LL_GPIO_AF_2 (0x0000002U) /*!< Select alternate function 2 */
  169. #define LL_GPIO_AF_3 (0x0000003U) /*!< Select alternate function 3 */
  170. #define LL_GPIO_AF_4 (0x0000004U) /*!< Select alternate function 4 */
  171. #define LL_GPIO_AF_5 (0x0000005U) /*!< Select alternate function 5 */
  172. #define LL_GPIO_AF_6 (0x0000006U) /*!< Select alternate function 6 */
  173. #define LL_GPIO_AF_7 (0x0000007U) /*!< Select alternate function 7 */
  174. #define LL_GPIO_AF_8 (0x0000008U) /*!< Select alternate function 8 */
  175. #define LL_GPIO_AF_9 (0x0000009U) /*!< Select alternate function 9 */
  176. #define LL_GPIO_AF_10 (0x000000AU) /*!< Select alternate function 10 */
  177. #define LL_GPIO_AF_11 (0x000000BU) /*!< Select alternate function 11 */
  178. #define LL_GPIO_AF_12 (0x000000CU) /*!< Select alternate function 12 */
  179. #define LL_GPIO_AF_13 (0x000000DU) /*!< Select alternate function 13 */
  180. #define LL_GPIO_AF_14 (0x000000EU) /*!< Select alternate function 14 */
  181. #define LL_GPIO_AF_15 (0x000000FU) /*!< Select alternate function 15 */
  182. /**
  183. * @}
  184. */
  185. /**
  186. * @}
  187. */
  188. /* Exported macro ------------------------------------------------------------*/
  189. /** @defgroup GPIO_LL_Exported_Macros GPIO Exported Macros
  190. * @{
  191. */
  192. /** @defgroup GPIO_LL_EM_WRITE_READ Common Write and read registers Macros
  193. * @{
  194. */
  195. /**
  196. * @brief Write a value in GPIO register
  197. * @param __INSTANCE__ GPIO Instance
  198. * @param __REG__ Register to be written
  199. * @param __VALUE__ Value to be written in the register
  200. * @retval None
  201. */
  202. #define LL_GPIO_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  203. /**
  204. * @brief Read a value in GPIO register
  205. * @param __INSTANCE__ GPIO Instance
  206. * @param __REG__ Register to be read
  207. * @retval Register value
  208. */
  209. #define LL_GPIO_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  210. /**
  211. * @}
  212. */
  213. /**
  214. * @}
  215. */
  216. /* Exported functions --------------------------------------------------------*/
  217. /** @defgroup GPIO_LL_Exported_Functions GPIO Exported Functions
  218. * @{
  219. */
  220. /** @defgroup GPIO_LL_EF_Port_Configuration Port Configuration
  221. * @{
  222. */
  223. /**
  224. * @brief Configure gpio mode for a dedicated pin on dedicated port.
  225. * @note I/O mode can be Input mode, General purpose output, Alternate function mode or Analog.
  226. * @note Warning: only one pin can be passed as parameter.
  227. * @rmtoll MODER MODEy LL_GPIO_SetPinMode
  228. * @param GPIOx GPIO Port
  229. * @param Pin This parameter can be one of the following values:
  230. * @arg @ref LL_GPIO_PIN_0
  231. * @arg @ref LL_GPIO_PIN_1
  232. * @arg @ref LL_GPIO_PIN_2
  233. * @arg @ref LL_GPIO_PIN_3
  234. * @arg @ref LL_GPIO_PIN_4
  235. * @arg @ref LL_GPIO_PIN_5
  236. * @arg @ref LL_GPIO_PIN_6
  237. * @arg @ref LL_GPIO_PIN_7
  238. * @arg @ref LL_GPIO_PIN_8
  239. * @arg @ref LL_GPIO_PIN_9
  240. * @arg @ref LL_GPIO_PIN_10
  241. * @arg @ref LL_GPIO_PIN_11
  242. * @arg @ref LL_GPIO_PIN_12
  243. * @arg @ref LL_GPIO_PIN_13
  244. * @arg @ref LL_GPIO_PIN_14
  245. * @arg @ref LL_GPIO_PIN_15
  246. * @param Mode This parameter can be one of the following values:
  247. * @arg @ref LL_GPIO_MODE_INPUT
  248. * @arg @ref LL_GPIO_MODE_OUTPUT
  249. * @arg @ref LL_GPIO_MODE_ALTERNATE
  250. * @arg @ref LL_GPIO_MODE_ANALOG
  251. * @retval None
  252. */
  253. __STATIC_INLINE void LL_GPIO_SetPinMode(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Mode)
  254. {
  255. MODIFY_REG(GPIOx->MODER, (GPIO_MODER_MODER0 << (POSITION_VAL(Pin) * 2U)), (Mode << (POSITION_VAL(Pin) * 2U)));
  256. }
  257. /**
  258. * @brief Return gpio mode for a dedicated pin on dedicated port.
  259. * @note I/O mode can be Input mode, General purpose output, Alternate function mode or Analog.
  260. * @note Warning: only one pin can be passed as parameter.
  261. * @rmtoll MODER MODEy LL_GPIO_GetPinMode
  262. * @param GPIOx GPIO Port
  263. * @param Pin This parameter can be one of the following values:
  264. * @arg @ref LL_GPIO_PIN_0
  265. * @arg @ref LL_GPIO_PIN_1
  266. * @arg @ref LL_GPIO_PIN_2
  267. * @arg @ref LL_GPIO_PIN_3
  268. * @arg @ref LL_GPIO_PIN_4
  269. * @arg @ref LL_GPIO_PIN_5
  270. * @arg @ref LL_GPIO_PIN_6
  271. * @arg @ref LL_GPIO_PIN_7
  272. * @arg @ref LL_GPIO_PIN_8
  273. * @arg @ref LL_GPIO_PIN_9
  274. * @arg @ref LL_GPIO_PIN_10
  275. * @arg @ref LL_GPIO_PIN_11
  276. * @arg @ref LL_GPIO_PIN_12
  277. * @arg @ref LL_GPIO_PIN_13
  278. * @arg @ref LL_GPIO_PIN_14
  279. * @arg @ref LL_GPIO_PIN_15
  280. * @retval Returned value can be one of the following values:
  281. * @arg @ref LL_GPIO_MODE_INPUT
  282. * @arg @ref LL_GPIO_MODE_OUTPUT
  283. * @arg @ref LL_GPIO_MODE_ALTERNATE
  284. * @arg @ref LL_GPIO_MODE_ANALOG
  285. */
  286. __STATIC_INLINE uint32_t LL_GPIO_GetPinMode(GPIO_TypeDef *GPIOx, uint32_t Pin)
  287. {
  288. return (uint32_t)(READ_BIT(GPIOx->MODER,
  289. (GPIO_MODER_MODER0 << (POSITION_VAL(Pin) * 2U))) >> (POSITION_VAL(Pin) * 2U));
  290. }
  291. /**
  292. * @brief Configure gpio output type for several pins on dedicated port.
  293. * @note Output type as to be set when gpio pin is in output or
  294. * alternate modes. Possible type are Push-pull or Open-drain.
  295. * @rmtoll OTYPER OTy LL_GPIO_SetPinOutputType
  296. * @param GPIOx GPIO Port
  297. * @param PinMask This parameter can be a combination of the following values:
  298. * @arg @ref LL_GPIO_PIN_0
  299. * @arg @ref LL_GPIO_PIN_1
  300. * @arg @ref LL_GPIO_PIN_2
  301. * @arg @ref LL_GPIO_PIN_3
  302. * @arg @ref LL_GPIO_PIN_4
  303. * @arg @ref LL_GPIO_PIN_5
  304. * @arg @ref LL_GPIO_PIN_6
  305. * @arg @ref LL_GPIO_PIN_7
  306. * @arg @ref LL_GPIO_PIN_8
  307. * @arg @ref LL_GPIO_PIN_9
  308. * @arg @ref LL_GPIO_PIN_10
  309. * @arg @ref LL_GPIO_PIN_11
  310. * @arg @ref LL_GPIO_PIN_12
  311. * @arg @ref LL_GPIO_PIN_13
  312. * @arg @ref LL_GPIO_PIN_14
  313. * @arg @ref LL_GPIO_PIN_15
  314. * @arg @ref LL_GPIO_PIN_ALL
  315. * @param OutputType This parameter can be one of the following values:
  316. * @arg @ref LL_GPIO_OUTPUT_PUSHPULL
  317. * @arg @ref LL_GPIO_OUTPUT_OPENDRAIN
  318. * @retval None
  319. */
  320. __STATIC_INLINE void LL_GPIO_SetPinOutputType(GPIO_TypeDef *GPIOx, uint32_t PinMask, uint32_t OutputType)
  321. {
  322. MODIFY_REG(GPIOx->OTYPER, PinMask, (PinMask * OutputType));
  323. }
  324. /**
  325. * @brief Return gpio output type for several pins on dedicated port.
  326. * @note Output type as to be set when gpio pin is in output or
  327. * alternate modes. Possible type are Push-pull or Open-drain.
  328. * @note Warning: only one pin can be passed as parameter.
  329. * @rmtoll OTYPER OTy LL_GPIO_GetPinOutputType
  330. * @param GPIOx GPIO Port
  331. * @param Pin This parameter can be one of the following values:
  332. * @arg @ref LL_GPIO_PIN_0
  333. * @arg @ref LL_GPIO_PIN_1
  334. * @arg @ref LL_GPIO_PIN_2
  335. * @arg @ref LL_GPIO_PIN_3
  336. * @arg @ref LL_GPIO_PIN_4
  337. * @arg @ref LL_GPIO_PIN_5
  338. * @arg @ref LL_GPIO_PIN_6
  339. * @arg @ref LL_GPIO_PIN_7
  340. * @arg @ref LL_GPIO_PIN_8
  341. * @arg @ref LL_GPIO_PIN_9
  342. * @arg @ref LL_GPIO_PIN_10
  343. * @arg @ref LL_GPIO_PIN_11
  344. * @arg @ref LL_GPIO_PIN_12
  345. * @arg @ref LL_GPIO_PIN_13
  346. * @arg @ref LL_GPIO_PIN_14
  347. * @arg @ref LL_GPIO_PIN_15
  348. * @arg @ref LL_GPIO_PIN_ALL
  349. * @retval Returned value can be one of the following values:
  350. * @arg @ref LL_GPIO_OUTPUT_PUSHPULL
  351. * @arg @ref LL_GPIO_OUTPUT_OPENDRAIN
  352. */
  353. __STATIC_INLINE uint32_t LL_GPIO_GetPinOutputType(GPIO_TypeDef *GPIOx, uint32_t Pin)
  354. {
  355. return (uint32_t)(READ_BIT(GPIOx->OTYPER, Pin) >> POSITION_VAL(Pin));
  356. }
  357. /**
  358. * @brief Configure gpio speed for a dedicated pin on dedicated port.
  359. * @note I/O speed can be Low, Medium, Fast or High speed.
  360. * @note Warning: only one pin can be passed as parameter.
  361. * @note Refer to datasheet for frequency specifications and the power
  362. * supply and load conditions for each speed.
  363. * @rmtoll OSPEEDR OSPEEDy LL_GPIO_SetPinSpeed
  364. * @param GPIOx GPIO Port
  365. * @param Pin This parameter can be one of the following values:
  366. * @arg @ref LL_GPIO_PIN_0
  367. * @arg @ref LL_GPIO_PIN_1
  368. * @arg @ref LL_GPIO_PIN_2
  369. * @arg @ref LL_GPIO_PIN_3
  370. * @arg @ref LL_GPIO_PIN_4
  371. * @arg @ref LL_GPIO_PIN_5
  372. * @arg @ref LL_GPIO_PIN_6
  373. * @arg @ref LL_GPIO_PIN_7
  374. * @arg @ref LL_GPIO_PIN_8
  375. * @arg @ref LL_GPIO_PIN_9
  376. * @arg @ref LL_GPIO_PIN_10
  377. * @arg @ref LL_GPIO_PIN_11
  378. * @arg @ref LL_GPIO_PIN_12
  379. * @arg @ref LL_GPIO_PIN_13
  380. * @arg @ref LL_GPIO_PIN_14
  381. * @arg @ref LL_GPIO_PIN_15
  382. * @param Speed This parameter can be one of the following values:
  383. * @arg @ref LL_GPIO_SPEED_FREQ_LOW
  384. * @arg @ref LL_GPIO_SPEED_FREQ_MEDIUM
  385. * @arg @ref LL_GPIO_SPEED_FREQ_HIGH
  386. * @arg @ref LL_GPIO_SPEED_FREQ_VERY_HIGH
  387. * @retval None
  388. */
  389. __STATIC_INLINE void LL_GPIO_SetPinSpeed(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Speed)
  390. {
  391. MODIFY_REG(GPIOx->OSPEEDR, (GPIO_OSPEEDER_OSPEEDR0 << (POSITION_VAL(Pin) * 2U)),
  392. (Speed << (POSITION_VAL(Pin) * 2U)));
  393. }
  394. /**
  395. * @brief Return gpio speed for a dedicated pin on dedicated port.
  396. * @note I/O speed can be Low, Medium, Fast or High speed.
  397. * @note Warning: only one pin can be passed as parameter.
  398. * @note Refer to datasheet for frequency specifications and the power
  399. * supply and load conditions for each speed.
  400. * @rmtoll OSPEEDR OSPEEDy LL_GPIO_GetPinSpeed
  401. * @param GPIOx GPIO Port
  402. * @param Pin This parameter can be one of the following values:
  403. * @arg @ref LL_GPIO_PIN_0
  404. * @arg @ref LL_GPIO_PIN_1
  405. * @arg @ref LL_GPIO_PIN_2
  406. * @arg @ref LL_GPIO_PIN_3
  407. * @arg @ref LL_GPIO_PIN_4
  408. * @arg @ref LL_GPIO_PIN_5
  409. * @arg @ref LL_GPIO_PIN_6
  410. * @arg @ref LL_GPIO_PIN_7
  411. * @arg @ref LL_GPIO_PIN_8
  412. * @arg @ref LL_GPIO_PIN_9
  413. * @arg @ref LL_GPIO_PIN_10
  414. * @arg @ref LL_GPIO_PIN_11
  415. * @arg @ref LL_GPIO_PIN_12
  416. * @arg @ref LL_GPIO_PIN_13
  417. * @arg @ref LL_GPIO_PIN_14
  418. * @arg @ref LL_GPIO_PIN_15
  419. * @retval Returned value can be one of the following values:
  420. * @arg @ref LL_GPIO_SPEED_FREQ_LOW
  421. * @arg @ref LL_GPIO_SPEED_FREQ_MEDIUM
  422. * @arg @ref LL_GPIO_SPEED_FREQ_HIGH
  423. * @arg @ref LL_GPIO_SPEED_FREQ_VERY_HIGH
  424. */
  425. __STATIC_INLINE uint32_t LL_GPIO_GetPinSpeed(GPIO_TypeDef *GPIOx, uint32_t Pin)
  426. {
  427. return (uint32_t)(READ_BIT(GPIOx->OSPEEDR,
  428. (GPIO_OSPEEDER_OSPEEDR0 << (POSITION_VAL(Pin) * 2U))) >> (POSITION_VAL(Pin) * 2U));
  429. }
  430. /**
  431. * @brief Configure gpio pull-up or pull-down for a dedicated pin on a dedicated port.
  432. * @note Warning: only one pin can be passed as parameter.
  433. * @rmtoll PUPDR PUPDy LL_GPIO_SetPinPull
  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. * @param Pull This parameter can be one of the following values:
  453. * @arg @ref LL_GPIO_PULL_NO
  454. * @arg @ref LL_GPIO_PULL_UP
  455. * @arg @ref LL_GPIO_PULL_DOWN
  456. * @retval None
  457. */
  458. __STATIC_INLINE void LL_GPIO_SetPinPull(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Pull)
  459. {
  460. MODIFY_REG(GPIOx->PUPDR, (GPIO_PUPDR_PUPDR0 << (POSITION_VAL(Pin) * 2U)), (Pull << (POSITION_VAL(Pin) * 2U)));
  461. }
  462. /**
  463. * @brief Return gpio pull-up or pull-down for a dedicated pin on a dedicated port
  464. * @note Warning: only one pin can be passed as parameter.
  465. * @rmtoll PUPDR PUPDy LL_GPIO_GetPinPull
  466. * @param GPIOx GPIO Port
  467. * @param Pin This parameter can be one of the following values:
  468. * @arg @ref LL_GPIO_PIN_0
  469. * @arg @ref LL_GPIO_PIN_1
  470. * @arg @ref LL_GPIO_PIN_2
  471. * @arg @ref LL_GPIO_PIN_3
  472. * @arg @ref LL_GPIO_PIN_4
  473. * @arg @ref LL_GPIO_PIN_5
  474. * @arg @ref LL_GPIO_PIN_6
  475. * @arg @ref LL_GPIO_PIN_7
  476. * @arg @ref LL_GPIO_PIN_8
  477. * @arg @ref LL_GPIO_PIN_9
  478. * @arg @ref LL_GPIO_PIN_10
  479. * @arg @ref LL_GPIO_PIN_11
  480. * @arg @ref LL_GPIO_PIN_12
  481. * @arg @ref LL_GPIO_PIN_13
  482. * @arg @ref LL_GPIO_PIN_14
  483. * @arg @ref LL_GPIO_PIN_15
  484. * @retval Returned value can be one of the following values:
  485. * @arg @ref LL_GPIO_PULL_NO
  486. * @arg @ref LL_GPIO_PULL_UP
  487. * @arg @ref LL_GPIO_PULL_DOWN
  488. */
  489. __STATIC_INLINE uint32_t LL_GPIO_GetPinPull(GPIO_TypeDef *GPIOx, uint32_t Pin)
  490. {
  491. return (uint32_t)(READ_BIT(GPIOx->PUPDR,
  492. (GPIO_PUPDR_PUPDR0 << (POSITION_VAL(Pin) * 2U))) >> (POSITION_VAL(Pin) * 2U));
  493. }
  494. /**
  495. * @brief Configure gpio alternate function of a dedicated pin from 0 to 7 for a dedicated port.
  496. * @note Possible values are from AF0 to AF15 depending on target.
  497. * @note Warning: only one pin can be passed as parameter.
  498. * @rmtoll AFRL AFSELy LL_GPIO_SetAFPin_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. * @param Alternate This parameter 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. * @arg @ref LL_GPIO_AF_8
  519. * @arg @ref LL_GPIO_AF_9
  520. * @arg @ref LL_GPIO_AF_10
  521. * @arg @ref LL_GPIO_AF_11
  522. * @arg @ref LL_GPIO_AF_12
  523. * @arg @ref LL_GPIO_AF_13
  524. * @arg @ref LL_GPIO_AF_14
  525. * @arg @ref LL_GPIO_AF_15
  526. * @retval None
  527. */
  528. __STATIC_INLINE void LL_GPIO_SetAFPin_0_7(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Alternate)
  529. {
  530. MODIFY_REG(GPIOx->AFR[0], (GPIO_AFRL_AFSEL0 << (POSITION_VAL(Pin) * 4U)),
  531. (Alternate << (POSITION_VAL(Pin) * 4U)));
  532. }
  533. /**
  534. * @brief Return gpio alternate function of a dedicated pin from 0 to 7 for a dedicated port.
  535. * @rmtoll AFRL AFSELy LL_GPIO_GetAFPin_0_7
  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. * @retval Returned value can be one of the following values:
  547. * @arg @ref LL_GPIO_AF_0
  548. * @arg @ref LL_GPIO_AF_1
  549. * @arg @ref LL_GPIO_AF_2
  550. * @arg @ref LL_GPIO_AF_3
  551. * @arg @ref LL_GPIO_AF_4
  552. * @arg @ref LL_GPIO_AF_5
  553. * @arg @ref LL_GPIO_AF_6
  554. * @arg @ref LL_GPIO_AF_7
  555. * @arg @ref LL_GPIO_AF_8
  556. * @arg @ref LL_GPIO_AF_9
  557. * @arg @ref LL_GPIO_AF_10
  558. * @arg @ref LL_GPIO_AF_11
  559. * @arg @ref LL_GPIO_AF_12
  560. * @arg @ref LL_GPIO_AF_13
  561. * @arg @ref LL_GPIO_AF_14
  562. * @arg @ref LL_GPIO_AF_15
  563. */
  564. __STATIC_INLINE uint32_t LL_GPIO_GetAFPin_0_7(GPIO_TypeDef *GPIOx, uint32_t Pin)
  565. {
  566. return (uint32_t)(READ_BIT(GPIOx->AFR[0],
  567. (GPIO_AFRL_AFSEL0 << (POSITION_VAL(Pin) * 4U))) >> (POSITION_VAL(Pin) * 4U));
  568. }
  569. /**
  570. * @brief Configure gpio alternate function of a dedicated pin from 8 to 15 for a dedicated port.
  571. * @note Possible values are from AF0 to AF15 depending on target.
  572. * @note Warning: only one pin can be passed as parameter.
  573. * @rmtoll AFRH AFSELy LL_GPIO_SetAFPin_8_15
  574. * @param GPIOx GPIO Port
  575. * @param Pin This parameter can be one of the following values:
  576. * @arg @ref LL_GPIO_PIN_8
  577. * @arg @ref LL_GPIO_PIN_9
  578. * @arg @ref LL_GPIO_PIN_10
  579. * @arg @ref LL_GPIO_PIN_11
  580. * @arg @ref LL_GPIO_PIN_12
  581. * @arg @ref LL_GPIO_PIN_13
  582. * @arg @ref LL_GPIO_PIN_14
  583. * @arg @ref LL_GPIO_PIN_15
  584. * @param Alternate This parameter can be one of the following values:
  585. * @arg @ref LL_GPIO_AF_0
  586. * @arg @ref LL_GPIO_AF_1
  587. * @arg @ref LL_GPIO_AF_2
  588. * @arg @ref LL_GPIO_AF_3
  589. * @arg @ref LL_GPIO_AF_4
  590. * @arg @ref LL_GPIO_AF_5
  591. * @arg @ref LL_GPIO_AF_6
  592. * @arg @ref LL_GPIO_AF_7
  593. * @arg @ref LL_GPIO_AF_8
  594. * @arg @ref LL_GPIO_AF_9
  595. * @arg @ref LL_GPIO_AF_10
  596. * @arg @ref LL_GPIO_AF_11
  597. * @arg @ref LL_GPIO_AF_12
  598. * @arg @ref LL_GPIO_AF_13
  599. * @arg @ref LL_GPIO_AF_14
  600. * @arg @ref LL_GPIO_AF_15
  601. * @retval None
  602. */
  603. __STATIC_INLINE void LL_GPIO_SetAFPin_8_15(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Alternate)
  604. {
  605. MODIFY_REG(GPIOx->AFR[1], (GPIO_AFRH_AFSEL8 << (POSITION_VAL(Pin >> 8U) * 4U)),
  606. (Alternate << (POSITION_VAL(Pin >> 8U) * 4U)));
  607. }
  608. /**
  609. * @brief Return gpio alternate function of a dedicated pin from 8 to 15 for a dedicated port.
  610. * @note Possible values are from AF0 to AF15 depending on target.
  611. * @rmtoll AFRH AFSELy LL_GPIO_GetAFPin_8_15
  612. * @param GPIOx GPIO Port
  613. * @param Pin This parameter can be one of the following values:
  614. * @arg @ref LL_GPIO_PIN_8
  615. * @arg @ref LL_GPIO_PIN_9
  616. * @arg @ref LL_GPIO_PIN_10
  617. * @arg @ref LL_GPIO_PIN_11
  618. * @arg @ref LL_GPIO_PIN_12
  619. * @arg @ref LL_GPIO_PIN_13
  620. * @arg @ref LL_GPIO_PIN_14
  621. * @arg @ref LL_GPIO_PIN_15
  622. * @retval Returned value can be one of the following values:
  623. * @arg @ref LL_GPIO_AF_0
  624. * @arg @ref LL_GPIO_AF_1
  625. * @arg @ref LL_GPIO_AF_2
  626. * @arg @ref LL_GPIO_AF_3
  627. * @arg @ref LL_GPIO_AF_4
  628. * @arg @ref LL_GPIO_AF_5
  629. * @arg @ref LL_GPIO_AF_6
  630. * @arg @ref LL_GPIO_AF_7
  631. * @arg @ref LL_GPIO_AF_8
  632. * @arg @ref LL_GPIO_AF_9
  633. * @arg @ref LL_GPIO_AF_10
  634. * @arg @ref LL_GPIO_AF_11
  635. * @arg @ref LL_GPIO_AF_12
  636. * @arg @ref LL_GPIO_AF_13
  637. * @arg @ref LL_GPIO_AF_14
  638. * @arg @ref LL_GPIO_AF_15
  639. */
  640. __STATIC_INLINE uint32_t LL_GPIO_GetAFPin_8_15(GPIO_TypeDef *GPIOx, uint32_t Pin)
  641. {
  642. return (uint32_t)(READ_BIT(GPIOx->AFR[1],
  643. (GPIO_AFRH_AFSEL8 << (POSITION_VAL(Pin >> 8U) * 4U))) >> (POSITION_VAL(Pin >> 8U) * 4U));
  644. }
  645. /**
  646. * @brief Lock configuration of several pins for a dedicated port.
  647. * @note When the lock sequence has been applied on a port bit, the
  648. * value of this port bit can no longer be modified until the
  649. * next reset.
  650. * @note Each lock bit freezes a specific configuration register
  651. * (control and alternate function registers).
  652. * @rmtoll LCKR LCKK LL_GPIO_LockPin
  653. * @param GPIOx GPIO Port
  654. * @param PinMask This parameter can be a combination of the following values:
  655. * @arg @ref LL_GPIO_PIN_0
  656. * @arg @ref LL_GPIO_PIN_1
  657. * @arg @ref LL_GPIO_PIN_2
  658. * @arg @ref LL_GPIO_PIN_3
  659. * @arg @ref LL_GPIO_PIN_4
  660. * @arg @ref LL_GPIO_PIN_5
  661. * @arg @ref LL_GPIO_PIN_6
  662. * @arg @ref LL_GPIO_PIN_7
  663. * @arg @ref LL_GPIO_PIN_8
  664. * @arg @ref LL_GPIO_PIN_9
  665. * @arg @ref LL_GPIO_PIN_10
  666. * @arg @ref LL_GPIO_PIN_11
  667. * @arg @ref LL_GPIO_PIN_12
  668. * @arg @ref LL_GPIO_PIN_13
  669. * @arg @ref LL_GPIO_PIN_14
  670. * @arg @ref LL_GPIO_PIN_15
  671. * @arg @ref LL_GPIO_PIN_ALL
  672. * @retval None
  673. */
  674. __STATIC_INLINE void LL_GPIO_LockPin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
  675. {
  676. __IO uint32_t temp;
  677. WRITE_REG(GPIOx->LCKR, GPIO_LCKR_LCKK | PinMask);
  678. WRITE_REG(GPIOx->LCKR, PinMask);
  679. WRITE_REG(GPIOx->LCKR, GPIO_LCKR_LCKK | PinMask);
  680. temp = READ_REG(GPIOx->LCKR);
  681. (void) temp;
  682. }
  683. /**
  684. * @brief Return 1 if all pins passed as parameter, of a dedicated port, are locked. else Return 0.
  685. * @rmtoll LCKR LCKy LL_GPIO_IsPinLocked
  686. * @param GPIOx GPIO Port
  687. * @param PinMask This parameter can be a combination of the following values:
  688. * @arg @ref LL_GPIO_PIN_0
  689. * @arg @ref LL_GPIO_PIN_1
  690. * @arg @ref LL_GPIO_PIN_2
  691. * @arg @ref LL_GPIO_PIN_3
  692. * @arg @ref LL_GPIO_PIN_4
  693. * @arg @ref LL_GPIO_PIN_5
  694. * @arg @ref LL_GPIO_PIN_6
  695. * @arg @ref LL_GPIO_PIN_7
  696. * @arg @ref LL_GPIO_PIN_8
  697. * @arg @ref LL_GPIO_PIN_9
  698. * @arg @ref LL_GPIO_PIN_10
  699. * @arg @ref LL_GPIO_PIN_11
  700. * @arg @ref LL_GPIO_PIN_12
  701. * @arg @ref LL_GPIO_PIN_13
  702. * @arg @ref LL_GPIO_PIN_14
  703. * @arg @ref LL_GPIO_PIN_15
  704. * @arg @ref LL_GPIO_PIN_ALL
  705. * @retval State of bit (1 or 0).
  706. */
  707. __STATIC_INLINE uint32_t LL_GPIO_IsPinLocked(GPIO_TypeDef *GPIOx, uint32_t PinMask)
  708. {
  709. return (READ_BIT(GPIOx->LCKR, PinMask) == (PinMask));
  710. }
  711. /**
  712. * @brief Return 1 if one of the pin of a dedicated port is locked. else return 0.
  713. * @rmtoll LCKR LCKK LL_GPIO_IsAnyPinLocked
  714. * @param GPIOx GPIO Port
  715. * @retval State of bit (1 or 0).
  716. */
  717. __STATIC_INLINE uint32_t LL_GPIO_IsAnyPinLocked(GPIO_TypeDef *GPIOx)
  718. {
  719. return (READ_BIT(GPIOx->LCKR, GPIO_LCKR_LCKK) == (GPIO_LCKR_LCKK));
  720. }
  721. /**
  722. * @}
  723. */
  724. /** @defgroup GPIO_LL_EF_Data_Access Data Access
  725. * @{
  726. */
  727. /**
  728. * @brief Return full input data register value for a dedicated port.
  729. * @rmtoll IDR IDy LL_GPIO_ReadInputPort
  730. * @param GPIOx GPIO Port
  731. * @retval Input data register value of port
  732. */
  733. __STATIC_INLINE uint32_t LL_GPIO_ReadInputPort(GPIO_TypeDef *GPIOx)
  734. {
  735. return (uint32_t)(READ_REG(GPIOx->IDR));
  736. }
  737. /**
  738. * @brief Return if input data level for several pins of dedicated port is high or low.
  739. * @rmtoll IDR IDy LL_GPIO_IsInputPinSet
  740. * @param GPIOx GPIO Port
  741. * @param PinMask This parameter can be a combination of the following values:
  742. * @arg @ref LL_GPIO_PIN_0
  743. * @arg @ref LL_GPIO_PIN_1
  744. * @arg @ref LL_GPIO_PIN_2
  745. * @arg @ref LL_GPIO_PIN_3
  746. * @arg @ref LL_GPIO_PIN_4
  747. * @arg @ref LL_GPIO_PIN_5
  748. * @arg @ref LL_GPIO_PIN_6
  749. * @arg @ref LL_GPIO_PIN_7
  750. * @arg @ref LL_GPIO_PIN_8
  751. * @arg @ref LL_GPIO_PIN_9
  752. * @arg @ref LL_GPIO_PIN_10
  753. * @arg @ref LL_GPIO_PIN_11
  754. * @arg @ref LL_GPIO_PIN_12
  755. * @arg @ref LL_GPIO_PIN_13
  756. * @arg @ref LL_GPIO_PIN_14
  757. * @arg @ref LL_GPIO_PIN_15
  758. * @arg @ref LL_GPIO_PIN_ALL
  759. * @retval State of bit (1 or 0).
  760. */
  761. __STATIC_INLINE uint32_t LL_GPIO_IsInputPinSet(GPIO_TypeDef *GPIOx, uint32_t PinMask)
  762. {
  763. return (READ_BIT(GPIOx->IDR, PinMask) == (PinMask));
  764. }
  765. /**
  766. * @brief Write output data register for the port.
  767. * @rmtoll ODR ODy LL_GPIO_WriteOutputPort
  768. * @param GPIOx GPIO Port
  769. * @param PortValue Level value for each pin of the port
  770. * @retval None
  771. */
  772. __STATIC_INLINE void LL_GPIO_WriteOutputPort(GPIO_TypeDef *GPIOx, uint32_t PortValue)
  773. {
  774. WRITE_REG(GPIOx->ODR, PortValue);
  775. }
  776. /**
  777. * @brief Return full output data register value for a dedicated port.
  778. * @rmtoll ODR ODy LL_GPIO_ReadOutputPort
  779. * @param GPIOx GPIO Port
  780. * @retval Output data register value of port
  781. */
  782. __STATIC_INLINE uint32_t LL_GPIO_ReadOutputPort(GPIO_TypeDef *GPIOx)
  783. {
  784. return (uint32_t)(READ_REG(GPIOx->ODR));
  785. }
  786. /**
  787. * @brief Return if input data level for several pins of dedicated port is high or low.
  788. * @rmtoll ODR ODy LL_GPIO_IsOutputPinSet
  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_IsOutputPinSet(GPIO_TypeDef *GPIOx, uint32_t PinMask)
  811. {
  812. return (READ_BIT(GPIOx->ODR, PinMask) == (PinMask));
  813. }
  814. /**
  815. * @brief Set several pins to high level on dedicated gpio port.
  816. * @rmtoll BSRR BSy LL_GPIO_SetOutputPin
  817. * @param GPIOx GPIO Port
  818. * @param PinMask This parameter can be a combination of the following values:
  819. * @arg @ref LL_GPIO_PIN_0
  820. * @arg @ref LL_GPIO_PIN_1
  821. * @arg @ref LL_GPIO_PIN_2
  822. * @arg @ref LL_GPIO_PIN_3
  823. * @arg @ref LL_GPIO_PIN_4
  824. * @arg @ref LL_GPIO_PIN_5
  825. * @arg @ref LL_GPIO_PIN_6
  826. * @arg @ref LL_GPIO_PIN_7
  827. * @arg @ref LL_GPIO_PIN_8
  828. * @arg @ref LL_GPIO_PIN_9
  829. * @arg @ref LL_GPIO_PIN_10
  830. * @arg @ref LL_GPIO_PIN_11
  831. * @arg @ref LL_GPIO_PIN_12
  832. * @arg @ref LL_GPIO_PIN_13
  833. * @arg @ref LL_GPIO_PIN_14
  834. * @arg @ref LL_GPIO_PIN_15
  835. * @arg @ref LL_GPIO_PIN_ALL
  836. * @retval None
  837. */
  838. __STATIC_INLINE void LL_GPIO_SetOutputPin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
  839. {
  840. WRITE_REG(GPIOx->BSRR, PinMask);
  841. }
  842. /**
  843. * @brief Set several pins to low level on dedicated gpio port.
  844. * @rmtoll BSRR BRy LL_GPIO_ResetOutputPin
  845. * @param GPIOx GPIO Port
  846. * @param PinMask This parameter can be a combination of the following values:
  847. * @arg @ref LL_GPIO_PIN_0
  848. * @arg @ref LL_GPIO_PIN_1
  849. * @arg @ref LL_GPIO_PIN_2
  850. * @arg @ref LL_GPIO_PIN_3
  851. * @arg @ref LL_GPIO_PIN_4
  852. * @arg @ref LL_GPIO_PIN_5
  853. * @arg @ref LL_GPIO_PIN_6
  854. * @arg @ref LL_GPIO_PIN_7
  855. * @arg @ref LL_GPIO_PIN_8
  856. * @arg @ref LL_GPIO_PIN_9
  857. * @arg @ref LL_GPIO_PIN_10
  858. * @arg @ref LL_GPIO_PIN_11
  859. * @arg @ref LL_GPIO_PIN_12
  860. * @arg @ref LL_GPIO_PIN_13
  861. * @arg @ref LL_GPIO_PIN_14
  862. * @arg @ref LL_GPIO_PIN_15
  863. * @arg @ref LL_GPIO_PIN_ALL
  864. * @retval None
  865. */
  866. __STATIC_INLINE void LL_GPIO_ResetOutputPin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
  867. {
  868. WRITE_REG(GPIOx->BSRR, (PinMask << 16));
  869. }
  870. /**
  871. * @brief Toggle data value for several pin of dedicated port.
  872. * @rmtoll ODR ODy LL_GPIO_TogglePin
  873. * @param GPIOx GPIO Port
  874. * @param PinMask This parameter can be a combination of the following values:
  875. * @arg @ref LL_GPIO_PIN_0
  876. * @arg @ref LL_GPIO_PIN_1
  877. * @arg @ref LL_GPIO_PIN_2
  878. * @arg @ref LL_GPIO_PIN_3
  879. * @arg @ref LL_GPIO_PIN_4
  880. * @arg @ref LL_GPIO_PIN_5
  881. * @arg @ref LL_GPIO_PIN_6
  882. * @arg @ref LL_GPIO_PIN_7
  883. * @arg @ref LL_GPIO_PIN_8
  884. * @arg @ref LL_GPIO_PIN_9
  885. * @arg @ref LL_GPIO_PIN_10
  886. * @arg @ref LL_GPIO_PIN_11
  887. * @arg @ref LL_GPIO_PIN_12
  888. * @arg @ref LL_GPIO_PIN_13
  889. * @arg @ref LL_GPIO_PIN_14
  890. * @arg @ref LL_GPIO_PIN_15
  891. * @arg @ref LL_GPIO_PIN_ALL
  892. * @retval None
  893. */
  894. __STATIC_INLINE void LL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
  895. {
  896. WRITE_REG(GPIOx->ODR, READ_REG(GPIOx->ODR) ^ PinMask);
  897. }
  898. /**
  899. * @}
  900. */
  901. #if defined(USE_FULL_LL_DRIVER)
  902. /** @defgroup GPIO_LL_EF_Init Initialization and de-initialization functions
  903. * @{
  904. */
  905. ErrorStatus LL_GPIO_DeInit(GPIO_TypeDef *GPIOx);
  906. ErrorStatus LL_GPIO_Init(GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct);
  907. void LL_GPIO_StructInit(LL_GPIO_InitTypeDef *GPIO_InitStruct);
  908. /**
  909. * @}
  910. */
  911. #endif /* USE_FULL_LL_DRIVER */
  912. /**
  913. * @}
  914. */
  915. /**
  916. * @}
  917. */
  918. #endif /* defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOF) || defined (GPIOG) || defined (GPIOH) || defined (GPIOI) || defined (GPIOJ) || defined (GPIOK) */
  919. /**
  920. * @}
  921. */
  922. #ifdef __cplusplus
  923. }
  924. #endif
  925. #endif /* __STM32F4xx_LL_GPIO_H */
  926. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/