stm32f1xx_hal_gpio.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx_hal_gpio.c
  4. * @author MCD Application Team
  5. * @brief GPIO HAL module driver.
  6. * This file provides firmware functions to manage the following
  7. * functionalities of the General Purpose Input/Output (GPIO) peripheral:
  8. * + Initialization and de-initialization functions
  9. * + IO operation functions
  10. *
  11. ******************************************************************************
  12. * @attention
  13. *
  14. * Copyright (c) 2016 STMicroelectronics.
  15. * All rights reserved.
  16. *
  17. * This software is licensed under terms that can be found in the LICENSE file
  18. * in the root directory of this software component.
  19. * If no LICENSE file comes with this software, it is provided AS-IS.
  20. *
  21. ******************************************************************************
  22. @verbatim
  23. ==============================================================================
  24. ##### GPIO Peripheral features #####
  25. ==============================================================================
  26. [..]
  27. Subject to the specific hardware characteristics of each I/O port listed in the datasheet, each
  28. port bit of the General Purpose IO (GPIO) Ports, can be individually configured by software
  29. in several modes:
  30. (+) Input mode
  31. (+) Analog mode
  32. (+) Output mode
  33. (+) Alternate function mode
  34. (+) External interrupt/event lines
  35. [..]
  36. During and just after reset, the alternate functions and external interrupt
  37. lines are not active and the I/O ports are configured in input floating mode.
  38. [..]
  39. All GPIO pins have weak internal pull-up and pull-down resistors, which can be
  40. activated or not.
  41. [..]
  42. In Output or Alternate mode, each IO can be configured on open-drain or push-pull
  43. type and the IO speed can be selected depending on the VDD value.
  44. [..]
  45. All ports have external interrupt/event capability. To use external interrupt
  46. lines, the port must be configured in input mode. All available GPIO pins are
  47. connected to the 16 external interrupt/event lines from EXTI0 to EXTI15.
  48. [..]
  49. The external interrupt/event controller consists of up to 20 edge detectors in connectivity
  50. line devices, or 19 edge detectors in other devices for generating event/interrupt requests.
  51. Each input line can be independently configured to select the type (event or interrupt) and
  52. the corresponding trigger event (rising or falling or both). Each line can also masked
  53. independently. A pending register maintains the status line of the interrupt requests
  54. ##### How to use this driver #####
  55. ==============================================================================
  56. [..]
  57. (#) Enable the GPIO APB2 clock using the following function : __HAL_RCC_GPIOx_CLK_ENABLE().
  58. (#) Configure the GPIO pin(s) using HAL_GPIO_Init().
  59. (++) Configure the IO mode using "Mode" member from GPIO_InitTypeDef structure
  60. (++) Activate Pull-up, Pull-down resistor using "Pull" member from GPIO_InitTypeDef
  61. structure.
  62. (++) In case of Output or alternate function mode selection: the speed is
  63. configured through "Speed" member from GPIO_InitTypeDef structure
  64. (++) Analog mode is required when a pin is to be used as ADC channel
  65. or DAC output.
  66. (++) In case of external interrupt/event selection the "Mode" member from
  67. GPIO_InitTypeDef structure select the type (interrupt or event) and
  68. the corresponding trigger event (rising or falling or both).
  69. (#) In case of external interrupt/event mode selection, configure NVIC IRQ priority
  70. mapped to the EXTI line using HAL_NVIC_SetPriority() and enable it using
  71. HAL_NVIC_EnableIRQ().
  72. (#) To get the level of a pin configured in input mode use HAL_GPIO_ReadPin().
  73. (#) To set/reset the level of a pin configured in output mode use
  74. HAL_GPIO_WritePin()/HAL_GPIO_TogglePin().
  75. (#) To lock pin configuration until next reset use HAL_GPIO_LockPin().
  76. (#) During and just after reset, the alternate functions are not
  77. active and the GPIO pins are configured in input floating mode (except JTAG
  78. pins).
  79. (#) The LSE oscillator pins OSC32_IN and OSC32_OUT can be used as general purpose
  80. (PC14 and PC15, respectively) when the LSE oscillator is off. The LSE has
  81. priority over the GPIO function.
  82. (#) The HSE oscillator pins OSC_IN/OSC_OUT can be used as
  83. general purpose PD0 and PD1, respectively, when the HSE oscillator is off.
  84. The HSE has priority over the GPIO function.
  85. @endverbatim
  86. ******************************************************************************
  87. */
  88. /* Includes ------------------------------------------------------------------*/
  89. #include "stm32f1xx_hal.h"
  90. /** @addtogroup STM32F1xx_HAL_Driver
  91. * @{
  92. */
  93. /** @defgroup GPIO GPIO
  94. * @brief GPIO HAL module driver
  95. * @{
  96. */
  97. #ifdef HAL_GPIO_MODULE_ENABLED
  98. /* Private typedef -----------------------------------------------------------*/
  99. /* Private define ------------------------------------------------------------*/
  100. /** @addtogroup GPIO_Private_Constants GPIO Private Constants
  101. * @{
  102. */
  103. #define GPIO_MODE 0x00000003u
  104. #define EXTI_MODE 0x10000000u
  105. #define GPIO_MODE_IT 0x00010000u
  106. #define GPIO_MODE_EVT 0x00020000u
  107. #define RISING_EDGE 0x00100000u
  108. #define FALLING_EDGE 0x00200000u
  109. #define GPIO_OUTPUT_TYPE 0x00000010u
  110. #define GPIO_NUMBER 16u
  111. /* Definitions for bit manipulation of CRL and CRH register */
  112. #define GPIO_CR_MODE_INPUT 0x00000000u /*!< 00: Input mode (reset state) */
  113. #define GPIO_CR_CNF_ANALOG 0x00000000u /*!< 00: Analog mode */
  114. #define GPIO_CR_CNF_INPUT_FLOATING 0x00000004u /*!< 01: Floating input (reset state) */
  115. #define GPIO_CR_CNF_INPUT_PU_PD 0x00000008u /*!< 10: Input with pull-up / pull-down */
  116. #define GPIO_CR_CNF_GP_OUTPUT_PP 0x00000000u /*!< 00: General purpose output push-pull */
  117. #define GPIO_CR_CNF_GP_OUTPUT_OD 0x00000004u /*!< 01: General purpose output Open-drain */
  118. #define GPIO_CR_CNF_AF_OUTPUT_PP 0x00000008u /*!< 10: Alternate function output Push-pull */
  119. #define GPIO_CR_CNF_AF_OUTPUT_OD 0x0000000Cu /*!< 11: Alternate function output Open-drain */
  120. /**
  121. * @}
  122. */
  123. /* Private macro -------------------------------------------------------------*/
  124. /* Private variables ---------------------------------------------------------*/
  125. /* Private function prototypes -----------------------------------------------*/
  126. /* Private functions ---------------------------------------------------------*/
  127. /* Exported functions --------------------------------------------------------*/
  128. /** @defgroup GPIO_Exported_Functions GPIO Exported Functions
  129. * @{
  130. */
  131. /** @defgroup GPIO_Exported_Functions_Group1 Initialization and de-initialization functions
  132. * @brief Initialization and Configuration functions
  133. *
  134. @verbatim
  135. ===============================================================================
  136. ##### Initialization and de-initialization functions #####
  137. ===============================================================================
  138. [..]
  139. This section provides functions allowing to initialize and de-initialize the GPIOs
  140. to be ready for use.
  141. @endverbatim
  142. * @{
  143. */
  144. /**
  145. * @brief Initializes the GPIOx peripheral according to the specified parameters in the GPIO_Init.
  146. * @param GPIOx: where x can be (A..G depending on device used) to select the GPIO peripheral
  147. * @param GPIO_Init: pointer to a GPIO_InitTypeDef structure that contains
  148. * the configuration information for the specified GPIO peripheral.
  149. * @retval None
  150. */
  151. void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init)
  152. {
  153. uint32_t position = 0x00u;
  154. uint32_t ioposition;
  155. uint32_t iocurrent;
  156. uint32_t temp;
  157. uint32_t config = 0x00u;
  158. __IO uint32_t *configregister; /* Store the address of CRL or CRH register based on pin number */
  159. uint32_t registeroffset; /* offset used during computation of CNF and MODE bits placement inside CRL or CRH register */
  160. /* Check the parameters */
  161. assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
  162. assert_param(IS_GPIO_PIN(GPIO_Init->Pin));
  163. assert_param(IS_GPIO_MODE(GPIO_Init->Mode));
  164. /* Configure the port pins */
  165. while (((GPIO_Init->Pin) >> position) != 0x00u)
  166. {
  167. /* Get the IO position */
  168. ioposition = (0x01uL << position);
  169. /* Get the current IO position */
  170. iocurrent = (uint32_t)(GPIO_Init->Pin) & ioposition;
  171. if (iocurrent == ioposition)
  172. {
  173. /* Check the Alternate function parameters */
  174. assert_param(IS_GPIO_AF_INSTANCE(GPIOx));
  175. /* Based on the required mode, filling config variable with MODEy[1:0] and CNFy[3:2] corresponding bits */
  176. switch (GPIO_Init->Mode)
  177. {
  178. /* If we are configuring the pin in OUTPUT push-pull mode */
  179. case GPIO_MODE_OUTPUT_PP:
  180. /* Check the GPIO speed parameter */
  181. assert_param(IS_GPIO_SPEED(GPIO_Init->Speed));
  182. config = GPIO_Init->Speed + GPIO_CR_CNF_GP_OUTPUT_PP;
  183. break;
  184. /* If we are configuring the pin in OUTPUT open-drain mode */
  185. case GPIO_MODE_OUTPUT_OD:
  186. /* Check the GPIO speed parameter */
  187. assert_param(IS_GPIO_SPEED(GPIO_Init->Speed));
  188. config = GPIO_Init->Speed + GPIO_CR_CNF_GP_OUTPUT_OD;
  189. break;
  190. /* If we are configuring the pin in ALTERNATE FUNCTION push-pull mode */
  191. case GPIO_MODE_AF_PP:
  192. /* Check the GPIO speed parameter */
  193. assert_param(IS_GPIO_SPEED(GPIO_Init->Speed));
  194. config = GPIO_Init->Speed + GPIO_CR_CNF_AF_OUTPUT_PP;
  195. break;
  196. /* If we are configuring the pin in ALTERNATE FUNCTION open-drain mode */
  197. case GPIO_MODE_AF_OD:
  198. /* Check the GPIO speed parameter */
  199. assert_param(IS_GPIO_SPEED(GPIO_Init->Speed));
  200. config = GPIO_Init->Speed + GPIO_CR_CNF_AF_OUTPUT_OD;
  201. break;
  202. /* If we are configuring the pin in INPUT (also applicable to EVENT and IT mode) */
  203. case GPIO_MODE_INPUT:
  204. case GPIO_MODE_IT_RISING:
  205. case GPIO_MODE_IT_FALLING:
  206. case GPIO_MODE_IT_RISING_FALLING:
  207. case GPIO_MODE_EVT_RISING:
  208. case GPIO_MODE_EVT_FALLING:
  209. case GPIO_MODE_EVT_RISING_FALLING:
  210. /* Check the GPIO pull parameter */
  211. assert_param(IS_GPIO_PULL(GPIO_Init->Pull));
  212. if (GPIO_Init->Pull == GPIO_NOPULL)
  213. {
  214. config = GPIO_CR_MODE_INPUT + GPIO_CR_CNF_INPUT_FLOATING;
  215. }
  216. else if (GPIO_Init->Pull == GPIO_PULLUP)
  217. {
  218. config = GPIO_CR_MODE_INPUT + GPIO_CR_CNF_INPUT_PU_PD;
  219. /* Set the corresponding ODR bit */
  220. GPIOx->BSRR = ioposition;
  221. }
  222. else /* GPIO_PULLDOWN */
  223. {
  224. config = GPIO_CR_MODE_INPUT + GPIO_CR_CNF_INPUT_PU_PD;
  225. /* Reset the corresponding ODR bit */
  226. GPIOx->BRR = ioposition;
  227. }
  228. break;
  229. /* If we are configuring the pin in INPUT analog mode */
  230. case GPIO_MODE_ANALOG:
  231. config = GPIO_CR_MODE_INPUT + GPIO_CR_CNF_ANALOG;
  232. break;
  233. /* Parameters are checked with assert_param */
  234. default:
  235. break;
  236. }
  237. /* Check if the current bit belongs to first half or last half of the pin count number
  238. in order to address CRH or CRL register*/
  239. configregister = (iocurrent < GPIO_PIN_8) ? &GPIOx->CRL : &GPIOx->CRH;
  240. registeroffset = (iocurrent < GPIO_PIN_8) ? (position << 2u) : ((position - 8u) << 2u);
  241. /* Apply the new configuration of the pin to the register */
  242. MODIFY_REG((*configregister), ((GPIO_CRL_MODE0 | GPIO_CRL_CNF0) << registeroffset), (config << registeroffset));
  243. /*--------------------- EXTI Mode Configuration ------------------------*/
  244. /* Configure the External Interrupt or event for the current IO */
  245. if ((GPIO_Init->Mode & EXTI_MODE) == EXTI_MODE)
  246. {
  247. /* Enable AFIO Clock */
  248. __HAL_RCC_AFIO_CLK_ENABLE();
  249. temp = AFIO->EXTICR[position >> 2u];
  250. CLEAR_BIT(temp, (0x0Fu) << (4u * (position & 0x03u)));
  251. SET_BIT(temp, (GPIO_GET_INDEX(GPIOx)) << (4u * (position & 0x03u)));
  252. AFIO->EXTICR[position >> 2u] = temp;
  253. /* Enable or disable the rising trigger */
  254. if ((GPIO_Init->Mode & RISING_EDGE) == RISING_EDGE)
  255. {
  256. SET_BIT(EXTI->RTSR, iocurrent);
  257. }
  258. else
  259. {
  260. CLEAR_BIT(EXTI->RTSR, iocurrent);
  261. }
  262. /* Enable or disable the falling trigger */
  263. if ((GPIO_Init->Mode & FALLING_EDGE) == FALLING_EDGE)
  264. {
  265. SET_BIT(EXTI->FTSR, iocurrent);
  266. }
  267. else
  268. {
  269. CLEAR_BIT(EXTI->FTSR, iocurrent);
  270. }
  271. /* Configure the event mask */
  272. if ((GPIO_Init->Mode & GPIO_MODE_EVT) == GPIO_MODE_EVT)
  273. {
  274. SET_BIT(EXTI->EMR, iocurrent);
  275. }
  276. else
  277. {
  278. CLEAR_BIT(EXTI->EMR, iocurrent);
  279. }
  280. /* Configure the interrupt mask */
  281. if ((GPIO_Init->Mode & GPIO_MODE_IT) == GPIO_MODE_IT)
  282. {
  283. SET_BIT(EXTI->IMR, iocurrent);
  284. }
  285. else
  286. {
  287. CLEAR_BIT(EXTI->IMR, iocurrent);
  288. }
  289. }
  290. }
  291. position++;
  292. }
  293. }
  294. /**
  295. * @brief De-initializes the GPIOx peripheral registers to their default reset values.
  296. * @param GPIOx: where x can be (A..G depending on device used) to select the GPIO peripheral
  297. * @param GPIO_Pin: specifies the port bit to be written.
  298. * This parameter can be one of GPIO_PIN_x where x can be (0..15).
  299. * @retval None
  300. */
  301. void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin)
  302. {
  303. uint32_t position = 0x00u;
  304. uint32_t iocurrent;
  305. uint32_t tmp;
  306. __IO uint32_t *configregister; /* Store the address of CRL or CRH register based on pin number */
  307. uint32_t registeroffset;
  308. /* Check the parameters */
  309. assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
  310. assert_param(IS_GPIO_PIN(GPIO_Pin));
  311. /* Configure the port pins */
  312. while ((GPIO_Pin >> position) != 0u)
  313. {
  314. /* Get current io position */
  315. iocurrent = (GPIO_Pin) & (1uL << position);
  316. if (iocurrent)
  317. {
  318. /*------------------------- EXTI Mode Configuration --------------------*/
  319. /* Clear the External Interrupt or Event for the current IO */
  320. tmp = AFIO->EXTICR[position >> 2u];
  321. tmp &= 0x0FuL << (4u * (position & 0x03u));
  322. if (tmp == (GPIO_GET_INDEX(GPIOx) << (4u * (position & 0x03u))))
  323. {
  324. /* Clear EXTI line configuration */
  325. CLEAR_BIT(EXTI->IMR, (uint32_t)iocurrent);
  326. CLEAR_BIT(EXTI->EMR, (uint32_t)iocurrent);
  327. /* Clear Rising Falling edge configuration */
  328. CLEAR_BIT(EXTI->FTSR, (uint32_t)iocurrent);
  329. CLEAR_BIT(EXTI->RTSR, (uint32_t)iocurrent);
  330. tmp = 0x0FuL << (4u * (position & 0x03u));
  331. CLEAR_BIT(AFIO->EXTICR[position >> 2u], tmp);
  332. }
  333. /*------------------------- GPIO Mode Configuration --------------------*/
  334. /* Check if the current bit belongs to first half or last half of the pin count number
  335. in order to address CRH or CRL register */
  336. configregister = (iocurrent < GPIO_PIN_8) ? &GPIOx->CRL : &GPIOx->CRH;
  337. registeroffset = (iocurrent < GPIO_PIN_8) ? (position << 2u) : ((position - 8u) << 2u);
  338. /* CRL/CRH default value is floating input(0x04) shifted to correct position */
  339. MODIFY_REG(*configregister, ((GPIO_CRL_MODE0 | GPIO_CRL_CNF0) << registeroffset), GPIO_CRL_CNF0_0 << registeroffset);
  340. /* ODR default value is 0 */
  341. CLEAR_BIT(GPIOx->ODR, iocurrent);
  342. }
  343. position++;
  344. }
  345. }
  346. /**
  347. * @}
  348. */
  349. /** @defgroup GPIO_Exported_Functions_Group2 IO operation functions
  350. * @brief GPIO Read and Write
  351. *
  352. @verbatim
  353. ===============================================================================
  354. ##### IO operation functions #####
  355. ===============================================================================
  356. [..]
  357. This subsection provides a set of functions allowing to manage the GPIOs.
  358. @endverbatim
  359. * @{
  360. */
  361. /**
  362. * @brief Reads the specified input port pin.
  363. * @param GPIOx: where x can be (A..G depending on device used) to select the GPIO peripheral
  364. * @param GPIO_Pin: specifies the port bit to read.
  365. * This parameter can be GPIO_PIN_x where x can be (0..15).
  366. * @retval The input port pin value.
  367. */
  368. GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
  369. {
  370. GPIO_PinState bitstatus;
  371. /* Check the parameters */
  372. assert_param(IS_GPIO_PIN(GPIO_Pin));
  373. if ((GPIOx->IDR & GPIO_Pin) != (uint32_t)GPIO_PIN_RESET)
  374. {
  375. bitstatus = GPIO_PIN_SET;
  376. }
  377. else
  378. {
  379. bitstatus = GPIO_PIN_RESET;
  380. }
  381. return bitstatus;
  382. }
  383. /**
  384. * @brief Sets or clears the selected data port bit.
  385. *
  386. * @note This function uses GPIOx_BSRR register to allow atomic read/modify
  387. * accesses. In this way, there is no risk of an IRQ occurring between
  388. * the read and the modify access.
  389. *
  390. * @param GPIOx: where x can be (A..G depending on device used) to select the GPIO peripheral
  391. * @param GPIO_Pin: specifies the port bit to be written.
  392. * This parameter can be one of GPIO_PIN_x where x can be (0..15).
  393. * @param PinState: specifies the value to be written to the selected bit.
  394. * This parameter can be one of the GPIO_PinState enum values:
  395. * @arg GPIO_PIN_RESET: to clear the port pin
  396. * @arg GPIO_PIN_SET: to set the port pin
  397. * @retval None
  398. */
  399. void HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState)
  400. {
  401. /* Check the parameters */
  402. assert_param(IS_GPIO_PIN(GPIO_Pin));
  403. assert_param(IS_GPIO_PIN_ACTION(PinState));
  404. if (PinState != GPIO_PIN_RESET)
  405. {
  406. GPIOx->BSRR = GPIO_Pin;
  407. }
  408. else
  409. {
  410. GPIOx->BSRR = (uint32_t)GPIO_Pin << 16u;
  411. }
  412. }
  413. /**
  414. * @brief Toggles the specified GPIO pin
  415. * @param GPIOx: where x can be (A..G depending on device used) to select the GPIO peripheral
  416. * @param GPIO_Pin: Specifies the pins to be toggled.
  417. * @retval None
  418. */
  419. void HAL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
  420. {
  421. uint32_t odr;
  422. /* Check the parameters */
  423. assert_param(IS_GPIO_PIN(GPIO_Pin));
  424. /* get current Output Data Register value */
  425. odr = GPIOx->ODR;
  426. /* Set selected pins that were at low level, and reset ones that were high */
  427. GPIOx->BSRR = ((odr & GPIO_Pin) << GPIO_NUMBER) | (~odr & GPIO_Pin);
  428. }
  429. /**
  430. * @brief Locks GPIO Pins configuration registers.
  431. * @note The locking mechanism allows the IO configuration to be frozen. When the LOCK sequence
  432. * has been applied on a port bit, it is no longer possible to modify the value of the port bit until
  433. * the next reset.
  434. * @param GPIOx: where x can be (A..G depending on device used) to select the GPIO peripheral
  435. * @param GPIO_Pin: specifies the port bit to be locked.
  436. * This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
  437. * @retval None
  438. */
  439. HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
  440. {
  441. __IO uint32_t tmp = GPIO_LCKR_LCKK;
  442. /* Check the parameters */
  443. assert_param(IS_GPIO_LOCK_INSTANCE(GPIOx));
  444. assert_param(IS_GPIO_PIN(GPIO_Pin));
  445. /* Apply lock key write sequence */
  446. SET_BIT(tmp, GPIO_Pin);
  447. /* Set LCKx bit(s): LCKK='1' + LCK[15-0] */
  448. GPIOx->LCKR = tmp;
  449. /* Reset LCKx bit(s): LCKK='0' + LCK[15-0] */
  450. GPIOx->LCKR = GPIO_Pin;
  451. /* Set LCKx bit(s): LCKK='1' + LCK[15-0] */
  452. GPIOx->LCKR = tmp;
  453. /* Read LCKK register. This read is mandatory to complete key lock sequence */
  454. tmp = GPIOx->LCKR;
  455. /* read again in order to confirm lock is active */
  456. if ((uint32_t)(GPIOx->LCKR & GPIO_LCKR_LCKK))
  457. {
  458. return HAL_OK;
  459. }
  460. else
  461. {
  462. return HAL_ERROR;
  463. }
  464. }
  465. /**
  466. * @brief This function handles EXTI interrupt request.
  467. * @param GPIO_Pin: Specifies the pins connected EXTI line
  468. * @retval None
  469. */
  470. void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin)
  471. {
  472. /* EXTI line interrupt detected */
  473. if (__HAL_GPIO_EXTI_GET_IT(GPIO_Pin) != 0x00u)
  474. {
  475. __HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
  476. HAL_GPIO_EXTI_Callback(GPIO_Pin);
  477. }
  478. }
  479. /**
  480. * @brief EXTI line detection callbacks.
  481. * @param GPIO_Pin: Specifies the pins connected EXTI line
  482. * @retval None
  483. */
  484. __weak void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
  485. {
  486. /* Prevent unused argument(s) compilation warning */
  487. UNUSED(GPIO_Pin);
  488. /* NOTE: This function Should not be modified, when the callback is needed,
  489. the HAL_GPIO_EXTI_Callback could be implemented in the user file
  490. */
  491. }
  492. /**
  493. * @}
  494. */
  495. /**
  496. * @}
  497. */
  498. #endif /* HAL_GPIO_MODULE_ENABLED */
  499. /**
  500. * @}
  501. */
  502. /**
  503. * @}
  504. */