SemiDrive SSDK Appication Program Interface PTG3.0
Data Structures | Macros | Functions
sdrv_watchdog.h File Reference
#include <types.h>
#include <regs_base.h>
#include "sdrv_common.h"

Go to the source code of this file.

Data Structures

struct  sdrv_wdt
 
struct  sdrv_wdt_internal_reset
 
struct  sdrv_wdt_external_reset
 
struct  sdrv_wdt_config
 

Macros

#define __I   volatile const
 
#define __O   volatile
 
#define __IO   volatile
 

Functions

status_t sdrv_wdt_get_default_config (sdrv_wdt_config_t *config)
 
status_t sdrv_wdt_init (sdrv_wdt_t *base, sdrv_wdt_config_t *config)
 
status_t sdrv_wdt_deinit (sdrv_wdt_t *base)
 
status_t sdrv_wdt_enable (sdrv_wdt_t *base)
 
status_t sdrv_wdt_disable (sdrv_wdt_t *base)
 
status_t sdrv_wdt_set_timeout (sdrv_wdt_t *base, uint32_t timeout)
 
status_t sdrv_wdt_set_window_low (sdrv_wdt_t *base, uint32_t low_limit)
 
status_t sdrv_wdt_set_sequence_delta (sdrv_wdt_t *base, uint32_t delta)
 
status_t sdrv_wdt_refresh (sdrv_wdt_t *base)
 
uint32_t sdrv_wdt_read_timestamp (sdrv_wdt_t *base)
 
status_t sdrv_wdt_write_timestamp (sdrv_wdt_t *base, uint32_t timestamp)
 
status_t sdrv_wdt_get_intr_status (sdrv_wdt_t *base, sdrv_wdt_intr_e intr)
 
status_t sdrv_wdt_clear_intr_status (sdrv_wdt_t *base, sdrv_wdt_intr_e intr)
 

Detailed Description

Macro Definition Documentation

◆ __I

#define __I   volatile const

Defines 'read only' permissions

◆ __IO

#define __IO   volatile

Defines 'read / write' permissions

◆ __O

#define __O   volatile

Defines 'write only' permissions

Typedef Documentation

◆ sdrv_wdt_clock_e

Definition for watchdog clock source.

◆ sdrv_wdt_config_t

Definition for watchdog initialize config.

◆ sdrv_wdt_external_reset_t

Definition for watchdog external reset config.

◆ sdrv_wdt_internal_reset_t

Definition for watchdog internal reset config.

◆ sdrv_wdt_intr_e

Definition for watchdog interrupt type.

◆ sdrv_wdt_refresh_e

Definition for watchdog refresh type.

◆ sdrv_wdt_t

typedef struct sdrv_wdt sdrv_wdt_t

Definition for sdrv watchdog register.

Enumeration Type Documentation

◆ sdrv_watchdog_error

watchdog status error code.

Enumerator
SDRV_STATUS_TIMEOUT_FAILED 
SDRV_STATUS_DELTA_FAILED 
SDRV_STATUS_WINDOW_LOW_FAILED 
SDRV_STATUS_INTR_UNCLEARED 

◆ sdrv_wdt_clock

Definition for watchdog clock source.

Enumerator
WDT_MAIN_CLOCK 

System 24M clock

WDT_BUS_CLOCK 

System bus clock

WDT_EXT_CLOCK 

External clock

WDT_TIE_OFF 

Tie off

WDT_LP_CLOCK 

System 32K clock

◆ sdrv_wdt_intr

Definition for watchdog interrupt type.

Enumerator
WDT_ILL_WINDOW_REFRESH 

WDT illeage window based counter refresh interrupt.

WDT_ILL_SEQUENCE_RESRESH 

WDT illeage sequential refresh interrupt.

WDT_OVERFLOW 

WDT timer overflow interrupt.

◆ sdrv_wdt_refresh

Definition for watchdog refresh type.

Enumerator
WDT_DIRECT_REFRESH 

WDT direct refresh, you must feed dog before timeout.

WDT_WINDOW_REFRESH 

WDT window based refresh, you must feed dog bewteen time low limit and timeout.

WDT_SEQUENCE_REFRESH 

WDT sequence based refresh, after you read current counter, you must write it to timestamp register before delta time.

WDT_DIRECT_SEQUENCE_REFRESH 

WDT direct/sequence base refresh combine.

WDT_WINDOW_SEQUENCE_REFRESH 

WDT window base/sequence base refresh combine.

Function Documentation

◆ sdrv_wdt_clear_intr_status()

status_t sdrv_wdt_clear_intr_status ( sdrv_wdt_t base,
sdrv_wdt_intr_e  intr 
)

Clear watchdog interrupt status of specific type.

Parameters
[in]baseWDT control base.
[in]intrinterrupt type defined in sdrv_wdt_intr_e.
Returns
SDRV_STATUS_OK represents success, SDRV_STATUS_FAIL represents failed.

◆ sdrv_wdt_deinit()

status_t sdrv_wdt_deinit ( sdrv_wdt_t base)

