stm32f4xx_hal_gpio.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_hal_gpio.h
  4. * @author MCD Application Team
  5. * @brief Header file of GPIO HAL 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_HAL_GPIO_H
  37. #define __STM32F4xx_HAL_GPIO_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32f4xx_hal_def.h"
  43. /** @addtogroup STM32F4xx_HAL_Driver
  44. * @{
  45. */
  46. /** @addtogroup GPIO
  47. * @{
  48. */
  49. #include "com_gpio.h"
  50. /**
  51. * @}
  52. */
  53. /**
  54. * @}
  55. */
  56. /* Exported macro ------------------------------------------------------------*/
  57. /** @defgroup GPIO_Exported_Macros GPIO Exported Macros
  58. * @{
  59. */
  60. /**
  61. * @brief Checks whether the specified EXTI line flag is set or not.
  62. * @param __EXTI_LINE__ specifies the EXTI line flag to check.
  63. * This parameter can be GPIO_PIN_x where x can be(0..15)
  64. * @retval The new state of __EXTI_LINE__ (SET or RESET).
  65. */
  66. #define __HAL_GPIO_EXTI_GET_FLAG(__EXTI_LINE__) (EXTI->PR & (__EXTI_LINE__))
  67. /**
  68. * @brief Clears the EXTI's line pending flags.
  69. * @param __EXTI_LINE__ specifies the EXTI lines flags to clear.
  70. * This parameter can be any combination of GPIO_PIN_x where x can be (0..15)
  71. * @retval None
  72. */
  73. #define __HAL_GPIO_EXTI_CLEAR_FLAG(__EXTI_LINE__) (EXTI->PR = (__EXTI_LINE__))
  74. /**
  75. * @brief Checks whether the specified EXTI line is asserted or not.
  76. * @param __EXTI_LINE__ specifies the EXTI line to check.
  77. * This parameter can be GPIO_PIN_x where x can be(0..15)
  78. * @retval The new state of __EXTI_LINE__ (SET or RESET).
  79. */
  80. #define __HAL_GPIO_EXTI_GET_IT(__EXTI_LINE__) (EXTI->PR & (__EXTI_LINE__))
  81. /**
  82. * @brief Clears the EXTI's line pending bits.
  83. * @param __EXTI_LINE__ specifies the EXTI lines to clear.
  84. * This parameter can be any combination of GPIO_PIN_x where x can be (0..15)
  85. * @retval None
  86. */
  87. #define __HAL_GPIO_EXTI_CLEAR_IT(__EXTI_LINE__) (EXTI->PR = (__EXTI_LINE__))
  88. /**
  89. * @brief Generates a Software interrupt on selected EXTI line.
  90. * @param __EXTI_LINE__ specifies the EXTI line to check.
  91. * This parameter can be GPIO_PIN_x where x can be(0..15)
  92. * @retval None
  93. */
  94. #define __HAL_GPIO_EXTI_GENERATE_SWIT(__EXTI_LINE__) (EXTI->SWIER |= (__EXTI_LINE__))
  95. /**
  96. * @}
  97. */
  98. /* Include GPIO HAL Extension module */
  99. #include "stm32f4xx_hal_gpio_ex.h"
  100. /* Exported functions --------------------------------------------------------*/
  101. /** @addtogroup GPIO_Exported_Functions
  102. * @{
  103. */
  104. /** @addtogroup GPIO_Exported_Functions_Group1
  105. * @{
  106. */
  107. /* Initialization and de-initialization functions *****************************/
  108. void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init);
  109. void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin);
  110. /**
  111. * @}
  112. */
  113. /** @addtogroup GPIO_Exported_Functions_Group2
  114. * @{
  115. */
  116. /* IO operation functions *****************************************************/
  117. GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
  118. void HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState);
  119. void HAL_GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
  120. HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
  121. void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin);
  122. void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin);
  123. /**
  124. * @}
  125. */
  126. /**
  127. * @}
  128. */
  129. /* Private types -------------------------------------------------------------*/
  130. /* Private variables ---------------------------------------------------------*/
  131. /* Private constants ---------------------------------------------------------*/
  132. /** @defgroup GPIO_Private_Constants GPIO Private Constants
  133. * @{
  134. */
  135. /**
  136. * @}
  137. */
  138. /* Private macros ------------------------------------------------------------*/
  139. /** @defgroup GPIO_Private_Macros GPIO Private Macros
  140. * @{
  141. */
  142. #define IS_GPIO_PIN_ACTION(ACTION) (((ACTION) == GPIO_PIN_RESET) || ((ACTION) == GPIO_PIN_SET))
  143. #define IS_GPIO_PIN(PIN) ((((PIN) & GPIO_PIN_MASK ) != 0x00U) && (((PIN) & ~GPIO_PIN_MASK) == 0x00U))
  144. #define IS_GPIO_MODE(MODE) (((MODE) == GPIO_MODE_INPUT) ||\
  145. ((MODE) == GPIO_MODE_OUTPUT_PP) ||\
  146. ((MODE) == GPIO_MODE_OUTPUT_OD) ||\
  147. ((MODE) == GPIO_MODE_AF_PP) ||\
  148. ((MODE) == GPIO_MODE_AF_OD) ||\
  149. ((MODE) == GPIO_MODE_IT_RISING) ||\
  150. ((MODE) == GPIO_MODE_IT_FALLING) ||\
  151. ((MODE) == GPIO_MODE_IT_RISING_FALLING) ||\
  152. ((MODE) == GPIO_MODE_EVT_RISING) ||\
  153. ((MODE) == GPIO_MODE_EVT_FALLING) ||\
  154. ((MODE) == GPIO_MODE_EVT_RISING_FALLING) ||\
  155. ((MODE) == GPIO_MODE_ANALOG))
  156. #define IS_GPIO_SPEED(SPEED) (((SPEED) == GPIO_SPEED_FREQ_LOW) || ((SPEED) == GPIO_SPEED_FREQ_MEDIUM) || \
  157. ((SPEED) == GPIO_SPEED_FREQ_HIGH) || ((SPEED) == GPIO_SPEED_FREQ_VERY_HIGH))
  158. #define IS_GPIO_PULL(PULL) (((PULL) == GPIO_NOPULL) || ((PULL) == GPIO_PULLUP) || \
  159. ((PULL) == GPIO_PULLDOWN))
  160. /**
  161. * @}
  162. */
  163. /* Private functions ---------------------------------------------------------*/
  164. /** @defgroup GPIO_Private_Functions GPIO Private Functions
  165. * @{
  166. */
  167. /**
  168. * @}
  169. */
  170. /**
  171. * @}
  172. */
  173. /**
  174. * @}
  175. */
  176. #ifdef __cplusplus
  177. }
  178. #endif
  179. #endif /* __STM32F4xx_HAL_GPIO_H */
  180. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/