WDOG32 Peripheral driver
Watchdog Timer (WDOG32)
Collaboration diagram for WDOG32 Peripheral driver:

## Data Structures

struct | wdog32_work_mode_t
| Defines WDOG32 work mode. More...
struct | wdog32_config_t
| Describes WDOG32 configuration structure. More...

## Enumerations

enum | wdog32_clock_source_t { kWDOG32_ClockSource0 = 0U, kWDOG32_ClockSource1 = 1U, kWDOG32_ClockSource2 = 2U, kWDOG32_ClockSource3 = 3U }
| Describes WDOG32 clock source. More...
enum | wdog32_clock_prescaler_t { kWDOG32_ClockPrescalerDivide1 = 0x0U, kWDOG32_ClockPrescalerDivide256 = 0x1U }
| Describes the selection of the clock prescaler. More...
enum | wdog32_test_mode_t { kWDOG32_TestModeDisabled = 0U, kWDOG32_UserModeEnabled = 1U, kWDOG32_LowByteTest = 2U, kWDOG32_HighByteTest = 3U }
| Describes WDOG32 test mode. More...
enum | _wdog32_interrupt_enable_t { kWDOG32_InterruptEnable = WDOG_CS_INT_MASK }
| WDOG32 interrupt configuration structure. More...
enum | _wdog32_status_flags_t { kWDOG32_RunningFlag = WDOG_CS_EN_MASK, kWDOG32_InterruptFlag = WDOG_CS_FLG_MASK }
| WDOG32 status flags. More...

## WDOG32 Initialization and De-initialization

void | WDOG32_GetDefaultConfig (wdog32_config_t *config)
| Initializes WDOG32 configure sturcture. More...
void | WDOG32_Init (WDOG_Type *base, const wdog32_config_t *config)
| Initializes WDOG32 module. More...
void | WDOG32_Deinit (WDOG_Type *base)
| De-initializes WDOG32 module. More...

## WDOG32 functional Operation

static void | WDOG32_Enable (WDOG_Type *base)
| Enables WDOG32 module. More...
static void | WDOG32_Disable (WDOG_Type *base)
| Disables WDOG32 module. More...
static void | WDOG32_EnableInterrupts (WDOG_Type *base, uint32_t mask)
| Enable WDOG32 interrupt. More...
static void | WDOG32_DisableInterrupts (WDOG_Type *base, uint32_t mask)
| Disable WDOG32 interrupt. More...
uint32_t | WDOG32_GetStatusFlags (WDOG_Type *base)
| Gets WDOG32 all status flags. More...
void | WDOG32_ClearStatusFlags (WDOG_Type *base, uint32_t mask)
| Clear WDOG32 flag. More...
static void | WDOG32_SetTimeoutValue (WDOG_Type *base, uint16_t timeoutCount)
| Set the WDOG32 timeout value. More...
static void | WDOG32_SetWindowValue (WDOG_Type *base, uint16_t windowValue)
| Sets the WDOG32 window value. More...
static void | WDOG32_Unlock (WDOG_Type *base)
| Unlocks the WDOG32 register written. More...
static void | WDOG32_Refresh (WDOG_Type *base)
| Refreshes the WDOG32 timer. More...
static uint16_t | WDOG32_GetCounterValue (WDOG_Type *base)
| Gets WDOG32 counter value. More...

## Usage Information

This section describes the programming interface of the WDOG32 Peripheral driver. The WDOG32 driver configures the WDOG32 module.

# Function groups

This function group initializes and de-initializes the WDOG32 module.

This function group implements the WDOG32 functional API.

# Typical use case

wdog32_config_t config;
WDOG32_GetDefaultConfig(&config);
config.timeoutValue = 0x7ffU;
config.enableWindowMode = true;
config.windowValue = 0x1ffU;
WDOG32_Init(wdog_base,&config);

## Data Structure Documentation

struct wdog32_work_mode_t

Defines WDOG32 work mode.

Data Fields
bool | enableDebug | Enables or disables WDOG32 in debug mode
bool | enableStop | Enables or disables WDOG32 in stop mode
bool | enableWait | Enables or disables WDOG32 in wait mode

struct wdog32_config_t

Describes WDOG32 configuration structure.

Collaboration diagram for wdog32_config_t:
[legend]

