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