ft32f0xx_pwr.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /**
  2. ******************************************************************************
  3. * @file ft32f0xx_pwr.h
  4. * @author FMD AE
  5. * @brief This file contains all the functions prototypes for the PWR firmware
  6. * library.
  7. * @version V1.0.0
  8. * @data 2021-07-01
  9. ******************************************************************************
  10. */
  11. /* Define to prevent recursive inclusion -------------------------------------*/
  12. #ifndef __FT32F0XX_PWR_H
  13. #define __FT32F0XX_PWR_H
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /* Includes ------------------------------------------------------------------*/
  18. #include "ft32f0xx.h"
  19. /** @addtogroup PWR
  20. * @{
  21. */
  22. /* Exported types ------------------------------------------------------------*/
  23. /* Exported constants --------------------------------------------------------*/
  24. /** @defgroup PWR_Exported_Constants
  25. * @{
  26. */
  27. /** @defgroup PWR_PVD_detection_level
  28. * @brief
  29. * @{
  30. */
  31. #define PWR_PVDLevel_0 PWR_CR_PLS_LEV0
  32. #define PWR_PVDLevel_1 PWR_CR_PLS_LEV1
  33. #define PWR_PVDLevel_2 PWR_CR_PLS_LEV2
  34. #define PWR_PVDLevel_3 PWR_CR_PLS_LEV3
  35. #define PWR_PVDLevel_4 PWR_CR_PLS_LEV4
  36. #define PWR_PVDLevel_5 PWR_CR_PLS_LEV5
  37. #define PWR_PVDLevel_6 PWR_CR_PLS_LEV6
  38. #define PWR_PVDLevel_7 PWR_CR_PLS_LEV7
  39. #define PWR_PVDLevel_8 PWR_CR_PLS_LEV8
  40. #define PWR_PVDLevel_9 PWR_CR_PLS_LEV9
  41. #define PWR_PVDLevel_10 PWR_CR_PLS_LEV10
  42. #define PWR_PVDLevel_11 PWR_CR_PLS_LEV11
  43. #define PWR_PVDLevel_12 PWR_CR_PLS_LEV12
  44. #define PWR_PVDLevel_13 PWR_CR_PLS_LEV13
  45. #define PWR_PVDLevel_14 PWR_CR_PLS_LEV14
  46. #define PWR_PVDLevel_15 PWR_CR_PLS_LEV15
  47. #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLevel_0) || ((LEVEL) == PWR_PVDLevel_1)|| \
  48. ((LEVEL) == PWR_PVDLevel_2) || ((LEVEL) == PWR_PVDLevel_3)|| \
  49. ((LEVEL) == PWR_PVDLevel_4) || ((LEVEL) == PWR_PVDLevel_5)|| \
  50. ((LEVEL) == PWR_PVDLevel_6) || ((LEVEL) == PWR_PVDLevel_7)|| \
  51. ((LEVEL) == PWR_PVDLevel_8) || ((LEVEL) == PWR_PVDLevel_9)|| \
  52. ((LEVEL) == PWR_PVDLevel_10) || ((LEVEL) == PWR_PVDLevel_11)|| \
  53. ((LEVEL) == PWR_PVDLevel_12) || ((LEVEL) == PWR_PVDLevel_13)|| \
  54. ((LEVEL) == PWR_PVDLevel_14) || ((LEVEL) == PWR_PVDLevel_15))
  55. /**
  56. * @}
  57. */
  58. /** @defgroup PWR_WakeUp_Pins
  59. * @{
  60. */
  61. #define PWR_WakeUpPin_1 PWR_CSR_EWUP1
  62. #define PWR_WakeUpPin_2 PWR_CSR_EWUP2
  63. #define PWR_WakeUpPin_3 PWR_CSR_EWUP3
  64. #define PWR_WakeUpPin_4 PWR_CSR_EWUP4
  65. #define PWR_WakeUpPin_5 PWR_CSR_EWUP5
  66. #define PWR_WakeUpPin_6 PWR_CSR_EWUP6
  67. #define PWR_WakeUpPin_7 PWR_CSR_EWUP7
  68. #define PWR_WakeUpPin_8 PWR_CSR_EWUP8
  69. #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WakeUpPin_1) || ((PIN) == PWR_WakeUpPin_2) || \
  70. ((PIN) == PWR_WakeUpPin_3) || ((PIN) == PWR_WakeUpPin_4) || \
  71. ((PIN) == PWR_WakeUpPin_5) || ((PIN) == PWR_WakeUpPin_6) || \
  72. ((PIN) == PWR_WakeUpPin_7) || ((PIN) == PWR_WakeUpPin_8))
  73. /**
  74. * @}
  75. */
  76. /** @defgroup PWR_Regulator_state_is_Sleep_STOP_mode
  77. * @{
  78. */
  79. #define PWR_Regulator_ON ((uint32_t)0x00000000)
  80. #define PWR_Regulator_LowPower PWR_CR_LPSDSR
  81. #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_Regulator_ON) || \
  82. ((REGULATOR) == PWR_Regulator_LowPower))
  83. /**
  84. * @}
  85. */
  86. /** @defgroup PWR_SLEEP_mode_entry
  87. * @{
  88. */
  89. #define PWR_SLEEPEntry_WFI ((uint8_t)0x01)
  90. #define PWR_SLEEPEntry_WFE ((uint8_t)0x02)
  91. #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPEntry_WFI) || ((ENTRY) == PWR_SLEEPEntry_WFE))
  92. /**
  93. * @}
  94. */
  95. /** @defgroup PWR_STOP_mode_entry
  96. * @{
  97. */
  98. #define PWR_STOPEntry_WFI ((uint8_t)0x01)
  99. #define PWR_STOPEntry_WFE ((uint8_t)0x02)
  100. #define PWR_STOPEntry_SLEEPONEXIT ((uint8_t)0x03)
  101. #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPEntry_WFI) || ((ENTRY) == PWR_STOPEntry_WFE) ||\
  102. ((ENTRY) == PWR_STOPEntry_SLEEPONEXIT))
  103. /**
  104. * @}
  105. */
  106. /** @defgroup PWR_Flag
  107. * @{
  108. */
  109. #define PWR_FLAG_WU PWR_CSR_WUF
  110. #define PWR_FLAG_SB PWR_CSR_SBF
  111. #define PWR_FLAG_PVDO PWR_CSR_PVDO
  112. #define PWR_FLAG_VREFINTRDY PWR_CSR_VREFINTRDYF
  113. #define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \
  114. ((FLAG) == PWR_FLAG_PVDO) || ((FLAG) == PWR_FLAG_VREFINTRDY))
  115. #define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB))
  116. /**
  117. * @}
  118. */
  119. /**
  120. * @}
  121. */
  122. /* Exported macro ------------------------------------------------------------*/
  123. /* Exported functions ------------------------------------------------------- */
  124. /* Function used to set the PWR configuration to the default reset state ******/
  125. void PWR_DeInit(void);
  126. /* Backup Domain Access function **********************************************/
  127. void PWR_BackupAccessCmd(FunctionalState NewState);
  128. /* PVD configuration functions ************************************************/
  129. void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel);
  130. void PWR_PVDCmd(FunctionalState NewState);
  131. /* WakeUp pins configuration functions ****************************************/
  132. void PWR_WakeUpPinCmd(uint32_t PWR_WakeUpPin, FunctionalState NewState);
  133. /* Low Power modes configuration functions ************************************/
  134. void PWR_EnterSleepMode(uint8_t PWR_SLEEPEntry);
  135. void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry);
  136. void PWR_EnterSTANDBYMode(void);
  137. /* Flags management functions *************************************************/
  138. FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG);
  139. void PWR_ClearFlag(uint32_t PWR_FLAG);
  140. #ifdef __cplusplus
  141. }
  142. #endif
  143. #endif /* __FT32F0XX_PWR_H */
  144. /**
  145. * @}
  146. */
  147. /**
  148. * @}
  149. */
  150. /************************ (C) COPYRIGHT FMD *****END OF FILE****/