HPM SDK
HPMicro Software Development Kit
EWDG driver APIs

EWDG driver APIs. More...

Modules

 EWDG Event definitions
 EWDG Events.
 
 EWDG Password definitions
 EWDG Password Definitions.
 
 EWDG interrupt definitions
 EWDG Interrupts.
 
 EWDG reset source definitions
 EWDG Resets.
 

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...
 

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...
 

Detailed Description

EWDG driver APIs.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

#include <drivers/inc/hpm_ewdg_drv.h>

EWDG error codes.

Enumerator
status_ewdg_tick_out_of_range 

The tick is out of range

status_ewdg_div_out_of_range 

Clock Divider is out of range

status_ewdg_feature_unsupported 

Feature is not supported

◆ ewdg_cnt_clk_sel_t

#include <drivers/inc/hpm_ewdg_drv.h>

EWDG Clock source for internal counter.

Enumerator
ewdg_cnt_clk_src_bus_clk 

Clock is from BUS clock

ewdg_cnt_clk_src_ext_osc_clk 

Clock is from External OSC

◆ ewdg_low_power_mode_t

#include <drivers/inc/hpm_ewdg_drv.h>

Enumerator
ewdg_low_power_mode_halt 

Watchdog is halted in low power mode

ewdg_low_power_mode_work_clock_normal 

Watchdog is will work with normal clock in low power mode

◆ ewdg_refresh_unlock_method_t

#include <drivers/inc/hpm_ewdg_drv.h>

EWDG Refresh Unlock Methods.

Enumerator
ewdg_refresh_unlock_method_password 

Use the Unlock Password directly

ewdg_refresh_unlock_method_ring_left_shift_password_by_1 

Use password[14:0] | password[15]

ewdg_refresh_unlock_method_fixed_key 

Use fixed key: 0x55AA

ewdg_refresh_unlock_method_ring_left_shift_password_by_1_bit0_xor_password_bit0 

Use last_password[14:0] | (last_password[15] ^ password[0])

ewdg_refresh_unlock_method_max 

Max allowed range

◆ ewdg_window_low_limit_t

#include <drivers/inc/hpm_ewdg_drv.h>

EWDG Lower Window Limitations.

Enumerator
ewdg_window_lower_timeout_period_8_div_16 

Refresh should be issued after 8/16 of timeout period

ewdg_window_lower_timeout_period_10_div_16 

Refresh should be issued after 10/16 of timeout period

ewdg_window_lower_timeout_period_12_div_16 

Refresh should be issued after 12/16 of timeout period

ewdg_window_lower_timeout_period_14_div_16 

Refresh should be issued after 14/16 of timeout period

ewdg_window_lower_timeout_period_max 

Maximum allowed limit value

◆ ewdg_window_upper_limit_t

#include <drivers/inc/hpm_ewdg_drv.h>

EWDG Upper Window Limitations.

The Actual Upper Window = Lower Window + Upper Window Limit

Enumerator
ewdg_window_upper_timeout_period_8_div_16 

8/16 of timeout_reset_val

ewdg_window_upper_timeout_period_1_div_16 

1/16 of timeout_reset_val

ewdg_window_upper_timeout_period_2_div_16 

2/16 of timeout_reset_val

ewdg_window_upper_timeout_period_3_div_16 

3/16 of timeout_reset_val

ewdg_window_upper_timeout_period_4_div_16 

4/16 of timeout_reset_val

ewdg_window_upper_timeout_period_5_div_16 

5/16 of timeout_reset_val

ewdg_window_upper_timeout_period_6_div_16 

6/16 of timeout_reset_val

ewdg_window_upper_timeout_period_7_div_16 

7/16 of timeout_reset_val

ewdg_window_upper_timeout_period_max 

Maximum allowed upper limit

Function Documentation

◆ ewdg_clear_status_flags()

static void ewdg_clear_status_flags ( EWDG_Type ptr,
uint32_t  mask 
)
inlinestatic

#include <drivers/inc/hpm_ewdg_drv.h>

Clear Interrupt Status for EWDG.

Note
The TIMEOUT_INT_EVENT cannot be cleared directly, it needs to be cleared by the refresh sequence
Parameters
[in]ptrEWDG base
[in]maskStatus Mask Bits, EWDG Event definitions

◆ ewdg_convert_timeout_ticks_to_timeout_us()

uint32_t ewdg_convert_timeout_ticks_to_timeout_us ( EWDG_Type ptr,
uint32_t  src_clk_freq,
uint32_t  timeout_ticks 
)

