12 #include "hpm_ewdg_regs.h"
13 #include "hpm_soc_feature.h"
41 #define EWDG_REFRESH_UNLOCK_PASSWORD_DEFAULT (0xED09U)
42 #define EWDG_UPDATE_PASSWORD_DEFAULT (0xECF9U)
43 #define EWDG_REFRESH_UNLOCK_FIXED_KEY (0x55AAU)
44 #define EWDG_REFRESH_KEY (0x5A45524FUL)
55 #define EWDG_EVENT_PARITY_ERROR (1UL << 6)
56 #define EWDG_EVENT_TIMEOUT_RESET (1UL << 5)
57 #define EWDG_EVENT_TIMEOUT_INTERRUPT (1UL << 4)
58 #define EWDG_EVENT_CFG_REG_UPDATE_UNLOCK_FAIL (1UL << 3)
59 #define EWDG_EVENT_CFG_REG_UPDATE_VIOLATION (1UL << 2)
60 #define EWDG_EVENT_REFRESH_UNLOCK_FAIL (1UL << 1)
61 #define EWDG_EVENT_REFRESH_VIOLATION (1UL << 0)
71 #define EWDG_INT_PARITY_FAIL (1UL << 2)
72 #define EWDG_INT_CTRL_REG_UNLOCK_FAIL (1UL << 4)
73 #define EWDG_INT_CTRL_REG_UPDATE_FAIL (1UL << 6)
74 #define EWDG_INT_TIMEOUT (1UL << 16)
75 #define EWDG_INT_REFRESH_UNLOCK_FAIL (1UL << 20)
76 #define EWDG_INT_REFRESH_VIOLATION (1UL << 22)
78 #define EWDG_INT_ALL (EWDG_INT_PARITY_FAIL | EWDG_INT_CTRL_REG_UNLOCK_FAIL | EWDG_INT_CTRL_REG_UPDATE_FAIL | \
79 EWDG_INT_TIMEOUT | EWDG_INT_REFRESH_UNLOCK_FAIL | EWDG_INT_REFRESH_VIOLATION)
90 #define EWDG_RST_PARITY_FAIL (1UL << 3)
91 #define EWDG_RST_CTRL_REG_UNLOCK_FAIL (1UL << 5)
92 #define EWDG_RST_CTRL_REG_UPDATE_FAIL (1UL << 7)
93 #define EWDG_RST_TIMEOUT (1UL << 17)
94 #define EWDG_RST_REFRESH_UNLOCK_FAIL (1UL << 21)
95 #define EWDG_RST_REFRESH_VIOLATION (1UL << 23)
97 #define EWDG_RST_ALL (EWDG_RST_PARITY_FAIL | EWDG_RST_CTRL_REG_UNLOCK_FAIL | EWDG_RST_CTRL_REG_UPDATE_FAIL | \
98 EWDG_RST_TIMEOUT | EWDG_RST_REFRESH_UNLOCK_FAIL | EWDG_RST_REFRESH_VIOLATION)
289 uint32_t ctrl_update_prot = ptr->
CFG_PROT;
312 #if defined(HPM_IP_FEATURE_EWDG_SOC_SUPPORT_TIMEOUT_INTERRUPT) && (HPM_IP_FEATURE_EWDG_SOC_SUPPORT_TIMEOUT_INTERRUPT == 1)
318 static inline uint32_t ewdg_get_timeout_interrupt_ticks(
EWDG_Type *ptr)
#define EWDG_CTRL0_REF_UNLOCK_MEC_GET(x)
Definition: hpm_ewdg_regs.h:132
#define EWDG_CTRL0_DIV_VALUE_GET(x)
Definition: hpm_ewdg_regs.h:49
#define EWDG_CTRL0_CFG_LOCK_MASK
Definition: hpm_ewdg_regs.h:82
#define EWDG_CTRL0_REF_LOCK_MASK
Definition: hpm_ewdg_regs.h:115
uint32_t hpm_stat_t
Definition: hpm_common.h:126
#define MAKE_STATUS(group, code)
Definition: hpm_common.h:135
@ status_group_ewdg
Definition: hpm_common.h:165
void ewdg_switch_clock_source(EWDG_Type *ptr, ewdg_cnt_clk_sel_t clk_sel)
Switch the EWDG clock source.
Definition: hpm_ewdg_drv.c:452
ewdg_refresh_unlock_method_t
EWDG Refresh Unlock Methods.
Definition: hpm_ewdg_drv.h:108
void ewdg_disable_interrupt(EWDG_Type *ptr, uint32_t mask)
Disable EWDG interrupt.
Definition: hpm_ewdg_drv.c:404
hpm_stat_t ewdg_init(EWDG_Type *ptr, ewdg_config_t *config)
Initialize the EWDG module.
Definition: hpm_ewdg_drv.c:274
uint64_t ewdg_convert_timeout_us_to_timeout_ticks(uint32_t src_clk_freq, uint32_t timeout_us)
Convert the timeout in terms of microseconds to the timeout in terms of timeout ticks.
Definition: hpm_ewdg_drv.c:363
uint32_t ewdg_get_count_clock_freq(EWDG_Type *ptr, uint32_t src_clk_freq)
Get the Divided Counter Clock Frequency for EWDG.
Definition: hpm_ewdg_drv.c:353
ewdg_window_upper_limit_t
EWDG Upper Window Limitations.
Definition: hpm_ewdg_drv.h:150
ewdg_window_low_limit_t
EWDG Lower Window Limitations.
Definition: hpm_ewdg_drv.h:132
static uint32_t ewdg_get_count_clk_divider(EWDG_Type *ptr)
Get the Divider for Counter Clock.
Definition: hpm_ewdg_drv.h:264
void ewdg_disable_reset(EWDG_Type *ptr, uint32_t mask)
Disable EWDG Reset.
Definition: hpm_ewdg_drv.c:436
static void ewdg_unlock_ctrl_regs(EWDG_Type *ptr)
Unlock Write to Control Registers.
Definition: hpm_ewdg_drv.h:287
hpm_stat_t ewdg_init_ctrl_func(EWDG_Type *ptr, ewdg_func_ctrl_config_t *config, uint32_t cnt_src_freq)
Initialize the Control function for EWDG.
Definition: hpm_ewdg_drv.c:85
hpm_stat_t ewdg_init_interrupt_reset(EWDG_Type *ptr, ewdg_interrupt_reset_config_t *config)
Initialize the Error function for EWDG.
Definition: hpm_ewdg_drv.c:202
hpm_stat_t ewdg_unlock_refresh(EWDG_Type *ptr)
Unlock the write to refresh register.
Definition: hpm_ewdg_drv.c:302
uint32_t ewdg_convert_timeout_ticks_to_timeout_us(EWDG_Type *ptr, uint32_t src_clk_freq, uint32_t timeout_ticks)
Convert the timeout in terms of timeout ticks to the timeout in terms of microseconds.
Definition: hpm_ewdg_drv.c:374
static void ewdg_clear_status_flags(EWDG_Type *ptr, uint32_t mask)
Clear Interrupt Status for EWDG.
Definition: hpm_ewdg_drv.h:332
void ewdg_enable(EWDG_Type *ptr)
Enable EWDG.
Definition: hpm_ewdg_drv.c:470
static bool ewdg_is_ctrl_reg_locked(EWDG_Type *ptr)
Check whether the Control Registers are locked.
Definition: hpm_ewdg_drv.h:252
static bool ewdg_is_refresh_locked(EWDG_Type *ptr)
Check whether the Refresh register is locked.
Definition: hpm_ewdg_drv.h:277
static uint32_t ewdg_get_timeout_reset_ticks(EWDG_Type *ptr)
Get the Timeout Reset ticks.
Definition: hpm_ewdg_drv.h:307
void ewdg_disable(EWDG_Type *ptr)
Disable EWDG.
Definition: hpm_ewdg_drv.c:478
ewdg_low_power_mode_t
Definition: hpm_ewdg_drv.h:163
ewdg_cnt_clk_sel_t
EWDG Clock source for internal counter.
Definition: hpm_ewdg_drv.h:124
static void ewdg_write_refresh_reg(EWDG_Type *ptr)
Write Refresh Magic Number to EWDG Refresh register.
Definition: hpm_ewdg_drv.h:297
static ewdg_refresh_unlock_method_t ewdg_get_refresh_unlock_method(EWDG_Type *ptr)
Get the Refresh Unlock Mechanism.
Definition: hpm_ewdg_drv.h:354
void ewdg_get_default_config(EWDG_Type *ptr, ewdg_config_t *config)
Get default configuration for EWDG.
Definition: hpm_ewdg_drv.c:60
hpm_stat_t ewdg_refresh(EWDG_Type *ptr)
Refresh EWDG.
Definition: hpm_ewdg_drv.c:344
static uint32_t ewdg_get_status_flags(EWDG_Type *ptr)
Get the Status of EWDG.
Definition: hpm_ewdg_drv.h:344
void ewdg_enable_reset(EWDG_Type *ptr, uint32_t mask)
Enable EWDG Reset.
Definition: hpm_ewdg_drv.c:420
void ewdg_enable_interrupt(EWDG_Type *ptr, uint32_t mask)
Enable EWDG interrupt.
Definition: hpm_ewdg_drv.c:388
@ ewdg_refresh_unlock_method_ring_left_shift_password_by_1_bit0_xor_password_bit0
Definition: hpm_ewdg_drv.h:116
@ ewdg_refresh_unlock_method_fixed_key
Definition: hpm_ewdg_drv.h:114
@ ewdg_refresh_unlock_method_password
Definition: hpm_ewdg_drv.h:110
@ ewdg_refresh_unlock_method_ring_left_shift_password_by_1
Definition: hpm_ewdg_drv.h:112
@ ewdg_refresh_unlock_method_max
Definition: hpm_ewdg_drv.h:118
@ ewdg_window_upper_timeout_period_4_div_16
Definition: hpm_ewdg_drv.h:155
@ ewdg_window_upper_timeout_period_7_div_16
Definition: hpm_ewdg_drv.h:158
@ ewdg_window_upper_timeout_period_1_div_16
Definition: hpm_ewdg_drv.h:152
@ ewdg_window_upper_timeout_period_2_div_16
Definition: hpm_ewdg_drv.h:153
@ ewdg_window_upper_timeout_period_6_div_16
Definition: hpm_ewdg_drv.h:157
@ ewdg_window_upper_timeout_period_8_div_16
Definition: hpm_ewdg_drv.h:151
@ ewdg_window_upper_timeout_period_3_div_16
Definition: hpm_ewdg_drv.h:154
@ ewdg_window_upper_timeout_period_max
Definition: hpm_ewdg_drv.h:160
@ ewdg_window_upper_timeout_period_5_div_16
Definition: hpm_ewdg_drv.h:156
@ ewdg_window_lower_timeout_period_8_div_16
Definition: hpm_ewdg_drv.h:134
@ ewdg_window_lower_timeout_period_14_div_16
Definition: hpm_ewdg_drv.h:140
@ ewdg_window_lower_timeout_period_max
Definition: hpm_ewdg_drv.h:142
@ ewdg_window_lower_timeout_period_10_div_16
Definition: hpm_ewdg_drv.h:136
@ ewdg_window_lower_timeout_period_12_div_16
Definition: hpm_ewdg_drv.h:138
@ status_ewdg_feature_unsupported
Definition: hpm_ewdg_drv.h:32
@ status_ewdg_div_out_of_range
Definition: hpm_ewdg_drv.h:31
@ status_ewdg_tick_out_of_range
Definition: hpm_ewdg_drv.h:30
@ ewdg_low_power_mode_halt
Definition: hpm_ewdg_drv.h:164
@ ewdg_low_power_mode_work_clock_normal
Definition: hpm_ewdg_drv.h:165
@ ewdg_cnt_clk_src_bus_clk
Definition: hpm_ewdg_drv.h:125
@ ewdg_cnt_clk_src_ext_osc_clk
Definition: hpm_ewdg_drv.h:126
#define EWDG_REFRESH_KEY
Definition: hpm_ewdg_drv.h:44
Definition: hpm_ewdg_regs.h:12
__RW uint32_t OT_RST_VAL
Definition: hpm_ewdg_regs.h:18
__W uint32_t WDT_REFRESH_REG
Definition: hpm_ewdg_regs.h:19
__RW uint32_t CFG_PROT
Definition: hpm_ewdg_regs.h:21
__RW uint32_t CTRL0
Definition: hpm_ewdg_regs.h:13
__RW uint32_t OT_INT_VAL
Definition: hpm_ewdg_regs.h:17
__W uint32_t WDT_STATUS
Definition: hpm_ewdg_regs.h:20
Enhanced Watchdog Configuration Structure.
Definition: hpm_ewdg_drv.h:237
uint32_t cnt_src_freq
Definition: hpm_ewdg_drv.h:241
bool enable_watchdog
Definition: hpm_ewdg_drv.h:240
ewdg_func_ctrl_config_t ctrl_config
Definition: hpm_ewdg_drv.h:239
ewdg_interrupt_reset_config_t int_rst_config
Definition: hpm_ewdg_drv.h:238
Definition: hpm_ewdg_drv.h:171
bool enable_config_lock
Definition: hpm_ewdg_drv.h:180
bool keep_running_in_debug_mode
Definition: hpm_ewdg_drv.h:186
uint32_t timeout_reset_val
Definition: hpm_ewdg_drv.h:204
ewdg_refresh_unlock_method_t refresh_unlock_method
Definition: hpm_ewdg_drv.h:184
uint32_t timeout_interrupt_val
Definition: hpm_ewdg_drv.h:200
bool enable_window_mode
Definition: hpm_ewdg_drv.h:173
bool use_lowlevel_timeout
Definition: hpm_ewdg_drv.h:193
ewdg_cnt_clk_sel_t cnt_clk_sel
Definition: hpm_ewdg_drv.h:172
uint32_t clock_div_by_power_of_2
Definition: hpm_ewdg_drv.h:205
uint32_t timeout_interrupt_us
Definition: hpm_ewdg_drv.h:196
uint32_t timeout_reset_us
Definition: hpm_ewdg_drv.h:197
bool enable_refresh_lock
Definition: hpm_ewdg_drv.h:183
bool enable_refresh_period
Definition: hpm_ewdg_drv.h:182
uint16_t refresh_period_in_bus_cycles
Definition: hpm_ewdg_drv.h:209
ewdg_window_low_limit_t window_lower_limit
Definition: hpm_ewdg_drv.h:174
uint16_t ctrl_reg_update_period_bus_clk_x_128
Definition: hpm_ewdg_drv.h:213
uint16_t ctrl_reg_update_password
Definition: hpm_ewdg_drv.h:212
ewdg_low_power_mode_t low_power_mode
Definition: hpm_ewdg_drv.h:187
ewdg_window_upper_limit_t window_upper_limit
Definition: hpm_ewdg_drv.h:178
uint16_t refresh_unlock_password
Definition: hpm_ewdg_drv.h:210
EWDG Reset and Interrupt Configurations.
Definition: hpm_ewdg_drv.h:219
bool enable_ctrl_unlock_fail_interrupt
Definition: hpm_ewdg_drv.h:222
bool enable_refresh_unlock_fail_interrupt
Definition: hpm_ewdg_drv.h:228
bool enable_ctrl_update_violation_reset
Definition: hpm_ewdg_drv.h:225
bool enable_ctrl_unlock_fail_reset
Definition: hpm_ewdg_drv.h:223
bool enable_refresh_violation_interrupt
Definition: hpm_ewdg_drv.h:230
bool enable_ctrl_parity_fail_interrupt
Definition: hpm_ewdg_drv.h:220
bool enable_refresh_violation_reset
Definition: hpm_ewdg_drv.h:231
bool enable_timeout_reset
Definition: hpm_ewdg_drv.h:227
bool enable_timeout_interrupt
Definition: hpm_ewdg_drv.h:226
bool enable_refresh_unlock_fail_reset
Definition: hpm_ewdg_drv.h:229
bool enable_ctrl_update_violation_interrupt
Definition: hpm_ewdg_drv.h:224
bool enable_ctrl_parity_fail_reset
Definition: hpm_ewdg_drv.h:221