Data Fields
wdog32_clock_source_t | clockSource | Clock source select
bool | enableInterrupt | Enables or disables WDOG32 interrupt
bool | enableUpdate | Update write-once register enable
bool | enableWdog32 | Enables or disables WDOG32
bool | enableWindowMode | Enables or disables WDOG32 window mode
wdog32_clock_prescaler_t | prescaler | Clock prescaler value
wdog32_test_mode_t | testMode | Configures WDOG32 test mode
uint16_t | timeoutValue | Timeout value
uint16_t | windowValue | Window value
wdog32_work_mode_t | workMode | Configures WDOG32 work mode in debug stop and wait mode

## Enumeration Type Documentation

enum _wdog32_interrupt_enable_t

WDOG32 interrupt configuration structure.

This structure contains the settings for all of the WDOG32 interrupt configurations.

Enumerator
kWDOG32_InterruptEnable | Interrupt will be generated before forcing a reset

enum _wdog32_status_flags_t

WDOG32 status flags.

This structure contains the WDOG32 status flags for use in the WDOG32 functions.

Enumerator
kWDOG32_RunningFlag | Running flag, set when WDOG32 is enabled
kWDOG32_InterruptFlag | Interrupt flag, set when interrupt occurs

enum wdog32_clock_prescaler_t

Describes the selection of the clock prescaler.

Enumerator
kWDOG32_ClockPrescalerDivide1 | Divided by 1
kWDOG32_ClockPrescalerDivide256 | Divided by 256

enum wdog32_clock_source_t

Describes WDOG32 clock source.

Enumerator
kWDOG32_ClockSource0 | Clock source 0
kWDOG32_ClockSource1 | Clock source 1
kWDOG32_ClockSource2 | Clock source 2
kWDOG32_ClockSource3 | Clock source 3

enum wdog32_test_mode_t

Describes WDOG32 test mode.

Enumerator
kWDOG32_TestModeDisabled | Test Mode diabled
kWDOG32_UserModeEnabled | User Mode enabled
kWDOG32_LowByteTest | Test Mode enabled, only low byte is used
kWDOG32_HighByteTest | Test Mode enabled, only high byte is used

## Function Documentation

void WDOG32_ClearStatusFlags | ( | WDOG_Type * | base,
|  | uint32_t | mask
| ) |  |

Clear WDOG32 flag.

This function clears WDOG32 status flag.

Example for clearing interrupt flag:

WDOG32_ClearStatusFlags(wdog_base,kWDOG32_InterruptFlag);

Parameters

  base | WDOG32 peripheral base address

  mask

  The status flags to clear. The parameter could be any combination of the following values:
  - kWDOG32_InterruptFlag

void WDOG32_Deinit | ( | WDOG_Type * | base | ) |

De-initializes WDOG32 module.

This function shuts down the WDOG32. Make sure that the WDOG_CS.UPDATE is 1 which means that the register update is enabled.

Parameters

  base | WDOG32 peripheral base address

static void WDOG32_Disable | ( | WDOG_Type * | base | ) |

inlinestatic

Disables WDOG32 module.

This function write value into WDOG_CS register to disable WDOG32. WDOG_CS register is a write-once register, make sure the WCT window is still open and this register has not been written in this WCT while this function is called.

Parameters

  base | WDOG32 peripheral base address

static void WDOG32_DisableInterrupts | ( | WDOG_Type * | base,
|  | uint32_t | mask
| ) |  |

inlinestatic

Disable WDOG32 interrupt.

This function write value into WDOG_CS register to disable the WDOG32 interrupt. WDOG_CS register is a write-once register, make sure the WCT window is still open and this register has not been written in this WCT while this function is called.

Parameters

  base | WDOG32 peripheral base address

  mask

  The interrupts to disable The parameter can be combination of the following source if defined:
  - kWDOG32_InterruptEnable

static void WDOG32_Enable | ( | WDOG_Type * | base | ) |

inlinestatic

Enables WDOG32 module.

This function write value into WDOG_CS register to enable WDOG32. WDOG_CS register is a write-once register, make sure the WCT window is still open and this register has not been written in this WCT while this function is called.

Parameters

  base | WDOG32 peripheral base address

static void WDOG32_EnableInterrupts | ( | WDOG_Type * | base,
|  | uint32_t | mask
| ) |  |

inlinestatic

Enable WDOG32 interrupt.

