scuwdt: Scuwdt_v2_1

| scuwdt Xilinx SDK Drivers API Documentation

- Overview
- Data Structures
- APIs
- File List
- Examples

Data Structures | Macros | Functions | Variables
Scuwdt_v2_1

## Data Structures
struct | XScuWdt_Config
| This typedef contains configuration information for the device. More...
struct | XScuWdt
| The XScuWdt driver instance data. More...

## Macros
#define | XScuWdt_IsWdtExpired(InstancePtr)
| This function is used to check if the watchdog has timed-out and the last reset was caused by the watchdog reset. More...
#define | XScuWdt_IsTimerExpired(InstancePtr)
| This function is used to check if the watchdog counter has reached 0 in timer mode. More...
#define | XScuWdt_RestartWdt(InstancePtr)
| Re-start the watchdog timer. More...
#define | XScuWdt_LoadWdt(InstancePtr, Value)
| Write to the watchdog timer load register. More...
#define | XScuWdt_SetWdMode(InstancePtr)
| Put the watchdog timer in Watchdog mode by setting the WD mode bit of the Watchdog control register. More...
#define | XScuWdt_SetTimerMode(InstancePtr)
| Put the watchdog timer in Timer mode by writing 0x12345678 and 0x87654321 successively to the Watchdog Disable Register. More...
#define | XScuWdt_GetControlReg(InstancePtr)
| Get the contents of the watchdog control register. More...
#define | XScuWdt_SetControlReg(InstancePtr, ControlReg)
| Write to the watchdog control register. More...
#define | XScuWdt_EnableAutoReload(InstancePtr)
| Enable auto-reload mode. More...
#define | XScuWdt_ReadReg(BaseAddr, RegOffset) Xil_In32((BaseAddr) + ((u32)RegOffset))
| Read the given register. More...
#define | XScuWdt_WriteReg(BaseAddr, RegOffset, Data) Xil_Out32((BaseAddr) + ((u32)RegOffset), ((u32)Data))
| Write the given register. More...

## Functions
s32 | XScuWdt_CfgInitialize (XScuWdt *InstancePtr, XScuWdt_Config *ConfigPtr, u32 EffectiveAddress)
| Initialize a specific watchdog timer instance/driver. More...
void | XScuWdt_Start (XScuWdt *InstancePtr)
| Start the watchdog counter of the device. More...
void | XScuWdt_Stop (XScuWdt *InstancePtr)
| Stop the watchdog timer. More...
XScuWdt_Config * | XScuWdt_LookupConfig (u16 DeviceId)
| Lookup the device configuration based on the unique device ID. More...
s32 | XScuWdt_SelfTest (XScuWdt *InstancePtr)
| Run a self-test on the WDT. More...

## Variables
XScuWdt_Config | XScuWdt_ConfigTable [XPAR_XSCUWDT_NUM_INSTANCES]
| This table contains configuration information for each watchdog timer device in the system. More...
XScuWdt_Config | XScuWdt_ConfigTable [XPAR_XSCUWDT_NUM_INSTANCES]
| This table contains configuration information for each watchdog timer device in the system. More...

## Register Map
Offsets of registers from the start of the device. The WDT registers start at an offset 0x20
#define | XSCUWDT_LOAD_OFFSET 0x00U
| Watchdog Load Register. More...
#define | XSCUWDT_COUNTER_OFFSET 0x04U
| Watchdog Counter Register. More...
#define | XSCUWDT_CONTROL_OFFSET 0x08U
| Watchdog Control Register. More...
#define | XSCUWDT_ISR_OFFSET 0x0CU
| Watchdog Interrupt Status Register. More...
#define | XSCUWDT_RST_STS_OFFSET 0x10U
| Watchdog Reset Status Register. More...
#define | XSCUWDT_DISABLE_OFFSET 0x14U
| Watchdog Disable Register. More...

