reg_rtc.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. ////////////////////////////////////////////////////////////////////////////////
  2. /// @file reg_rtc.h
  3. /// @author AE TEAM
  4. /// @brief THIS FILE CONTAINS ALL THE FUNCTIONS PROTOTYPES FOR THE SERIES OF
  5. /// MM32 FIRMWARE LIBRARY.
  6. ////////////////////////////////////////////////////////////////////////////////
  7. /// @attention
  8. ///
  9. /// THE EXISTING FIRMWARE IS ONLY FOR REFERENCE, WHICH IS DESIGNED TO PROVIDE
  10. /// CUSTOMERS WITH CODING INFORMATION ABOUT THEIR PRODUCTS SO THEY CAN SAVE
  11. /// TIME. THEREFORE, MINDMOTION SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT OR
  12. /// CONSEQUENTIAL DAMAGES ABOUT ANY CLAIMS ARISING OUT OF THE CONTENT OF SUCH
  13. /// HARDWARE AND/OR THE USE OF THE CODING INFORMATION CONTAINED HEREIN IN
  14. /// CONNECTION WITH PRODUCTS MADE BY CUSTOMERS.
  15. ///
  16. /// <H2><CENTER>&COPY; COPYRIGHT MINDMOTION </CENTER></H2>
  17. ////////////////////////////////////////////////////////////////////////////////
  18. // Define to prevent recursive inclusion
  19. #ifndef __REG_RTC_H
  20. #define __REG_RTC_H
  21. // Files includes
  22. #include <stdint.h>
  23. #include <stdbool.h>
  24. #include "types.h"
  25. #if defined ( __CC_ARM )
  26. #pragma anon_unions
  27. #endif
  28. ////////////////////////////////////////////////////////////////////////////////
  29. /// @brief RTC Base Address Definition
  30. ////////////////////////////////////////////////////////////////////////////////
  31. #define RTC_BASE (APB1PERIPH_BASE + 0x2800) ///< Base Address: 0x40002800
  32. ////////////////////////////////////////////////////////////////////////////////
  33. /// @brief RTC Registers Structure Definition
  34. ////////////////////////////////////////////////////////////////////////////////
  35. typedef struct {
  36. union {
  37. __IO u32 CR; ///< Control Register, offset: 0x00
  38. __IO u32 CRH;
  39. };
  40. union {
  41. __IO u32 CSR; ///< Control & Status Register, offset: 0x04
  42. __IO u32 CRL;
  43. };
  44. __IO u32 PRLH; ///< Prescaler Reload Value High, offset: 0x08
  45. __IO u32 PRLL; ///< Prescaler Reload Value Low, offset: 0x0C
  46. __IO u32 DIVH; ///< Clock Divider High, offset: 0x10
  47. __IO u32 DIVL; ///< Clock Divider Low, offset: 0x14
  48. __IO u32 CNTH; ///< Counter High, offset: 0x18
  49. __IO u32 CNTL; ///< Counter Low, offset: 0x1C
  50. __IO u32 ALRH; ///< Alarm High, offset: 0x20
  51. __IO u32 ALRL; ///< Alarm Low, offset: 0x24
  52. __IO u32 MSRH; ///< Millisecond alarm high register offset: 0x28
  53. __IO u32 MSRL; ///< Millisecond alarm low register offset: 0x2C
  54. __IO u32 RESERVED0; ///< Reserved offset: 0x30
  55. __IO u32 RESERVED1; ///< Reserved offset: 0x34
  56. __IO u32 RESERVED2; ///< Reserved offset: 0x38
  57. __IO u32 LSE_CFG; ///< LSE configure register offset: 0x3C
  58. } RTC_TypeDef;
  59. ////////////////////////////////////////////////////////////////////////////////
  60. /// @brief RTC type pointer Definition
  61. ////////////////////////////////////////////////////////////////////////////////
  62. #define RTC ((RTC_TypeDef*)RTC_BASE)
  63. ////////////////////////////////////////////////////////////////////////////////
  64. /// @brief RTC_CR Register Bit Definition
  65. ////////////////////////////////////////////////////////////////////////////////
  66. #define RTC_CR_SECIE_Pos (0)
  67. #define RTC_CR_SECIE (0x01U << RTC_CR_SECIE_Pos) ///< Second Interrupt Enable
  68. #define RTC_CR_ALRIE_Pos (1)
  69. #define RTC_CR_ALRIE (0x01U << RTC_CR_ALRIE_Pos) ///< Alarm Interrupt Enable
  70. #define RTC_CR_OWIE_Pos (2)
  71. #define RTC_CR_OWIE (0x01U << RTC_CR_OWIE_Pos) ///< OverfloW Interrupt Enable
  72. ////////////////////////////////////////////////////////////////////////////////
  73. /// @brief RTC_CSR Register Bit Definition
  74. ////////////////////////////////////////////////////////////////////////////////
  75. #define RTC_CSR_SECF_Pos (0)
  76. #define RTC_CSR_SECF (0x01 << RTC_CSR_SECF_Pos) ///< Second Flag
  77. #define RTC_CSR_ALRF_Pos (1)
  78. #define RTC_CSR_ALRF (0x01 << RTC_CSR_ALRF_Pos) ///< Alarm Flag
  79. #define RTC_CSR_OWF_Pos (2)
  80. #define RTC_CSR_OWF (0x01 << RTC_CSR_OWF_Pos) ///< OverfloW Flag
  81. #define RTC_CSR_RSF_Pos (3)
  82. #define RTC_CSR_RSF (0x01 << RTC_CSR_RSF_Pos) ///< Registers Synchronized Flag
  83. #define RTC_CSR_CNF_Pos (4)
  84. #define RTC_CSR_CNF (0x01 << RTC_CSR_CNF_Pos) ///< Configuration Flag
  85. #define RTC_CSR_RTOFF_Pos (5)
  86. #define RTC_CSR_RTOFF (0x01 << RTC_CSR_RTOFF_Pos) ///< RTC operation OFF
  87. #define RTC_CSR_ALPEN_Pos (6)
  88. #define RTC_CSR_ALPEN (0x01 << RTC_CSR_ALPEN_Pos) ///< RTC Alarm Loop Enable
  89. ////////////////////////////////////////////////////////////////////////////////
  90. /// @brief RTC_PRLH Register Bit Definition
  91. ////////////////////////////////////////////////////////////////////////////////
  92. #define RTC_PRLH_PRL_Pos (0)
  93. #define RTC_PRLH_PRL (0x0F << RTC_PRLH_PRL_Pos) ///< RTC Prescaler Reload Value High
  94. ////////////////////////////////////////////////////////////////////////////////
  95. /// @brief RTC_PRLL Register Bit Definition
  96. ////////////////////////////////////////////////////////////////////////////////
  97. #define RTC_PRLL_PRL_Pos (0)
  98. #define RTC_PRLL_PRL (0xFFFFU << RTC_PRLL_PRL_Pos) ///< RTC Prescaler Reload Value Low
  99. ////////////////////////////////////////////////////////////////////////////////
  100. /// @brief RTC_DIVH Register Bit Definition
  101. ////////////////////////////////////////////////////////////////////////////////
  102. #define RTC_DIVH_DIV_Pos (0)
  103. #define RTC_DIVH_DIV (0x0F << RTC_DIVH_DIV_Pos) ///< RTC Clock Divider High
  104. ////////////////////////////////////////////////////////////////////////////////
  105. /// @brief RTC_DIVL Register Bit Definition
  106. ////////////////////////////////////////////////////////////////////////////////
  107. #define RTC_DIVL_DIV_Pos (0)
  108. #define RTC_DIVL_DIV (0xFFFFU << RTC_DIVL_DIV_Pos) ///< RTC Clock Divider Low
  109. ////////////////////////////////////////////////////////////////////////////////
  110. /// @brief RTC_CNTH Register Bit Definition
  111. ////////////////////////////////////////////////////////////////////////////////
  112. #define RTC_CNTH_CNT_Pos (0)
  113. #define RTC_CNTH_CNT (0xFFFFU << RTC_CNTH_CNT_Pos) ///< RTC Counter High
  114. ////////////////////////////////////////////////////////////////////////////////
  115. /// @brief RTC_CNTL Register Bit Definition
  116. ////////////////////////////////////////////////////////////////////////////////
  117. #define RTC_CNTL_CNT_Pos (0)
  118. #define RTC_CNTL_CNT (0xFFFFU << RTC_CNTL_CNT_Pos) ///< RTC Counter Low
  119. ////////////////////////////////////////////////////////////////////////////////
  120. /// @brief RTC_ALRH Register Bit Definition
  121. ////////////////////////////////////////////////////////////////////////////////
  122. #define RTC_ALRH_ALR_Pos (0)
  123. #define RTC_ALRH_ALR (0xFFFFU << RTC_ALRH_ALR_Pos) ///< RTC Alarm High
  124. ////////////////////////////////////////////////////////////////////////////////
  125. /// @brief RTC_ALRL Register Bit Definition
  126. ////////////////////////////////////////////////////////////////////////////////
  127. #define RTC_ALRL_ALR_Pos (0)
  128. #define RTC_ALRL_ALR (0xFFFFU << RTC_ALRL_ALR_Pos) ///< RTC Alarm Low
  129. ////////////////////////////////////////////////////////////////////////////////
  130. /// @brief RTC_MSRH Register Bit Definition
  131. ////////////////////////////////////////////////////////////////////////////////
  132. #define RTC_MSRH_MSR_Pos (0)
  133. #define RTC_MSRH_MSR (0xFFFFU << RTC_MSRH_MSR_Pos) ///< RTC MS Alarm Register High
  134. ////////////////////////////////////////////////////////////////////////////////
  135. /// @brief RTC_MSRL Register Bit Definition
  136. ////////////////////////////////////////////////////////////////////////////////
  137. #define RTC_MSRL_MSR_Pos (0)
  138. #define RTC_MSRL_MSR (0xFFFFU << RTC_MSRL_MSR_Pos) ///< RTC MS Alarm Register Low
  139. ////////////////////////////////////////////////////////////////////////////////
  140. /// @brief RTC_LSE_CFG Register Bit Definition
  141. ////////////////////////////////////////////////////////////////////////////////
  142. #define RTC_LSE_CFG_TEST_Pos (0)
  143. #define RTC_LSE_CFG_TEST (0x0FU << RTC_LSE_CFG_TEST_Pos) ///< Test control signal
  144. #define RTC_LSE_CFG_DR_Pos (4)
  145. #define RTC_LSE_CFG_DR (0x03U << RTC_LSE_CFG_DR_Pos) ///< Drive capability selection
  146. #define RTC_LSE_CFG_RFB_SEL_Pos (6)
  147. #define RTC_LSE_CFG_RFB_SEL_3 (0x03U << RTC_LSE_CFG_RFB_SEL_Pos) ///< Feedback resistance selection 3M
  148. #define RTC_LSE_CFG_RFB_SEL_6 (0x02U << RTC_LSE_CFG_RFB_SEL_Pos) ///< Feedback resistance selection 6M
  149. #define RTC_LSE_CFG_RFB_SEL_10 (0x01U << RTC_LSE_CFG_RFB_SEL_Pos) ///< Feedback resistance selection 10M
  150. #define RTC_LSE_CFG_RFB_SEL_12 (0x00U << RTC_LSE_CFG_RFB_SEL_Pos) ///< Feedback resistance selection 12M
  151. #define RTC_LSE_CFG_IB_Pos (8)
  152. #define RTC_LSE_CFG_IB (0x01U << RTC_MSRL_MSR_Pos) ///< Bias current regulation
  153. /// @}
  154. /// @}
  155. /// @}
  156. ////////////////////////////////////////////////////////////////////////////////
  157. #endif
  158. ////////////////////////////////////////////////////////////////////////////////