HPM SDK
HPMicro Software Development Kit
hpm_ewdg_drv.h File Reference
#include "hpm_common.h"
#include "hpm_ewdg_regs.h"
#include "hpm_soc_feature.h"

Go to the source code of this file.

Data Structures

struct  ewdg_func_ctrl_config_t
 
struct  ewdg_interrupt_reset_config_t
 EWDG Reset and Interrupt Configurations. More...
 
struct  ewdg_config_t
 Enhanced Watchdog Configuration Structure. More...
 

Macros

#define EWDG_REFRESH_UNLOCK_PASSWORD_DEFAULT   (0xED09U)
 
#define EWDG_UPDATE_PASSWORD_DEFAULT   (0xECF9U)
 
#define EWDG_REFRESH_UNLOCK_FIXED_KEY   (0x55AAU)
 
#define EWDG_REFRESH_KEY   (0x5A45524FUL)
 
#define EWDG_EVENT_PARITY_ERROR   (1UL << 6)
 
#define EWDG_EVENT_TIMEOUT_RESET   (1UL << 5)
 
#define EWDG_EVENT_TIMEOUT_INTERRUPT   (1UL << 4)
 
#define EWDG_EVENT_CFG_REG_UPDATE_UNLOCK_FAIL   (1UL << 3)
 
#define EWDG_EVENT_CFG_REG_UPDATE_VIOLATION   (1UL << 2)
 
#define EWDG_EVENT_REFRESH_UNLOCK_FAIL   (1UL << 1)
 
#define EWDG_EVENT_REFRESH_VIOLATION   (1UL << 0)
 
#define EWDG_INT_PARITY_FAIL   (1UL << 2)
 
#define EWDG_INT_CTRL_REG_UNLOCK_FAIL   (1UL << 4)
 
#define EWDG_INT_CTRL_REG_UPDATE_FAIL   (1UL << 6)
 
#define EWDG_INT_TIMEOUT   (1UL << 16)
 
#define EWDG_INT_REFRESH_UNLOCK_FAIL   (1UL << 20)
 
#define EWDG_INT_REFRESH_VIOLATION   (1UL << 22)
 
#define EWDG_INT_ALL
 
#define EWDG_RST_PARITY_FAIL   (1UL << 3)
 
#define EWDG_RST_CTRL_REG_UNLOCK_FAIL   (1UL << 5)
 
#define EWDG_RST_CTRL_REG_UPDATE_FAIL   (1UL << 7)
 
#define EWDG_RST_TIMEOUT   (1UL << 17)
 
#define EWDG_RST_REFRESH_UNLOCK_FAIL   (1UL << 21)
 
#define EWDG_RST_REFRESH_VIOLATION   (1UL << 23)
 
#define EWDG_RST_ALL
 

Enumerations

enum  { status_ewdg_tick_out_of_range = ((uint32_t)( status_group_ewdg )*1000U + (uint32_t)( 0 )) , status_ewdg_div_out_of_range = ((uint32_t)( status_group_ewdg )*1000U + (uint32_t)( 1 )) , status_ewdg_feature_unsupported = ((uint32_t)( status_group_ewdg )*1000U + (uint32_t)( 2 )) }
 EWDG error codes. More...
 
enum  ewdg_refresh_unlock_method_t {
  ewdg_refresh_unlock_method_password = 0 , ewdg_refresh_unlock_method_ring_left_shift_password_by_1 = 1 , ewdg_refresh_unlock_method_fixed_key = 2 , ewdg_refresh_unlock_method_ring_left_shift_password_by_1_bit0_xor_password_bit0 = 3 ,
  ewdg_refresh_unlock_method_max = ewdg_refresh_unlock_method_ring_left_shift_password_by_1_bit0_xor_password_bit0
}
 EWDG Refresh Unlock Methods. More...
 
enum  ewdg_cnt_clk_sel_t { ewdg_cnt_clk_src_bus_clk , ewdg_cnt_clk_src_ext_osc_clk }
 EWDG Clock source for internal counter. More...
 