## Watchdog Control register
This register bits control the prescaler, WD/Timer mode, Intr enable, auto-reload, watchdog enable.
#define | XSCUWDT_CONTROL_PRESCALER_MASK 0x0000FF00U
| Prescaler. More...
#define | XSCUWDT_CONTROL_PRESCALER_SHIFT 8U
#define | XSCUWDT_CONTROL_WD_MODE_MASK 0x00000008U
| Watchdog/Timer mode. More...
#define | XSCUWDT_CONTROL_IT_ENABLE_MASK 0x00000004U
| Intr enable (in timer mode) More...
#define | XSCUWDT_CONTROL_AUTO_RELOAD_MASK 0x00000002U
| Auto-reload (in timer mode) More...
#define | XSCUWDT_CONTROL_WD_ENABLE_MASK 0x00000001U
| Watchdog enable. More...

## Interrupt Status register
This register indicates the Counter register has reached zero in Counter mode.
#define | XSCUWDT_ISR_EVENT_FLAG_MASK 0x00000001U
| Event flag. More...

## Reset Status register
This register indicates the Counter register has reached zero in Watchdog mode and a reset request is sent.
#define | XSCUWDT_RST_STS_RESET_FLAG_MASK 0x00000001U
| Time out occurred. More...

## Disable register
This register is used to switch from watchdog mode to timer mode. The software must write 0x12345678 and 0x87654321 successively to the Watchdog Disable Register so that the watchdog mode bit in the Watchdog Control Register is set to zero.
#define | XSCUWDT_DISABLE_VALUE1 0x12345678U
| Watchdog mode disable value 1. More...
#define | XSCUWDT_DISABLE_VALUE2 0x87654321U
| Watchdog mode disable value 2. More...

## Macro Definition Documentation

#define XSCUWDT_CONTROL_AUTO_RELOAD_MASK 0x00000002U

Auto-reload (in timer mode)

#define XSCUWDT_CONTROL_IT_ENABLE_MASK 0x00000004U

Intr enable (in timer mode)

#define XSCUWDT_CONTROL_OFFSET 0x08U

Watchdog Control Register.

Referenced by XScuWdt_Start(), and XScuWdt_Stop().

#define XSCUWDT_CONTROL_PRESCALER_MASK 0x0000FF00U

Prescaler.

#define XSCUWDT_CONTROL_WD_ENABLE_MASK 0x00000001U

Watchdog enable.

Referenced by XScuWdt_SelfTest(), XScuWdt_Start(), and XScuWdt_Stop().

#define XSCUWDT_CONTROL_WD_MODE_MASK 0x00000008U

Watchdog/Timer mode.

#define XSCUWDT_COUNTER_OFFSET 0x04U

Watchdog Counter Register.

Referenced by XScuWdt_SelfTest().

#define XSCUWDT_DISABLE_OFFSET 0x14U

Watchdog Disable Register.

#define XSCUWDT_DISABLE_VALUE1 0x12345678U

Watchdog mode disable value 1.

#define XSCUWDT_DISABLE_VALUE2 0x87654321U

Watchdog mode disable value 2.

#define XScuWdt_EnableAutoReload | ( |  | InstancePtr | ) |

Value:
XScuWdt_SetControlReg((InstancePtr), \
(XScuWdt_GetControlReg(InstancePtr) | \
XSCUWDT_CONTROL_AUTO_RELOAD_MASK))
XSCUWDT_CONTROL_AUTO_RELOAD_MASK
#define XSCUWDT_CONTROL_AUTO_RELOAD_MASK
Auto-reload (in timer mode)
Definition: xscuwdt_hw.h:93
XScuWdt_SetControlReg
#define XScuWdt_SetControlReg(InstancePtr, ControlReg)
Write to the watchdog control register.
Definition: xscuwdt.h:327
XScuWdt_GetControlReg
#define XScuWdt_GetControlReg(InstancePtr)
Get the contents of the watchdog control register.
Definition: xscuwdt.h:308

Enable auto-reload mode.

Parameters

  InstancePtr | is a pointer to the XScuWdt instance.

Returns
  None.

Note
  C-style signature: void XScuWdt_EnableAutoReload(XScuWdt *InstancePtr)

#define XScuWdt_GetControlReg | ( |  | InstancePtr | ) |

