Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

309 lines
12 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx_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) 2016 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST 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. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32F1xx_HAL_GPIO_H
  21. #define STM32F1xx_HAL_GPIO_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32f1xx_hal_def.h"
  27. /** @addtogroup STM32F1xx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup GPIO
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /** @defgroup GPIO_Exported_Types GPIO Exported Types
  35. * @{
  36. */
  37. /**
  38. * @brief GPIO Init structure definition
  39. */
  40. typedef struct
  41. {
  42. uint32_t Pin; /*!< Specifies the GPIO pins to be configured.
  43. This parameter can be any value of @ref GPIO_pins_define */
  44. uint32_t Mode; /*!< Specifies the operating mode for the selected pins.
  45. This parameter can be a value of @ref GPIO_mode_define */
  46. uint32_t Pull; /*!< Specifies the Pull-up or Pull-Down activation for the selected pins.
  47. This parameter can be a value of @ref GPIO_pull_define */
  48. uint32_t Speed; /*!< Specifies the speed for the selected pins.
  49. This parameter can be a value of @ref GPIO_speed_define */
  50. } GPIO_InitTypeDef;
  51. /**
  52. * @brief GPIO Bit SET and Bit RESET enumeration
  53. */
  54. typedef enum
  55. {
  56. GPIO_PIN_RESET = 0u,
  57. GPIO_PIN_SET
  58. } GPIO_PinState;
  59. /**
  60. * @}
  61. */
  62. /* Exported constants --------------------------------------------------------*/
  63. /** @defgroup GPIO_Exported_Constants GPIO Exported Constants
  64. * @{
  65. */
  66. /** @defgroup GPIO_pins_define GPIO pins define
  67. * @{
  68. */
  69. #define GPIO_PIN_0 ((uint16_t)0x0001) /* Pin 0 selected */
  70. #define GPIO_PIN_1 ((uint16_t)0x0002) /* Pin 1 selected */
  71. #define GPIO_PIN_2 ((uint16_t)0x0004) /* Pin 2 selected */
  72. #define GPIO_PIN_3 ((uint16_t)0x0008) /* Pin 3 selected */
  73. #define GPIO_PIN_4 ((uint16_t)0x0010) /* Pin 4 selected */
  74. #define GPIO_PIN_5 ((uint16_t)0x0020) /* Pin 5 selected */
  75. #define GPIO_PIN_6 ((uint16_t)0x0040) /* Pin 6 selected */
  76. #define GPIO_PIN_7 ((uint16_t)0x0080) /* Pin 7 selected */
  77. #define GPIO_PIN_8 ((uint16_t)0x0100) /* Pin 8 selected */
  78. #define GPIO_PIN_9 ((uint16_t)0x0200) /* Pin 9 selected */
  79. #define GPIO_PIN_10 ((uint16_t)0x0400) /* Pin 10 selected */
  80. #define GPIO_PIN_11 ((uint16_t)0x0800) /* Pin 11 selected */
  81. #define GPIO_PIN_12 ((uint16_t)0x1000) /* Pin 12 selected */
  82. #define GPIO_PIN_13 ((uint16_t)0x2000) /* Pin 13 selected */
  83. #define GPIO_PIN_14 ((uint16_t)0x4000) /* Pin 14 selected */
  84. #define GPIO_PIN_15 ((uint16_t)0x8000) /* Pin 15 selected */
  85. #define GPIO_PIN_All ((uint16_t)0xFFFF) /* All pins selected */
  86. #define GPIO_PIN_MASK 0x0000FFFFu /* PIN mask for assert test */
  87. /**
  88. * @}
  89. */
  90. /** @defgroup GPIO_mode_define GPIO mode define
  91. * @brief GPIO Configuration Mode
  92. * Elements values convention: 0xX0yz00YZ
  93. * - X : GPIO mode or EXTI Mode
  94. * - y : External IT or Event trigger detection
  95. * - z : IO configuration on External IT or Event
  96. * - Y : Output type (Push Pull or Open Drain)
  97. * - Z : IO Direction mode (Input, Output, Alternate or Analog)
  98. * @{
  99. */
  100. #define GPIO_MODE_INPUT 0x00000000u /*!< Input Floating Mode */
  101. #define GPIO_MODE_OUTPUT_PP 0x00000001u /*!< Output Push Pull Mode */
  102. #define GPIO_MODE_OUTPUT_OD 0x00000011u /*!< Output Open Drain Mode */
  103. #define GPIO_MODE_AF_PP 0x00000002u /*!< Alternate Function Push Pull Mode */
  104. #define GPIO_MODE_AF_OD 0x00000012u /*!< Alternate Function Open Drain Mode */
  105. #define GPIO_MODE_AF_INPUT GPIO_MODE_INPUT /*!< Alternate Function Input Mode */
  106. #define GPIO_MODE_ANALOG 0x00000003u /*!< Analog Mode */
  107. #define GPIO_MODE_IT_RISING 0x10110000u /*!< External Interrupt Mode with Rising edge trigger detection */
  108. #define GPIO_MODE_IT_FALLING 0x10210000u /*!< External Interrupt Mode with Falling edge trigger detection */
  109. #define GPIO_MODE_IT_RISING_FALLING 0x10310000u /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
  110. #define GPIO_MODE_EVT_RISING 0x10120000u /*!< External Event Mode with Rising edge trigger detection */
  111. #define GPIO_MODE_EVT_FALLING 0x10220000u /*!< External Event Mode with Falling edge trigger detection */
  112. #define GPIO_MODE_EVT_RISING_FALLING 0x10320000u /*!< External Event Mode with Rising/Falling edge trigger detection */
  113. /**
  114. * @}
  115. */
  116. /** @defgroup GPIO_speed_define GPIO speed define
  117. * @brief GPIO Output Maximum frequency
  118. * @{
  119. */
  120. #define GPIO_SPEED_FREQ_LOW (GPIO_CRL_MODE0_1) /*!< Low speed */
  121. #define GPIO_SPEED_FREQ_MEDIUM (GPIO_CRL_MODE0_0) /*!< Medium speed */
  122. #define GPIO_SPEED_FREQ_HIGH (GPIO_CRL_MODE0) /*!< High speed */
  123. /**
  124. * @}
  125. */
  126. /** @defgroup GPIO_pull_define GPIO pull define
  127. * @brief GPIO Pull-Up or Pull-Down Activation
  128. * @{
  129. */
  130. #define GPIO_NOPULL 0x00000000u /*!< No Pull-up or Pull-down activation */
  131. #define GPIO_PULLUP 0x00000001u /*!< Pull-up activation */
  132. #define GPIO_PULLDOWN 0x00000002u /*!< Pull-down activation */
  133. /**
  134. * @}
  135. */
  136. /**
  137. * @}
  138. */
  139. /* Exported macro ------------------------------------------------------------*/
  140. /** @defgroup GPIO_Exported_Macros GPIO Exported Macros
  141. * @{
  142. */
  143. /**
  144. * @brief Checks whether the specified EXTI line flag is set or not.
  145. * @param __EXTI_LINE__: specifies the EXTI line flag to check.
  146. * This parameter can be GPIO_PIN_x where x can be(0..15)
  147. * @retval The new state of __EXTI_LINE__ (SET or RESET).
  148. */
  149. #define __HAL_GPIO_EXTI_GET_FLAG(__EXTI_LINE__) (EXTI->PR & (__EXTI_LINE__))
  150. /**
  151. * @brief Clears the EXTI's line pending flags.
  152. * @param __EXTI_LINE__: specifies the EXTI lines flags to clear.
  153. * This parameter can be any combination of GPIO_PIN_x where x can be (0..15)
  154. * @retval None
  155. */
  156. #define __HAL_GPIO_EXTI_CLEAR_FLAG(__EXTI_LINE__) (EXTI->PR = (__EXTI_LINE__))
  157. /**
  158. * @brief Checks whether the specified EXTI line is asserted or not.
  159. * @param __EXTI_LINE__: specifies the EXTI line to check.
  160. * This parameter can be GPIO_PIN_x where x can be(0..15)
  161. * @retval The new state of __EXTI_LINE__ (SET or RESET).
  162. */
  163. #define __HAL_GPIO_EXTI_GET_IT(__EXTI_LINE__) (EXTI->PR & (__EXTI_LINE__))
  164. /**
  165. * @brief Clears the EXTI's line pending bits.
  166. * @param __EXTI_LINE__: specifies the EXTI lines to clear.
  167. * This parameter can be any combination of GPIO_PIN_x where x can be (0..15)
  168. * @retval None
  169. */
  170. #define __HAL_GPIO_EXTI_CLEAR_IT(__EXTI_LINE__) (EXTI->PR = (__EXTI_LINE__))
  171. /**
  172. * @brief Generates a Software interrupt on selected EXTI line.
  173. * @param __EXTI_LINE__: specifies the EXTI line to check.
  174. * This parameter can be GPIO_PIN_x where x can be(0..15)
  175. * @retval None
  176. */
  177. #define __HAL_GPIO_EXTI_GENERATE_SWIT(__EXTI_LINE__) (EXTI->SWIER |= (__EXTI_LINE__))
  178. /**
  179. * @}
  180. */
  181. /* Include GPIO HAL Extension module */
  182. #include "stm32f1xx_hal_gpio_ex.h"
  183. /* Exported functions --------------------------------------------------------*/
  184. /** @addtogroup GPIO_Exported_Functions
  185. * @{
  186. */
  187. /** @addtogroup GPIO_Exported_Functions_Group1
  188. * @{
  189. */
  190. /* Initialization and de-initialization functions *****************************/
  191. void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init);
  192. void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin);
  193. /**
  194. * @}
  195. */
  196. /** @addtogroup GPIO_Exported_Functions_Group2
  197. * @{
  198. */
  199. /* IO operation functions *****************************************************/
  200. GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);
  201. void HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState);
  202. void HAL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);
  203. HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);
  204. void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin);
  205. void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin);
  206. /**
  207. * @}
  208. */
  209. /**
  210. * @}
  211. */
  212. /* Private types -------------------------------------------------------------*/
  213. /* Private variables ---------------------------------------------------------*/
  214. /* Private constants ---------------------------------------------------------*/
  215. /** @defgroup GPIO_Private_Constants GPIO Private Constants
  216. * @{
  217. */
  218. /**
  219. * @}
  220. */
  221. /* Private macros ------------------------------------------------------------*/
  222. /** @defgroup GPIO_Private_Macros GPIO Private Macros
  223. * @{
  224. */
  225. #define IS_GPIO_PIN_ACTION(ACTION) (((ACTION) == GPIO_PIN_RESET) || ((ACTION) == GPIO_PIN_SET))
  226. #define IS_GPIO_PIN(PIN) (((((uint32_t)PIN) & GPIO_PIN_MASK ) != 0x00u) && ((((uint32_t)PIN) & ~GPIO_PIN_MASK) == 0x00u))
  227. #define IS_GPIO_MODE(MODE) (((MODE) == GPIO_MODE_INPUT) ||\
  228. ((MODE) == GPIO_MODE_OUTPUT_PP) ||\
  229. ((MODE) == GPIO_MODE_OUTPUT_OD) ||\
  230. ((MODE) == GPIO_MODE_AF_PP) ||\
  231. ((MODE) == GPIO_MODE_AF_OD) ||\
  232. ((MODE) == GPIO_MODE_IT_RISING) ||\
  233. ((MODE) == GPIO_MODE_IT_FALLING) ||\
  234. ((MODE) == GPIO_MODE_IT_RISING_FALLING) ||\
  235. ((MODE) == GPIO_MODE_EVT_RISING) ||\
  236. ((MODE) == GPIO_MODE_EVT_FALLING) ||\
  237. ((MODE) == GPIO_MODE_EVT_RISING_FALLING) ||\
  238. ((MODE) == GPIO_MODE_ANALOG))
  239. #define IS_GPIO_SPEED(SPEED) (((SPEED) == GPIO_SPEED_FREQ_LOW) || \
  240. ((SPEED) == GPIO_SPEED_FREQ_MEDIUM) || ((SPEED) == GPIO_SPEED_FREQ_HIGH))
  241. #define IS_GPIO_PULL(PULL) (((PULL) == GPIO_NOPULL) || ((PULL) == GPIO_PULLUP) || \
  242. ((PULL) == GPIO_PULLDOWN))
  243. /**
  244. * @}
  245. */
  246. /* Private functions ---------------------------------------------------------*/
  247. /** @defgroup GPIO_Private_Functions GPIO Private Functions
  248. * @{
  249. */
  250. /**
  251. * @}
  252. */
  253. /**
  254. * @}
  255. */
  256. /**
  257. * @}
  258. */
  259. #ifdef __cplusplus
  260. }
  261. #endif
  262. #endif /* STM32F1xx_HAL_GPIO_H */
  263. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/