stm32f7xx_hal_pwr_ex.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. /**
  2. ******************************************************************************
  3. * @file stm32f7xx_hal_pwr_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of PWR HAL Extension 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 __STM32F7xx_HAL_PWR_EX_H
  37. #define __STM32F7xx_HAL_PWR_EX_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32f7xx_hal_def.h"
  43. /** @addtogroup STM32F7xx_HAL_Driver
  44. * @{
  45. */
  46. /** @addtogroup PWREx
  47. * @{
  48. */
  49. /* Exported types ------------------------------------------------------------*/
  50. /* Exported constants --------------------------------------------------------*/
  51. /** @defgroup PWREx_Exported_Constants PWREx Exported Constants
  52. * @{
  53. */
  54. /** @defgroup PWREx_WakeUp_Pins PWREx Wake Up Pins
  55. * @{
  56. */
  57. #define PWR_WAKEUP_PIN1 PWR_CSR2_EWUP1
  58. #define PWR_WAKEUP_PIN2 PWR_CSR2_EWUP2
  59. #define PWR_WAKEUP_PIN3 PWR_CSR2_EWUP3
  60. #define PWR_WAKEUP_PIN4 PWR_CSR2_EWUP4
  61. #define PWR_WAKEUP_PIN5 PWR_CSR2_EWUP5
  62. #define PWR_WAKEUP_PIN6 PWR_CSR2_EWUP6
  63. #define PWR_WAKEUP_PIN1_HIGH PWR_CSR2_EWUP1
  64. #define PWR_WAKEUP_PIN2_HIGH PWR_CSR2_EWUP2
  65. #define PWR_WAKEUP_PIN3_HIGH PWR_CSR2_EWUP3
  66. #define PWR_WAKEUP_PIN4_HIGH PWR_CSR2_EWUP4
  67. #define PWR_WAKEUP_PIN5_HIGH PWR_CSR2_EWUP5
  68. #define PWR_WAKEUP_PIN6_HIGH PWR_CSR2_EWUP6
  69. #define PWR_WAKEUP_PIN1_LOW (uint32_t)((PWR_CR2_WUPP1<<6) | PWR_CSR2_EWUP1)
  70. #define PWR_WAKEUP_PIN2_LOW (uint32_t)((PWR_CR2_WUPP2<<6) | PWR_CSR2_EWUP2)
  71. #define PWR_WAKEUP_PIN3_LOW (uint32_t)((PWR_CR2_WUPP3<<6) | PWR_CSR2_EWUP3)
  72. #define PWR_WAKEUP_PIN4_LOW (uint32_t)((PWR_CR2_WUPP4<<6) | PWR_CSR2_EWUP4)
  73. #define PWR_WAKEUP_PIN5_LOW (uint32_t)((PWR_CR2_WUPP5<<6) | PWR_CSR2_EWUP5)
  74. #define PWR_WAKEUP_PIN6_LOW (uint32_t)((PWR_CR2_WUPP6<<6) | PWR_CSR2_EWUP6)
  75. /**
  76. * @}
  77. */
  78. /** @defgroup PWREx_Regulator_state_in_UnderDrive_mode PWREx Regulator state in UnderDrive mode
  79. * @{
  80. */
  81. #define PWR_MAINREGULATOR_UNDERDRIVE_ON PWR_CR1_MRUDS
  82. #define PWR_LOWPOWERREGULATOR_UNDERDRIVE_ON ((uint32_t)(PWR_CR1_LPDS | PWR_CR1_LPUDS))
  83. /**
  84. * @}
  85. */
  86. /** @defgroup PWREx_Over_Under_Drive_Flag PWREx Over Under Drive Flag
  87. * @{
  88. */
  89. #define PWR_FLAG_ODRDY PWR_CSR1_ODRDY
  90. #define PWR_FLAG_ODSWRDY PWR_CSR1_ODSWRDY
  91. #define PWR_FLAG_UDRDY PWR_CSR1_UDRDY
  92. /**
  93. * @}
  94. */
  95. /** @defgroup PWREx_Wakeup_Pins_Flag PWREx Wake Up Pin Flags
  96. * @{
  97. */
  98. #define PWR_WAKEUP_PIN_FLAG1 PWR_CSR2_WUPF1
  99. #define PWR_WAKEUP_PIN_FLAG2 PWR_CSR2_WUPF2
  100. #define PWR_WAKEUP_PIN_FLAG3 PWR_CSR2_WUPF3
  101. #define PWR_WAKEUP_PIN_FLAG4 PWR_CSR2_WUPF4
  102. #define PWR_WAKEUP_PIN_FLAG5 PWR_CSR2_WUPF5
  103. #define PWR_WAKEUP_PIN_FLAG6 PWR_CSR2_WUPF6
  104. /**
  105. * @}
  106. */
  107. /**
  108. * @}
  109. */
  110. /* Exported macro ------------------------------------------------------------*/
  111. /** @defgroup PWREx_Exported_Macro PWREx Exported Macro
  112. * @{
  113. */
  114. /** @brief Macros to enable or disable the Over drive mode.
  115. */
  116. #define __HAL_PWR_OVERDRIVE_ENABLE() (PWR->CR1 |= (uint32_t)PWR_CR1_ODEN)
  117. #define __HAL_PWR_OVERDRIVE_DISABLE() (PWR->CR1 &= (uint32_t)(~PWR_CR1_ODEN))
  118. /** @brief Macros to enable or disable the Over drive switching.
  119. */
  120. #define __HAL_PWR_OVERDRIVESWITCHING_ENABLE() (PWR->CR1 |= (uint32_t)PWR_CR1_ODSWEN)
  121. #define __HAL_PWR_OVERDRIVESWITCHING_DISABLE() (PWR->CR1 &= (uint32_t)(~PWR_CR1_ODSWEN))
  122. /** @brief Macros to enable or disable the Under drive mode.
  123. * @note This mode is enabled only with STOP low power mode.
  124. * In this mode, the 1.2V domain is preserved in reduced leakage mode. This
  125. * mode is only available when the main regulator or the low power regulator
  126. * is in low voltage mode.
  127. * @note If the Under-drive mode was enabled, it is automatically disabled after
  128. * exiting Stop mode.
  129. * When the voltage regulator operates in Under-drive mode, an additional
  130. * startup delay is induced when waking up from Stop mode.
  131. */
  132. #define __HAL_PWR_UNDERDRIVE_ENABLE() (PWR->CR1 |= (uint32_t)PWR_CR1_UDEN)
  133. #define __HAL_PWR_UNDERDRIVE_DISABLE() (PWR->CR1 &= (uint32_t)(~PWR_CR1_UDEN))
  134. /** @brief Check PWR flag is set or not.
  135. * @param __FLAG__ specifies the flag to check.
  136. * This parameter can be one of the following values:
  137. * @arg PWR_FLAG_ODRDY: This flag indicates that the Over-drive mode
  138. * is ready
  139. * @arg PWR_FLAG_ODSWRDY: This flag indicates that the Over-drive mode
  140. * switching is ready
  141. * @arg PWR_FLAG_UDRDY: This flag indicates that the Under-drive mode
  142. * is enabled in Stop mode
  143. * @retval The new state of __FLAG__ (TRUE or FALSE).
  144. */
  145. #define __HAL_PWR_GET_ODRUDR_FLAG(__FLAG__) ((PWR->CSR1 & (__FLAG__)) == (__FLAG__))
  146. /** @brief Clear the Under-Drive Ready flag.
  147. */
  148. #define __HAL_PWR_CLEAR_ODRUDR_FLAG() (PWR->CSR1 |= PWR_FLAG_UDRDY)
  149. /** @brief Check Wake Up flag is set or not.
  150. * @param __WUFLAG__ specifies the Wake Up flag to check.
  151. * This parameter can be one of the following values:
  152. * @arg PWR_WAKEUP_PIN_FLAG1: Wakeup Pin Flag for PA0
  153. * @arg PWR_WAKEUP_PIN_FLAG2: Wakeup Pin Flag for PA2
  154. * @arg PWR_WAKEUP_PIN_FLAG3: Wakeup Pin Flag for PC1
  155. * @arg PWR_WAKEUP_PIN_FLAG4: Wakeup Pin Flag for PC13
  156. * @arg PWR_WAKEUP_PIN_FLAG5: Wakeup Pin Flag for PI8
  157. * @arg PWR_WAKEUP_PIN_FLAG6: Wakeup Pin Flag for PI11
  158. */
  159. #define __HAL_PWR_GET_WAKEUP_FLAG(__WUFLAG__) (PWR->CSR2 & (__WUFLAG__))
  160. /** @brief Clear the WakeUp pins flags.
  161. * @param __WUFLAG__ specifies the Wake Up pin flag to clear.
  162. * This parameter can be one of the following values:
  163. * @arg PWR_WAKEUP_PIN_FLAG1: Wakeup Pin Flag for PA0
  164. * @arg PWR_WAKEUP_PIN_FLAG2: Wakeup Pin Flag for PA2
  165. * @arg PWR_WAKEUP_PIN_FLAG3: Wakeup Pin Flag for PC1
  166. * @arg PWR_WAKEUP_PIN_FLAG4: Wakeup Pin Flag for PC13
  167. * @arg PWR_WAKEUP_PIN_FLAG5: Wakeup Pin Flag for PI8
  168. * @arg PWR_WAKEUP_PIN_FLAG6: Wakeup Pin Flag for PI11
  169. */
  170. #define __HAL_PWR_CLEAR_WAKEUP_FLAG(__WUFLAG__) (PWR->CR2 |= (__WUFLAG__))
  171. /**
  172. * @}
  173. */
  174. /* Exported functions --------------------------------------------------------*/
  175. /** @addtogroup PWREx_Exported_Functions PWREx Exported Functions
  176. * @{
  177. */
  178. /** @addtogroup PWREx_Exported_Functions_Group1
  179. * @{
  180. */
  181. uint32_t HAL_PWREx_GetVoltageRange(void);
  182. HAL_StatusTypeDef HAL_PWREx_ControlVoltageScaling(uint32_t VoltageScaling);
  183. void HAL_PWREx_EnableFlashPowerDown(void);
  184. void HAL_PWREx_DisableFlashPowerDown(void);
  185. HAL_StatusTypeDef HAL_PWREx_EnableBkUpReg(void);
  186. HAL_StatusTypeDef HAL_PWREx_DisableBkUpReg(void);
  187. void HAL_PWREx_EnableMainRegulatorLowVoltage(void);
  188. void HAL_PWREx_DisableMainRegulatorLowVoltage(void);
  189. void HAL_PWREx_EnableLowRegulatorLowVoltage(void);
  190. void HAL_PWREx_DisableLowRegulatorLowVoltage(void);
  191. HAL_StatusTypeDef HAL_PWREx_EnableOverDrive(void);
  192. HAL_StatusTypeDef HAL_PWREx_DisableOverDrive(void);
  193. HAL_StatusTypeDef HAL_PWREx_EnterUnderDriveSTOPMode(uint32_t Regulator, uint8_t STOPEntry);
  194. /**
  195. * @}
  196. */
  197. /**
  198. * @}
  199. */
  200. /* Private types -------------------------------------------------------------*/
  201. /* Private variables ---------------------------------------------------------*/
  202. /* Private constants ---------------------------------------------------------*/
  203. /* Private macros ------------------------------------------------------------*/
  204. /** @defgroup PWREx_Private_Macros PWREx Private Macros
  205. * @{
  206. */
  207. /** @defgroup PWREx_IS_PWR_Definitions PWREx Private macros to check input parameters
  208. * @{
  209. */
  210. #define IS_PWR_REGULATOR_UNDERDRIVE(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_UNDERDRIVE_ON) || \
  211. ((REGULATOR) == PWR_LOWPOWERREGULATOR_UNDERDRIVE_ON))
  212. #define IS_PWR_WAKEUP_PIN(__PIN__) (((__PIN__) == PWR_WAKEUP_PIN1) || \
  213. ((__PIN__) == PWR_WAKEUP_PIN2) || \
  214. ((__PIN__) == PWR_WAKEUP_PIN3) || \
  215. ((__PIN__) == PWR_WAKEUP_PIN4) || \
  216. ((__PIN__) == PWR_WAKEUP_PIN5) || \
  217. ((__PIN__) == PWR_WAKEUP_PIN6) || \
  218. ((__PIN__) == PWR_WAKEUP_PIN1_HIGH) || \
  219. ((__PIN__) == PWR_WAKEUP_PIN2_HIGH) || \
  220. ((__PIN__) == PWR_WAKEUP_PIN3_HIGH) || \
  221. ((__PIN__) == PWR_WAKEUP_PIN4_HIGH) || \
  222. ((__PIN__) == PWR_WAKEUP_PIN5_HIGH) || \
  223. ((__PIN__) == PWR_WAKEUP_PIN6_HIGH) || \
  224. ((__PIN__) == PWR_WAKEUP_PIN1_LOW) || \
  225. ((__PIN__) == PWR_WAKEUP_PIN2_LOW) || \
  226. ((__PIN__) == PWR_WAKEUP_PIN3_LOW) || \
  227. ((__PIN__) == PWR_WAKEUP_PIN4_LOW) || \
  228. ((__PIN__) == PWR_WAKEUP_PIN5_LOW) || \
  229. ((__PIN__) == PWR_WAKEUP_PIN6_LOW))
  230. /**
  231. * @}
  232. */
  233. /**
  234. * @}
  235. */
  236. /**
  237. * @}
  238. */
  239. /**
  240. * @}
  241. */
  242. #ifdef __cplusplus
  243. }
  244. #endif
  245. #endif /* __STM32F7xx_HAL_PWR_EX_H */
  246. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/