enum  ewdg_window_low_limit_t {
  ewdg_window_lower_timeout_period_8_div_16 = 0 , ewdg_window_lower_timeout_period_10_div_16 = 1 , ewdg_window_lower_timeout_period_12_div_16 = 2 , ewdg_window_lower_timeout_period_14_div_16 = 3 ,
  ewdg_window_lower_timeout_period_max = ewdg_window_lower_timeout_period_14_div_16
}
 EWDG Lower Window Limitations. More...
 
enum  ewdg_window_upper_limit_t {
  ewdg_window_upper_timeout_period_8_div_16 = 0 , ewdg_window_upper_timeout_period_1_div_16 = 1 , ewdg_window_upper_timeout_period_2_div_16 = 2 , ewdg_window_upper_timeout_period_3_div_16 = 3 ,
  ewdg_window_upper_timeout_period_4_div_16 = 4 , ewdg_window_upper_timeout_period_5_div_16 = 5 , ewdg_window_upper_timeout_period_6_div_16 = 6 , ewdg_window_upper_timeout_period_7_div_16 = 8 ,
  ewdg_window_upper_timeout_period_max = ewdg_window_upper_timeout_period_7_div_16
}
 EWDG Upper Window Limitations. More...
 
enum  ewdg_low_power_mode_t { ewdg_low_power_mode_halt = 0 , ewdg_low_power_mode_work_clock_normal = 1 }
 

Functions

static bool ewdg_is_ctrl_reg_locked (EWDG_Type *ptr)
 Check whether the Control Registers are locked. More...
 
static uint32_t ewdg_get_count_clk_divider (EWDG_Type *ptr)
 Get the Divider for Counter Clock. More...
 
static bool ewdg_is_refresh_locked (EWDG_Type *ptr)
 Check whether the Refresh register is locked. More...
 
static void ewdg_unlock_ctrl_regs (EWDG_Type *ptr)
 Unlock Write to Control Registers. More...
 
static void ewdg_write_refresh_reg (EWDG_Type *ptr)
 Write Refresh Magic Number to EWDG Refresh register. More...
 
static uint32_t ewdg_get_timeout_reset_ticks (EWDG_Type *ptr)
 Get the Timeout Reset ticks. More...
 
static void ewdg_clear_status_flags (EWDG_Type *ptr, uint32_t mask)
 Clear Interrupt Status for EWDG. More...
 
static uint32_t ewdg_get_status_flags (EWDG_Type *ptr)
 Get the Status of EWDG. More...
 
static ewdg_refresh_unlock_method_t ewdg_get_refresh_unlock_method (EWDG_Type *ptr)
 Get the Refresh Unlock Mechanism. More...
 
void ewdg_enable (EWDG_Type *ptr)
 Enable EWDG. More...
 
void ewdg_disable (EWDG_Type *ptr)
 Disable EWDG. More...
 
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. More...
 
hpm_stat_t ewdg_init_interrupt_reset (EWDG_Type *ptr, ewdg_interrupt_reset_config_t *config)
 Initialize the Error function for EWDG. More...
 
void ewdg_get_default_config (EWDG_Type *ptr, ewdg_config_t *config)
 Get default configuration for EWDG. More...
 
hpm_stat_t ewdg_init (EWDG_Type *ptr, ewdg_config_t *config)
 Initialize the EWDG module. More...
 
hpm_stat_t ewdg_unlock_refresh (EWDG_Type *ptr)
 Unlock the write to refresh register. More...
 
hpm_stat_t ewdg_refresh (EWDG_Type *ptr)
 Refresh EWDG. More...
 
uint32_t ewdg_get_count_clock_freq (EWDG_Type *ptr, uint32_t src_clk_freq)
 Get the Divided Counter Clock Frequency for EWDG. More...
 
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. More...
 
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. More...
 
void ewdg_enable_interrupt (EWDG_Type *ptr, uint32_t mask)
 Enable EWDG interrupt. More...
 
void ewdg_disable_interrupt (EWDG_Type *ptr, uint32_t mask)
 Disable EWDG interrupt. More...
 
void ewdg_enable_reset (EWDG_Type *ptr, uint32_t mask)
 Enable EWDG Reset. More...
 
void ewdg_disable_reset (EWDG_Type *ptr, uint32_t mask)
 Disable EWDG Reset. More...
 
void ewdg_switch_clock_source (EWDG_Type *ptr, ewdg_cnt_clk_sel_t clk_sel)
 Switch the EWDG clock source. More...