Value:
XScuWdt_ReadReg((InstancePtr)->Config.BaseAddr, \
XSCUWDT_CONTROL_OFFSET)
XSCUWDT_CONTROL_OFFSET
#define XSCUWDT_CONTROL_OFFSET
Watchdog Control Register.
Definition: xscuwdt_hw.h:75
XScuWdt_ReadReg
#define XScuWdt_ReadReg(BaseAddr, RegOffset)
Read the given register.
Definition: xscuwdt_hw.h:150

Get the contents of the watchdog control register.

Parameters

  InstancePtr | is a pointer to the XScuWdt instance.

Returns
  Contents of the watchdog control register.

Note
  C-style signature: u32 XScuWdt_GetControlReg(XScuWdt *InstancePtr)

Referenced by XScuWdt_SelfTest().

#define XSCUWDT_ISR_EVENT_FLAG_MASK 0x00000001U

Event flag.

Referenced by ScuWdtIntrExample().

#define XSCUWDT_ISR_OFFSET 0x0CU

Watchdog Interrupt Status Register.

Referenced by ScuWdtIntrExample().

#define XScuWdt_IsTimerExpired | ( |  | InstancePtr | ) |

Value:
((XScuWdt_ReadReg((InstancePtr)->Config.BaseAddr, \
XSCUWDT_ISR_OFFSET) & \
XSCUWDT_ISR_EVENT_FLAG_MASK) == XSCUWDT_ISR_EVENT_FLAG_MASK)
XSCUWDT_ISR_EVENT_FLAG_MASK
#define XSCUWDT_ISR_EVENT_FLAG_MASK
Event flag.
Definition: xscuwdt_hw.h:105
XSCUWDT_ISR_OFFSET
#define XSCUWDT_ISR_OFFSET
Watchdog Interrupt Status Register.
Definition: xscuwdt_hw.h:76
XScuWdt_ReadReg
#define XScuWdt_ReadReg(BaseAddr, RegOffset)
Read the given register.
Definition: xscuwdt_hw.h:150

This function is used to check if the watchdog counter has reached 0 in timer mode.

Parameters

  InstancePtr | is a pointer to the XScuWdt instance.

Returns
  - TRUE if the watchdog has expired.
  - FALSE if the watchdog has not expired.

Note
  C-style signature: int XScuWdt_IsTimerExpired(XScuWdt *InstancePtr)

Referenced by ScuWdtIntrExample().

#define XScuWdt_IsWdtExpired | ( |  | InstancePtr | ) |

Value:
((XScuWdt_ReadReg((InstancePtr)->Config.BaseAddr, \
XSCUWDT_RST_STS_OFFSET) & \
XSCUWDT_RST_STS_RESET_FLAG_MASK) == XSCUWDT_RST_STS_RESET_FLAG_MASK)
XSCUWDT_RST_STS_OFFSET
#define XSCUWDT_RST_STS_OFFSET
Watchdog Reset Status Register.
Definition: xscuwdt_hw.h:77
XScuWdt_ReadReg
#define XScuWdt_ReadReg(BaseAddr, RegOffset)
Read the given register.
Definition: xscuwdt_hw.h:150
XSCUWDT_RST_STS_RESET_FLAG_MASK
#define XSCUWDT_RST_STS_RESET_FLAG_MASK
Time out occurred.
Definition: xscuwdt_hw.h:114

This function is used to check if the watchdog has timed-out and the last reset was caused by the watchdog reset.

Parameters

  InstancePtr | is a pointer to the XScuWdt instance.

Returns
  - TRUE if the watchdog has expired.
  - FALSE if the watchdog has not expired.

Note
  C-style signature: int XScuWdt_IsWdtExpired(XScuWdt *InstancePtr)

#define XSCUWDT_LOAD_OFFSET 0x00U

Watchdog Load Register.

Referenced by XScuWdt_SelfTest().

#define XScuWdt_LoadWdt | ( |  | InstancePtr,
|  |  | Value
| ) |  |

