Software Drivers

xscutimer.h File Reference

#include "xstatus.h"
#include "xscutimer_hw.h"

Classes

struct  XScuTimer_Config
struct  XScuTimer

Defines

#define XSCUTIMER_H
#define XScuTimer_IsExpired(InstancePtr)
#define XScuTimer_RestartTimer(InstancePtr)
#define XScuTimer_LoadTimer(InstancePtr, Value)
#define XScuTimer_GetCounterValue(InstancePtr)
#define XScuTimer_EnableAutoReload(InstancePtr)
#define XScuTimer_DisableAutoReload(InstancePtr)
#define XScuTimer_EnableInterrupt(InstancePtr)
#define XScuTimer_DisableInterrupt(InstancePtr)
#define XScuTimer_GetInterruptStatus(InstancePtr)
#define XScuTimer_ClearInterruptStatus(InstancePtr)

Functions

XScuTimer_ConfigXScuTimer_LookupConfig (u16 DeviceId)
int XScuTimer_SelfTest (XScuTimer *InstancePtr)
int XScuTimer_CfgInitialize (XScuTimer *InstancePtr, XScuTimer_Config *ConfigPtr, u32 EffectiveAddress)
void XScuTimer_Start (XScuTimer *InstancePtr)
void XScuTimer_Stop (XScuTimer *InstancePtr)
void XScuTimer_SetPrescaler (XScuTimer *InstancePtr, u8 PrescalerValue)
u8 XScuTimer_GetPrescaler (XScuTimer *InstancePtr)

Detailed Description


Define Documentation

#define XScuTimer_ClearInterruptStatus ( InstancePtr   ) 
Value:

This function clears the interrupt status.

Parameters:
InstancePtr is a pointer to the XScuTimer instance.
Returns:
None.
Note:
C-style signature: void XScuTimer_ClearInterruptStatus(XScuTimer *InstancePtr)
#define XScuTimer_DisableAutoReload ( InstancePtr   ) 
Value:
XScuTimer_WriteReg((InstancePtr)->Config.BaseAddr,              \
                        XSCUTIMER_CONTROL_OFFSET,                       \
                        (XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \
                                XSCUTIMER_CONTROL_OFFSET) &             \
                                ~(XSCUTIMER_CONTROL_AUTO_RELOAD_MASK)))

Disable auto-reload mode.

Parameters:
InstancePtr is a pointer to the XScuTimer instance.
Returns:
None.
Note:
C-style signature: void XScuTimer_DisableAutoReload(XScuTimer *InstancePtr)
#define XScuTimer_DisableInterrupt ( InstancePtr   ) 
Value:
XScuTimer_WriteReg((InstancePtr)->Config.BaseAddr,              \
                        XSCUTIMER_CONTROL_OFFSET,                       \
                        (XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \
                                XSCUTIMER_CONTROL_OFFSET) &             \
                                ~(XSCUTIMER_CONTROL_IRQ_ENABLE_MASK)))

Disable the Timer interrupt.

Parameters:
InstancePtr is a pointer to the XScuTimer instance.
Returns:
None.
Note:
C-style signature: void XScuTimer_DisableInterrupt(XScuTimer *InstancePtr)
#define XScuTimer_EnableAutoReload ( InstancePtr   ) 
Value:
XScuTimer_WriteReg((InstancePtr)->Config.BaseAddr,              \
                        XSCUTIMER_CONTROL_OFFSET,                       \
                        (XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \
                                XSCUTIMER_CONTROL_OFFSET) |              \
                                XSCUTIMER_CONTROL_AUTO_RELOAD_MASK))

Enable auto-reload mode.

Parameters:
InstancePtr is a pointer to the XScuTimer instance.
Returns:
None.
Note:
C-style signature: void XScuTimer_EnableAutoReload(XScuTimer *InstancePtr)
#define XScuTimer_EnableInterrupt ( InstancePtr   ) 
Value:
XScuTimer_WriteReg((InstancePtr)->Config.BaseAddr,              \
                        XSCUTIMER_CONTROL_OFFSET,                       \
                        (XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \
                                        XSCUTIMER_CONTROL_OFFSET) |     \
                                        XSCUTIMER_CONTROL_IRQ_ENABLE_MASK))

Enable the Timer interrupt.

