#include "xttcps_hw.h"
#include "xstatus.h"
Classes | |
struct | XTtcPs_Config |
struct | XTtcPs |
Defines | |
#define | XTTCPS_H |
#define | InstReadReg(InstancePtr, RegOffset) (Xil_In32(((InstancePtr)->Config.BaseAddress) + (RegOffset))) |
#define | InstWriteReg(InstancePtr, RegOffset, Data) (Xil_Out32(((InstancePtr)->Config.BaseAddress) + (RegOffset), (Data))) |
#define | XTtcPs_Start(InstancePtr) |
#define | XTtcPs_Stop(InstancePtr) |
#define | XTtcPs_IsStarted(InstancePtr) |
#define | XTtcPs_GetCounterValue(InstancePtr) (u16)InstReadReg((InstancePtr), XTTCPS_COUNT_VALUE_OFFSET) |
#define | XTtcPs_SetInterval(InstancePtr, Value) InstWriteReg((InstancePtr), XTTCPS_INTERVAL_VAL_OFFSET, (Value)) |
#define | XTtcPs_GetInterval(InstancePtr) (u16)InstReadReg((InstancePtr), XTTCPS_INTERVAL_VAL_OFFSET) |
#define | XTtcPs_ResetCounterValue(InstancePtr) |
#define | XTtcPs_EnableInterrupts(InstancePtr, InterruptMask) |
#define | XTtcPs_DisableInterrupts(InstancePtr, InterruptMask) |
#define | XTtcPs_GetInterruptStatus(InstancePtr) InstReadReg((InstancePtr), XTTCPS_ISR_OFFSET) |
#define | XTtcPs_ClearInterruptStatus(InstancePtr, InterruptMask) |
Configuration options | |
#define | XTTCPS_OPTION_EXTERNAL_CLK 0x0001 |
#define | XTTCPS_OPTION_CLK_EDGE_NEG 0x0002 |
#define | XTTCPS_OPTION_INTERVAL_MODE 0x0004 |
#define | XTTCPS_OPTION_DECREMENT 0x0008 |
#define | XTTCPS_OPTION_MATCH_MODE 0x0010 |
#define | XTTCPS_OPTION_WAVE_DISABLE 0x0020 |
#define | XTTCPS_OPTION_WAVE_POLARITY 0x0040 |
Functions | |
XTtcPs_Config * | XTtcPs_LookupConfig (u16 DeviceId) |
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) |
int | XTtcPs_SetOptions (XTtcPs *InstancePtr, u32 Options) |
u32 | XTtcPs_GetOptions (XTtcPs *InstancePtr) |
int | XTtcPs_SelfTest (XTtcPs *InstancePtr) |
#define InstReadReg | ( | InstancePtr, | |||
RegOffset | ) | (Xil_In32(((InstancePtr)->Config.BaseAddress) + (RegOffset))) |
#define InstWriteReg | ( | InstancePtr, | |||
RegOffset, | |||||
Data | ) | (Xil_Out32(((InstancePtr)->Config.BaseAddress) + (RegOffset), (Data))) |
#define XTtcPs_ClearInterruptStatus | ( | InstancePtr, | |||
InterruptMask | ) |
InstWriteReg((InstancePtr), XTTCPS_ISR_OFFSET, \ (InterruptMask))
This function clears the interrupt status.
InstancePtr | is a pointer to the XTtcPs instance. | |
InterruptMask | defines which interrupt should be cleared. Constants are defined in xttcps_hw.h as XTTCPS_IXR_*. This is a bit mask, all set bits will be cleared, cleared bits will not be cleared. |
#define XTtcPs_DisableInterrupts | ( | InstancePtr, | |||
InterruptMask | ) |
InstWriteReg((InstancePtr), XTTCPS_IER_OFFSET, \ (InstReadReg((InstancePtr), XTTCPS_IER_OFFSET) & \ ~(InterruptMask)))
This function disables the interrupts.
InstancePtr | is a pointer to the XTtcPs instance. | |
InterruptMask | defines which interrupt should be disabled. Constants are defined in xttcps_hw.h as XTTCPS_IXR_*. This is a bit mask, all set bits will be disabled, cleared bits will not be disabled. |
#define XTtcPs_EnableInterrupts | ( | InstancePtr, | |||
InterruptMask | ) |
InstWriteReg((InstancePtr), XTTCPS_IER_OFFSET, \ (InstReadReg((InstancePtr), XTTCPS_IER_OFFSET) | \ (InterruptMask)))
This function enables the interrupts.
InstancePtr | is a pointer to the XTtcPs instance. | |
InterruptMask | defines which interrupt should be enabled. Constants are defined in xttcps_hw.h as XTTCPS_IXR_*. This is a bit mask, all set bits will be enabled, cleared bits will not be disabled. |
#define XTtcPs_GetCounterValue | ( | InstancePtr | ) | (u16)InstReadReg((InstancePtr), XTTCPS_COUNT_VALUE_OFFSET) |
This function returns the current 16-bit counter value. It may be called at any time.
InstancePtr | is a pointer to the XTtcPs instance. |
#define XTtcPs_GetInterruptStatus | ( | InstancePtr | ) | InstReadReg((InstancePtr), XTTCPS_ISR_OFFSET) |
This function reads the interrupt status.
InstancePtr | is a pointer to the XTtcPs instance. |
#define XTtcPs_GetInterval | ( | InstancePtr | ) | (u16)InstReadReg((InstancePtr), XTTCPS_INTERVAL_VAL_OFFSET) |
This function gets the interval value from the interval register.
InstancePtr | is a pointer to the XTtcPs instance. |
#define XTTCPS_H |
#define XTtcPs_IsStarted | ( | InstancePtr | ) |
(int)((InstReadReg((InstancePtr), XTTCPS_CNT_CNTRL_OFFSET) & \ XTTCPS_CNT_CNTRL_DIS_MASK) == 0)
This function checks whether the timer counter has already started.
InstancePtr | is a pointer to the XTtcPs instance |
#define XTTCPS_OPTION_CLK_EDGE_NEG 0x0002 |
Clock on trailing edge for external clock
#define XTTCPS_OPTION_DECREMENT 0x0008 |
Decrement the counter
#define XTTCPS_OPTION_EXTERNAL_CLK 0x0001 |
External clock source
#define XTTCPS_OPTION_INTERVAL_MODE 0x0004 |
Interval mode
#define XTTCPS_OPTION_MATCH_MODE 0x0010 |
Match mode
#define XTTCPS_OPTION_WAVE_DISABLE 0x0020 |
No waveform output
#define XTTCPS_OPTION_WAVE_POLARITY 0x0040 |
Waveform polarity
#define XTtcPs_ResetCounterValue | ( | InstancePtr | ) |
InstWriteReg((InstancePtr), XTTCPS_CNT_CNTRL_OFFSET, \ (InstReadReg((InstancePtr), XTTCPS_CNT_CNTRL_OFFSET) | \ XTTCPS_CNT_CNTRL_RST_MASK))
This macro resets the count register. It may be called at any time. The counter is reset to either 0 or 0xFFFF, or the interval value, depending on the increment/decrement mode. The state of the counter, as started or stopped, is not affected by calling reset.
InstancePtr | is a pointer to the XTtcPs instance. |
#define XTtcPs_SetInterval | ( | InstancePtr, | |||
Value | ) | InstWriteReg((InstancePtr), XTTCPS_INTERVAL_VAL_OFFSET, (Value)) |
This function sets the interval value to be used in interval mode.
InstancePtr | is a pointer to the XTtcPs instance. | |
Value | is the 16-bit value to be set in the interval register. |
#define XTtcPs_Start | ( | InstancePtr | ) |
InstWriteReg((InstancePtr), XTTCPS_CNT_CNTRL_OFFSET, \ (InstReadReg((InstancePtr), XTTCPS_CNT_CNTRL_OFFSET) & \ ~XTTCPS_CNT_CNTRL_DIS_MASK))
This function starts the counter/timer without resetting the counter value.
InstancePtr | is a pointer to the XTtcPs instance. |
#define XTtcPs_Stop | ( | InstancePtr | ) |
InstWriteReg((InstancePtr), XTTCPS_CNT_CNTRL_OFFSET, \ (InstReadReg((InstancePtr), XTTCPS_CNT_CNTRL_OFFSET) | \ XTTCPS_CNT_CNTRL_DIS_MASK))
This function stops the counter/timer. This macro may be called at any time to stop the counter. The counter holds the last value until it is reset, restarted or enabled.
InstancePtr | is a pointer to the XTtcPs instance. |
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.
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. |
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:
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. |
u16 XTtcPs_GetMatchValue | ( | XTtcPs * | InstancePtr, | |
u8 | MatchIndex | |||
) |
This function is used to get the value of the match registers. There are three match registers.
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. |
u32 XTtcPs_GetOptions | ( | XTtcPs * | InstancePtr | ) |
This function gets the settings for the options for the TTC device.
InstancePtr | is a pointer to the XTtcPs instance. |
The return u32 contains the specified options that are set. This is a bit mask where a '1' means the option is on, and a'0' means the option is off. One or more bit values may be contained in the mask. See the bit definitions named XTTCPS_*_OPTION in the file xttcps.h.
u8 XTtcPs_GetPrescaler | ( | XTtcPs * | InstancePtr | ) |
This function gets the input clock prescaler
InstancePtr | is a pointer to the XTtcPs instance. |
Value Prescaler 0 2 1 4 N 2^(n+1) 15 65536 16 1
XTtcPs_Config* XTtcPs_LookupConfig | ( | u16 | DeviceId | ) |
Looks up the device configuration based on the unique device ID. A table contains the configuration info for each device in the system.
DeviceId | contains the unique ID of the device |
A pointer to the configuration found or NULL if the specified device ID was not found. See xttcps.h for the definition of XTtcPs_Config.
int XTtcPs_SelfTest | ( | XTtcPs * | InstancePtr | ) |
Runs a self-test on the driver/device.
InstancePtr | is a pointer to the XTtcPs instance. |
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.
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. |
int XTtcPs_SetOptions | ( | XTtcPs * | InstancePtr, | |
u32 | Options | |||
) |
This function sets the options for the TTC device.
InstancePtr | is a pointer to the XTtcPs instance. | |
Options | contains the specified options to be set. This is a bit mask where a 1 means to turn the option on, and a 0 means to turn the option off. One or more bit values may be contained in the mask. See the bit definitions named XTTCPS_*_OPTION in the file xttcps.h. |
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.
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. |
Copyright © 1995-2014 Xilinx, Inc. All rights reserved.