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.
 
 
 
 
 
 

389 lines
11 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx_hal_pwr.h
  4. * @author MCD Application Team
  5. * @brief Header file of PWR 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_PWR_H
  21. #define __STM32F1xx_HAL_PWR_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 PWR
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /** @defgroup PWR_Exported_Types PWR Exported Types
  35. * @{
  36. */
  37. /**
  38. * @brief PWR PVD configuration structure definition
  39. */
  40. typedef struct
  41. {
  42. uint32_t PVDLevel; /*!< PVDLevel: Specifies the PVD detection level.
  43. This parameter can be a value of @ref PWR_PVD_detection_level */
  44. uint32_t Mode; /*!< Mode: Specifies the operating mode for the selected pins.
  45. This parameter can be a value of @ref PWR_PVD_Mode */
  46. }PWR_PVDTypeDef;
  47. /**
  48. * @}
  49. */
  50. /* Internal constants --------------------------------------------------------*/
  51. /** @addtogroup PWR_Private_Constants
  52. * @{
  53. */
  54. #define PWR_EXTI_LINE_PVD ((uint32_t)0x00010000) /*!< External interrupt line 16 Connected to the PVD EXTI Line */
  55. /**
  56. * @}
  57. */
  58. /* Exported constants --------------------------------------------------------*/
  59. /** @defgroup PWR_Exported_Constants PWR Exported Constants
  60. * @{
  61. */
  62. /** @defgroup PWR_PVD_detection_level PWR PVD detection level
  63. * @{
  64. */
  65. #define PWR_PVDLEVEL_0 PWR_CR_PLS_2V2
  66. #define PWR_PVDLEVEL_1 PWR_CR_PLS_2V3
  67. #define PWR_PVDLEVEL_2 PWR_CR_PLS_2V4
  68. #define PWR_PVDLEVEL_3 PWR_CR_PLS_2V5
  69. #define PWR_PVDLEVEL_4 PWR_CR_PLS_2V6
  70. #define PWR_PVDLEVEL_5 PWR_CR_PLS_2V7
  71. #define PWR_PVDLEVEL_6 PWR_CR_PLS_2V8
  72. #define PWR_PVDLEVEL_7 PWR_CR_PLS_2V9
  73. /**
  74. * @}
  75. */
  76. /** @defgroup PWR_PVD_Mode PWR PVD Mode
  77. * @{
  78. */
  79. #define PWR_PVD_MODE_NORMAL 0x00000000U /*!< basic mode is used */
  80. #define PWR_PVD_MODE_IT_RISING 0x00010001U /*!< External Interrupt Mode with Rising edge trigger detection */
  81. #define PWR_PVD_MODE_IT_FALLING 0x00010002U /*!< External Interrupt Mode with Falling edge trigger detection */
  82. #define PWR_PVD_MODE_IT_RISING_FALLING 0x00010003U /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
  83. #define PWR_PVD_MODE_EVENT_RISING 0x00020001U /*!< Event Mode with Rising edge trigger detection */
  84. #define PWR_PVD_MODE_EVENT_FALLING 0x00020002U /*!< Event Mode with Falling edge trigger detection */
  85. #define PWR_PVD_MODE_EVENT_RISING_FALLING 0x00020003U /*!< Event Mode with Rising/Falling edge trigger detection */
  86. /**
  87. * @}
  88. */
  89. /** @defgroup PWR_WakeUp_Pins PWR WakeUp Pins
  90. * @{
  91. */
  92. #define PWR_WAKEUP_PIN1 PWR_CSR_EWUP
  93. /**
  94. * @}
  95. */
  96. /** @defgroup PWR_Regulator_state_in_SLEEP_STOP_mode PWR Regulator state in SLEEP/STOP mode
  97. * @{
  98. */
  99. #define PWR_MAINREGULATOR_ON 0x00000000U
  100. #define PWR_LOWPOWERREGULATOR_ON PWR_CR_LPDS
  101. /**
  102. * @}
  103. */
  104. /** @defgroup PWR_SLEEP_mode_entry PWR SLEEP mode entry
  105. * @{
  106. */
  107. #define PWR_SLEEPENTRY_WFI ((uint8_t)0x01)
  108. #define PWR_SLEEPENTRY_WFE ((uint8_t)0x02)
  109. /**
  110. * @}
  111. */
  112. /** @defgroup PWR_STOP_mode_entry PWR STOP mode entry
  113. * @{
  114. */
  115. #define PWR_STOPENTRY_WFI ((uint8_t)0x01)
  116. #define PWR_STOPENTRY_WFE ((uint8_t)0x02)
  117. /**
  118. * @}
  119. */
  120. /** @defgroup PWR_Flag PWR Flag
  121. * @{
  122. */
  123. #define PWR_FLAG_WU PWR_CSR_WUF
  124. #define PWR_FLAG_SB PWR_CSR_SBF
  125. #define PWR_FLAG_PVDO PWR_CSR_PVDO
  126. /**
  127. * @}
  128. */
  129. /**
  130. * @}
  131. */
  132. /* Exported macro ------------------------------------------------------------*/
  133. /** @defgroup PWR_Exported_Macros PWR Exported Macros
  134. * @{
  135. */
  136. /** @brief Check PWR flag is set or not.
  137. * @param __FLAG__: specifies the flag to check.
  138. * This parameter can be one of the following values:
  139. * @arg PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event
  140. * was received from the WKUP pin or from the RTC alarm
  141. * An additional wakeup event is detected if the WKUP pin is enabled
  142. * (by setting the EWUP bit) when the WKUP pin level is already high.
  143. * @arg PWR_FLAG_SB: StandBy flag. This flag indicates that the system was
  144. * resumed from StandBy mode.
  145. * @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled
  146. * by the HAL_PWR_EnablePVD() function. The PVD is stopped by Standby mode
  147. * For this reason, this bit is equal to 0 after Standby or reset
  148. * until the PVDE bit is set.
  149. * @retval The new state of __FLAG__ (TRUE or FALSE).
  150. */
  151. #define __HAL_PWR_GET_FLAG(__FLAG__) ((PWR->CSR & (__FLAG__)) == (__FLAG__))
  152. /** @brief Clear the PWR's pending flags.
  153. * @param __FLAG__: specifies the flag to clear.
  154. * This parameter can be one of the following values:
  155. * @arg PWR_FLAG_WU: Wake Up flag
  156. * @arg PWR_FLAG_SB: StandBy flag
  157. */
  158. #define __HAL_PWR_CLEAR_FLAG(__FLAG__) SET_BIT(PWR->CR, ((__FLAG__) << 2))
  159. /**
  160. * @brief Enable interrupt on PVD Exti Line 16.
  161. * @retval None.
  162. */
  163. #define __HAL_PWR_PVD_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR, PWR_EXTI_LINE_PVD)
  164. /**
  165. * @brief Disable interrupt on PVD Exti Line 16.
  166. * @retval None.
  167. */
  168. #define __HAL_PWR_PVD_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR, PWR_EXTI_LINE_PVD)
  169. /**
  170. * @brief Enable event on PVD Exti Line 16.
  171. * @retval None.
  172. */
  173. #define __HAL_PWR_PVD_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR, PWR_EXTI_LINE_PVD)
  174. /**
  175. * @brief Disable event on PVD Exti Line 16.
  176. * @retval None.
  177. */
  178. #define __HAL_PWR_PVD_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR, PWR_EXTI_LINE_PVD)
  179. /**
  180. * @brief PVD EXTI line configuration: set falling edge trigger.
  181. * @retval None.
  182. */
  183. #define __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD)
  184. /**
  185. * @brief Disable the PVD Extended Interrupt Falling Trigger.
  186. * @retval None.
  187. */
  188. #define __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD)
  189. /**
  190. * @brief PVD EXTI line configuration: set rising edge trigger.
  191. * @retval None.
  192. */
  193. #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD)
  194. /**
  195. * @brief Disable the PVD Extended Interrupt Rising Trigger.
  196. * This parameter can be:
  197. * @retval None.
  198. */
  199. #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD)
  200. /**
  201. * @brief PVD EXTI line configuration: set rising & falling edge trigger.
  202. * @retval None.
  203. */
  204. #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_FALLING_EDGE() __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE();__HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE();
  205. /**
  206. * @brief Disable the PVD Extended Interrupt Rising & Falling Trigger.
  207. * This parameter can be:
  208. * @retval None.
  209. */
  210. #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_FALLING_EDGE() __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();__HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE();
  211. /**
  212. * @brief Check whether the specified PVD EXTI interrupt flag is set or not.
  213. * @retval EXTI PVD Line Status.
  214. */
  215. #define __HAL_PWR_PVD_EXTI_GET_FLAG() (EXTI->PR & (PWR_EXTI_LINE_PVD))
  216. /**
  217. * @brief Clear the PVD EXTI flag.
  218. * @retval None.
  219. */
  220. #define __HAL_PWR_PVD_EXTI_CLEAR_FLAG() (EXTI->PR = (PWR_EXTI_LINE_PVD))
  221. /**
  222. * @brief Generate a Software interrupt on selected EXTI line.
  223. * @retval None.
  224. */
  225. #define __HAL_PWR_PVD_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER, PWR_EXTI_LINE_PVD)
  226. /**
  227. * @}
  228. */
  229. /* Private macro -------------------------------------------------------------*/
  230. /** @defgroup PWR_Private_Macros PWR Private Macros
  231. * @{
  232. */
  233. #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLEVEL_0) || ((LEVEL) == PWR_PVDLEVEL_1)|| \
  234. ((LEVEL) == PWR_PVDLEVEL_2) || ((LEVEL) == PWR_PVDLEVEL_3)|| \
  235. ((LEVEL) == PWR_PVDLEVEL_4) || ((LEVEL) == PWR_PVDLEVEL_5)|| \
  236. ((LEVEL) == PWR_PVDLEVEL_6) || ((LEVEL) == PWR_PVDLEVEL_7))
  237. #define IS_PWR_PVD_MODE(MODE) (((MODE) == PWR_PVD_MODE_IT_RISING)|| ((MODE) == PWR_PVD_MODE_IT_FALLING) || \
  238. ((MODE) == PWR_PVD_MODE_IT_RISING_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING) || \
  239. ((MODE) == PWR_PVD_MODE_EVENT_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING_FALLING) || \
  240. ((MODE) == PWR_PVD_MODE_NORMAL))
  241. #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1))
  242. #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \
  243. ((REGULATOR) == PWR_LOWPOWERREGULATOR_ON))
  244. #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE))
  245. #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE))
  246. /**
  247. * @}
  248. */
  249. /* Exported functions --------------------------------------------------------*/
  250. /** @addtogroup PWR_Exported_Functions PWR Exported Functions
  251. * @{
  252. */
  253. /** @addtogroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions
  254. * @{
  255. */
  256. /* Initialization and de-initialization functions *******************************/
  257. void HAL_PWR_DeInit(void);
  258. void HAL_PWR_EnableBkUpAccess(void);
  259. void HAL_PWR_DisableBkUpAccess(void);
  260. /**
  261. * @}
  262. */
  263. /** @addtogroup PWR_Exported_Functions_Group2 Peripheral Control functions
  264. * @{
  265. */
  266. /* Peripheral Control functions ************************************************/
  267. void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD);
  268. /* #define HAL_PWR_ConfigPVD 12*/
  269. void HAL_PWR_EnablePVD(void);
  270. void HAL_PWR_DisablePVD(void);
  271. /* WakeUp pins configuration functions ****************************************/
  272. void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx);
  273. void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx);
  274. /* Low Power modes configuration functions ************************************/
  275. void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry);
  276. void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry);
  277. void HAL_PWR_EnterSTANDBYMode(void);
  278. void HAL_PWR_EnableSleepOnExit(void);
  279. void HAL_PWR_DisableSleepOnExit(void);
  280. void HAL_PWR_EnableSEVOnPend(void);
  281. void HAL_PWR_DisableSEVOnPend(void);
  282. void HAL_PWR_PVD_IRQHandler(void);
  283. void HAL_PWR_PVDCallback(void);
  284. /**
  285. * @}
  286. */
  287. /**
  288. * @}
  289. */
  290. /**
  291. * @}
  292. */
  293. /**
  294. * @}
  295. */
  296. #ifdef __cplusplus
  297. }
  298. #endif
  299. #endif /* __STM32F1xx_HAL_PWR_H */
  300. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/