De-Initialize watchdog.

This function disable watchdog interrupt and clear interrupt status. Disable internal and external reset config.

Parameters
[in]baseWDT control base.
Returns
SDRV_STATUS_OK represents success, SDRV_STATUS_FAIL represents failed, SDRV_STATUS_INTR_UNCLEARED represents interrupt not cleared.

◆ sdrv_wdt_disable()

status_t sdrv_wdt_disable ( sdrv_wdt_t base)

Disable watchdog.

This function disable watchdog timer counter.

Parameters
[in]baseWDT control base
Returns
SDRV_STATUS_OK represents success, SDRV_STATUS_FAIL represents failed.

◆ sdrv_wdt_enable()

status_t sdrv_wdt_enable ( sdrv_wdt_t base)

Enable watchdog.

This function enable watchdog timer counter.

Parameters
[in]baseWDT control base.
Returns
SDRV_STATUS_OK represents success, SDRV_STATUS_FAIL represents failed.

◆ sdrv_wdt_get_default_config()

status_t sdrv_wdt_get_default_config ( sdrv_wdt_config_t config)

Get the default configuration for watchdog.

This function get the default configuration for watchdog. When you want initialize, you can call this function first and modify some of them, then call sdrv_wdt_init.

Parameters
[in]configWDT config struct.
Returns
SDRV_STATUS_OK represents success, SDRV_STATUS_FAIL represents failed.

◆ sdrv_wdt_get_intr_status()

status_t sdrv_wdt_get_intr_status ( sdrv_wdt_t base,
sdrv_wdt_intr_e  intr 
)

Get watchdog interrupt status of specific type.

This function get specific type interrupt status.

Parameters
[in]baseWDT control base.
[in]intrinterrupt type defined in sdrv_wdt_intr_e.
Returns
true represents status is set, false represents status not set.

◆ sdrv_wdt_init()

status_t sdrv_wdt_init ( sdrv_wdt_t base,
sdrv_wdt_config_t config 
)

Initialize watchdog with config parameters.

This function config watchdog with parameters in sdrv_wdt_config_t.

Parameters
[in]baseWDT control base.
[in]configWDT config struct.
Returns
Return SDRV_STATUS_OK or error code.

◆ sdrv_wdt_read_timestamp()

uint32_t sdrv_wdt_read_timestamp ( sdrv_wdt_t base)

Read watchdog current counter.

This function read watchdog current counter. When you enable sequence refresh, you need call this function first and store read value. Before time delta, use sdrv_wdt_write_timestamp with stored value. Otherwise, illeage sequential refresh interrupt status will set.

Parameters
[in]baseWDT control base.
Returns
current timer counter.

◆ sdrv_wdt_refresh()

Feed watchdog.

This function trigger watchdog do refresh.

Parameters
[in]baseWDT control base.
Returns
SDRV_STATUS_OK represents success, SDRV_STATUS_FAIL represents failed.

◆ sdrv_wdt_set_sequence_delta()

status_t sdrv_wdt_set_sequence_delta ( sdrv_wdt_t base,
uint32_t  delta 
)

Set watchdog sequence delta value.

This function get sequence delta value in milliseconds and convert to timer counter according to clock source pre-configed.

Parameters
[in]baseWDT control base.
[in]deltaunit: ms.
Returns
SDRV_STATUS_OK represents success, SDRV_STATUS_FAIL represents failed, SDRV_STATUS_INVALID_PARAM represents invalid paramemt.

◆ sdrv_wdt_set_timeout()

status_t sdrv_wdt_set_timeout ( sdrv_wdt_t base,
uint32_t  timeout 
)

Set watchdog timeout value.

This function get timeout value in milliseconds and convert to timer counter according to clock source pre-configed.

Parameters
[in]baseWDT control base.
[in]timeoutunit: ms.
Returns
SDRV_STATUS_OK represents success, SDRV_STATUS_FAIL represents failed, SDRV_STATUS_INVALID_PARAM represents invalid paramemt.

◆ sdrv_wdt_set_window_low()

status_t sdrv_wdt_set_window_low ( sdrv_wdt_t base,
uint32_t  low_limit 
)

Set watchdog time window low limit value.

This function get time window low limit value in milliseconds and convert to timer counter according to clock source pre-configed.

Parameters
[in]baseWDT control base.
[in]low_limitunit: ms.
Returns
SDRV_STATUS_OK represents success, SDRV_STATUS_FAIL represents failed, SDRV_STATUS_INVALID_PARAM represents invalid paramemt.

◆ sdrv_wdt_write_timestamp()

status_t sdrv_wdt_write_timestamp ( sdrv_wdt_t base,
uint32_t  timestamp 
)

Write watchdog counter to TSW register.

This function write counter to TSW register. When config sequence base refresh, read timestamp first, then write read value to TSW before sequence delta.

Parameters
[in]baseWDT control base.
[in]timestamplast read wdt conunter.
Returns
SDRV_STATUS_OK represents success, SDRV_STATUS_FAIL represents failed.