Value:
XScuWdt_WriteReg((InstancePtr)->Config.BaseAddr, \
XSCUWDT_LOAD_OFFSET, (Value))
XSCUWDT_LOAD_OFFSET
#define XSCUWDT_LOAD_OFFSET
Watchdog Load Register.
Definition: xscuwdt_hw.h:73
XScuWdt_WriteReg
#define XScuWdt_WriteReg(BaseAddr, RegOffset, Data)
Write the given register.
Definition: xscuwdt_hw.h:168

Write to the watchdog timer load register.

This will also update the watchdog counter register with the new value. This macro can be used to change the time-out value.

Parameters

  InstancePtr | is a pointer to the XScuWdt instance.
  Value | is the value to be written to the Watchdog Load register.

Returns
  None.

Note
  C-style signature: void XScuWdt_LoadWdt(XScuWdt *InstancePtr, u32 Value)

Referenced by ScuWdtIntrExample(), ScuWdtPolledExample(), and XScuWdt_SelfTest().

#define XScuWdt_ReadReg | ( |  | BaseAddr,
|  |  | RegOffset
| ) |  | Xil_In32((BaseAddr) + ((u32)RegOffset))

Read the given register.

Parameters

  BaseAddr | is the base address of the device
  RegOffset | is the register offset to be read

Returns
  The 32-bit value of the register

Note
  C-style signature: u32 XScuWdt_ReadReg(u32 BaseAddr, u32 RegOffset)

Referenced by XScuWdt_SelfTest(), XScuWdt_Start(), and XScuWdt_Stop().

#define XScuWdt_RestartWdt | ( |  | InstancePtr | ) |

Value:
XScuWdt_LoadWdt((InstancePtr), \
(XScuWdt_ReadReg((InstancePtr)->Config.BaseAddr, \
XSCUWDT_LOAD_OFFSET)))
XScuWdt_LoadWdt
#define XScuWdt_LoadWdt(InstancePtr, Value)
Write to the watchdog timer load register.
Definition: xscuwdt.h:243
XSCUWDT_LOAD_OFFSET
#define XSCUWDT_LOAD_OFFSET
Watchdog Load Register.
Definition: xscuwdt_hw.h:73
XScuWdt_ReadReg
#define XScuWdt_ReadReg(BaseAddr, RegOffset)
Read the given register.
Definition: xscuwdt_hw.h:150

Re-start the watchdog timer.

This macro will read the watchdog load register and write the same value to load register to update the counter register. An application needs to call this function periodically to keep the watchdog from asserting the WDRESETREQ reset request output pin.

Parameters

  InstancePtr | is a pointer to the XScuWdt instance.

Returns
  None.

Note
  C-style signature: void XScuWdt_RestartWdt(XScuWdt *InstancePtr)

Referenced by ScuWdtIntrExample(), and ScuWdtPolledExample().

#define XSCUWDT_RST_STS_OFFSET 0x10U

Watchdog Reset Status Register.

#define XSCUWDT_RST_STS_RESET_FLAG_MASK 0x00000001U

Time out occurred.

#define XScuWdt_SetControlReg | ( |  | InstancePtr,
|  |  | ControlReg
| ) |  |

Value:
XScuWdt_WriteReg((InstancePtr)->Config.BaseAddr, \
XSCUWDT_CONTROL_OFFSET, (ControlReg))
XSCUWDT_CONTROL_OFFSET
#define XSCUWDT_CONTROL_OFFSET
Watchdog Control Register.
Definition: xscuwdt_hw.h:75
XScuWdt_WriteReg
#define XScuWdt_WriteReg(BaseAddr, RegOffset, Data)
Write the given register.
Definition: xscuwdt_hw.h:168

Write to the watchdog control register.

Parameters

  InstancePtr | is a pointer to the XScuWdt instance.
  ControlReg | is the value to be written to the watchdog control register.

Returns
  None.

Note
  C-style signature: void XScuWdt_SetControlReg(XScuWdt *InstancePtr, u32 ControlReg)

Referenced by XScuWdt_SelfTest().

#define XScuWdt_SetTimerMode | ( |  | InstancePtr | ) |