This function write value into WDOG_CS register to enable the WDOG32 interrupt. WDOG_CS register is a write-once register, make sure the WCT window is still open and this register has not been written in this WCT while this function is called.

Parameters

  base | WDOG32 peripheral base address

  mask

  The interrupts to enable The parameter can be combination of the following source if defined:
  - kWDOG32_InterruptEnable

static uint16_t WDOG32_GetCounterValue | ( | WDOG_Type * | base | ) |

inlinestatic

Gets WDOG32 counter value.

This function gets the WDOG32 counter value.

Parameters

  base | WDOG32 peripheral base address

Returns
  Current WDOG32 counter value

void WDOG32_GetDefaultConfig | ( | wdog32_config_t * | config | ) |

Initializes WDOG32 configure sturcture.

This function initializes the WDOG32 configure structure to default value. The default value are:

wdog32Config->enableWdog32 = true;
wdog32Config->clockSource = kWDOG32_ClockSource1;
wdog32Config->prescaler = kWDOG32_ClockPrescalerDivide1;
wdog32Config->workMode.enableWait = true;
wdog32Config->workMode.enableStop = false;
wdog32Config->workMode.enableDebug = false;
wdog32Config->testMode = kWDOG32_TestModeDisabled;
wdog32Config->enableUpdate = true;
wdog32Config->enableInterrupt = false;
wdog32Config->enableWindowMode = false;
wdog32Config->windowValue = 0U;
wdog32Config->timeoutValue = 0xFFFFU;

Parameters

  config | Pointer to WDOG32 config structure.

See also
  wdog32_config_t

uint32_t WDOG32_GetStatusFlags | ( | WDOG_Type * | base | ) |

inline

Gets WDOG32 all status flags.

This function gets all status flags.

Example for getting Running Flag:

uint32_t status;
status = WDOG32_GetStatusFlags(wdog_base) & kWDOG32_RunningFlag;

Parameters

  base | WDOG32 peripheral base address

Returns
  State of the status flag: asserted (true) or not-asserted (false).

See also
  _wdog32_status_flags_t
  - true: related status flag has been set.
  - false: related status flag is not set.

void WDOG32_Init | ( | WDOG_Type * | base,
|  | const wdog32_config_t * | config
| ) |  |

Initializes WDOG32 module.

This function is used to initializes WDOG32. If user wants to reconfigure WDOG32 without forcing a reset first, enableUpdate must be set to true in configuration.

Example:

wdog32_config_t config;
WDOG32_GetDefaultConfig(&config);
config.timeoutValue = 0x7ffU;
config.enableUpdate = true;
WDOG32_Init(wdog_base,&config);

Parameters

  base | WDOG32 peripheral base address
  config | The configuration of WDOG32

static void WDOG32_Refresh | ( | WDOG_Type * | base | ) |

inlinestatic

Refreshes the WDOG32 timer.

This function feeds the WDOG32. This function should be called before watchdog timer is in timeout. Otherwise, a reset is asserted.

Parameters

  base | WDOG32 peripheral base address

static void WDOG32_SetTimeoutValue | ( | WDOG_Type * | base,
|  | uint16_t | timeoutCount
| ) |  |

inlinestatic

Set the WDOG32 timeout value.

This function write timeout value into WDOG_TOVAL register. WDOG_TOVAL register is a write-once register, make sure the WCT window is still open and this register has not been written in this WCT while this function is called.

Parameters

  base | WDOG32 peripheral base address
  timeoutCount | WDOG32 timeout value, count of WDOG32 clock tick.

static void WDOG32_SetWindowValue | ( | WDOG_Type * | base,
|  | uint16_t | windowValue
| ) |  |

inlinestatic

Sets the WDOG32 window value.

This function write window value into WDOG_WIN register. WDOG_WIN register is a write-once register, make sure the WCT window is still open and this register has not been written in this WCT while this function is called.

Parameters

  base | WDOG32 peripheral base address
  windowValue | WDOG32 window value.

static void WDOG32_Unlock | ( | WDOG_Type * | base | ) |

inlinestatic

Unlocks the WDOG32 register written.

This function unlocks the WDOG32 register written.

Before starting the unlock sequence and following congfiguration, disable the global interrupts. Otherwise, an interrupt could effectively invalidate the unlock sequence and the WCT may expire, After the configuration finishes, re-enable the global interrupts.

Parameters

  base | WDOG32 peripheral base address