n32g45x_pwr.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*****************************************************************************
  2. * Copyright (c) 2019, Nations Technologies Inc.
  3. *
  4. * All rights reserved.
  5. * ****************************************************************************
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. *
  10. * - Redistributions of source code must retain the above copyright notice,
  11. * this list of conditions and the disclaimer below.
  12. *
  13. * Nations' name may not be used to endorse or promote products derived from
  14. * this software without specific prior written permission.
  15. *
  16. * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
  17. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  18. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  19. * DISCLAIMED. IN NO EVENT SHALL NATIONS BE LIABLE FOR ANY DIRECT, INDIRECT,
  20. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  21. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  22. * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  23. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  25. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. * ****************************************************************************/
  27. /**
  28. * @file n32g45x_pwr.h
  29. * @author Nations
  30. * @version v1.0.0
  31. *
  32. * @copyright Copyright (c) 2019, Nations Technologies Inc. All rights reserved.
  33. */
  34. #ifndef __N32G45X_PWR_H__
  35. #define __N32G45X_PWR_H__
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. #include "n32g45x.h"
  40. /** @addtogroup N32G45X_StdPeriph_Driver
  41. * @{
  42. */
  43. /** @addtogroup PWR
  44. * @{
  45. */
  46. /** @addtogroup PWR_Exported_Types
  47. * @{
  48. */
  49. /**
  50. * @}
  51. */
  52. /** @addtogroup PWR_Exported_Constants
  53. * @{
  54. */
  55. /** @addtogroup PVD_detection_level
  56. * @{
  57. */
  58. #define PWR_PVDRANGRE_2V2 ((uint32_t)0x00000000)
  59. #define PWR_PVDRANGRE_2V3 ((uint32_t)0x00000020)
  60. #define PWR_PVDRANGRE_2V4 ((uint32_t)0x00000040)
  61. #define PWR_PVDRANGRE_2V5 ((uint32_t)0x00000060)
  62. #define PWR_PVDRANGRE_2V6 ((uint32_t)0x00000080)
  63. #define PWR_PVDRANGRE_2V7 ((uint32_t)0x000000A0)
  64. #define PWR_PVDRANGRE_2V8 ((uint32_t)0x000000C0)
  65. #define PWR_PVDRANGRE_2V9 ((uint32_t)0x000000E0)
  66. #define PWR_PVDRANGE_1V78 ((uint32_t)0x00000200)
  67. #define PWR_PVDRANGE_1V88 ((uint32_t)0x00000220)
  68. #define PWR_PVDRANGE_1V98 ((uint32_t)0x00000240)
  69. #define PWR_PVDRANGE_2V08 ((uint32_t)0x00000260)
  70. #define PWR_PVDRANGE_3V06 ((uint32_t)0x00000280)
  71. #define PWR_PVDRANGE_3V24 ((uint32_t)0x000002A0)
  72. #define PWR_PVDRANGE_3V42 ((uint32_t)0x000002C0)
  73. #define PWR_PVDRANGE_3V60 ((uint32_t)0x000002E0)
  74. #define IS_PWR_PVD_LEVEL(LEVEL) \
  75. (((LEVEL) == PWR_PVDRANGRE_2V2) || ((LEVEL) == PWR_PVDRANGRE_2V3) || ((LEVEL) == PWR_PVDRANGRE_2V4) \
  76. || ((LEVEL) == PWR_PVDRANGRE_2V5) || ((LEVEL) == PWR_PVDRANGRE_2V6) || ((LEVEL) == PWR_PVDRANGRE_2V7) \
  77. || ((LEVEL) == PWR_PVDRANGRE_2V8) || ((LEVEL) == PWR_PVDRANGRE_2V9) || ((LEVEL) == PWR_PVDRANGE_1V78) \
  78. || ((LEVEL) == PWR_PVDRANGE_1V88) || ((LEVEL) == PWR_PVDRANGE_1V98) || ((LEVEL) == PWR_PVDRANGE_2V08) \
  79. || ((LEVEL) == PWR_PVDRANGE_3V06) || ((LEVEL) == PWR_PVDRANGE_3V24) || ((LEVEL) == PWR_PVDRANGE_3V42) \
  80. || ((LEVEL) == PWR_PVDRANGE_3V60))
  81. /**
  82. * @}
  83. */
  84. /** @addtogroup Regulator_state_is_STOP_mode
  85. * @{
  86. */
  87. #define PWR_REGULATOR_ON ((uint32_t)0x00000000)
  88. #define PWR_REGULATOR_LOWPOWER ((uint32_t)0x00000001)
  89. #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_REGULATOR_ON) || ((REGULATOR) == PWR_REGULATOR_LOWPOWER))
  90. /**
  91. * @}
  92. */
  93. /** @addtogroup STOP_mode_entry
  94. * @{
  95. */
  96. #define PWR_STOPENTRY_WFI ((uint8_t)0x01)
  97. #define PWR_STOPENTRY_WFE ((uint8_t)0x02)
  98. #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE))
  99. /**
  100. * @}
  101. */
  102. /** @addtogroup PWR_Flag
  103. * @{
  104. */
  105. #define PWR_WU_FLAG ((uint32_t)0x00000001)
  106. #define PWR_SB_FLAG ((uint32_t)0x00000002)
  107. #define PWR_PVDO_FLAG ((uint32_t)0x00000004)
  108. #define PWR_VBATF_FLAG ((uint32_t)0x00000008)
  109. #define IS_PWR_GET_FLAG(FLAG) \
  110. (((FLAG) == PWR_WU_FLAG) || ((FLAG) == PWR_SB_FLAG) || ((FLAG) == PWR_PVDO_FLAG) || ((FLAG) == PWR_VBATF_FLAG))
  111. #define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_WU_FLAG) || ((FLAG) == PWR_SB_FLAG) || ((FLAG) == PWR_VBATF_FLAG))
  112. /**
  113. * @}
  114. */
  115. /**
  116. * @}
  117. */
  118. /** @addtogroup PWR_Exported_Macros
  119. * @{
  120. */
  121. /**
  122. * @}
  123. */
  124. /** @addtogroup PWR_Exported_Functions
  125. * @{
  126. */
  127. void PWR_DeInit(void);
  128. void PWR_BackupAccessEnable(FunctionalState Cmd);
  129. void PWR_PvdEnable(FunctionalState Cmd);
  130. void PWR_PvdRangeConfig(uint32_t PWR_PVDLevel);
  131. void PWR_WakeUpPinEnable(FunctionalState Cmd);
  132. void PWR_EnterStopState(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry);
  133. void PWR_EnterSLEEPMode(uint8_t SLEEPONEXIT, uint8_t PWR_STOPEntry);
  134. void PWR_EnterSTOP2Mode(uint8_t PWR_STOPEntry);
  135. void PWR_EnterStandbyState(void);
  136. FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG);
  137. void PWR_ClearFlag(uint32_t PWR_FLAG);
  138. #ifdef __cplusplus
  139. }
  140. #endif
  141. #endif /* __N32G45X_PWR_H__ */
  142. /**
  143. * @}
  144. */
  145. /**
  146. * @}
  147. */
  148. /**
  149. * @}
  150. */