fm33lc0xx_fl_rmu.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. /**
  2. *******************************************************************************************************
  3. * @file fm33lc0xx_fl_rmu.h
  4. * @author FMSH Application Team
  5. * @brief Head file of RMU FL Module
  6. *******************************************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) [2019] [Fudan Microelectronics]
  10. * THIS SOFTWARE is licensed under the Mulan PSL v1.
  11. * can use this software according to the terms and conditions of the Mulan PSL v1.
  12. * You may obtain a copy of Mulan PSL v1 at:
  13. * http://license.coscl.org.cn/MulanPSL
  14. * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
  16. * PURPOSE.
  17. * See the Mulan PSL v1 for more details.
  18. *
  19. *******************************************************************************************************
  20. */
  21. /* Define to prevent recursive inclusion---------------------------------------------------------------*/
  22. #ifndef __FM33LC0XX_FL_RMU_H
  23. #define __FM33LC0XX_FL_RMU_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /* Includes -------------------------------------------------------------------------------------------*/
  28. #include "fm33lc0xx_fl.h"
  29. /** @addtogroup FM33LC0XX_FL_Driver
  30. * @{
  31. */
  32. /** @defgroup RMU RMU
  33. * @brief RMU FL driver
  34. * @{
  35. */
  36. /* Exported types -------------------------------------------------------------------------------------*/
  37. /** @defgroup RMU_FL_ES_INIT RMU Exported Init structures
  38. * @{
  39. */
  40. /**
  41. * @}
  42. */
  43. /* Exported constants ---------------------------------------------------------------------------------*/
  44. /** @defgroup RMU_FL_Exported_Constants RMU Exported Constants
  45. * @{
  46. */
  47. #define RMU_PDRCR_CFG_Pos (1U)
  48. #define RMU_PDRCR_CFG_Msk (0x3U << RMU_PDRCR_CFG_Pos)
  49. #define RMU_PDRCR_CFG RMU_PDRCR_CFG_Msk
  50. #define RMU_PDRCR_EN_Pos (0U)
  51. #define RMU_PDRCR_EN_Msk (0x1U << RMU_PDRCR_EN_Pos)
  52. #define RMU_PDRCR_EN RMU_PDRCR_EN_Msk
  53. #define RMU_BORCR_CFG_Pos (1U)
  54. #define RMU_BORCR_CFG_Msk (0x3U << RMU_BORCR_CFG_Pos)
  55. #define RMU_BORCR_CFG RMU_BORCR_CFG_Msk
  56. #define RMU_BORCR_OFF_BOR_1P2_Pos (0U)
  57. #define RMU_BORCR_OFF_BOR_1P2_Msk (0x1U << RMU_BORCR_OFF_BOR_1P2_Pos)
  58. #define RMU_BORCR_OFF_BOR_1P2 RMU_BORCR_OFF_BOR_1P2_Msk
  59. #define RMU_BORCR_OFF_BOR_1P0_Pos (1U)
  60. #define RMU_BORCR_OFF_BOR_1P0_Msk (0x1U << RMU_BORCR_OFF_BOR_1P0_Pos)
  61. #define RMU_BORCR_OFF_BOR_1P0 RMU_BORCR_OFF_BOR_1P0_Msk
  62. #define FL_RMU_PDR_THRESHOLD_1P5V (0x0U << RMU_PDRCR_CFG_Pos)
  63. #define FL_RMU_PDR_THRESHOLD_1P25V (0x1U << RMU_PDRCR_CFG_Pos)
  64. #define FL_RMU_PDR_THRESHOLD_1P35V (0x2U << RMU_PDRCR_CFG_Pos)
  65. #define FL_RMU_PDR_THRESHOLD_1P4V (0x3U << RMU_PDRCR_CFG_Pos)
  66. #define FL_RMU_BOR_THRESHOLD_1P7V (0x0U << RMU_BORCR_CFG_Pos)
  67. #define FL_RMU_BOR_THRESHOLD_1P6V (0x1U << RMU_BORCR_CFG_Pos)
  68. #define FL_RMU_BOR_THRESHOLD_1P65V (0x2U << RMU_BORCR_CFG_Pos)
  69. #define FL_RMU_BOR_THRESHOLD_1P75V (0x3U << RMU_BORCR_CFG_Pos)
  70. /**
  71. * @}
  72. */
  73. /* Exported functions ---------------------------------------------------------------------------------*/
  74. /** @defgroup RMU_FL_Exported_Functions RMU Exported Functions
  75. * @{
  76. */
  77. /**
  78. * @brief Set PDR Power Down Reset Voltage
  79. * @rmtoll PDRCR CFG FL_RMU_PDR_SetThreshold
  80. * @param RMUx RMU instance
  81. * @param threshold This parameter can be one of the following values:
  82. * @arg @ref FL_RMU_PDR_THRESHOLD_1P5V
  83. * @arg @ref FL_RMU_PDR_THRESHOLD_1P25V
  84. * @arg @ref FL_RMU_PDR_THRESHOLD_1P35V
  85. * @arg @ref FL_RMU_PDR_THRESHOLD_1P4V
  86. * @retval None
  87. */
  88. __STATIC_INLINE void FL_RMU_PDR_SetThreshold(RMU_Type *RMUx, uint32_t threshold)
  89. {
  90. MODIFY_REG(RMUx->PDRCR, RMU_PDRCR_CFG_Msk, threshold);
  91. }
  92. /**
  93. * @brief Get PDR Power Down Reset Voltage Setting
  94. * @rmtoll PDRCR CFG FL_RMU_PDR_GetThreshold
  95. * @param RMUx RMU instance
  96. * @retval Returned value can be one of the following values:
  97. * @arg @ref FL_RMU_PDR_THRESHOLD_1P5V
  98. * @arg @ref FL_RMU_PDR_THRESHOLD_1P25V
  99. * @arg @ref FL_RMU_PDR_THRESHOLD_1P35V
  100. * @arg @ref FL_RMU_PDR_THRESHOLD_1P4V
  101. */
  102. __STATIC_INLINE uint32_t FL_RMU_PDR_GetThreshold(RMU_Type *RMUx)
  103. {
  104. return (uint32_t)(READ_BIT(RMUx->PDRCR, RMU_PDRCR_CFG_Msk));
  105. }
  106. /**
  107. * @brief Get PDR Power Down Reset Enable Status
  108. * @rmtoll PDRCR EN FL_RMU_PDR_IsEnabled
  109. * @param RMUx RMU instance
  110. * @retval State of bit (1 or 0).
  111. */
  112. __STATIC_INLINE uint32_t FL_RMU_PDR_IsEnabled(RMU_Type *RMUx)
  113. {
  114. return (uint32_t)(READ_BIT(RMUx->PDRCR, RMU_PDRCR_EN_Msk) == RMU_PDRCR_EN_Msk);
  115. }
  116. /**
  117. * @brief Disable PDR Power Down Reset
  118. * @rmtoll PDRCR EN FL_RMU_PDR_Disable
  119. * @param RMUx RMU instance
  120. * @retval None
  121. */
  122. __STATIC_INLINE void FL_RMU_PDR_Disable(RMU_Type *RMUx)
  123. {
  124. CLEAR_BIT(RMUx->PDRCR, RMU_PDRCR_EN_Msk);
  125. }
  126. /**
  127. * @brief Enable PDR Power Down Reset
  128. * @rmtoll PDRCR EN FL_RMU_PDR_Enable
  129. * @param RMUx RMU instance
  130. * @retval None
  131. */
  132. __STATIC_INLINE void FL_RMU_PDR_Enable(RMU_Type *RMUx)
  133. {
  134. SET_BIT(RMUx->PDRCR, RMU_PDRCR_EN_Msk);
  135. }
  136. /**
  137. * @brief Set BOR Power Down Reset Voltage
  138. * @rmtoll BORCR CFG FL_RMU_BOR_SetThreshold
  139. * @param RMUx RMU instance
  140. * @param threshold This parameter can be one of the following values:
  141. * @arg @ref FL_RMU_BOR_THRESHOLD_1P7V
  142. * @arg @ref FL_RMU_BOR_THRESHOLD_1P6V
  143. * @arg @ref FL_RMU_BOR_THRESHOLD_1P65V
  144. * @arg @ref FL_RMU_BOR_THRESHOLD_1P75V
  145. * @retval None
  146. */
  147. __STATIC_INLINE void FL_RMU_BOR_SetThreshold(RMU_Type *RMUx, uint32_t threshold)
  148. {
  149. MODIFY_REG(RMUx->BORCR, RMU_BORCR_CFG_Msk, threshold);
  150. }
  151. /**
  152. * @brief Get BOR Power Down Reset Voltage Setting
  153. * @rmtoll BORCR CFG FL_RMU_BOR_GetThreshold
  154. * @param RMUx RMU instance
  155. * @retval Returned value can be one of the following values:
  156. * @arg @ref FL_RMU_BOR_THRESHOLD_1P7V
  157. * @arg @ref FL_RMU_BOR_THRESHOLD_1P6V
  158. * @arg @ref FL_RMU_BOR_THRESHOLD_1P65V
  159. * @arg @ref FL_RMU_BOR_THRESHOLD_1P75V
  160. */
  161. __STATIC_INLINE uint32_t FL_RMU_BOR_GetThreshold(RMU_Type *RMUx)
  162. {
  163. return (uint32_t)(READ_BIT(RMUx->BORCR, RMU_BORCR_CFG_Msk));
  164. }
  165. /**
  166. * @brief Get BOR Power Down Reset Enable Status
  167. * @rmtoll BORCR OFF_BOR_1P2 FL_RMU_BORPowerDown_IsEnabled
  168. * @param RMUx RMU instance
  169. * @retval State of bit (1 or 0).
  170. */
  171. __STATIC_INLINE uint32_t FL_RMU_BORPowerDown_IsEnabled(RMU_Type *RMUx)
  172. {
  173. return (uint32_t)!(READ_BIT(RMUx->BORCR, RMU_BORCR_OFF_BOR_1P2_Msk) == RMU_BORCR_OFF_BOR_1P2_Msk);
  174. }
  175. /**
  176. * @brief Disable BOR Power Down Reset
  177. * @rmtoll BORCR OFF_BOR_1P2 FL_RMU_BORPowerDown_Disable
  178. * @param RMUx RMU instance
  179. * @retval None
  180. */
  181. __STATIC_INLINE void FL_RMU_BORPowerDown_Disable(RMU_Type *RMUx)
  182. {
  183. SET_BIT(RMUx->BORCR, RMU_BORCR_OFF_BOR_1P2_Msk);
  184. }
  185. /**
  186. * @brief Enable BOR Power Down Reset
  187. * @rmtoll BORCR OFF_BOR_1P2 FL_RMU_BORPowerDown_Enable
  188. * @param RMUx RMU instance
  189. * @retval None
  190. */
  191. __STATIC_INLINE void FL_RMU_BORPowerDown_Enable(RMU_Type *RMUx)
  192. {
  193. CLEAR_BIT(RMUx->BORCR, RMU_BORCR_OFF_BOR_1P2_Msk);
  194. }
  195. /**
  196. * @brief Get BOR Power On Reset Enable Status
  197. * @rmtoll BORCR OFF_BOR_1P0 FL_RMU_BORPowerUp_IsEnabled
  198. * @param RMUx RMU instance
  199. * @retval State of bit (1 or 0).
  200. */
  201. __STATIC_INLINE uint32_t FL_RMU_BORPowerUp_IsEnabled(RMU_Type *RMUx)
  202. {
  203. return (uint32_t)!(READ_BIT(RMUx->BORCR, RMU_BORCR_OFF_BOR_1P0_Msk) == RMU_BORCR_OFF_BOR_1P0_Msk);
  204. }
  205. /**
  206. * @brief Disable BOR Power On Reset
  207. * @rmtoll BORCR OFF_BOR_1P0 FL_RMU_BORPowerUp_Disable
  208. * @param RMUx RMU instance
  209. * @retval None
  210. */
  211. __STATIC_INLINE void FL_RMU_BORPowerUp_Disable(RMU_Type *RMUx)
  212. {
  213. SET_BIT(RMUx->BORCR, RMU_BORCR_OFF_BOR_1P0_Msk);
  214. }
  215. /**
  216. * @brief Enable BOR Power On Reset
  217. * @rmtoll BORCR OFF_BOR_1P0 FL_RMU_BORPowerUp_Enable
  218. * @param RMUx RMU instance
  219. * @retval None
  220. */
  221. __STATIC_INLINE void FL_RMU_BORPowerUp_Enable(RMU_Type *RMUx)
  222. {
  223. CLEAR_BIT(RMUx->BORCR, RMU_BORCR_OFF_BOR_1P0_Msk);
  224. }
  225. /**
  226. * @}
  227. */
  228. /** @defgroup RMU_FL_EF_Init Initialization and de-initialization functions
  229. * @{
  230. */
  231. /**
  232. * @}
  233. */
  234. /**
  235. * @}
  236. */
  237. /**
  238. * @}
  239. */
  240. #ifdef __cplusplus
  241. }
  242. #endif
  243. #endif /* __FM33LC0XX_FL_RMU_H*/
  244. /*************************Py_Code_Generator Version: 0.1-0.11-0.2 @ 2020-09-23*************************/
  245. /*************************(C) COPYRIGHT Fudan Microelectronics **** END OF FILE*************************/