#include <drivers/inc/hpm_ewdg_drv.h>

Convert the timeout in terms of timeout ticks to the timeout in terms of microseconds.

Parameters
[in]ptrEWDG base
[in]src_clk_freqClock Frequency of the counter clock source
[in]timeout_ticksTimeout in terms of ticks
Returns
timeout in terms of counter clock ticks

◆ ewdg_convert_timeout_us_to_timeout_ticks()

uint64_t ewdg_convert_timeout_us_to_timeout_ticks ( uint32_t  src_clk_freq,
uint32_t  timeout_us 
)

#include <drivers/inc/hpm_ewdg_drv.h>

Convert the timeout in terms of microseconds to the timeout in terms of timeout ticks.

Parameters
[in]src_clk_freqClock Frequency of the counter clock source
[in]timeout_usTimeout in terms of microseconds
Returns
timeout in terms of counter clock ticks

◆ ewdg_disable()

void ewdg_disable ( EWDG_Type ptr)

#include <drivers/inc/hpm_ewdg_drv.h>

Disable EWDG.

Parameters
[in]ptrEWDG base

◆ ewdg_disable_interrupt()

void ewdg_disable_interrupt ( EWDG_Type ptr,
uint32_t  mask 
)

#include <drivers/inc/hpm_ewdg_drv.h>

Disable EWDG interrupt.

Parameters
[in]ptrEWDG base
[in]maskInterrupt Mask, valid value refer to EWDG interrupt definitions

< Parity bit for Control Register

◆ ewdg_disable_reset()

void ewdg_disable_reset ( EWDG_Type ptr,
uint32_t  mask 
)

#include <drivers/inc/hpm_ewdg_drv.h>

Disable EWDG Reset.

Parameters
[in]ptrEWDG base
[in]maskReset Mask, valid value refer to EWDG reset source definitions

< Parity bit for Control Register

◆ ewdg_enable()

void ewdg_enable ( EWDG_Type ptr)

#include <drivers/inc/hpm_ewdg_drv.h>

Enable EWDG.

This function enables the functionality of the EWDG and start the watchdog timer

Parameters
[in]ptrEWDG base
Note
Once the EWDG is enabled,
  • if the software needs to update the control register, the update unlock must be performed first if the control register lock is enabled.

◆ ewdg_enable_interrupt()

void ewdg_enable_interrupt ( EWDG_Type ptr,
uint32_t  mask 
)

#include <drivers/inc/hpm_ewdg_drv.h>

Enable EWDG interrupt.

Parameters
[in]ptrEWDG base
[in]maskInterrupt Mask, valid value refer to EWDG interrupt definitions

< Parity bit for Control Register

◆ ewdg_enable_reset()

void ewdg_enable_reset ( EWDG_Type ptr,
uint32_t  mask 
)

#include <drivers/inc/hpm_ewdg_drv.h>

Enable EWDG Reset.

Parameters
[in]ptrEWDG base
[in]maskReset Mask, valid value refer to EWDG reset source definitions

< Parity bit for Control Register

◆ ewdg_get_count_clk_divider()

static uint32_t ewdg_get_count_clk_divider ( EWDG_Type ptr)
inlinestatic

#include <drivers/inc/hpm_ewdg_drv.h>

Get the Divider for Counter Clock.

Parameters
[in]ptrEWDG base
Returns
divider value

◆ ewdg_get_count_clock_freq()

uint32_t ewdg_get_count_clock_freq ( EWDG_Type ptr,
uint32_t  src_clk_freq 
)

#include <drivers/inc/hpm_ewdg_drv.h>

Get the Divided Counter Clock Frequency for EWDG.

Parameters
[in]ptrEWDG base
[in]src_clk_freqSource clock of the Counter clock
Returns
divided Counter clock Frequency

◆ ewdg_get_default_config()

void ewdg_get_default_config ( EWDG_Type ptr,
ewdg_config_t config 
)

#include <drivers/inc/hpm_ewdg_drv.h>

Get default configuration for EWDG.

Parameters
[in]ptrEWDG base
[out]configEWDG Configuration

◆ ewdg_get_refresh_unlock_method()

static ewdg_refresh_unlock_method_t ewdg_get_refresh_unlock_method ( EWDG_Type ptr)
inlinestatic

#include <drivers/inc/hpm_ewdg_drv.h>

Get the Refresh Unlock Mechanism.

Parameters
[in]ptrEWDG base
Returns
EWDG refresh unlock method

