PSoC 6 Hardware Abstraction Layer (HAL)
WDT (Watchdog Timer)

General Description

High level interface for interacting with the Cypress Watchdog Timer (WDT).

The watchdog timer is initialized with a timeout interval. Once the WDT is started, if cyhal_wdt_kick is not called at least once every timeout interval, the device will be reset.

Macros

#define CY_RSLT_WDT_INVALID_TIMEOUT   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_WDT, 0))
 
#define CY_RSLT_WDT_ALREADY_INITIALIZED   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_WDT, 1))
 

Functions

cy_rslt_t cyhal_wdt_init (cyhal_wdt_t *obj, uint32_t timeout_ms)
 
void cyhal_wdt_free (cyhal_wdt_t *obj)
 
void cyhal_wdt_kick (cyhal_wdt_t *obj)
 
void cyhal_wdt_start (cyhal_wdt_t *obj)
 
void cyhal_wdt_stop (cyhal_wdt_t *obj)
 
uint32_t cyhal_wdt_get_timeout_ms (cyhal_wdt_t *obj)
 
uint32_t cyhal_wdt_get_max_timeout_ms (void)
 

Macro Definition Documentation

◆ CY_RSLT_WDT_INVALID_TIMEOUT

#define CY_RSLT_WDT_INVALID_TIMEOUT   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_WDT, 0))

WDT timeout out of range

◆ CY_RSLT_WDT_ALREADY_INITIALIZED

#define CY_RSLT_WDT_ALREADY_INITIALIZED   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_WDT, 1))

WDT already initialized

Function Documentation

◆ cyhal_wdt_init()

cy_rslt_t cyhal_wdt_init ( cyhal_wdt_t *  obj,
uint32_t  timeout_ms 
)

Initialize and start the WDT

Initialize or re-initialize the WDT.

Attention
The specified timeout must be at least 1ms and at most the WDT's maximum timeout (see cyhal_wdt_get_max_timeout_ms()).
Parameters
[out]objThe WDT object
[in]timeout_msThe time in milliseconds before the WDT times out (1ms - max) (see cyhal_wdt_get_max_timeout_ms())
Returns
The status of the init request

◆ cyhal_wdt_free()

void cyhal_wdt_free ( cyhal_wdt_t *  obj)

Deinitialize the WDT

Powers down the WDT. After calling this function no other WDT functions should be called except cyhal_wdt_init(). Calling any function other than init after freeing is undefined.

Parameters
[in,out]objThe WDT object

◆ cyhal_wdt_kick()

void cyhal_wdt_kick ( cyhal_wdt_t *  obj)

Refresh the WDT

Refreshes the WDT. This function should be called periodically to prevent the WDT from timing out. In the event of a timeout, the WDT resets the system.

Parameters
[in,out]objThe WDT object

◆ cyhal_wdt_start()

void cyhal_wdt_start ( cyhal_wdt_t *  obj)

Start the WDT

Enables the WDT.

Parameters
[in,out]objThe WDT object
Returns
The status of the start request

◆ cyhal_wdt_stop()

void cyhal_wdt_stop ( cyhal_wdt_t *  obj)

Stop the WDT

Disables the WDT.

Parameters
[in,out]objThe WDT object
Returns
The status of the stop request

◆ cyhal_wdt_get_timeout_ms()

uint32_t cyhal_wdt_get_timeout_ms ( cyhal_wdt_t *  obj)

Get the WDT timeout

Gets the time in milliseconds before the WDT times out.

Parameters
[in,out]objThe WDT object
Returns
The time in milliseconds before the WDT times out

◆ cyhal_wdt_get_max_timeout_ms()

uint32_t cyhal_wdt_get_max_timeout_ms ( void  )

Gets the maximum WDT timeout

Gets the maximum timeout for the WDT.

Returns
The maximum timeout for the WDT