Software Drivers

xtmrctr.c File Reference

#include "xstatus.h"
#include "xparameters.h"
#include "xtmrctr.h"
#include "xtmrctr_i.h"

Functions

int XTmrCtr_Initialize (XTmrCtr *InstancePtr, u16 DeviceId)
void XTmrCtr_Start (XTmrCtr *InstancePtr, u8 TmrCtrNumber)
void XTmrCtr_Stop (XTmrCtr *InstancePtr, u8 TmrCtrNumber)
u32 XTmrCtr_GetValue (XTmrCtr *InstancePtr, u8 TmrCtrNumber)
void XTmrCtr_SetResetValue (XTmrCtr *InstancePtr, u8 TmrCtrNumber, u32 ResetValue)
u32 XTmrCtr_GetCaptureValue (XTmrCtr *InstancePtr, u8 TmrCtrNumber)
void XTmrCtr_Reset (XTmrCtr *InstancePtr, u8 TmrCtrNumber)
int XTmrCtr_IsExpired (XTmrCtr *InstancePtr, u8 TmrCtrNumber)
XTmrCtr_ConfigXTmrCtr_LookupConfig (u16 DeviceId)

Detailed Description

Contains required functions for the XTmrCtr driver.

 MODIFICATION HISTORY:
 Ver   Who  Date     Changes
 ----- ---- -------- -----------------------------------------------
 1.00a ecm  08/16/01 First release
 1.00b jhl  02/21/02 Repartitioned the driver for smaller files
 1.10b mta  03/21/07 Updated to new coding style
 2.00a ktn  10/30/09 Updated to use HAL API's. _m is removed from all the macro
		      definitions.
 2.05a adk  15/05/13 Fixed the CR:693066
		      Added the IsStartedTmrCtr0/IsStartedTmrCtr1 members to the
		      XTmrCtr instance structure.
		      The IsStartedTmrCtrX will be assigned XIL_COMPONENT_IS_STARTED in
		      the XTmrCtr_Start function.
		      The IsStartedTmrCtrX will be cleared in the XTmrCtr_Stop function.
		      There will be no Initialization done in the
		      XTmrCtr_Initialize if both the timers have already started and
		      the XST_DEVICE_IS_STARTED Status is returned.
		      Removed the logic in the XTmrCtr_Initialize function
		      which was checking the Register Value to know whether
		      a timer has started or not.
 

Function Documentation

u32 XTmrCtr_GetCaptureValue ( XTmrCtr InstancePtr,
u8  TmrCtrNumber 
)

Returns the timer counter value that was captured the last time the external capture input was asserted.

Parameters:
InstancePtr is a pointer to the XTmrCtr instance.
TmrCtrNumber is the timer counter of the device to operate on. Each device may contain multiple timer counters. The timer number is a zero based number with a range of 0 - (XTC_DEVICE_TIMER_COUNT - 1).
Returns:
The current capture value for the indicated timer counter.
Note:
None.
u32 XTmrCtr_GetValue ( XTmrCtr InstancePtr,
u8  TmrCtrNumber 
)

Get the current value of the specified timer counter. The timer counter may be either incrementing or decrementing based upon the current mode of operation.

Parameters:
InstancePtr is a pointer to the XTmrCtr instance.
TmrCtrNumber is the timer counter of the device to operate on. Each device may contain multiple timer counters. The timer number is a zero based number with a range of 0 - (XTC_DEVICE_TIMER_COUNT - 1).
Returns:
The current value for the timer counter.
Note:
None.
int XTmrCtr_Initialize ( XTmrCtr InstancePtr,
u16  DeviceId 
)

Initializes a specific timer/counter instance/driver. Initialize fields of the XTmrCtr structure, then reset the timer/counter.If a timer is already running then it is not initialized.

Parameters:
InstancePtr is a pointer to the XTmrCtr instance.
DeviceId is the unique id of the device controlled by this XTmrCtr component. Passing in a device id associates the generic XTmrCtr component to a specific device, as chosen by the caller or application developer.
Returns:
  • XST_SUCCESS if initialization was successful
  • XST_DEVICE_IS_STARTED if the device has already been started
  • XST_DEVICE_NOT_FOUND if the device doesn't exist
Note:
None.
int XTmrCtr_IsExpired ( XTmrCtr InstancePtr,
u8  TmrCtrNumber 
)

Checks if the specified timer counter of the device has expired. In capture mode, expired is defined as a capture occurred. In compare mode, expired is defined as the timer counter rolled over/under for up/down counting.

When interrupts are enabled, the expiration causes an interrupt. This function is typically used to poll a timer counter to determine when it has expired.

Parameters:
InstancePtr is a pointer to the XTmrCtr instance.
TmrCtrNumber is the timer counter of the device to operate on. Each device may contain multiple timer counters. The timer number is a zero based number with a range of 0 - (XTC_DEVICE_TIMER_COUNT - 1).
Returns:
TRUE if the timer has expired, and FALSE otherwise.
Note:
None.
XTmrCtr_Config* XTmrCtr_LookupConfig ( u16  DeviceId  ) 
void XTmrCtr_Reset ( XTmrCtr InstancePtr,
u8  TmrCtrNumber 
)

Resets the specified timer counter of the device. A reset causes the timer counter to set it's value to the reset value.

Parameters:
InstancePtr is a pointer to the XTmrCtr instance.
TmrCtrNumber is the timer counter of the device to operate on. Each device may contain multiple timer counters. The timer number is a zero based number with a range of 0 - (XTC_DEVICE_TIMER_COUNT - 1).
Returns:
None.
Note:
None.
void XTmrCtr_SetResetValue ( XTmrCtr InstancePtr,
u8  TmrCtrNumber,
u32  ResetValue 
)

Set the reset value for the specified timer counter. This is the value that is loaded into the timer counter when it is reset. This value is also loaded when the timer counter is started.

Parameters:
InstancePtr is a pointer to the XTmrCtr instance.
TmrCtrNumber is the timer counter of the device to operate on. Each device may contain multiple timer counters. The timer number is a zero based number with a range of 0 - (XTC_DEVICE_TIMER_COUNT - 1).
ResetValue contains the value to be used to reset the timer counter.
Returns:
None.
Note:
None.
void XTmrCtr_Start ( XTmrCtr InstancePtr,
u8  TmrCtrNumber 
)

Starts the specified timer counter of the device such that it starts running. The timer counter is reset before it is started and the reset value is loaded into the timer counter.

If interrupt mode is specified in the options, it is necessary for the caller to connect the interrupt handler of the timer/counter to the interrupt source, typically an interrupt controller, and enable the interrupt within the interrupt controller.

Parameters:
InstancePtr is a pointer to the XTmrCtr instance.
TmrCtrNumber is the timer counter of the device to operate on. Each device may contain multiple timer counters. The timer number is a zero based number with a range of 0 - (XTC_DEVICE_TIMER_COUNT - 1).
Returns:
None.
Note:
None.
void XTmrCtr_Stop ( XTmrCtr InstancePtr,
u8  TmrCtrNumber 
)

Stops the timer counter by disabling it.

It is the callers' responsibility to disconnect the interrupt handler of the timer_counter from the interrupt source, typically an interrupt controller, and disable the interrupt within the interrupt controller.

Parameters:
InstancePtr is a pointer to the XTmrCtr instance.
TmrCtrNumber is the timer counter of the device to operate on. Each device may contain multiple timer counters. The timer number is a zero based number with a range of 0 - (XTC_DEVICE_TIMER_COUNT - 1).
Returns:
None.
Note:
None.