Software Drivers

xttcps.c File Reference

#include "xttcps.h"

Functions

int XTtcPs_CfgInitialize (XTtcPs *InstancePtr, XTtcPs_Config *ConfigPtr, u32 EffectiveAddr)
void XTtcPs_SetMatchValue (XTtcPs *InstancePtr, u8 MatchIndex, u16 Value)
u16 XTtcPs_GetMatchValue (XTtcPs *InstancePtr, u8 MatchIndex)
void XTtcPs_SetPrescaler (XTtcPs *InstancePtr, u8 PrescalerValue)
u8 XTtcPs_GetPrescaler (XTtcPs *InstancePtr)
void XTtcPs_CalcIntervalFromFreq (XTtcPs *InstancePtr, u32 Freq, u16 *Interval, u8 *Prescaler)

Detailed Description

This file contains the implementation of the XTtcPs driver. This driver controls the operation of one timer counter in the Triple Timer Counter (TTC) module in the Ps block. Refer to xttcps.h for more detailed description of the driver.

 MODIFICATION HISTORY:
 Ver   Who    Date     Changes
 ----- ------ -------- -------------------------------------------------
 1.00a drg/jz 01/21/10 First release
 

Function Documentation

void XTtcPs_CalcIntervalFromFreq ( XTtcPs InstancePtr,
u32  Freq,
u16 *  Interval,
u8 *  Prescaler 
)

This function calculates the interval value as well as the prescaler value for a given frequency.

Parameters:
InstancePtr is a pointer to the XTtcPs instance.
Freq is the requested output frequency for the device.
Interval is the interval value for the given frequency, it is the output value for this function.
Prescaler is the prescaler value for the given frequency, it is the output value for this function.
Returns:
None.
Note:
Upon successful calculation for the given frequency, Interval and Prescaler carry the settings for the timer counter; Upon unsuccessful calculation, Interval and Prescaler are set to 0xFF(FF) for their maximum values to signal the caller of failure. Therefore, caller needs to check the return interval or prescaler values for whether the function has succeeded.
int XTtcPs_CfgInitialize ( XTtcPs InstancePtr,
XTtcPs_Config ConfigPtr,
u32  EffectiveAddr 
)

Initializes a specific XTtcPs instance such that the driver is ready to use. This function initializes a single timer counter in the triple timer counter function block.

The state of the device after initialization is:

  • Overflow Mode
  • Internal (pclk) selected
  • Counter disabled
  • All Interrupts disabled
  • Output waveforms disabled
Parameters:
InstancePtr is a pointer to the XTtcPs instance.
ConfigPtr is a reference to a structure containing information about a specific TTC device.
EffectiveAddr is the device base address in the virtual memory address space. The caller is responsible for keeping the address mapping from EffectiveAddr to the device physical base address unchanged once this function is invoked. Unexpected errors may occur if the address mapping changes after this function is called. If address translation is not used, then use ConfigPtr->BaseAddress for this parameter, passing the physical address instead.
Returns:
  • XST_SUCCESS if the initialization is successful.
  • XST_DEVICE_IS_STARTED if the device is started. It must be stopped to re-initialize.
Note:
Device has to be stopped first to call this function to initialize it.
u16 XTtcPs_GetMatchValue ( XTtcPs InstancePtr,
u8  MatchIndex 
)

This function is used to get the value of the match registers. There are three match registers.

Parameters:
InstancePtr is a pointer to the XTtcPs instance.
MatchIndex is the index to the match register to be set. Valid values are 0, 1, or 2.
Returns:
None
Note:
None
u8 XTtcPs_GetPrescaler ( XTtcPs InstancePtr  ) 

This function gets the input clock prescaler

Parameters:
InstancePtr is a pointer to the XTtcPs instance.
 
Returns:
The value(n) from which the prescalar value is calculated as 2^(n+1). Some example values are given below :

Value Prescaler 0 2 1 4 N 2^(n+1) 15 65536 16 1

Note:
None.
void XTtcPs_SetMatchValue ( XTtcPs InstancePtr,
u8  MatchIndex,
u16  Value 
)

This function is used to set the match registers. There are three match registers.

The match 0 register is special. If the waveform output mode is enabled, the waveform will change polarity when the count matches the value in the match 0 register. The polarity of the waveform output can also be set using the XTtcPs_SetOptions() function.

Parameters:
InstancePtr is a pointer to the XTtcPs instance.
MatchIndex is the index to the match register to be set. Valid values are 0, 1, or 2.
Value is the 16-bit value to be set in the match register.
Returns:
None
Note:
None
void XTtcPs_SetPrescaler ( XTtcPs InstancePtr,
u8  PrescalerValue 
)

This function sets the prescaler enable bit and if needed sets the prescaler bits in the control register.

Parameters:
InstancePtr is a pointer to the XTtcPs instance.
PrescalerValue is a number from 0-16 that sets the prescaler to use. If the parameter is 0 - 15, use a prescaler on the clock of 2^(PrescalerValue+1), or 2-65536. If the parameter is XTTCPS_CLK_CNTRL_PS_DISABLE, do not use a prescaler.
Returns:
None
Note:
None