hpm_bmon_regs.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (c) 2021-2023 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_BMON_H
  8. #define HPM_BMON_H
  9. typedef struct {
  10. struct {
  11. __RW uint32_t CONTROL; /* 0x0: Glitch and clock monitor control */
  12. __RW uint32_t STATUS; /* 0x4: Glitch and clock monitor status */
  13. __R uint8_t RESERVED0[8]; /* 0x8 - 0xF: Reserved */
  14. } MONITOR[2];
  15. } BMON_Type;
  16. /* Bitfield definition for register of struct array MONITOR: CONTROL */
  17. /*
  18. * ACTIVE (RW)
  19. *
  20. * select glitch works in active mode or passve mode.
  21. * 0: passive mode, depends on power glitch destory DFF value
  22. * 1: active mode, check glitch by DFF chain
  23. */
  24. #define BMON_MONITOR_CONTROL_ACTIVE_MASK (0x10U)
  25. #define BMON_MONITOR_CONTROL_ACTIVE_SHIFT (4U)
  26. #define BMON_MONITOR_CONTROL_ACTIVE_SET(x) (((uint32_t)(x) << BMON_MONITOR_CONTROL_ACTIVE_SHIFT) & BMON_MONITOR_CONTROL_ACTIVE_MASK)
  27. #define BMON_MONITOR_CONTROL_ACTIVE_GET(x) (((uint32_t)(x) & BMON_MONITOR_CONTROL_ACTIVE_MASK) >> BMON_MONITOR_CONTROL_ACTIVE_SHIFT)
  28. /*
  29. * ENABLE (RW)
  30. *
  31. * enable glitch detector
  32. * 0: detector disabled
  33. * 1: detector enabled
  34. */
  35. #define BMON_MONITOR_CONTROL_ENABLE_MASK (0x1U)
  36. #define BMON_MONITOR_CONTROL_ENABLE_SHIFT (0U)
  37. #define BMON_MONITOR_CONTROL_ENABLE_SET(x) (((uint32_t)(x) << BMON_MONITOR_CONTROL_ENABLE_SHIFT) & BMON_MONITOR_CONTROL_ENABLE_MASK)
  38. #define BMON_MONITOR_CONTROL_ENABLE_GET(x) (((uint32_t)(x) & BMON_MONITOR_CONTROL_ENABLE_MASK) >> BMON_MONITOR_CONTROL_ENABLE_SHIFT)
  39. /* Bitfield definition for register of struct array MONITOR: STATUS */
  40. /*
  41. * FLAG (RW)
  42. *
  43. * flag for glitch detected, write 1 to clear this flag
  44. * 0: glitch not detected
  45. * 1: glitch detected
  46. */
  47. #define BMON_MONITOR_STATUS_FLAG_MASK (0x1U)
  48. #define BMON_MONITOR_STATUS_FLAG_SHIFT (0U)
  49. #define BMON_MONITOR_STATUS_FLAG_SET(x) (((uint32_t)(x) << BMON_MONITOR_STATUS_FLAG_SHIFT) & BMON_MONITOR_STATUS_FLAG_MASK)
  50. #define BMON_MONITOR_STATUS_FLAG_GET(x) (((uint32_t)(x) & BMON_MONITOR_STATUS_FLAG_MASK) >> BMON_MONITOR_STATUS_FLAG_SHIFT)
  51. /* MONITOR register group index macro definition */
  52. #define BMON_MONITOR_GLITCH0 (0UL)
  53. #define BMON_MONITOR_CLOCK0 (1UL)
  54. #endif /* HPM_BMON_H */