hpm_rtc_regs.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * Copyright (c) 2021-2023 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_RTC_H
  8. #define HPM_RTC_H
  9. typedef struct {
  10. __RW uint32_t SECOND; /* 0x0: Second counter */
  11. __R uint32_t SUBSEC; /* 0x4: Sub-second counter */
  12. __RW uint32_t SEC_SNAP; /* 0x8: Second counter snap shot */
  13. __RW uint32_t SUB_SNAP; /* 0xC: Sub-second counter snap shot */
  14. __RW uint32_t ALARM0; /* 0x10: RTC alarm0 */
  15. __RW uint32_t ALARM0_INC; /* 0x14: Alarm0 incremental */
  16. __RW uint32_t ALARM1; /* 0x18: RTC alarm1 */
  17. __RW uint32_t ALARM1_INC; /* 0x1C: Alarm1 incremental */
  18. __RW uint32_t ALARM_FLAG; /* 0x20: RTC alarm flag */
  19. __RW uint32_t ALARM_EN; /* 0x24: RTC alarm enable */
  20. } RTC_Type;
  21. /* Bitfield definition for register: SECOND */
  22. /*
  23. * SECOND (RW)
  24. *
  25. * second counter
  26. */
  27. #define RTC_SECOND_SECOND_MASK (0xFFFFFFFFUL)
  28. #define RTC_SECOND_SECOND_SHIFT (0U)
  29. #define RTC_SECOND_SECOND_SET(x) (((uint32_t)(x) << RTC_SECOND_SECOND_SHIFT) & RTC_SECOND_SECOND_MASK)
  30. #define RTC_SECOND_SECOND_GET(x) (((uint32_t)(x) & RTC_SECOND_SECOND_MASK) >> RTC_SECOND_SECOND_SHIFT)
  31. /* Bitfield definition for register: SUBSEC */
  32. /*
  33. * SUBSEC (RO)
  34. *
  35. * sub second counter
  36. */
  37. #define RTC_SUBSEC_SUBSEC_MASK (0xFFFFFFFFUL)
  38. #define RTC_SUBSEC_SUBSEC_SHIFT (0U)
  39. #define RTC_SUBSEC_SUBSEC_GET(x) (((uint32_t)(x) & RTC_SUBSEC_SUBSEC_MASK) >> RTC_SUBSEC_SUBSEC_SHIFT)
  40. /* Bitfield definition for register: SEC_SNAP */
  41. /*
  42. * SEC_SNAP (RW)
  43. *
  44. * second snap shot, write to take snap shot
  45. */
  46. #define RTC_SEC_SNAP_SEC_SNAP_MASK (0xFFFFFFFFUL)
  47. #define RTC_SEC_SNAP_SEC_SNAP_SHIFT (0U)
  48. #define RTC_SEC_SNAP_SEC_SNAP_SET(x) (((uint32_t)(x) << RTC_SEC_SNAP_SEC_SNAP_SHIFT) & RTC_SEC_SNAP_SEC_SNAP_MASK)
  49. #define RTC_SEC_SNAP_SEC_SNAP_GET(x) (((uint32_t)(x) & RTC_SEC_SNAP_SEC_SNAP_MASK) >> RTC_SEC_SNAP_SEC_SNAP_SHIFT)
  50. /* Bitfield definition for register: SUB_SNAP */
  51. /*
  52. * SUB_SNAP (RW)
  53. *
  54. * sub second snap shot, write to take snap shot
  55. */
  56. #define RTC_SUB_SNAP_SUB_SNAP_MASK (0xFFFFFFFFUL)
  57. #define RTC_SUB_SNAP_SUB_SNAP_SHIFT (0U)
  58. #define RTC_SUB_SNAP_SUB_SNAP_SET(x) (((uint32_t)(x) << RTC_SUB_SNAP_SUB_SNAP_SHIFT) & RTC_SUB_SNAP_SUB_SNAP_MASK)
  59. #define RTC_SUB_SNAP_SUB_SNAP_GET(x) (((uint32_t)(x) & RTC_SUB_SNAP_SUB_SNAP_MASK) >> RTC_SUB_SNAP_SUB_SNAP_SHIFT)
  60. /* Bitfield definition for register: ALARM0 */
  61. /*
  62. * ALARM (RW)
  63. *
  64. * Alarm time for second counter, on each alarm match, alarm increase ALARM0_INC
  65. */
  66. #define RTC_ALARM0_ALARM_MASK (0xFFFFFFFFUL)
  67. #define RTC_ALARM0_ALARM_SHIFT (0U)
  68. #define RTC_ALARM0_ALARM_SET(x) (((uint32_t)(x) << RTC_ALARM0_ALARM_SHIFT) & RTC_ALARM0_ALARM_MASK)
  69. #define RTC_ALARM0_ALARM_GET(x) (((uint32_t)(x) & RTC_ALARM0_ALARM_MASK) >> RTC_ALARM0_ALARM_SHIFT)
  70. /* Bitfield definition for register: ALARM0_INC */
  71. /*
  72. * INCREASE (RW)
  73. *
  74. * adder when ARLAM0 happen, helps to create periodical alarm
  75. */
  76. #define RTC_ALARM0_INC_INCREASE_MASK (0xFFFFFFFFUL)
  77. #define RTC_ALARM0_INC_INCREASE_SHIFT (0U)
  78. #define RTC_ALARM0_INC_INCREASE_SET(x) (((uint32_t)(x) << RTC_ALARM0_INC_INCREASE_SHIFT) & RTC_ALARM0_INC_INCREASE_MASK)
  79. #define RTC_ALARM0_INC_INCREASE_GET(x) (((uint32_t)(x) & RTC_ALARM0_INC_INCREASE_MASK) >> RTC_ALARM0_INC_INCREASE_SHIFT)
  80. /* Bitfield definition for register: ALARM1 */
  81. /*
  82. * ALARM (RW)
  83. *
  84. * Alarm time for second counter, on each alarm match, alarm increase ALARM0_INC
  85. */
  86. #define RTC_ALARM1_ALARM_MASK (0xFFFFFFFFUL)
  87. #define RTC_ALARM1_ALARM_SHIFT (0U)
  88. #define RTC_ALARM1_ALARM_SET(x) (((uint32_t)(x) << RTC_ALARM1_ALARM_SHIFT) & RTC_ALARM1_ALARM_MASK)
  89. #define RTC_ALARM1_ALARM_GET(x) (((uint32_t)(x) & RTC_ALARM1_ALARM_MASK) >> RTC_ALARM1_ALARM_SHIFT)
  90. /* Bitfield definition for register: ALARM1_INC */
  91. /*
  92. * INCREASE (RW)
  93. *
  94. * adder when ARLAM0 happen, helps to create periodical alarm
  95. */
  96. #define RTC_ALARM1_INC_INCREASE_MASK (0xFFFFFFFFUL)
  97. #define RTC_ALARM1_INC_INCREASE_SHIFT (0U)
  98. #define RTC_ALARM1_INC_INCREASE_SET(x) (((uint32_t)(x) << RTC_ALARM1_INC_INCREASE_SHIFT) & RTC_ALARM1_INC_INCREASE_MASK)
  99. #define RTC_ALARM1_INC_INCREASE_GET(x) (((uint32_t)(x) & RTC_ALARM1_INC_INCREASE_MASK) >> RTC_ALARM1_INC_INCREASE_SHIFT)
  100. /* Bitfield definition for register: ALARM_FLAG */
  101. /*
  102. * ALARM1 (RW)
  103. *
  104. * alarm1 happen
  105. */
  106. #define RTC_ALARM_FLAG_ALARM1_MASK (0x2U)
  107. #define RTC_ALARM_FLAG_ALARM1_SHIFT (1U)
  108. #define RTC_ALARM_FLAG_ALARM1_SET(x) (((uint32_t)(x) << RTC_ALARM_FLAG_ALARM1_SHIFT) & RTC_ALARM_FLAG_ALARM1_MASK)
  109. #define RTC_ALARM_FLAG_ALARM1_GET(x) (((uint32_t)(x) & RTC_ALARM_FLAG_ALARM1_MASK) >> RTC_ALARM_FLAG_ALARM1_SHIFT)
  110. /*
  111. * ALARM0 (RW)
  112. *
  113. * alarm0 happen
  114. */
  115. #define RTC_ALARM_FLAG_ALARM0_MASK (0x1U)
  116. #define RTC_ALARM_FLAG_ALARM0_SHIFT (0U)
  117. #define RTC_ALARM_FLAG_ALARM0_SET(x) (((uint32_t)(x) << RTC_ALARM_FLAG_ALARM0_SHIFT) & RTC_ALARM_FLAG_ALARM0_MASK)
  118. #define RTC_ALARM_FLAG_ALARM0_GET(x) (((uint32_t)(x) & RTC_ALARM_FLAG_ALARM0_MASK) >> RTC_ALARM_FLAG_ALARM0_SHIFT)
  119. /* Bitfield definition for register: ALARM_EN */
  120. /*
  121. * ENABLE1 (RW)
  122. *
  123. * alarm1 mask
  124. * 0: alarm1 disabled
  125. * 1: alarm1 enabled
  126. */
  127. #define RTC_ALARM_EN_ENABLE1_MASK (0x2U)
  128. #define RTC_ALARM_EN_ENABLE1_SHIFT (1U)
  129. #define RTC_ALARM_EN_ENABLE1_SET(x) (((uint32_t)(x) << RTC_ALARM_EN_ENABLE1_SHIFT) & RTC_ALARM_EN_ENABLE1_MASK)
  130. #define RTC_ALARM_EN_ENABLE1_GET(x) (((uint32_t)(x) & RTC_ALARM_EN_ENABLE1_MASK) >> RTC_ALARM_EN_ENABLE1_SHIFT)
  131. /*
  132. * ENABLE0 (RW)
  133. *
  134. * alarm0 mask
  135. * 0: alarm0 disabled
  136. * 1: alarm0 enabled
  137. */
  138. #define RTC_ALARM_EN_ENABLE0_MASK (0x1U)
  139. #define RTC_ALARM_EN_ENABLE0_SHIFT (0U)
  140. #define RTC_ALARM_EN_ENABLE0_SET(x) (((uint32_t)(x) << RTC_ALARM_EN_ENABLE0_SHIFT) & RTC_ALARM_EN_ENABLE0_MASK)
  141. #define RTC_ALARM_EN_ENABLE0_GET(x) (((uint32_t)(x) & RTC_ALARM_EN_ENABLE0_MASK) >> RTC_ALARM_EN_ENABLE0_SHIFT)
  142. #endif /* HPM_RTC_H */