Value:
{ \
XScuWdt_WriteReg((InstancePtr)->Config.BaseAddr, \
XSCUWDT_DISABLE_OFFSET, \
XSCUWDT_DISABLE_VALUE1); \
XScuWdt_WriteReg((InstancePtr)->Config.BaseAddr, \
XSCUWDT_DISABLE_OFFSET, \
XSCUWDT_DISABLE_VALUE2); \
}
XSCUWDT_DISABLE_VALUE2
#define XSCUWDT_DISABLE_VALUE2
Watchdog mode disable value 2.
Definition: xscuwdt_hw.h:127
XSCUWDT_DISABLE_OFFSET
#define XSCUWDT_DISABLE_OFFSET
Watchdog Disable Register.
Definition: xscuwdt_hw.h:78
XSCUWDT_DISABLE_VALUE1
#define XSCUWDT_DISABLE_VALUE1
Watchdog mode disable value 1.
Definition: xscuwdt_hw.h:124
XScuWdt_WriteReg
#define XScuWdt_WriteReg(BaseAddr, RegOffset, Data)
Write the given register.
Definition: xscuwdt_hw.h:168

Put the watchdog timer in Timer mode by writing 0x12345678 and 0x87654321 successively to the Watchdog Disable Register.

The software must write 0x12345678 and 0x87654321 successively to the Watchdog Disable Register so that the watchdog mode bit in the Watchdog Control Register is set to zero.

Parameters

  InstancePtr | is a pointer to the XScuWdt instance.

Returns
  None.

Note
  C-style signature: void XScuWdt_SetTimerMode(XScuWdt *InstancePtr)

Referenced by ScuWdtIntrExample().

#define XScuWdt_SetWdMode | ( |  | InstancePtr | ) |

Value:
XScuWdt_WriteReg((InstancePtr)->Config.BaseAddr, \
XSCUWDT_CONTROL_OFFSET, \
(XScuWdt_ReadReg((InstancePtr)->Config.BaseAddr, \
XSCUWDT_CONTROL_OFFSET) | \
(XSCUWDT_CONTROL_WD_MODE_MASK)))
XSCUWDT_CONTROL_WD_MODE_MASK
#define XSCUWDT_CONTROL_WD_MODE_MASK
Watchdog/Timer mode.
Definition: xscuwdt_hw.h:89
XSCUWDT_CONTROL_OFFSET
#define XSCUWDT_CONTROL_OFFSET
Watchdog Control Register.
Definition: xscuwdt_hw.h:75
XScuWdt_ReadReg
#define XScuWdt_ReadReg(BaseAddr, RegOffset)
Read the given register.
Definition: xscuwdt_hw.h:150
XScuWdt_WriteReg
#define XScuWdt_WriteReg(BaseAddr, RegOffset, Data)
Write the given register.
Definition: xscuwdt_hw.h:168

Put the watchdog timer in Watchdog mode by setting the WD mode bit of the Watchdog control register.

Parameters

  InstancePtr | is a pointer to the XScuWdt instance.

Returns
  None.

Note
  C-style signature: void XScuWdt_SetWdMode(XScuWdt *InstancePtr)

Referenced by ScuWdtPolledExample(), and XScuWdt_CfgInitialize().

#define XScuWdt_WriteReg | ( |  | BaseAddr,
|  |  | RegOffset,
|  |  | Data
| ) |  | Xil_Out32((BaseAddr) + ((u32)RegOffset), ((u32)Data))

Write the given register.

Parameters

  BaseAddr | is the base address of the device
  RegOffset | is the register offset to be written
  Data | is the 32-bit value to write to the register

Returns
  None.

Note
  C-style signature: void XScuWdt_WriteReg(u32 BaseAddr, u32 RegOffset, u32 Data)

Referenced by ScuWdtIntrExample(), XScuWdt_Start(), and XScuWdt_Stop().

## Function Documentation

s32 XScuWdt_CfgInitialize | ( | XScuWdt * | InstancePtr,
|  | XScuWdt_Config * | ConfigPtr,
|  | u32 | EffectiveAddress
| ) |  |

Initialize a specific watchdog timer instance/driver.