◆ ewdg_get_status_flags()

static uint32_t ewdg_get_status_flags ( EWDG_Type ptr)
inlinestatic

#include <drivers/inc/hpm_ewdg_drv.h>

Get the Status of EWDG.

Parameters
[in]ptrEWDG base
Returns
STATUS register value

◆ ewdg_get_timeout_reset_ticks()

static uint32_t ewdg_get_timeout_reset_ticks ( EWDG_Type ptr)
inlinestatic

#include <drivers/inc/hpm_ewdg_drv.h>

Get the Timeout Reset ticks.

Parameters
[in]ptrEWDG base
Returns
Timeout Reset ticks

◆ ewdg_init()

hpm_stat_t ewdg_init ( EWDG_Type ptr,
ewdg_config_t config 
)

#include <drivers/inc/hpm_ewdg_drv.h>

Initialize the EWDG module.

Parameters
[in]ptrEWDG base
[in]configEWDG configuration
Return values
status_invalid_argumentInvalid argument was detected
status_successNo error happened

◆ ewdg_init_ctrl_func()

hpm_stat_t ewdg_init_ctrl_func ( EWDG_Type ptr,
ewdg_func_ctrl_config_t config,
uint32_t  cnt_src_freq 
)

#include <drivers/inc/hpm_ewdg_drv.h>

Initialize the Control function for EWDG.

Parameters
[in]ptrEWDG base
[in]configControl Function Configuration
[in]cnt_src_freqSource frequency for EWDG counter
Return values
status_invalid_argumentInvalid argument was detected
status_successNo error happened

< Parity bit for Control Register

◆ ewdg_init_interrupt_reset()

hpm_stat_t ewdg_init_interrupt_reset ( EWDG_Type ptr,
ewdg_interrupt_reset_config_t config 
)

#include <drivers/inc/hpm_ewdg_drv.h>

Initialize the Error function for EWDG.

Parameters
[in]ptrEWDG base
[in]configError Function Configuration
Return values
status_invalid_argumentInvalid argument was detected
status_successNo error happened

< Parity bit for Control Register

◆ ewdg_is_ctrl_reg_locked()

static bool ewdg_is_ctrl_reg_locked ( EWDG_Type ptr)
inlinestatic

#include <drivers/inc/hpm_ewdg_drv.h>

Check whether the Control Registers are locked.

Parameters
[in]ptrEWDG base
Return values
trueControl Registers are locked
falseControl Registers are unlocked

◆ ewdg_is_refresh_locked()

static bool ewdg_is_refresh_locked ( EWDG_Type ptr)
inlinestatic

#include <drivers/inc/hpm_ewdg_drv.h>

Check whether the Refresh register is locked.

Parameters
[in]ptrEWDG base
Return values
trueControl Registers are locked
falseControl Registers are unlocked

◆ ewdg_refresh()

hpm_stat_t ewdg_refresh ( EWDG_Type ptr)

#include <drivers/inc/hpm_ewdg_drv.h>

Refresh EWDG.

Parameters
[in]ptrEWDG base
Return values
status_invalid_argumentInvalid argument was detected
status_successNo error happened

◆ ewdg_switch_clock_source()

void ewdg_switch_clock_source ( EWDG_Type ptr,
ewdg_cnt_clk_sel_t  clk_sel 
)

#include <drivers/inc/hpm_ewdg_drv.h>

Switch the EWDG clock source.

Parameters
[in]ptrEWDG base
[in]clk_selClock source selection for EWDG counter

< Parity bit for Control Register

◆ ewdg_unlock_ctrl_regs()

static void ewdg_unlock_ctrl_regs ( EWDG_Type ptr)
inlinestatic

#include <drivers/inc/hpm_ewdg_drv.h>

Unlock Write to Control Registers.

Parameters
[in]ptrEWDG base

◆ ewdg_unlock_refresh()

hpm_stat_t ewdg_unlock_refresh ( EWDG_Type ptr)

#include <drivers/inc/hpm_ewdg_drv.h>

Unlock the write to refresh register.

Parameters
[in]ptrEWDG base
Return values
status_invalid_argumentInvalid argument was detected
status_successNo error happened

◆ ewdg_write_refresh_reg()

static void ewdg_write_refresh_reg ( EWDG_Type ptr)
inlinestatic

#include <drivers/inc/hpm_ewdg_drv.h>

Write Refresh Magic Number to EWDG Refresh register.

Parameters
[in]ptrEWDG base

< EWDG Refresh key