1 /* 2 * Copyright (c) 2021-2023 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 __R uint8_t RESERVED0[8]; /* 0x8 - 0xF: Reserved */ 17 } MONITOR[2]; 18 } BMON_Type; 19 20 21 /* Bitfield definition for register of struct array MONITOR: CONTROL */ 22 /* 23 * ACTIVE (RW) 24 * 25 * select glitch works in active mode or passve mode. 26 * 0: passive mode, depends on power glitch destory DFF value 27 * 1: active mode, check glitch by DFF chain 28 */ 29 #define BMON_MONITOR_CONTROL_ACTIVE_MASK (0x10U) 30 #define BMON_MONITOR_CONTROL_ACTIVE_SHIFT (4U) 31 #define BMON_MONITOR_CONTROL_ACTIVE_SET(x) (((uint32_t)(x) << BMON_MONITOR_CONTROL_ACTIVE_SHIFT) & BMON_MONITOR_CONTROL_ACTIVE_MASK) 32 #define BMON_MONITOR_CONTROL_ACTIVE_GET(x) (((uint32_t)(x) & BMON_MONITOR_CONTROL_ACTIVE_MASK) >> BMON_MONITOR_CONTROL_ACTIVE_SHIFT) 33 34 /* 35 * ENABLE (RW) 36 * 37 * enable glitch detector 38 * 0: detector disabled 39 * 1: detector enabled 40 */ 41 #define BMON_MONITOR_CONTROL_ENABLE_MASK (0x1U) 42 #define BMON_MONITOR_CONTROL_ENABLE_SHIFT (0U) 43 #define BMON_MONITOR_CONTROL_ENABLE_SET(x) (((uint32_t)(x) << BMON_MONITOR_CONTROL_ENABLE_SHIFT) & BMON_MONITOR_CONTROL_ENABLE_MASK) 44 #define BMON_MONITOR_CONTROL_ENABLE_GET(x) (((uint32_t)(x) & BMON_MONITOR_CONTROL_ENABLE_MASK) >> BMON_MONITOR_CONTROL_ENABLE_SHIFT) 45 46 /* Bitfield definition for register of struct array MONITOR: STATUS */ 47 /* 48 * FLAG (RW) 49 * 50 * flag for glitch detected, write 1 to clear this flag 51 * 0: glitch not detected 52 * 1: glitch detected 53 */ 54 #define BMON_MONITOR_STATUS_FLAG_MASK (0x1U) 55 #define BMON_MONITOR_STATUS_FLAG_SHIFT (0U) 56 #define BMON_MONITOR_STATUS_FLAG_SET(x) (((uint32_t)(x) << BMON_MONITOR_STATUS_FLAG_SHIFT) & BMON_MONITOR_STATUS_FLAG_MASK) 57 #define BMON_MONITOR_STATUS_FLAG_GET(x) (((uint32_t)(x) & BMON_MONITOR_STATUS_FLAG_MASK) >> BMON_MONITOR_STATUS_FLAG_SHIFT) 58 59 60 61 /* MONITOR register group index macro definition */ 62 #define BMON_MONITOR_GLITCH0 (0UL) 63 #define BMON_MONITOR_CLOCK0 (1UL) 64 65 66 #endif /* HPM_BMON_H */ 67