hpm_bacc_regs.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Copyright (c) 2021-2023 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_BACC_H
  8. #define HPM_BACC_H
  9. typedef struct {
  10. __RW uint32_t CONFIG; /* 0x0: Access timing for access */
  11. __R uint8_t RESERVED0[4]; /* 0x4 - 0x7: Reserved */
  12. __RW uint32_t PRE_TIME; /* 0x8: Timing gap before rising edge */
  13. __RW uint32_t POST_TIME; /* 0xC: Timing gap after rising edge */
  14. } BACC_Type;
  15. /* Bitfield definition for register: CONFIG */
  16. /*
  17. * FAST_WRITE (RW)
  18. *
  19. * Use fast write
  20. * 0: Write normally
  21. * 1: boost write
  22. */
  23. #define BACC_CONFIG_FAST_WRITE_MASK (0x20000000UL)
  24. #define BACC_CONFIG_FAST_WRITE_SHIFT (29U)
  25. #define BACC_CONFIG_FAST_WRITE_SET(x) (((uint32_t)(x) << BACC_CONFIG_FAST_WRITE_SHIFT) & BACC_CONFIG_FAST_WRITE_MASK)
  26. #define BACC_CONFIG_FAST_WRITE_GET(x) (((uint32_t)(x) & BACC_CONFIG_FAST_WRITE_MASK) >> BACC_CONFIG_FAST_WRITE_SHIFT)
  27. /*
  28. * FAST_READ (RW)
  29. *
  30. * Use fast read
  31. * 0: Read normally
  32. * 1: boost read
  33. */
  34. #define BACC_CONFIG_FAST_READ_MASK (0x10000000UL)
  35. #define BACC_CONFIG_FAST_READ_SHIFT (28U)
  36. #define BACC_CONFIG_FAST_READ_SET(x) (((uint32_t)(x) << BACC_CONFIG_FAST_READ_SHIFT) & BACC_CONFIG_FAST_READ_MASK)
  37. #define BACC_CONFIG_FAST_READ_GET(x) (((uint32_t)(x) & BACC_CONFIG_FAST_READ_MASK) >> BACC_CONFIG_FAST_READ_SHIFT)
  38. /*
  39. * TIMING (RW)
  40. *
  41. * Time in APB clock cycles, for battery timing penerate
  42. */
  43. #define BACC_CONFIG_TIMING_MASK (0xFFFFU)
  44. #define BACC_CONFIG_TIMING_SHIFT (0U)
  45. #define BACC_CONFIG_TIMING_SET(x) (((uint32_t)(x) << BACC_CONFIG_TIMING_SHIFT) & BACC_CONFIG_TIMING_MASK)
  46. #define BACC_CONFIG_TIMING_GET(x) (((uint32_t)(x) & BACC_CONFIG_TIMING_MASK) >> BACC_CONFIG_TIMING_SHIFT)
  47. /* Bitfield definition for register: PRE_TIME */
  48. /*
  49. * PRE_RATIO (RW)
  50. *
  51. * Ratio of guard band before rising edge
  52. * 0: 0
  53. * 1: 1/32768 of low level width
  54. * 2: 1/16384 of low level width
  55. * 14: 1/4 of low level width
  56. * 15: 1/2 of low level width
  57. */
  58. #define BACC_PRE_TIME_PRE_RATIO_MASK (0xF0000UL)
  59. #define BACC_PRE_TIME_PRE_RATIO_SHIFT (16U)
  60. #define BACC_PRE_TIME_PRE_RATIO_SET(x) (((uint32_t)(x) << BACC_PRE_TIME_PRE_RATIO_SHIFT) & BACC_PRE_TIME_PRE_RATIO_MASK)
  61. #define BACC_PRE_TIME_PRE_RATIO_GET(x) (((uint32_t)(x) & BACC_PRE_TIME_PRE_RATIO_MASK) >> BACC_PRE_TIME_PRE_RATIO_SHIFT)
  62. /*
  63. * PRE_OFFSET (RW)
  64. *
  65. * guard band before rising edge
  66. * this value will be added to ratio number
  67. */
  68. #define BACC_PRE_TIME_PRE_OFFSET_MASK (0xFFFFU)
  69. #define BACC_PRE_TIME_PRE_OFFSET_SHIFT (0U)
  70. #define BACC_PRE_TIME_PRE_OFFSET_SET(x) (((uint32_t)(x) << BACC_PRE_TIME_PRE_OFFSET_SHIFT) & BACC_PRE_TIME_PRE_OFFSET_MASK)
  71. #define BACC_PRE_TIME_PRE_OFFSET_GET(x) (((uint32_t)(x) & BACC_PRE_TIME_PRE_OFFSET_MASK) >> BACC_PRE_TIME_PRE_OFFSET_SHIFT)
  72. /* Bitfield definition for register: POST_TIME */
  73. /*
  74. * POST_RATIO (RW)
  75. *
  76. * Ratio of guard band after rising edge
  77. * 0: 0
  78. * 1: 1/32768 of high level width
  79. * 2: 1/16384 of high level width
  80. * 14: 1/4 of high level width
  81. * 15: 1/2 of high level width
  82. */
  83. #define BACC_POST_TIME_POST_RATIO_MASK (0xF0000UL)
  84. #define BACC_POST_TIME_POST_RATIO_SHIFT (16U)
  85. #define BACC_POST_TIME_POST_RATIO_SET(x) (((uint32_t)(x) << BACC_POST_TIME_POST_RATIO_SHIFT) & BACC_POST_TIME_POST_RATIO_MASK)
  86. #define BACC_POST_TIME_POST_RATIO_GET(x) (((uint32_t)(x) & BACC_POST_TIME_POST_RATIO_MASK) >> BACC_POST_TIME_POST_RATIO_SHIFT)
  87. /*
  88. * POST_OFFSET (RW)
  89. *
  90. * guard band after rising edge
  91. * this value will be added to ratio number
  92. */
  93. #define BACC_POST_TIME_POST_OFFSET_MASK (0xFFFFU)
  94. #define BACC_POST_TIME_POST_OFFSET_SHIFT (0U)
  95. #define BACC_POST_TIME_POST_OFFSET_SET(x) (((uint32_t)(x) << BACC_POST_TIME_POST_OFFSET_SHIFT) & BACC_POST_TIME_POST_OFFSET_MASK)
  96. #define BACC_POST_TIME_POST_OFFSET_GET(x) (((uint32_t)(x) & BACC_POST_TIME_POST_OFFSET_MASK) >> BACC_POST_TIME_POST_OFFSET_SHIFT)
  97. #endif /* HPM_BACC_H */