Parameters:
InstancePtr is a pointer to the XScuTimer instance.
Returns:
None.
Note:
C-style signature: void XScuTimer_EnableInterrupt(XScuTimer *InstancePtr)
#define XScuTimer_GetCounterValue ( InstancePtr   ) 
Value:
XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr,               \
                                XSCUTIMER_COUNTER_OFFSET)

Returns the current timer counter register value. It can be called at any time.

Parameters:
InstancePtr is a pointer to the XScuTimer instance.
Returns:
Contents of the timer counter register.
Note:
C-style signature: u32 XScuTimer_GetCounterValue(XScuTimer *InstancePtr)
#define XScuTimer_GetInterruptStatus ( InstancePtr   ) 
Value:
XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr,               \
                        XSCUTIMER_ISR_OFFSET)

This function reads the interrupt status.

Parameters:
InstancePtr is a pointer to the XScuTimer instance.
Returns:
None.
Note:
C-style signature: void XScuTimer_GetInterruptStatus(XScuTimer *InstancePtr)
#define XSCUTIMER_H
#define XScuTimer_IsExpired ( InstancePtr   ) 
Value:

Check if the timer has expired.

Parameters:
InstancePtr is a pointer to the XScuTimer instance.
Returns:
  • TRUE if the timer has expired.
  • FALSE if the timer has not expired.
Note:
C-style signature: int XScuTimer_IsExpired(XScuTimer *InstancePtr)
#define XScuTimer_LoadTimer ( InstancePtr,
Value   ) 
Value:
XScuTimer_WriteReg((InstancePtr)->Config.BaseAddr,              \
                        XSCUTIMER_LOAD_OFFSET, Value)

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

Parameters:
InstancePtr is a pointer to the XScuTimer instance.
Value is the count to be loaded in to the load register.
Returns:
None.
Note:
C-style signature: void XScuTimer_LoadTimer(XScuTimer *InstancePtr, u32 Value)
#define XScuTimer_RestartTimer ( InstancePtr   ) 
Value:
XScuTimer_LoadTimer(InstancePtr,                                \
                XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \
                                        XSCUTIMER_LOAD_OFFSET))

Re-start the timer. This macro will read the timer load register and writes the same value to load register to update the counter register.

Parameters:
InstancePtr is a pointer to the XScuTimer instance.
Returns:
None.
Note:
C-style signature: void XScuTimer_RestartTimer(XScuTimer *InstancePtr)

Function Documentation

int XScuTimer_CfgInitialize ( XScuTimer InstancePtr,
XScuTimer_Config ConfigPtr,
u32  EffectiveAddress 
)

Initialize a specific timer instance/driver. This function must be called before other functions of the driver are called.

Parameters:
InstancePtr is a pointer to the XScuTimer instance.
ConfigPtr points to the XScuTimer configuration 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:
None.
u8 XScuTimer_GetPrescaler ( XScuTimer InstancePtr  ) 

This function returns the current prescaler value.

Parameters:
InstancePtr is a pointer to the XScuTimer instance.
Returns:
The prescaler value.
Note:
None.
XScuTimer_Config* XScuTimer_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.
int XScuTimer_SelfTest ( XScuTimer InstancePtr  ) 

Run a self-test on the timer. This test clears the timer enable bit in the control register, writes to the timer load register and verifies the value read back matches the value written and restores the control register and the timer load register.

Parameters:
InstancePtr is a pointer to the XScuTimer instance.
Returns:
  • XST_SUCCESS if self-test was successful.
  • XST_FAILURE if self test was not successful.
Note:
None.
void XScuTimer_SetPrescaler ( XScuTimer InstancePtr,
u8  PrescalerValue 
)

This function sets the prescaler bits in the timer control register.

Parameters:
InstancePtr is a pointer to the XScuTimer instance.
PrescalerValue is a 8 bit value that sets the prescaler to use.
Returns:
None
Note:
None
void XScuTimer_Start ( XScuTimer InstancePtr  ) 

Start the timer.

Parameters:
InstancePtr is a pointer to the XScuTimer instance.
Returns:
None.
Note:
None.
void XScuTimer_Stop ( XScuTimer InstancePtr  ) 

Stop the timer.

Parameters:
InstancePtr is a pointer to the XScuTimer instance.
Returns:
None.
Note:
None.