![]() |
rtcpsu
Xilinx SDK Drivers API Documentation
|
Data Structures | |
struct | XRtcPsu_Config |
This typedef contains configuration information for a device. More... | |
struct | XRtcPsu |
The XRtcPsu driver instance data. More... | |
struct | XRtcPsu_DT |
This typedef contains DateTime format structure. More... | |
Macros | |
#define | XRTCPSU_CRYSTAL_OSC_EN (u32)1 << XRTC_CTL_OSC_SHIFT |
Separate Mask for Crystal oscillator bit Enable. More... | |
#define | XRtcPsu_WriteSetTime(InstancePtr, Time) |
This macro updates the current time of RTC device. More... | |
#define | XRtcPsu_GetLastSetTime(InstancePtr) XRtcPsu_ReadReg((InstancePtr)->RtcConfig.BaseAddr + XRTC_SET_TIME_RD_OFFSET) |
This macro returns the last set time of RTC device. More... | |
#define | XRtcPsu_GetCalibration(InstancePtr) XRtcPsu_ReadReg((InstancePtr)->RtcConfig.BaseAddr+XRTC_CALIB_RD_OFFSET) |
This macro returns the calibration value of RTC device. More... | |
#define | XRtcPsu_ReadCurrentTime(InstancePtr) XRtcPsu_ReadReg((InstancePtr)->RtcConfig.BaseAddr+XRTC_CUR_TIME_OFFSET) |
This macro returns the current time of RTC device. More... | |
#define | XRtcPsu_SetControlRegister(InstancePtr, Value) |
This macro sets the control register value of RTC device. More... | |
#define | XRtcPsu_GetSafetyCheck(InstancePtr) XRtcPsu_ReadReg((InstancePtr)->RtcConfig.BaseAddr+XRTC_SFTY_CHK_OFFSET) |
This macro returns the safety check register value of RTC device. More... | |
#define | XRtcPsu_SetSafetyCheck(InstancePtr, Value) |
This macro sets the safety check register value of RTC device. More... | |
#define | XRtcPsu_ResetAlarm(InstancePtr) |
This macro resets the alarm register. More... | |
#define | XRtcPsu_RoundOff(Number) (u32)(((Number) < (u32)0) ? ((Number) - (u32)0.5) : ((Number) + (u32)0.5)) |
This macro rounds off the given number. More... | |
#define | XRTC_BASEADDR 0xFFA60000U |
Xrtc Base Address. More... | |
#define | XRTC_SET_TIME_WR_OFFSET 0x00000000U |
Register: XrtcSetTimeWr. More... | |
#define | XRTC_SET_TIME_RD_OFFSET 0x00000004U |
Register: XrtcSetTimeRd. More... | |
#define | XRTC_CALIB_WR_OFFSET 0x00000008U |
Register: XrtcCalibWr. More... | |
#define | XRTC_CALIB_RD_OFFSET 0x0000000CU |
Register: XrtcCalibRd. More... | |
#define | XRTC_CUR_TIME_OFFSET 0x00000010U |
Register: XrtcCurTime. More... | |
#define | XRTC_CUR_TCK_OFFSET 0x00000014U |
Register: XrtcCurTck. More... | |
#define | XRTC_ALRM_OFFSET 0x00000018U |
Register: XrtcAlrm. More... | |
#define | XRTC_INT_STS_OFFSET 0x00000020U |
Register: XrtcIntSts. More... | |
#define | XRTC_INT_MSK_OFFSET 0x00000024U |
Register: XrtcIntMsk. More... | |
#define | XRTC_INT_EN_OFFSET 0x00000028U |
Register: XrtcIntEn. More... | |
#define | XRTC_INT_DIS_OFFSET 0x0000002CU |
Register: XrtcIntDis. More... | |
#define | XRTC_ADD_ERR_OFFSET 0x00000030U |
Register: XrtcAddErr. More... | |
#define | XRTC_ADD_ERR_INT_MSK_OFFSET 0x00000034U |
Register: XrtcAddErrIntMsk. More... | |
#define | XRTC_ADD_ERR_INT_EN_OFFSET 0x00000038U |
Register: XrtcAddErrIntEn. More... | |
#define | XRTC_ADD_ERR_INT_DIS_OFFSET 0x0000003CU |
Register: XrtcAddErrIntDis. More... | |
#define | XRTC_CTL_OFFSET 0x00000040U |
Register: XrtcCtl. More... | |
#define | XRTC_SFTY_CHK_OFFSET 0x00000050U |
Register: XrtcSftyChk. More... | |
#define | XRTC_ECO_OFFSET 0x00000060U |
Register: XrtcEco. More... | |
#define | XRtcPsu_ReadReg(RegisterAddr) Xil_In32(RegisterAddr) |
This macro reads the given register. More... | |
#define | XRtcPsu_WriteReg(RegisterAddr, Data) Xil_Out32(RegisterAddr, (u32)(Data)) |
This macro writes the given register. More... | |
Typedefs | |
typedef void(* | XRtcPsu_Handler) (void *CallBackRef, u32 Event) |
This data type defines a handler that an application defines to communicate with interrupt system to retrieve state information about an application. More... | |
Functions | |
void | XRtcPsu_SetTime (XRtcPsu *InstancePtr, u32 Time) |
This function sets the RTC time by writing into rtc write register. More... | |
u32 | XRtcPsu_GetCurrentTime (XRtcPsu *InstancePtr) |
This function gets the current RTC time. More... | |
void | XRtcPsu_SetAlarm (XRtcPsu *InstancePtr, u32 Alarm, u32 Periodic) |
This function sets the alarm value of RTC device. More... | |
void | XRtcPsu_SecToDateTime (u32 Seconds, XRtcPsu_DT *dt) |
This function translates time in seconds to a YEAR:MON:DAY HR:MIN:SEC format and saves it in the DT structure variable. More... | |
u32 | XRtcPsu_DateTimeToSec (XRtcPsu_DT *dt) |
This function translates time in YEAR:MON:DAY HR:MIN:SEC format to seconds. More... | |
void | XRtcPsu_CalculateCalibration (XRtcPsu *InstancePtr, u32 TimeReal, u32 CrystalOscFreq) |
This function calculates the calibration value depending on the actual realworld time and also helps in deriving new calibration value if the user wishes to change his oscillator frequency.TimeReal is generally the internet time with EPOCH time as reference i.e.,1/1/1970 1st second. More... | |
u32 | XRtcPsu_IsSecondsEventGenerated (XRtcPsu *InstancePtr) |
This function returns the seconds event status by reading interrupt status register. More... | |
u32 | XRtcPsu_IsAlarmEventGenerated (XRtcPsu *InstancePtr) |
This function returns the alarm event status by reading interrupt status register. More... | |
void | XRtcPsu_SetInterruptMask (XRtcPsu *InstancePtr, u32 Mask) |
This function sets the interrupt mask. More... | |
void | XRtcPsu_ClearInterruptMask (XRtcPsu *InstancePtr, u32 Mask) |
This function clears the interrupt mask. More... | |
void | XRtcPsu_InterruptHandler (XRtcPsu *InstancePtr) |
This function is the interrupt handler for the driver. More... | |
void | XRtcPsu_SetHandler (XRtcPsu *InstancePtr, XRtcPsu_Handler FuncPtr, void *CallBackRef) |
This function sets the handler that will be called when an event (interrupt) occurs that needs application's attention. More... | |
s32 | XRtcPsu_SelfTest (XRtcPsu *InstancePtr) |
This function runs a self-test on the driver and hardware device. More... | |
XRtcPsu_Config * | XRtcPsu_LookupConfig (u16 DeviceId) |
This function looks for the device configuration based on the unique device ID. More... | |
Variables | |
XRtcPsu_Config | XRtcPsu_ConfigTable [XPAR_XRTCPSU_NUM_INSTANCES] |
This table contains configuration information for RTC device in the system. More... | |
XRtcPsu_Config | XRtcPsu_ConfigTable [] |
This table contains configuration information for RTC device in the system. More... | |
Callback events | |
These constants specify the handler events that an application can handle using its specific handler function. Note that these constants are not bit mask, so only one event can be passed to an application at a time. | |
#define | XRTCPSU_EVENT_ALARM_GEN 1U |
Alarm generated event. More... | |
#define | XRTCPSU_EVENT_SECS_GEN 2U |
A new second generated event. More... | |
#define XRTC_ADD_ERR_INT_DIS_OFFSET 0x0000003CU |
#include <xrtcpsu_hw.h>
Register: XrtcAddErrIntDis.
#define XRTC_ADD_ERR_INT_EN_OFFSET 0x00000038U |
#include <xrtcpsu_hw.h>
Register: XrtcAddErrIntEn.
#define XRTC_ADD_ERR_INT_MSK_OFFSET 0x00000034U |
#include <xrtcpsu_hw.h>
Register: XrtcAddErrIntMsk.
#define XRTC_ADD_ERR_OFFSET 0x00000030U |
#include <xrtcpsu_hw.h>
Register: XrtcAddErr.
#define XRTC_ALRM_OFFSET 0x00000018U |
#define XRTC_BASEADDR 0xFFA60000U |
#include <xrtcpsu_hw.h>
Xrtc Base Address.
#define XRTC_CALIB_RD_OFFSET 0x0000000CU |
#include <xrtcpsu_hw.h>
Register: XrtcCalibRd.
#define XRTC_CALIB_WR_OFFSET 0x00000008U |
#define XRTC_CTL_OFFSET 0x00000040U |
#include <xrtcpsu_hw.h>
Register: XrtcCtl.
#define XRTC_CUR_TCK_OFFSET 0x00000014U |
#include <xrtcpsu_hw.h>
Register: XrtcCurTck.
#define XRTC_CUR_TIME_OFFSET 0x00000010U |
#include <xrtcpsu_hw.h>
Register: XrtcCurTime.
#define XRTC_ECO_OFFSET 0x00000060U |
#include <xrtcpsu_hw.h>
Register: XrtcEco.
#define XRTC_INT_DIS_OFFSET 0x0000002CU |
#define XRTC_INT_EN_OFFSET 0x00000028U |
#include <xrtcpsu_hw.h>
Register: XrtcIntEn.
#define XRTC_INT_MSK_OFFSET 0x00000024U |
#include <xrtcpsu_hw.h>
Register: XrtcIntMsk.
Referenced by XRtcPsu_GetCurrentTime(), and XRtcPsu_InterruptHandler().
#define XRTC_INT_STS_OFFSET 0x00000020U |
#include <xrtcpsu_hw.h>
Register: XrtcIntSts.
Referenced by XRtcPsu_InterruptHandler(), XRtcPsu_IsAlarmEventGenerated(), XRtcPsu_IsSecondsEventGenerated(), XRtcPsu_SetInterruptMask(), and XRtcPsu_SetTime().
#define XRTC_SET_TIME_RD_OFFSET 0x00000004U |
#include <xrtcpsu_hw.h>
Register: XrtcSetTimeRd.
#define XRTC_SET_TIME_WR_OFFSET 0x00000000U |
#include <xrtcpsu_hw.h>
Register: XrtcSetTimeWr.
#define XRTC_SFTY_CHK_OFFSET 0x00000050U |
#define XRTCPSU_CRYSTAL_OSC_EN (u32)1 << XRTC_CTL_OSC_SHIFT |
#include <xrtcpsu.h>
Separate Mask for Crystal oscillator bit Enable.
#define XRTCPSU_EVENT_ALARM_GEN 1U |
#define XRTCPSU_EVENT_SECS_GEN 2U |
#define XRtcPsu_GetCalibration | ( | InstancePtr | ) | XRtcPsu_ReadReg((InstancePtr)->RtcConfig.BaseAddr+XRTC_CALIB_RD_OFFSET) |
#include <xrtcpsu.h>
This macro returns the calibration value of RTC device.
InstancePtr | is a pointer to the XRtcPsu instance. |
Referenced by XRtcPsu_CalculateCalibration().
#define XRtcPsu_GetLastSetTime | ( | InstancePtr | ) | XRtcPsu_ReadReg((InstancePtr)->RtcConfig.BaseAddr + XRTC_SET_TIME_RD_OFFSET) |
#include <xrtcpsu.h>
This macro returns the last set time of RTC device.
Whenever a reset happens, the last set time will be zeroth day first sec.
InstancePtr | is a pointer to the XRtcPsu instance. |
Referenced by XRtcPsu_CalculateCalibration().
#define XRtcPsu_GetSafetyCheck | ( | InstancePtr | ) | XRtcPsu_ReadReg((InstancePtr)->RtcConfig.BaseAddr+XRTC_SFTY_CHK_OFFSET) |
#include <xrtcpsu.h>
This macro returns the safety check register value of RTC device.
InstancePtr | is a pointer to the XRtcPsu instance. |
#define XRtcPsu_ReadCurrentTime | ( | InstancePtr | ) | XRtcPsu_ReadReg((InstancePtr)->RtcConfig.BaseAddr+XRTC_CUR_TIME_OFFSET) |
#include <xrtcpsu.h>
This macro returns the current time of RTC device.
InstancePtr | is a pointer to the XRtcPsu instance. |
#define XRtcPsu_ReadReg | ( | RegisterAddr | ) | Xil_In32(RegisterAddr) |
#include <xrtcpsu_hw.h>
This macro reads the given register.
RegisterAddr | is the register address in the address space of the RTC device. |
Referenced by XRtcPsu_GetCurrentTime(), XRtcPsu_InterruptHandler(), XRtcPsu_IsAlarmEventGenerated(), and XRtcPsu_IsSecondsEventGenerated().
#define XRtcPsu_ResetAlarm | ( | InstancePtr | ) |
#include <xrtcpsu.h>
This macro resets the alarm register.
InstancePtr | is a pointer to the XRtcPsu instance. |
#define XRtcPsu_RoundOff | ( | Number | ) | (u32)(((Number) < (u32)0) ? ((Number) - (u32)0.5) : ((Number) + (u32)0.5)) |
#include <xrtcpsu.h>
This macro rounds off the given number.
Number | is the one that needs to be rounded off.. |
#define XRtcPsu_SetControlRegister | ( | InstancePtr, | |
Value | |||
) |
#include <xrtcpsu.h>
This macro sets the control register value of RTC device.
InstancePtr | is a pointer to the XRtcPsu instance. |
Value | is the desired control register value for RTC. |
#define XRtcPsu_SetSafetyCheck | ( | InstancePtr, | |
Value | |||
) |
#include <xrtcpsu.h>
This macro sets the safety check register value of RTC device.
InstancePtr | is a pointer to the XRtcPsu instance. |
Value | is a safety check value to be written in register. |
#define XRtcPsu_WriteReg | ( | RegisterAddr, | |
Data | |||
) | Xil_Out32(RegisterAddr, (u32)(Data)) |
#include <xrtcpsu_hw.h>
This macro writes the given register.
RegisterAddr | is the register address in the address space of the RTC device. |
Data | is the 32-bit value to write to the register. |
Referenced by XRtcPsu_ClearInterruptMask(), XRtcPsu_InterruptHandler(), XRtcPsu_SelfTest(), XRtcPsu_SetAlarm(), XRtcPsu_SetInterruptMask(), and XRtcPsu_SetTime().
#define XRtcPsu_WriteSetTime | ( | InstancePtr, | |
Time | |||
) |
#include <xrtcpsu.h>
This macro updates the current time of RTC device.
InstancePtr | is a pointer to the XRtcPsu instance. |
Time | is the desired time for RTC in seconds. |
typedef void(* XRtcPsu_Handler) (void *CallBackRef, u32 Event) |
#include <xrtcpsu.h>
This data type defines a handler that an application defines to communicate with interrupt system to retrieve state information about an application.
CallBackRef | is a callback reference passed in by the upper layer when setting the handler, and is passed back to the upper layer when the handler is called. It is used to find the device driver instance. |
Event | contains one of the event constants indicating events that have occurred. |
EventData | contains the number of bytes sent or received at the time of the call for send and receive events and contains the modem status for modem events. |
void XRtcPsu_CalculateCalibration | ( | XRtcPsu * | InstancePtr, |
u32 | TimeReal, | ||
u32 | CrystalOscFreq | ||
) |
#include <xrtcpsu.c>
This function calculates the calibration value depending on the actual realworld time and also helps in deriving new calibration value if the user wishes to change his oscillator frequency.TimeReal is generally the internet time with EPOCH time as reference i.e.,1/1/1970 1st second.
But this RTC driver assumes start time from 1/1/2000 1st second. Hence,if the user maps the internet time InternetTimeInSecs, then he has to use XRtcPsu_SecToDateTime(InternetTimeInSecs,&InternetTime), TimeReal = XRtcPsu_DateTimeToSec(InternetTime) consecutively to arrive at TimeReal value.
InstancePtr | is a pointer to the XRtcPsu instance. |
TimeReal | is the actual realworld time generally an network time / Internet time in seconds. |
CrystalOscFreq | is the Oscillator new frequency. Say, If the user is going with the typical 32768Hz, then he inputs the same frequency value. |
References XRtcPsu_GetCalibration, XRtcPsu_GetCurrentTime(), and XRtcPsu_GetLastSetTime.
void XRtcPsu_ClearInterruptMask | ( | XRtcPsu * | InstancePtr, |
u32 | Mask | ||
) |
#include <xrtcpsu.h>
This function clears the interrupt mask.
InstancePtr | is a pointer to the XRtcPsu instance |
Mask | contains the interrupts to be disabled. A '1' enables an interrupt, and a '0' disables. |
References XRtcPsu_Config::BaseAddr, XRtcPsu::RtcConfig, XRTC_INT_DIS_OFFSET, and XRtcPsu_WriteReg.
u32 XRtcPsu_DateTimeToSec | ( | XRtcPsu_DT * | dt | ) |
#include <xrtcpsu.c>
This function translates time in YEAR:MON:DAY HR:MIN:SEC format to seconds.
dt | is a pointer to a DatetTime format structure variable of time that has to be shown in seconds. |
u32 XRtcPsu_GetCurrentTime | ( | XRtcPsu * | InstancePtr | ) |
#include <xrtcpsu.c>
This function gets the current RTC time.
InstancePtr | is a pointer to the XRtcPsu instance. |
References XRtcPsu_Config::BaseAddr, XRtcPsu::RtcConfig, XRTC_INT_MSK_OFFSET, and XRtcPsu_ReadReg.
Referenced by XRtcPsu_CalculateCalibration(), and XRtcPsu_SetAlarm().
void XRtcPsu_InterruptHandler | ( | XRtcPsu * | InstancePtr | ) |
#include <xrtcpsu.h>
This function is the interrupt handler for the driver.
It must be connected to an interrupt system by the application such that it can be called when an interrupt occurs.
InstancePtr | contains a pointer to the driver instance |
References XRtcPsu_Config::BaseAddr, XRtcPsu::IsReady, XRtcPsu::RtcConfig, XRTC_INT_MSK_OFFSET, XRTC_INT_STS_OFFSET, XRtcPsu_ReadReg, and XRtcPsu_WriteReg.
u32 XRtcPsu_IsAlarmEventGenerated | ( | XRtcPsu * | InstancePtr | ) |
#include <xrtcpsu.c>
This function returns the alarm event status by reading interrupt status register.
InstancePtr | is a pointer to the XRtcPsu instance. |
References XRtcPsu_Config::BaseAddr, XRtcPsu::RtcConfig, XRTC_INT_STS_OFFSET, and XRtcPsu_ReadReg.
u32 XRtcPsu_IsSecondsEventGenerated | ( | XRtcPsu * | InstancePtr | ) |
#include <xrtcpsu.c>
This function returns the seconds event status by reading interrupt status register.
InstancePtr | is a pointer to the XRtcPsu instance. |
References XRtcPsu_Config::BaseAddr, XRtcPsu::RtcConfig, XRTC_INT_STS_OFFSET, and XRtcPsu_ReadReg.
XRtcPsu_Config * XRtcPsu_LookupConfig | ( | u16 | DeviceId | ) |
#include <xrtcpsu.h>
This function looks for the device configuration based on the unique device ID.
The table XRtcPsu_ConfigTable[] contains the configuration information for each device in the system.
DeviceId | is the unique device ID of the device being looked up. |
Referenced by RtcPsuSetCalibrationExample(), and RtcPsuSetTimeExample().
void XRtcPsu_SecToDateTime | ( | u32 | Seconds, |
XRtcPsu_DT * | dt | ||
) |
#include <xrtcpsu.c>
This function translates time in seconds to a YEAR:MON:DAY HR:MIN:SEC format and saves it in the DT structure variable.
It also reports the weekday.
Seconds | is the time value that has to be shown in DateTime format. |
dt | is the DateTime format variable that stores the translated time. |
s32 XRtcPsu_SelfTest | ( | XRtcPsu * | InstancePtr | ) |
#include <xrtcpsu.h>
This function runs a self-test on the driver and hardware device.
This self test writes reset value into safety check register and read backs the same. If mismatch offers, returns the failure.
InstancePtr | is a pointer to the XRtcPsu instance |
This function can hang if the hardware is not functioning properly.
References XRtcPsu_Config::BaseAddr, XRtcPsu::IsReady, XRtcPsu::RtcConfig, XRTC_SFTY_CHK_OFFSET, and XRtcPsu_WriteReg.
void XRtcPsu_SetAlarm | ( | XRtcPsu * | InstancePtr, |
u32 | Alarm, | ||
u32 | Periodic | ||
) |
#include <xrtcpsu.c>
This function sets the alarm value of RTC device.
InstancePtr | is a pointer to the XRtcPsu instance |
Alarm | is the desired alarm time for RTC. |
Periodic | says whether the alarm need to set at periodic Intervals or a one-time alarm. |
References XRtcPsu_Config::BaseAddr, XRtcPsu::IsReady, XRtcPsu::RtcConfig, XRTC_ALRM_OFFSET, XRtcPsu_GetCurrentTime(), and XRtcPsu_WriteReg.
void XRtcPsu_SetHandler | ( | XRtcPsu * | InstancePtr, |
XRtcPsu_Handler | FuncPtr, | ||
void * | CallBackRef | ||
) |
#include <xrtcpsu.h>
This function sets the handler that will be called when an event (interrupt) occurs that needs application's attention.
InstancePtr | is a pointer to the XRtcPsu instance |
FuncPtr | is the pointer to the callback function. |
CallBackRef | is the upper layer callback reference passed back when the callback function is invoked. |
There is no assert on the CallBackRef since the driver doesn't know what it is (nor should it)
References XRtcPsu::CallBackRef, and XRtcPsu::IsReady.
void XRtcPsu_SetInterruptMask | ( | XRtcPsu * | InstancePtr, |
u32 | Mask | ||
) |
#include <xrtcpsu.h>
This function sets the interrupt mask.
InstancePtr | is a pointer to the XRtcPsu instance |
Mask | contains the interrupts to be enabled. A '1' enables an interupt, and a '0' disables. |
References XRtcPsu_Config::BaseAddr, XRtcPsu::RtcConfig, XRTC_INT_STS_OFFSET, and XRtcPsu_WriteReg.
void XRtcPsu_SetTime | ( | XRtcPsu * | InstancePtr, |
u32 | Time | ||
) |
#include <xrtcpsu.c>
This function sets the RTC time by writing into rtc write register.
InstancePtr | is a pointer to the XRtcPsu instance. |
Time | that should be updated into RTC write register. |
References XRtcPsu_Config::BaseAddr, XRtcPsu::RtcConfig, XRTC_CALIB_WR_OFFSET, XRTC_INT_STS_OFFSET, and XRtcPsu_WriteReg.
XRtcPsu_Config XRtcPsu_ConfigTable[] |
#include <xrtcpsu_sinit.c>
This table contains configuration information for RTC device in the system.
XRtcPsu_Config XRtcPsu_ConfigTable[XPAR_XRTCPSU_NUM_INSTANCES] |
#include <xrtcpsu_g.c>
This table contains configuration information for RTC device in the system.