hpm_synt_regs.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*
  2. * Copyright (c) 2021-2023 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_SYNT_H
  8. #define HPM_SYNT_H
  9. typedef struct {
  10. __RW uint32_t GCR; /* 0x0: Global control register */
  11. __RW uint32_t RLD; /* 0x4: Counter reload register */
  12. __RW uint32_t SYNT_NEW; /* 0x8: sync timer new value register */
  13. __R uint32_t CNT; /* 0xC: Counter */
  14. __R uint32_t SYNT_SAVE; /* 0x10: sync timer trig save value */
  15. __R uint32_t SYNT_READ; /* 0x14: sync timer read value */
  16. __R uint8_t RESERVED0[8]; /* 0x18 - 0x1F: Reserved */
  17. __RW uint32_t CMP[4]; /* 0x20 - 0x2C: Comparator */
  18. } SYNT_Type;
  19. /* Bitfield definition for register: GCR */
  20. /*
  21. * SYNC_TIMER_INC (WO)
  22. *
  23. * set to increase the sync timer with new_value, auto clr
  24. */
  25. #define SYNT_GCR_SYNC_TIMER_INC_MASK (0x80000000UL)
  26. #define SYNT_GCR_SYNC_TIMER_INC_SHIFT (31U)
  27. #define SYNT_GCR_SYNC_TIMER_INC_SET(x) (((uint32_t)(x) << SYNT_GCR_SYNC_TIMER_INC_SHIFT) & SYNT_GCR_SYNC_TIMER_INC_MASK)
  28. #define SYNT_GCR_SYNC_TIMER_INC_GET(x) (((uint32_t)(x) & SYNT_GCR_SYNC_TIMER_INC_MASK) >> SYNT_GCR_SYNC_TIMER_INC_SHIFT)
  29. /*
  30. * SYNC_TIMER_DEC (WO)
  31. *
  32. * set to decrease the sync timer with new_value, auto clr
  33. */
  34. #define SYNT_GCR_SYNC_TIMER_DEC_MASK (0x40000000UL)
  35. #define SYNT_GCR_SYNC_TIMER_DEC_SHIFT (30U)
  36. #define SYNT_GCR_SYNC_TIMER_DEC_SET(x) (((uint32_t)(x) << SYNT_GCR_SYNC_TIMER_DEC_SHIFT) & SYNT_GCR_SYNC_TIMER_DEC_MASK)
  37. #define SYNT_GCR_SYNC_TIMER_DEC_GET(x) (((uint32_t)(x) & SYNT_GCR_SYNC_TIMER_DEC_MASK) >> SYNT_GCR_SYNC_TIMER_DEC_SHIFT)
  38. /*
  39. * SYNC_TIMER_NEW (WO)
  40. *
  41. * set the sync timer to new_value, auto clr
  42. */
  43. #define SYNT_GCR_SYNC_TIMER_NEW_MASK (0x20000000UL)
  44. #define SYNT_GCR_SYNC_TIMER_NEW_SHIFT (29U)
  45. #define SYNT_GCR_SYNC_TIMER_NEW_SET(x) (((uint32_t)(x) << SYNT_GCR_SYNC_TIMER_NEW_SHIFT) & SYNT_GCR_SYNC_TIMER_NEW_MASK)
  46. #define SYNT_GCR_SYNC_TIMER_NEW_GET(x) (((uint32_t)(x) & SYNT_GCR_SYNC_TIMER_NEW_MASK) >> SYNT_GCR_SYNC_TIMER_NEW_SHIFT)
  47. /*
  48. * SYNC_TIMER_RESET (WO)
  49. *
  50. * reset sync timer to 0, auto clr
  51. */
  52. #define SYNT_GCR_SYNC_TIMER_RESET_MASK (0x10000000UL)
  53. #define SYNT_GCR_SYNC_TIMER_RESET_SHIFT (28U)
  54. #define SYNT_GCR_SYNC_TIMER_RESET_SET(x) (((uint32_t)(x) << SYNT_GCR_SYNC_TIMER_RESET_SHIFT) & SYNT_GCR_SYNC_TIMER_RESET_MASK)
  55. #define SYNT_GCR_SYNC_TIMER_RESET_GET(x) (((uint32_t)(x) & SYNT_GCR_SYNC_TIMER_RESET_MASK) >> SYNT_GCR_SYNC_TIMER_RESET_SHIFT)
  56. /*
  57. * SYNC_TIMER_STOPEN (RW)
  58. *
  59. * set to enable cpu_debug_mode to stop the sync timer
  60. */
  61. #define SYNT_GCR_SYNC_TIMER_STOPEN_MASK (0x20U)
  62. #define SYNT_GCR_SYNC_TIMER_STOPEN_SHIFT (5U)
  63. #define SYNT_GCR_SYNC_TIMER_STOPEN_SET(x) (((uint32_t)(x) << SYNT_GCR_SYNC_TIMER_STOPEN_SHIFT) & SYNT_GCR_SYNC_TIMER_STOPEN_MASK)
  64. #define SYNT_GCR_SYNC_TIMER_STOPEN_GET(x) (((uint32_t)(x) & SYNT_GCR_SYNC_TIMER_STOPEN_MASK) >> SYNT_GCR_SYNC_TIMER_STOPEN_SHIFT)
  65. /*
  66. * SYNC_TIMER_ENABLE (RW)
  67. *
  68. * set to enable the sync timer, clr to stop
  69. */
  70. #define SYNT_GCR_SYNC_TIMER_ENABLE_MASK (0x10U)
  71. #define SYNT_GCR_SYNC_TIMER_ENABLE_SHIFT (4U)
  72. #define SYNT_GCR_SYNC_TIMER_ENABLE_SET(x) (((uint32_t)(x) << SYNT_GCR_SYNC_TIMER_ENABLE_SHIFT) & SYNT_GCR_SYNC_TIMER_ENABLE_MASK)
  73. #define SYNT_GCR_SYNC_TIMER_ENABLE_GET(x) (((uint32_t)(x) & SYNT_GCR_SYNC_TIMER_ENABLE_MASK) >> SYNT_GCR_SYNC_TIMER_ENABLE_SHIFT)
  74. /*
  75. * STOPEN (RW)
  76. *
  77. * set to enable cpu_debug_mode to stop the counter
  78. */
  79. #define SYNT_GCR_STOPEN_MASK (0x4U)
  80. #define SYNT_GCR_STOPEN_SHIFT (2U)
  81. #define SYNT_GCR_STOPEN_SET(x) (((uint32_t)(x) << SYNT_GCR_STOPEN_SHIFT) & SYNT_GCR_STOPEN_MASK)
  82. #define SYNT_GCR_STOPEN_GET(x) (((uint32_t)(x) & SYNT_GCR_STOPEN_MASK) >> SYNT_GCR_STOPEN_SHIFT)
  83. /*
  84. * CRST (RW)
  85. *
  86. * 1- Reset counter
  87. */
  88. #define SYNT_GCR_CRST_MASK (0x2U)
  89. #define SYNT_GCR_CRST_SHIFT (1U)
  90. #define SYNT_GCR_CRST_SET(x) (((uint32_t)(x) << SYNT_GCR_CRST_SHIFT) & SYNT_GCR_CRST_MASK)
  91. #define SYNT_GCR_CRST_GET(x) (((uint32_t)(x) & SYNT_GCR_CRST_MASK) >> SYNT_GCR_CRST_SHIFT)
  92. /*
  93. * CEN (RW)
  94. *
  95. * 1- Enable counter
  96. */
  97. #define SYNT_GCR_CEN_MASK (0x1U)
  98. #define SYNT_GCR_CEN_SHIFT (0U)
  99. #define SYNT_GCR_CEN_SET(x) (((uint32_t)(x) << SYNT_GCR_CEN_SHIFT) & SYNT_GCR_CEN_MASK)
  100. #define SYNT_GCR_CEN_GET(x) (((uint32_t)(x) & SYNT_GCR_CEN_MASK) >> SYNT_GCR_CEN_SHIFT)
  101. /* Bitfield definition for register: RLD */
  102. /*
  103. * RLD (RW)
  104. *
  105. * counter reload value
  106. */
  107. #define SYNT_RLD_RLD_MASK (0xFFFFFFFFUL)
  108. #define SYNT_RLD_RLD_SHIFT (0U)
  109. #define SYNT_RLD_RLD_SET(x) (((uint32_t)(x) << SYNT_RLD_RLD_SHIFT) & SYNT_RLD_RLD_MASK)
  110. #define SYNT_RLD_RLD_GET(x) (((uint32_t)(x) & SYNT_RLD_RLD_MASK) >> SYNT_RLD_RLD_SHIFT)
  111. /* Bitfield definition for register: SYNT_NEW */
  112. /*
  113. * NEW_VALUE (RW)
  114. *
  115. * new value for sync timer, can be used as update/inc/dec
  116. */
  117. #define SYNT_SYNT_NEW_NEW_VALUE_MASK (0xFFFFFFFFUL)
  118. #define SYNT_SYNT_NEW_NEW_VALUE_SHIFT (0U)
  119. #define SYNT_SYNT_NEW_NEW_VALUE_SET(x) (((uint32_t)(x) << SYNT_SYNT_NEW_NEW_VALUE_SHIFT) & SYNT_SYNT_NEW_NEW_VALUE_MASK)
  120. #define SYNT_SYNT_NEW_NEW_VALUE_GET(x) (((uint32_t)(x) & SYNT_SYNT_NEW_NEW_VALUE_MASK) >> SYNT_SYNT_NEW_NEW_VALUE_SHIFT)
  121. /* Bitfield definition for register: CNT */
  122. /*
  123. * CNT (RO)
  124. *
  125. * counter
  126. */
  127. #define SYNT_CNT_CNT_MASK (0xFFFFFFFFUL)
  128. #define SYNT_CNT_CNT_SHIFT (0U)
  129. #define SYNT_CNT_CNT_GET(x) (((uint32_t)(x) & SYNT_CNT_CNT_MASK) >> SYNT_CNT_CNT_SHIFT)
  130. /* Bitfield definition for register: SYNT_SAVE */
  131. /*
  132. * TIME_SAVE (RO)
  133. *
  134. * use the trigger to save sync timer here
  135. */
  136. #define SYNT_SYNT_SAVE_TIME_SAVE_MASK (0xFFFFFFFFUL)
  137. #define SYNT_SYNT_SAVE_TIME_SAVE_SHIFT (0U)
  138. #define SYNT_SYNT_SAVE_TIME_SAVE_GET(x) (((uint32_t)(x) & SYNT_SYNT_SAVE_TIME_SAVE_MASK) >> SYNT_SYNT_SAVE_TIME_SAVE_SHIFT)
  139. /* Bitfield definition for register: SYNT_READ */
  140. /*
  141. * SYNC_TIME (RO)
  142. *
  143. * current sync timer value
  144. */
  145. #define SYNT_SYNT_READ_SYNC_TIME_MASK (0xFFFFFFFFUL)
  146. #define SYNT_SYNT_READ_SYNC_TIME_SHIFT (0U)
  147. #define SYNT_SYNT_READ_SYNC_TIME_GET(x) (((uint32_t)(x) & SYNT_SYNT_READ_SYNC_TIME_MASK) >> SYNT_SYNT_READ_SYNC_TIME_SHIFT)
  148. /* Bitfield definition for register array: CMP */
  149. /*
  150. * CMP (RW)
  151. *
  152. * comparator value, the output will assert when counter count to this value
  153. */
  154. #define SYNT_CMP_CMP_MASK (0xFFFFFFFFUL)
  155. #define SYNT_CMP_CMP_SHIFT (0U)
  156. #define SYNT_CMP_CMP_SET(x) (((uint32_t)(x) << SYNT_CMP_CMP_SHIFT) & SYNT_CMP_CMP_MASK)
  157. #define SYNT_CMP_CMP_GET(x) (((uint32_t)(x) & SYNT_CMP_CMP_MASK) >> SYNT_CMP_CMP_SHIFT)
  158. /* CMP register group index macro definition */
  159. #define SYNT_CMP_0 (0UL)
  160. #define SYNT_CMP_1 (1UL)
  161. #define SYNT_CMP_2 (2UL)
  162. #define SYNT_CMP_3 (3UL)
  163. #endif /* HPM_SYNT_H */