This function must be called before other functions of the driver are called.

Parameters

  InstancePtr | is a pointer to the XScuWdt instance.
  ConfigPtr | is the config structure.
  EffectiveAddress | is the base address for the device. It could be a virtual address if address translation is supported in the system, otherwise it is the physical address.

Returns
  - XST_SUCCESS if initialization was successful.
  - XST_DEVICE_IS_STARTED if the device has already been started.

Note
  This function enables the watchdog mode.

References XScuWdt_Config::BaseAddr, XScuWdt::Config, XScuWdt_Config::DeviceId, XScuWdt::IsReady, XScuWdt::IsStarted, and XScuWdt_SetWdMode.

Referenced by ScuWdtIntrExample(), and ScuWdtPolledExample().

XScuWdt_Config * XScuWdt_LookupConfig | ( | u16 | DeviceId | ) |

Lookup the device configuration based on the unique device ID.

The table contains the configuration info for each device in the system.

Parameters

  DeviceId | is the unique device ID of the device being looked up.

Returns
  A pointer to the configuration table entry corresponding to the given device ID, or NULL if no match is found.

Note
  None.

Referenced by ScuWdtIntrExample(), and ScuWdtPolledExample().

s32 XScuWdt_SelfTest | ( | XScuWdt * | InstancePtr | ) |

Run a self-test on the WDT.

This test stops the watchdog, writes a value to the watchdog load register, starts the watchdog and verifies that the value read from the counter register is less that the value written to the load register. It then restores the control register and the watchdog load register.

Parameters

  InstancePtr | is a pointer to the XScuWdt instance.

Returns
  - XST_SUCCESS if self-test was successful.
  - XST_FAILURE if the WDT is not decrementing.

Note
  None.

References XScuWdt::IsReady, XSCUWDT_CONTROL_WD_ENABLE_MASK, XSCUWDT_COUNTER_OFFSET, XScuWdt_GetControlReg, XSCUWDT_LOAD_OFFSET, XScuWdt_LoadWdt, XScuWdt_ReadReg, and XScuWdt_SetControlReg.

Referenced by ScuWdtIntrExample().

void XScuWdt_Start | ( | XScuWdt * | InstancePtr | ) |

Start the watchdog counter of the device.

Parameters

  InstancePtr | is a pointer to the XScuWdt instance.

Returns
  None.

Note
  User needs to select the appropriate mode (watchdog/timer) before using this API. See XScuWdt_SetWdMode/XScuWdt_SetTimerMode macros in xscuwdt.h.

References XScuWdt_Config::BaseAddr, XScuWdt::Config, XScuWdt::IsReady, XScuWdt::IsStarted, XSCUWDT_CONTROL_OFFSET, XSCUWDT_CONTROL_WD_ENABLE_MASK, XScuWdt_ReadReg, and XScuWdt_WriteReg.

Referenced by ScuWdtIntrExample(), and ScuWdtPolledExample().

void XScuWdt_Stop | ( | XScuWdt * | InstancePtr | ) |

Stop the watchdog timer.

Parameters

  InstancePtr | is a pointer to the XScuWdt instance.

Returns
  None.

Note
  None.

References XScuWdt_Config::BaseAddr, XScuWdt::Config, XScuWdt::IsReady, XScuWdt::IsStarted, XSCUWDT_CONTROL_OFFSET, XSCUWDT_CONTROL_WD_ENABLE_MASK, XScuWdt_ReadReg, and XScuWdt_WriteReg.

Referenced by ScuWdtIntrExample().

## Variable Documentation

XScuWdt_Config XScuWdt_ConfigTable[XPAR_XSCUWDT_NUM_INSTANCES]

This table contains configuration information for each watchdog timer device in the system.

XScuWdt_Config XScuWdt_ConfigTable[XPAR_XSCUWDT_NUM_INSTANCES]

Initial value:
= {
{
(u16)XPAR_SCUWDT_0_DEVICE_ID,
(u32)XPAR_SCUWDT_0_BASEADDR
}
}

This table contains configuration information for each watchdog timer device in the system.