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.
 
 
 

281 lines
12 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f7xx_hal_pwr_ex.h
  4. * @author MCD Application Team
  5. * @version V1.2.2
  6. * @date 14-April-2017
  7. * @brief Header file of PWR HAL Extension module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32F7xx_HAL_PWR_EX_H
  39. #define __STM32F7xx_HAL_PWR_EX_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32f7xx_hal_def.h"
  45. /** @addtogroup STM32F7xx_HAL_Driver
  46. * @{
  47. */
  48. /** @addtogroup PWREx
  49. * @{
  50. */
  51. /* Exported types ------------------------------------------------------------*/
  52. /* Exported constants --------------------------------------------------------*/
  53. /** @defgroup PWREx_Exported_Constants PWREx Exported Constants
  54. * @{
  55. */
  56. /** @defgroup PWREx_WakeUp_Pins PWREx Wake Up Pins
  57. * @{
  58. */
  59. #define PWR_WAKEUP_PIN1 PWR_CSR2_EWUP1
  60. #define PWR_WAKEUP_PIN2 PWR_CSR2_EWUP2
  61. #define PWR_WAKEUP_PIN3 PWR_CSR2_EWUP3
  62. #define PWR_WAKEUP_PIN4 PWR_CSR2_EWUP4
  63. #define PWR_WAKEUP_PIN5 PWR_CSR2_EWUP5
  64. #define PWR_WAKEUP_PIN6 PWR_CSR2_EWUP6
  65. #define PWR_WAKEUP_PIN1_HIGH PWR_CSR2_EWUP1
  66. #define PWR_WAKEUP_PIN2_HIGH PWR_CSR2_EWUP2
  67. #define PWR_WAKEUP_PIN3_HIGH PWR_CSR2_EWUP3
  68. #define PWR_WAKEUP_PIN4_HIGH PWR_CSR2_EWUP4
  69. #define PWR_WAKEUP_PIN5_HIGH PWR_CSR2_EWUP5
  70. #define PWR_WAKEUP_PIN6_HIGH PWR_CSR2_EWUP6
  71. #define PWR_WAKEUP_PIN1_LOW (uint32_t)((PWR_CR2_WUPP1<<6) | PWR_CSR2_EWUP1)
  72. #define PWR_WAKEUP_PIN2_LOW (uint32_t)((PWR_CR2_WUPP2<<6) | PWR_CSR2_EWUP2)
  73. #define PWR_WAKEUP_PIN3_LOW (uint32_t)((PWR_CR2_WUPP3<<6) | PWR_CSR2_EWUP3)
  74. #define PWR_WAKEUP_PIN4_LOW (uint32_t)((PWR_CR2_WUPP4<<6) | PWR_CSR2_EWUP4)
  75. #define PWR_WAKEUP_PIN5_LOW (uint32_t)((PWR_CR2_WUPP5<<6) | PWR_CSR2_EWUP5)
  76. #define PWR_WAKEUP_PIN6_LOW (uint32_t)((PWR_CR2_WUPP6<<6) | PWR_CSR2_EWUP6)
  77. /**
  78. * @}
  79. */
  80. /** @defgroup PWREx_Regulator_state_in_UnderDrive_mode PWREx Regulator state in UnderDrive mode
  81. * @{
  82. */
  83. #define PWR_MAINREGULATOR_UNDERDRIVE_ON PWR_CR1_MRUDS
  84. #define PWR_LOWPOWERREGULATOR_UNDERDRIVE_ON ((uint32_t)(PWR_CR1_LPDS | PWR_CR1_LPUDS))
  85. /**
  86. * @}
  87. */
  88. /** @defgroup PWREx_Over_Under_Drive_Flag PWREx Over Under Drive Flag
  89. * @{
  90. */
  91. #define PWR_FLAG_ODRDY PWR_CSR1_ODRDY
  92. #define PWR_FLAG_ODSWRDY PWR_CSR1_ODSWRDY
  93. #define PWR_FLAG_UDRDY PWR_CSR1_UDRDY
  94. /**
  95. * @}
  96. */
  97. /** @defgroup PWREx_Wakeup_Pins_Flag PWREx Wake Up Pin Flags
  98. * @{
  99. */
  100. #define PWR_WAKEUP_PIN_FLAG1 PWR_CSR2_WUPF1
  101. #define PWR_WAKEUP_PIN_FLAG2 PWR_CSR2_WUPF2
  102. #define PWR_WAKEUP_PIN_FLAG3 PWR_CSR2_WUPF3
  103. #define PWR_WAKEUP_PIN_FLAG4 PWR_CSR2_WUPF4
  104. #define PWR_WAKEUP_PIN_FLAG5 PWR_CSR2_WUPF5
  105. #define PWR_WAKEUP_PIN_FLAG6 PWR_CSR2_WUPF6
  106. /**
  107. * @}
  108. */
  109. /**
  110. * @}
  111. */
  112. /* Exported macro ------------------------------------------------------------*/
  113. /** @defgroup PWREx_Exported_Macro PWREx Exported Macro
  114. * @{
  115. */
  116. /** @brief Macros to enable or disable the Over drive mode.
  117. */
  118. #define __HAL_PWR_OVERDRIVE_ENABLE() (PWR->CR1 |= (uint32_t)PWR_CR1_ODEN)
  119. #define __HAL_PWR_OVERDRIVE_DISABLE() (PWR->CR1 &= (uint32_t)(~PWR_CR1_ODEN))
  120. /** @brief Macros to enable or disable the Over drive switching.
  121. */
  122. #define __HAL_PWR_OVERDRIVESWITCHING_ENABLE() (PWR->CR1 |= (uint32_t)PWR_CR1_ODSWEN)
  123. #define __HAL_PWR_OVERDRIVESWITCHING_DISABLE() (PWR->CR1 &= (uint32_t)(~PWR_CR1_ODSWEN))
  124. /** @brief Macros to enable or disable the Under drive mode.
  125. * @note This mode is enabled only with STOP low power mode.
  126. * In this mode, the 1.2V domain is preserved in reduced leakage mode. This
  127. * mode is only available when the main regulator or the low power regulator
  128. * is in low voltage mode.
  129. * @note If the Under-drive mode was enabled, it is automatically disabled after
  130. * exiting Stop mode.
  131. * When the voltage regulator operates in Under-drive mode, an additional
  132. * startup delay is induced when waking up from Stop mode.
  133. */
  134. #define __HAL_PWR_UNDERDRIVE_ENABLE() (PWR->CR1 |= (uint32_t)PWR_CR1_UDEN)
  135. #define __HAL_PWR_UNDERDRIVE_DISABLE() (PWR->CR1 &= (uint32_t)(~PWR_CR1_UDEN))
  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_ODRDY: This flag indicates that the Over-drive mode
  140. * is ready
  141. * @arg PWR_FLAG_ODSWRDY: This flag indicates that the Over-drive mode
  142. * switching is ready
  143. * @arg PWR_FLAG_UDRDY: This flag indicates that the Under-drive mode
  144. * is enabled in Stop mode
  145. * @retval The new state of __FLAG__ (TRUE or FALSE).
  146. */
  147. #define __HAL_PWR_GET_ODRUDR_FLAG(__FLAG__) ((PWR->CSR1 & (__FLAG__)) == (__FLAG__))
  148. /** @brief Clear the Under-Drive Ready flag.
  149. */
  150. #define __HAL_PWR_CLEAR_ODRUDR_FLAG() (PWR->CSR1 |= PWR_FLAG_UDRDY)
  151. /** @brief Check Wake Up flag is set or not.
  152. * @param __WUFLAG__: specifies the Wake Up flag to check.
  153. * This parameter can be one of the following values:
  154. * @arg PWR_WAKEUP_PIN_FLAG1: Wakeup Pin Flag for PA0
  155. * @arg PWR_WAKEUP_PIN_FLAG2: Wakeup Pin Flag for PA2
  156. * @arg PWR_WAKEUP_PIN_FLAG3: Wakeup Pin Flag for PC1
  157. * @arg PWR_WAKEUP_PIN_FLAG4: Wakeup Pin Flag for PC13
  158. * @arg PWR_WAKEUP_PIN_FLAG5: Wakeup Pin Flag for PI8
  159. * @arg PWR_WAKEUP_PIN_FLAG6: Wakeup Pin Flag for PI11
  160. */
  161. #define __HAL_PWR_GET_WAKEUP_FLAG(__WUFLAG__) (PWR->CSR2 & (__WUFLAG__))
  162. /** @brief Clear the WakeUp pins flags.
  163. * @param __WUFLAG__: specifies the Wake Up pin flag to clear.
  164. * This parameter can be one of the following values:
  165. * @arg PWR_WAKEUP_PIN_FLAG1: Wakeup Pin Flag for PA0
  166. * @arg PWR_WAKEUP_PIN_FLAG2: Wakeup Pin Flag for PA2
  167. * @arg PWR_WAKEUP_PIN_FLAG3: Wakeup Pin Flag for PC1
  168. * @arg PWR_WAKEUP_PIN_FLAG4: Wakeup Pin Flag for PC13
  169. * @arg PWR_WAKEUP_PIN_FLAG5: Wakeup Pin Flag for PI8
  170. * @arg PWR_WAKEUP_PIN_FLAG6: Wakeup Pin Flag for PI11
  171. */
  172. #define __HAL_PWR_CLEAR_WAKEUP_FLAG(__WUFLAG__) (PWR->CR2 |= (__WUFLAG__))
  173. /**
  174. * @}
  175. */
  176. /* Exported functions --------------------------------------------------------*/
  177. /** @addtogroup PWREx_Exported_Functions PWREx Exported Functions
  178. * @{
  179. */
  180. /** @addtogroup PWREx_Exported_Functions_Group1
  181. * @{
  182. */
  183. uint32_t HAL_PWREx_GetVoltageRange(void);
  184. HAL_StatusTypeDef HAL_PWREx_ControlVoltageScaling(uint32_t VoltageScaling);
  185. void HAL_PWREx_EnableFlashPowerDown(void);
  186. void HAL_PWREx_DisableFlashPowerDown(void);
  187. HAL_StatusTypeDef HAL_PWREx_EnableBkUpReg(void);
  188. HAL_StatusTypeDef HAL_PWREx_DisableBkUpReg(void);
  189. void HAL_PWREx_EnableMainRegulatorLowVoltage(void);
  190. void HAL_PWREx_DisableMainRegulatorLowVoltage(void);
  191. void HAL_PWREx_EnableLowRegulatorLowVoltage(void);
  192. void HAL_PWREx_DisableLowRegulatorLowVoltage(void);
  193. HAL_StatusTypeDef HAL_PWREx_EnableOverDrive(void);
  194. HAL_StatusTypeDef HAL_PWREx_DisableOverDrive(void);
  195. HAL_StatusTypeDef HAL_PWREx_EnterUnderDriveSTOPMode(uint32_t Regulator, uint8_t STOPEntry);
  196. /**
  197. * @}
  198. */
  199. /**
  200. * @}
  201. */
  202. /* Private types -------------------------------------------------------------*/
  203. /* Private variables ---------------------------------------------------------*/
  204. /* Private constants ---------------------------------------------------------*/
  205. /* Private macros ------------------------------------------------------------*/
  206. /** @defgroup PWREx_Private_Macros PWREx Private Macros
  207. * @{
  208. */
  209. /** @defgroup PWREx_IS_PWR_Definitions PWREx Private macros to check input parameters
  210. * @{
  211. */
  212. #define IS_PWR_REGULATOR_UNDERDRIVE(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_UNDERDRIVE_ON) || \
  213. ((REGULATOR) == PWR_LOWPOWERREGULATOR_UNDERDRIVE_ON))
  214. #define IS_PWR_WAKEUP_PIN(__PIN__) (((__PIN__) == PWR_WAKEUP_PIN1) || \
  215. ((__PIN__) == PWR_WAKEUP_PIN2) || \
  216. ((__PIN__) == PWR_WAKEUP_PIN3) || \
  217. ((__PIN__) == PWR_WAKEUP_PIN4) || \
  218. ((__PIN__) == PWR_WAKEUP_PIN5) || \
  219. ((__PIN__) == PWR_WAKEUP_PIN6) || \
  220. ((__PIN__) == PWR_WAKEUP_PIN1_HIGH) || \
  221. ((__PIN__) == PWR_WAKEUP_PIN2_HIGH) || \
  222. ((__PIN__) == PWR_WAKEUP_PIN3_HIGH) || \
  223. ((__PIN__) == PWR_WAKEUP_PIN4_HIGH) || \
  224. ((__PIN__) == PWR_WAKEUP_PIN5_HIGH) || \
  225. ((__PIN__) == PWR_WAKEUP_PIN6_HIGH) || \
  226. ((__PIN__) == PWR_WAKEUP_PIN1_LOW) || \
  227. ((__PIN__) == PWR_WAKEUP_PIN2_LOW) || \
  228. ((__PIN__) == PWR_WAKEUP_PIN3_LOW) || \
  229. ((__PIN__) == PWR_WAKEUP_PIN4_LOW) || \
  230. ((__PIN__) == PWR_WAKEUP_PIN5_LOW) || \
  231. ((__PIN__) == PWR_WAKEUP_PIN6_LOW))
  232. /**
  233. * @}
  234. */
  235. /**
  236. * @}
  237. */
  238. /**
  239. * @}
  240. */
  241. /**
  242. * @}
  243. */
  244. #ifdef __cplusplus
  245. }
  246. #endif
  247. #endif /* __STM32F7xx_HAL_PWR_EX_H */
  248. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/