| rtcpsu Vitis Drivers API Documentation

- Overview
- Data Structures
- APIs
- File List
- Examples

Data Structures | Macros | Typedefs | Functions | Variables
Overview

## 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 | XRTC_H_
| < prevent circular inclusions More...
#define | XRTCPSU_CRYSTAL_OSC_EN ((u32)1 << XRTC_CTL_OSC_SHIFT)
| Separate Mask for Crystal oscillator bit Enable. More...
#define | XRTC_CALIBRATION_VALUE 0x7FFFU
| Calibration value. More...
#define | XRTC_TYPICAL_OSC_FREQ 32768U
| Oscillator frequency. More...
#define | XRtcPsu_WriteSetTime(InstancePtr, Time)
| This macro updates the current time of RTC device. More...
#define | XRtcPsu_GetLastSetTime(InstancePtr)
| 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)
| This macro rounds off the given number. More...
#define | XRTC_HW_H_
| < prevent circular inclusions More...
#define | XRTC_BASEADDR 0xFFA60000U
| Xrtc Base Address. 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
s32 | XRtcPsu_CfgInitialize (XRtcPsu *InstancePtr, XRtcPsu_Config *ConfigPtr, UINTPTR EffectiveAddr)
| This function initializes a XRtcPsu instance/driver. More...
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 FunctionPtr, 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 []
| This table contains configuration information for RTC device in the system. More...
XRtcPsu_Config | XRtcPsu_ConfigTable [XPAR_XRTCPSU_NUM_INSTANCES]
| 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...

## Set Timer Register
This register contains bits for configuring Current time.
#define | XRTC_SET_TIME_WR_OFFSET 0x00000000U
| Register: XrtcSetTimeWr. More...
#define | XRTC_SET_TIME_WR_RSTVAL 0x00000000U
#define | XRTC_SET_TIME_WR_VAL_SHIFT 0U
#define | XRTC_SET_TIME_WR_VAL_WIDTH 32U
#define | XRTC_SET_TIME_WR_VAL_MASK 0xffffffffU
#define | XRTC_SET_TIME_WR_VAL_DEFVAL 0x0U
#define | XRTC_SET_TIME_RD_OFFSET 0x00000004U
| Register: XrtcSetTimeRd. More...
#define | XRTC_SET_TIME_RD_RSTVAL 0x00000000U
#define | XRTC_SET_TIME_RD_VAL_SHIFT 0U
#define | XRTC_SET_TIME_RD_VAL_WIDTH 32U
#define | XRTC_SET_TIME_RD_VAL_MASK 0xffffffffU
#define | XRTC_SET_TIME_RD_VAL_DEFVAL 0x0U

## Calibration Register
This register contains bits for configuring Calibration values.
#define | XRTC_CALIB_WR_OFFSET 0x00000008U
| Register: XrtcCalibWr. More...
#define | XRTC_CALIB_WR_RSTVAL 0x00000000U
#define | XRTC_CALIB_WR_FRACTN_EN_SHIFT 20U
#define | XRTC_CALIB_WR_FRACTN_EN_WIDTH 1U
#define | XRTC_CALIB_WR_FRACTN_EN_MASK 0x00100000U
#define | XRTC_CALIB_WR_FRACTN_EN_DEFVAL 0x0U
#define | XRTC_CALIB_WR_FRACTN_DATA_SHIFT 16U
#define | XRTC_CALIB_WR_FRACTN_DATA_WIDTH 4U
#define | XRTC_CALIB_WR_FRACTN_DATA_MASK 0x000f0000U
#define | XRTC_CALIB_WR_FRACTN_DATA_DEFVAL 0x0U
#define | XRTC_CALIB_WR_MAX_TCK_SHIFT 0U
#define | XRTC_CALIB_WR_MAX_TCK_WIDTH 16U
#define | XRTC_CALIB_WR_MAX_TCK_MASK 0x0000ffffU
#define | XRTC_CALIB_WR_MAX_TCK_DEFVAL 0x0U
#define | XRTC_CALIB_RD_OFFSET 0x0000000CU
| Register: XrtcCalibRd. More...
#define | XRTC_CALIB_RD_RSTVAL 0x00000000U
#define | XRTC_CALIB_RD_FRACTN_EN_SHIFT 20U
#define | XRTC_CALIB_RD_FRACTN_EN_WIDTH 1U
#define | XRTC_CALIB_RD_FRACTN_EN_MASK 0x00100000U
#define | XRTC_CALIB_RD_FRACTN_EN_DEFVAL 0x0U
#define | XRTC_CALIB_RD_FRACTN_DATA_SHIFT 16U
#define | XRTC_CALIB_RD_FRACTN_DATA_WIDTH 4U
#define | XRTC_CALIB_RD_FRACTN_DATA_MASK 0x000f0000U
#define | XRTC_CALIB_RD_FRACTN_DATA_DEFVAL 0x0U
#define | XRTC_CALIB_RD_MAX_TCK_SHIFT 0U
#define | XRTC_CALIB_RD_MAX_TCK_WIDTH 16U
#define | XRTC_CALIB_RD_MAX_TCK_MASK 0x0000ffffU
#define | XRTC_CALIB_RD_MAX_TCK_DEFVAL 0x0U

## Current time Register
This register contains bits for configuring Current time.
#define | XRTC_CUR_TIME_OFFSET 0x00000010U
| Register: XrtcCurTime. More...
#define | XRTC_CUR_TIME_RSTVAL 0x00000000U
#define | XRTC_CUR_TIME_VAL_SHIFT 0U
#define | XRTC_CUR_TIME_VAL_WIDTH 32U
#define | XRTC_CUR_TIME_VAL_MASK 0xffffffffU
#define | XRTC_CUR_TIME_VAL_DEFVAL 0x0U
#define | XRTC_CUR_TCK_OFFSET 0x00000014U
| Register: XrtcCurTck. More...
#define | XRTC_CUR_TCK_RSTVAL 0x00000000U
#define | XRTC_CUR_TCK_VAL_SHIFT 0U
#define | XRTC_CUR_TCK_VAL_WIDTH 16U
#define | XRTC_CUR_TCK_VAL_MASK 0x0000ffffU
#define | XRTC_CUR_TCK_VAL_DEFVAL 0x0U

## Alarm Register
This register contains bits for configuring Alarm.
#define | XRTC_ALRM_OFFSET 0x00000018U
| Register: XrtcAlrm. More...
#define | XRTC_ALRM_RSTVAL 0x00000000U
#define | XRTC_ALRM_VAL_SHIFT 0U
#define | XRTC_ALRM_VAL_WIDTH 32U
#define | XRTC_ALRM_VAL_MASK 0xffffffffU
#define | XRTC_ALRM_VAL_DEFVAL 0x0U

## Interrupt Status Register
This register contains bits for configuring Interrupt.
#define | XRTC_INT_STS_OFFSET 0x00000020U
| Register: XrtcIntSts. More...
#define | XRTC_INT_STS_RSTVAL 0x00000000U
#define | XRTC_INT_STS_ALRM_SHIFT 1U
#define | XRTC_INT_STS_ALRM_WIDTH 1U
#define | XRTC_INT_STS_ALRM_MASK 0x00000002U
#define | XRTC_INT_STS_ALRM_DEFVAL 0x0U
#define | XRTC_INT_STS_SECS_SHIFT 0U
#define | XRTC_INT_STS_SECS_WIDTH 1U
#define | XRTC_INT_STS_SECS_MASK 0x00000001U
#define | XRTC_INT_STS_SECS_DEFVAL 0x0U
#define | XRTC_INT_MSK_OFFSET 0x00000024U
| Register: XrtcIntMsk. More...
#define | XRTC_INT_MSK_RSTVAL 0x00000003U
#define | XRTC_INT_MSK_ALRM_SHIFT 1U
#define | XRTC_INT_MSK_ALRM_WIDTH 1U
#define | XRTC_INT_MSK_ALRM_MASK 0x00000002U
#define | XRTC_INT_MSK_ALRM_DEFVAL 0x1U
#define | XRTC_INT_MSK_SECS_SHIFT 0U
#define | XRTC_INT_MSK_SECS_WIDTH 1U
#define | XRTC_INT_MSK_SECS_MASK 0x00000001U
#define | XRTC_INT_MSK_SECS_DEFVAL 0x1U
#define | XRTC_INT_EN_OFFSET 0x00000028U
| Register: XrtcIntEn. More...
#define | XRTC_INT_EN_RSTVAL 0x00000000U
#define | XRTC_INT_EN_ALRM_SHIFT 1U
#define | XRTC_INT_EN_ALRM_WIDTH 1U
#define | XRTC_INT_EN_ALRM_MASK 0x00000002U
#define | XRTC_INT_EN_ALRM_DEFVAL 0x0U
#define | XRTC_INT_EN_SECS_SHIFT 0U
#define | XRTC_INT_EN_SECS_WIDTH 1U
#define | XRTC_INT_EN_SECS_MASK 0x00000001U
#define | XRTC_INT_EN_SECS_DEFVAL 0x0U
#define | XRTC_INT_DIS_OFFSET 0x0000002CU
| Register: XrtcIntDis. More...
#define | XRTC_INT_DIS_RSTVAL 0x00000000U
#define | XRTC_INT_DIS_ALRM_SHIFT 1U
#define | XRTC_INT_DIS_ALRM_WIDTH 1U
#define | XRTC_INT_DIS_ALRM_MASK 0x00000002U
#define | XRTC_INT_DIS_ALRM_DEFVAL 0x0U
#define | XRTC_INT_DIS_SECS_SHIFT 0U
#define | XRTC_INT_DIS_SECS_WIDTH 1U
#define | XRTC_INT_DIS_SECS_MASK 0x00000001U
#define | XRTC_INT_DIS_SECS_DEFVAL 0x0U
#define | XRTC_ADD_ERR_OFFSET 0x00000030U
| Register: XrtcAddErr. More...
#define | XRTC_ADD_ERR_RSTVAL 0x00000000U
#define | XRTC_ADD_ERR_STS_SHIFT 0U
#define | XRTC_ADD_ERR_STS_WIDTH 1U
#define | XRTC_ADD_ERR_STS_MASK 0x00000001U
#define | XRTC_ADD_ERR_STS_DEFVAL 0x0U
#define | XRTC_ADD_ERR_INT_MSK_OFFSET 0x00000034U
| Register: XrtcAddErrIntMsk. More...
#define | XRTC_ADD_ERR_INT_MSK_RSTVAL 0x00000001U
#define | XRTC_ADD_ERR_INT_MSK_SHIFT 0U
#define | XRTC_ADD_ERR_INT_MSK_WIDTH 1U
#define | XRTC_ADD_ERR_INT_MSK_MASK 0x00000001U
#define | XRTC_ADD_ERR_INT_MSK_DEFVAL 0x1U
#define | XRTC_ADD_ERR_INT_EN_OFFSET 0x00000038U
| Register: XrtcAddErrIntEn. More...
#define | XRTC_ADD_ERR_INT_EN_RSTVAL 0x00000000U
#define | XRTC_ADD_ERR_INT_EN_MSK_SHIFT 0U
#define | XRTC_ADD_ERR_INT_EN_MSK_WIDTH 1U
#define | XRTC_ADD_ERR_INT_EN_MSK_MASK 0x00000001U
#define | XRTC_ADD_ERR_INT_EN_MSK_DEFVAL 0x0U
#define | XRTC_ADD_ERR_INT_DIS_OFFSET 0x0000003CU
| Register: XrtcAddErrIntDis. More...
#define | XRTC_ADD_ERR_INT_DIS_RSTVAL 0x00000000U
#define | XRTC_ADD_ERR_INT_DIS_MSK_SHIFT 0U
#define | XRTC_ADD_ERR_INT_DIS_MSK_WIDTH 1U
#define | XRTC_ADD_ERR_INT_DIS_MSK_MASK 0x00000001U
#define | XRTC_ADD_ERR_INT_DIS_MSK_DEFVAL 0x0U

## Control Register
This register contains bits for control register.
#define | XRTC_CTL_OFFSET 0x00000040U
| Register: XrtcCtl. More...
#define | XRTC_CTL_RSTVAL 0x01000000U
#define | XRTC_CTL_BATTERY_EN_SHIFT 31U
#define | XRTC_CTL_BATTERY_EN_WIDTH 1U
#define | XRTC_CTL_BATTERY_EN_MASK 0x80000000U
#define | XRTC_CTL_BATTERY_EN_DEFVAL 0x0U
#define | XRTC_CTL_OSC_SHIFT 24U
#define | XRTC_CTL_OSC_WIDTH 4U
#define | XRTC_CTL_OSC_MASK 0x0f000000U
#define | XRTC_CTL_OSC_DEFVAL 0x1U
#define | XRTC_CTL_SLVERR_EN_SHIFT 0U
#define | XRTC_CTL_SLVERR_EN_WIDTH 1U
#define | XRTC_CTL_SLVERR_EN_MASK 0x00000001U
#define | XRTC_CTL_SLVERR_EN_DEFVAL 0x0U

## Safety Check Register
This register contains bits for configuring safety check.
#define | XRTC_SFTY_CHK_OFFSET 0x00000050U
| Register: XrtcSftyChk. More...
#define | XRTC_SFTY_CHK_RSTVAL 0x00000000U
#define | XRTC_SFTY_CHK_REG_SHIFT 0U
#define | XRTC_SFTY_CHK_REG_WIDTH 32U
#define | XRTC_SFTY_CHK_REG_MASK 0xffffffffU
#define | XRTC_SFTY_CHK_REG_DEFVAL 0x0U
#define | XRTC_ECO_OFFSET 0x00000060U
| Register: XrtcEco. More...
#define | XRTC_ECO_RSTVAL 0x00000000U
#define | XRTC_ECO_REG_SHIFT 0U
#define | XRTC_ECO_REG_WIDTH 32U
#define | XRTC_ECO_REG_MASK 0xffffffffU
#define | XRTC_ECO_REG_DEFVAL 0x0U

## Macro Definition Documentation

#define XRTC_ADD_ERR_INT_DIS_OFFSET 0x0000003CU

Register: XrtcAddErrIntDis.

#define XRTC_ADD_ERR_INT_EN_OFFSET 0x00000038U

Register: XrtcAddErrIntEn.

#define XRTC_ADD_ERR_INT_MSK_OFFSET 0x00000034U

Register: XrtcAddErrIntMsk.

#define XRTC_ADD_ERR_OFFSET 0x00000030U

Register: XrtcAddErr.

#define XRTC_ALRM_OFFSET 0x00000018U

Register: XrtcAlrm.

Referenced by XRtcPsu_SetAlarm().

#define XRTC_BASEADDR 0xFFA60000U

Xrtc Base Address.

#define XRTC_CALIB_RD_OFFSET 0x0000000CU

Register: XrtcCalibRd.

#define XRTC_CALIB_WR_OFFSET 0x00000008U

Register: XrtcCalibWr.

Referenced by XRtcPsu_CfgInitialize(), and XRtcPsu_SetTime().

#define XRTC_CALIBRATION_VALUE 0x7FFFU

Calibration value.

Referenced by XRtcPsu_CfgInitialize().

#define XRTC_CTL_OFFSET 0x00000040U

Register: XrtcCtl.

Referenced by XRtcPsu_CfgInitialize().

#define XRTC_CUR_TCK_OFFSET 0x00000014U

Register: XrtcCurTck.

#define XRTC_CUR_TIME_OFFSET 0x00000010U

Register: XrtcCurTime.

#define XRTC_ECO_OFFSET 0x00000060U

Register: XrtcEco.

#define XRTC_H_

< prevent circular inclusions

by using protection macros

#define XRTC_HW_H_

< prevent circular inclusions

by using protection macros

#define XRTC_INT_DIS_OFFSET 0x0000002CU

Register: XrtcIntDis.

Referenced by XRtcPsu_CfgInitialize(), and XRtcPsu_ClearInterruptMask().

#define XRTC_INT_EN_OFFSET 0x00000028U

Register: XrtcIntEn.

Referenced by XRtcPsu_SetInterruptMask().

#define XRTC_INT_MSK_OFFSET 0x00000024U

Register: XrtcIntMsk.

Referenced by XRtcPsu_GetCurrentTime(), and XRtcPsu_InterruptHandler().

#define XRTC_INT_STS_OFFSET 0x00000020U

Register: XrtcIntSts.

Referenced by XRtcPsu_CfgInitialize(), XRtcPsu_GetCurrentTime(), XRtcPsu_InterruptHandler(), XRtcPsu_IsAlarmEventGenerated(), XRtcPsu_IsSecondsEventGenerated(), XRtcPsu_SetInterruptMask(), and XRtcPsu_SetTime().

#define XRTC_SET_TIME_RD_OFFSET 0x00000004U

Register: XrtcSetTimeRd.

#define XRTC_SET_TIME_WR_OFFSET 0x00000000U

Register: XrtcSetTimeWr.

#define XRTC_SFTY_CHK_OFFSET 0x00000050U

Register: XrtcSftyChk.

Referenced by XRtcPsu_SelfTest().

#define XRTC_TYPICAL_OSC_FREQ 32768U

Oscillator frequency.

Referenced by XRtcPsu_CfgInitialize().

#define XRTCPSU_CRYSTAL_OSC_EN ((u32)1 << XRTC_CTL_OSC_SHIFT)

Separate Mask for Crystal oscillator bit Enable.

Referenced by XRtcPsu_CfgInitialize().

#define XRTCPSU_EVENT_ALARM_GEN 1U

Alarm generated event.

Referenced by Handler(), and XRtcPsu_InterruptHandler().

#define XRTCPSU_EVENT_SECS_GEN 2U

A new second generated event.

Referenced by XRtcPsu_InterruptHandler().

#define XRtcPsu_GetCalibration | ( |  | InstancePtr | ) | XRtcPsu_ReadReg((InstancePtr)->RtcConfig.BaseAddr+XRTC_CALIB_RD_OFFSET)

This macro returns the calibration value of RTC device.

Parameters

  InstancePtr | is a pointer to the XRtcPsu instance.

Returns
  Calibration value for RTC.

Note
  C-Style signature: u32 XRtcPsu_GetCalibration(XRtcPsu *InstancePtr)

Referenced by XRtcPsu_CalculateCalibration().

#define XRtcPsu_GetLastSetTime | ( |  | InstancePtr | ) |

Value:
XRtcPsu_ReadReg((InstancePtr)->RtcConfig.BaseAddr + \
XRTC_SET_TIME_RD_OFFSET)
XRTC_SET_TIME_RD_OFFSET
#define XRTC_SET_TIME_RD_OFFSET
Register: XrtcSetTimeRd.
Definition: xrtcpsu_hw.h:70
XRtcPsu_ReadReg
#define XRtcPsu_ReadReg(RegisterAddr)
This macro reads the given register.
Definition: xrtcpsu_hw.h:361

This macro returns the last set time of RTC device.

Whenever a reset happens, the last set time will be zeroth day first sec.

Parameters

  InstancePtr | is a pointer to the XRtcPsu instance.

Returns
  The last set time in seconds.

Note
  C-Style signature: u32 XRtcPsu_GetLastSetTime(XRtcPsu *InstancePtr)

Referenced by RtcPsuSetTimeExample(), XRtcPsu_CalculateCalibration(), and XRtcPsu_GetCurrentTime().

#define XRtcPsu_GetSafetyCheck | ( |  | InstancePtr | ) | XRtcPsu_ReadReg((InstancePtr)->RtcConfig.BaseAddr+XRTC_SFTY_CHK_OFFSET)

This macro returns the safety check register value of RTC device.

Parameters

  InstancePtr | is a pointer to the XRtcPsu instance.

Returns
  Safety check register value.

Note
  C-Style signature: u32 XRtcPsu_GetSafetyCheck(XRtcPsu *InstancePtr)

#define XRtcPsu_ReadCurrentTime | ( |  | InstancePtr | ) | XRtcPsu_ReadReg((InstancePtr)->RtcConfig.BaseAddr+XRTC_CUR_TIME_OFFSET)

This macro returns the current time of RTC device.

Parameters

  InstancePtr | is a pointer to the XRtcPsu instance.

Returns
  Current Time. This current time will be in seconds.

Note
  C-Style signature: u32 XRtcPsu_ReadCurrentTime(XRtcPsu *InstancePtr)

Referenced by XRtcPsu_GetCurrentTime().

#define XRtcPsu_ReadReg | ( |  | RegisterAddr | ) | Xil_In32(RegisterAddr)

This macro reads the given register.

Parameters

  RegisterAddr | is the register address in the address space of the RTC device.

Returns
  The 32-bit value of the register

Note
  None.

Referenced by XRtcPsu_CfgInitialize(), XRtcPsu_GetCurrentTime(), XRtcPsu_InterruptHandler(), XRtcPsu_IsAlarmEventGenerated(), XRtcPsu_IsSecondsEventGenerated(), and XRtcPsu_SelfTest().

#define XRtcPsu_ResetAlarm | ( |  | InstancePtr | ) |

Value:
XRtcPsu_WriteReg((InstancePtr)->RtcConfig.BaseAddr + \
XRTC_ALRM_OFFSET, XRTC_ALRM_RSTVAL)
XRTC_ALRM_OFFSET
#define XRTC_ALRM_OFFSET
Register: XrtcAlrm.
Definition: xrtcpsu_hw.h:166
XRtcPsu_WriteReg
#define XRtcPsu_WriteReg(RegisterAddr, Data)
This macro writes the given register.
Definition: xrtcpsu_hw.h:377

This macro resets the alarm register.

Parameters

  InstancePtr | is a pointer to the XRtcPsu instance.

Returns
  None.

Note
  C-Style signature: u32 XRtcPsu_ResetAlarm(XRtcPsu *InstancePtr)

Referenced by RtcPsuPeriodicAlarmIntrExample().

#define XRtcPsu_RoundOff | ( |  | Number | ) |

Value:
(u32)(((Number) < (float)0) ? ((Number) - (float)0.5) : \
((Number) + (float)0.5))

This macro rounds off the given number.

Parameters

  Number | is the one that needs to be rounded off..

Returns
  The rounded off value of the input number.

Note
  C-Style signature: u32 XRtcPsu_RoundOff(float Number)

Referenced by XRtcPsu_CalculateCalibration().

#define XRtcPsu_SetControlRegister | ( |  | InstancePtr,
|  |  | Value
| ) |  |

Value:
XRtcPsu_WriteReg((InstancePtr)->RtcConfig.BaseAddr + \
XRTC_CTL_OFFSET, (Value))
XRtcPsu_WriteReg
#define XRtcPsu_WriteReg(RegisterAddr, Data)
This macro writes the given register.
Definition: xrtcpsu_hw.h:377
XRTC_CTL_OFFSET
#define XRTC_CTL_OFFSET
Register: XrtcCtl.
Definition: xrtcpsu_hw.h:298

This macro sets the control register value of RTC device.

Parameters

  InstancePtr | is a pointer to the XRtcPsu instance.
  Value | is the desired control register value for RTC.

Returns
  None.

Note
  C-Style signature: void XRtcPsu_SetControlRegister(XRtcPsu *InstancePtr, u32 Value)

#define XRtcPsu_SetSafetyCheck | ( |  | InstancePtr,
|  |  | Value
| ) |  |

Value:
XRtcPsu_WriteReg((InstancePtr)->RtcConfig.BaseAddr + \
XRTC_SFTY_CHK_OFFSET, (Value))
XRTC_SFTY_CHK_OFFSET
#define XRTC_SFTY_CHK_OFFSET
Register: XrtcSftyChk.
Definition: xrtcpsu_hw.h:326
XRtcPsu_WriteReg
#define XRtcPsu_WriteReg(RegisterAddr, Data)
This macro writes the given register.
Definition: xrtcpsu_hw.h:377

This macro sets the safety check register value of RTC device.

Parameters

  InstancePtr | is a pointer to the XRtcPsu instance.
  Value | is a safety check value to be written in register.

Returns
  None.

Note
  C-Style signature: void XRtcPsu_SetSafetyCheck(XRtcPsu *InstancePtr, u32 Value)

#define XRtcPsu_WriteReg | ( |  | RegisterAddr,
|  |  | Data
| ) |  | Xil_Out32(RegisterAddr, (u32)(Data))

This macro writes the given register.

Parameters

  RegisterAddr | is the register address in the address space of the RTC device.
  Data | is the 32-bit value to write to the register.

Returns
  None.

Note
  None.

Referenced by XRtcPsu_CfgInitialize(), XRtcPsu_ClearInterruptMask(), XRtcPsu_InterruptHandler(), XRtcPsu_IsAlarmEventGenerated(), XRtcPsu_IsSecondsEventGenerated(), XRtcPsu_SelfTest(), XRtcPsu_SetAlarm(), XRtcPsu_SetInterruptMask(), and XRtcPsu_SetTime().

#define XRtcPsu_WriteSetTime | ( |  | InstancePtr,
|  |  | Time
| ) |  |

Value:
XRtcPsu_WriteReg(((InstancePtr)->RtcConfig.BaseAddr + \
XRTC_SET_TIME_WR_OFFSET), (Time))
XRTC_SET_TIME_WR_OFFSET
#define XRTC_SET_TIME_WR_OFFSET
Register: XrtcSetTimeWr.
Definition: xrtcpsu_hw.h:59
XRtcPsu_WriteReg
#define XRtcPsu_WriteReg(RegisterAddr, Data)
This macro writes the given register.
Definition: xrtcpsu_hw.h:377

This macro updates the current time of RTC device.

Parameters

  InstancePtr | is a pointer to the XRtcPsu instance.
  Time | is the desired time for RTC in seconds.

Returns
  None.

Note
  C-Style signature: void XRtcPsu_SetTime(XRtcPsu *InstancePtr, u32 Time)

Referenced by XRtcPsu_SetTime().

## Typedef Documentation

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.

Parameters

  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.

## Function Documentation

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.

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.

Parameters

  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.

Returns
  None.

Note
  After Calculating the calibration register, user / application has to call again CfgInitialize API to bring the new calibration into effect.

References XRtcPsu::CalibrationValue, XRtcPsu::OscillatorFreq, XRtcPsu_GetCalibration, XRtcPsu_GetCurrentTime(), XRtcPsu_GetLastSetTime, and XRtcPsu_RoundOff.

Referenced by RtcPsuSetCalibrationExample().

s32 XRtcPsu_CfgInitialize | ( | XRtcPsu * | InstancePtr,
|  | XRtcPsu_Config * | ConfigPtr,
|  | UINTPTR | EffectiveAddr
| ) |  |

This function initializes a XRtcPsu instance/driver.

The initialization entails:

- Initialize all members of the XRtcPsu structure.

Parameters

  InstancePtr | is a pointer to the XRtcPsu instance.
  ConfigPtr | points to the XRtcPsu device configuration structure.
  EffectiveAddr | is the device base address in the virtual memory address space. If the address translation is not used then the physical address is passed. Unexpected errors may occur if the address mapping is changed after this function is invoked.

Returns
  XST_SUCCESS always.

Note
  None.

References XRtcPsu_Config::BaseAddr, XRtcPsu::CalibrationValue, XRtcPsu::CurrTimeUpdated, XRtcPsu_Config::DeviceId, XRtcPsu::Handler, XRtcPsu::IsPeriodicAlarm, XRtcPsu::IsReady, XRtcPsu::OscillatorFreq, XRtcPsu::RtcConfig, XRtcPsu::TimeUpdated, XRTC_CALIB_WR_OFFSET, XRTC_CALIBRATION_VALUE, XRTC_CTL_OFFSET, XRTC_INT_DIS_OFFSET, XRTC_INT_STS_OFFSET, XRTC_TYPICAL_OSC_FREQ, XRTCPSU_CRYSTAL_OSC_EN, XRtcPsu_ReadReg, and XRtcPsu_WriteReg.

Referenced by RtcPsuAlarmIntrExample(), RtcPsuAlarmPolledExample(), RtcPsuPeriodicAlarmIntrExample(), RtcPsuSecondsIntrExample(), RtcPsuSecondsPolledExample(), RtcPsuSetCalibrationExample(), and RtcPsuSetTimeExample().

void XRtcPsu_ClearInterruptMask | ( | XRtcPsu * | InstancePtr,
|  | u32 | Mask
| ) |  |

This function clears the interrupt mask.

Parameters

  InstancePtr | is a pointer to the XRtcPsu instance
  Mask | contains the interrupts to be disabled. A '1' enables an interrupt, and a '0' disables.

Returns
  None.

Note
  None.

References XRtcPsu_Config::BaseAddr, XRtcPsu::RtcConfig, XRTC_INT_DIS_OFFSET, and XRtcPsu_WriteReg.

Referenced by RtcPsuAlarmIntrExample(), RtcPsuPeriodicAlarmIntrExample(), and RtcPsuSecondsIntrExample().

u32 XRtcPsu_DateTimeToSec | ( | XRtcPsu_DT * | dt | ) |

This function translates time in YEAR:MON:DAY HR:MIN:SEC format to seconds.

Parameters

  dt | is a pointer to a DatetTime format structure variable of time that has to be shown in seconds.

Returns
  Seconds value of provided in dt time.

Note
  None.

References XRtcPsu_DT::Day, XRtcPsu_DT::Hour, XRtcPsu_DT::Min, XRtcPsu_DT::Month, XRtcPsu_DT::Sec, and XRtcPsu_DT::Year.

Referenced by RtcPsuSetCalibrationExample(), and RtcPsuSetTimeExample().

u32 XRtcPsu_GetCurrentTime | ( | XRtcPsu * | InstancePtr | ) |

This function gets the current RTC time.

Parameters

  InstancePtr | is a pointer to the XRtcPsu instance.

Returns
  RTC Current time.

Note
  None.

References XRtcPsu_Config::BaseAddr, XRtcPsu::CurrTimeUpdated, XRtcPsu::RtcConfig, XRtcPsu::TimeUpdated, XRTC_INT_MSK_OFFSET, XRTC_INT_STS_OFFSET, XRtcPsu_GetLastSetTime, XRtcPsu_ReadCurrentTime, and XRtcPsu_ReadReg.

Referenced by RtcPsuAlarmIntrExample(), RtcPsuAlarmPolledExample(), RtcPsuPeriodicAlarmIntrExample(), RtcPsuSetTimeExample(), XRtcPsu_CalculateCalibration(), XRtcPsu_InterruptHandler(), and XRtcPsu_SetAlarm().

void XRtcPsu_InterruptHandler | ( | XRtcPsu * | InstancePtr | ) |

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.

Parameters

  InstancePtr | contains a pointer to the driver instance

Returns
  None.

Note
  None.

References XRtcPsu_Config::BaseAddr, XRtcPsu::CallBackRef, XRtcPsu::CurrTimeUpdated, XRtcPsu::Handler, XRtcPsu::IsPeriodicAlarm, XRtcPsu::IsReady, XRtcPsu::PeriodicAlarmTime, XRtcPsu::RtcConfig, XRtcPsu::TimeUpdated, XRTC_INT_MSK_OFFSET, XRTC_INT_STS_OFFSET, XRTCPSU_EVENT_ALARM_GEN, XRTCPSU_EVENT_SECS_GEN, XRtcPsu_GetCurrentTime(), XRtcPsu_ReadReg, XRtcPsu_SetAlarm(), and XRtcPsu_WriteReg.

Referenced by RtcPsuAlarmIntrExample(), RtcPsuPeriodicAlarmIntrExample(), and RtcPsuSecondsIntrExample().

u32 XRtcPsu_IsAlarmEventGenerated | ( | XRtcPsu * | InstancePtr | ) |

This function returns the alarm event status by reading interrupt status register.

Parameters

  InstancePtr | is a pointer to the XRtcPsu instance.

Returns
  Returns 1 if the alarm event is generated.Else 0.

Note
  This API is used in polled mode operation of RTC. This also clears interrupt status alarm bit.

References XRtcPsu_Config::BaseAddr, XRtcPsu::RtcConfig, XRTC_INT_STS_OFFSET, XRtcPsu_ReadReg, and XRtcPsu_WriteReg.

Referenced by RtcPsuAlarmPolledExample().

u32 XRtcPsu_IsSecondsEventGenerated | ( | XRtcPsu * | InstancePtr | ) |

This function returns the seconds event status by reading interrupt status register.

Parameters

  InstancePtr | is a pointer to the XRtcPsu instance.

Returns
  Returns 1 if a new second event is generated.Else 0..

Note
  This API is used in polled mode operation of RTC. This also clears interrupt status seconds bit.

References XRtcPsu_Config::BaseAddr, XRtcPsu::RtcConfig, XRTC_INT_STS_OFFSET, XRtcPsu_ReadReg, and XRtcPsu_WriteReg.

Referenced by RtcPsuSecondsPolledExample().

XRtcPsu_Config * XRtcPsu_LookupConfig | ( | u16 | DeviceId | ) |

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.

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.

References XRtcPsu_ConfigTable.

Referenced by RtcPsuAlarmIntrExample(), RtcPsuAlarmPolledExample(), RtcPsuPeriodicAlarmIntrExample(), RtcPsuSecondsIntrExample(), RtcPsuSecondsPolledExample(), RtcPsuSetCalibrationExample(), and RtcPsuSetTimeExample().

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.

     It also reports the weekday.

Parameters

  Seconds | is the time value that has to be shown in DateTime format.
  dt | is the DateTime format variable that stores the translated time.

Returns
  None.

Note
  This API supports this century i.e., 2000 - 2099 years only.

References XRtcPsu_DT::Day, XRtcPsu_DT::Hour, XRtcPsu_DT::Min, XRtcPsu_DT::Month, XRtcPsu_DT::Sec, XRtcPsu_DT::WeekDay, and XRtcPsu_DT::Year.

Referenced by RtcPsuAlarmIntrExample(), RtcPsuAlarmPolledExample(), RtcPsuPeriodicAlarmIntrExample(), and RtcPsuSetTimeExample().

s32 XRtcPsu_SelfTest | ( | XRtcPsu * | InstancePtr | ) |

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.

Parameters

  InstancePtr | is a pointer to the XRtcPsu instance

Returns
  - XST_SUCCESS if the test was successful

Note

This function can hang if the hardware is not functioning properly.

References XRtcPsu_Config::BaseAddr, XRtcPsu::IsReady, XRtcPsu::RtcConfig, XRTC_SFTY_CHK_OFFSET, XRtcPsu_ReadReg, and XRtcPsu_WriteReg.

Referenced by RtcPsuAlarmIntrExample(), RtcPsuAlarmPolledExample(), RtcPsuPeriodicAlarmIntrExample(), RtcPsuSecondsIntrExample(), RtcPsuSecondsPolledExample(), RtcPsuSetCalibrationExample(), and RtcPsuSetTimeExample().

void XRtcPsu_SetAlarm | ( | XRtcPsu * | InstancePtr,
|  | u32 | Alarm,
|  | u32 | Periodic
| ) |  |

This function sets the alarm value of RTC device.

Parameters

  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.

Returns
  None.

Note
  None.

References XRtcPsu_Config::BaseAddr, XRtcPsu::IsPeriodicAlarm, XRtcPsu::IsReady, XRtcPsu::PeriodicAlarmTime, XRtcPsu::RtcConfig, XRTC_ALRM_OFFSET, XRtcPsu_GetCurrentTime(), and XRtcPsu_WriteReg.

Referenced by RtcPsuAlarmIntrExample(), RtcPsuAlarmPolledExample(), RtcPsuPeriodicAlarmIntrExample(), and XRtcPsu_InterruptHandler().

void XRtcPsu_SetHandler | ( | XRtcPsu * | InstancePtr,
|  | XRtcPsu_Handler | FunctionPtr,
|  | void * | CallBackRef
| ) |  |

This function sets the handler that will be called when an event (interrupt) occurs that needs application's attention.

Parameters

  InstancePtr | is a pointer to the XRtcPsu instance
  FunctionPtr | is the pointer to the callback function.
  CallBackRef | is the upper layer callback reference passed back when the callback function is invoked.

Returns
  None.

Note

There is no assert on the CallBackRef since the driver doesn't know what it is (nor should it)

References XRtcPsu::CallBackRef, XRtcPsu::Handler, and XRtcPsu::IsReady.

Referenced by RtcPsuAlarmIntrExample(), RtcPsuPeriodicAlarmIntrExample(), and RtcPsuSecondsIntrExample().

void XRtcPsu_SetInterruptMask | ( | XRtcPsu * | InstancePtr,
|  | u32 | Mask
| ) |  |

This function sets the interrupt mask.

Parameters

  InstancePtr | is a pointer to the XRtcPsu instance
  Mask | contains the interrupts to be enabled. A '1' enables an interupt, and a '0' disables.

Returns
  None.

Note
  None.

References XRtcPsu_Config::BaseAddr, XRtcPsu::RtcConfig, XRTC_INT_EN_OFFSET, XRTC_INT_STS_OFFSET, and XRtcPsu_WriteReg.

Referenced by RtcPsuAlarmIntrExample(), RtcPsuPeriodicAlarmIntrExample(), and RtcPsuSecondsIntrExample().

void XRtcPsu_SetTime | ( | XRtcPsu * | InstancePtr,
|  | u32 | Time
| ) |  |

This function sets the RTC time by writing into rtc write register.

Parameters

  InstancePtr | is a pointer to the XRtcPsu instance.
  Time | that should be updated into RTC write register.

Returns
  None.

Note
  None.

References XRtcPsu_Config::BaseAddr, XRtcPsu::CalibrationValue, XRtcPsu::CurrTimeUpdated, XRtcPsu::RtcConfig, XRtcPsu::TimeUpdated, XRTC_CALIB_WR_OFFSET, XRTC_INT_STS_OFFSET, XRtcPsu_WriteReg, and XRtcPsu_WriteSetTime.

Referenced by RtcPsuSetCalibrationExample(), and RtcPsuSetTimeExample().

## Variable Documentation

XRtcPsu_Config XRtcPsu_ConfigTable[XPAR_XRTCPSU_NUM_INSTANCES]

Initial value:
= {
{
(u16)XPAR_XRTCPSU_0_DEVICE_ID,
(u32)XPAR_XRTCPSU_0_BASEADDR
}
}

This table contains configuration information for RTC device in the system.

Referenced by XRtcPsu_LookupConfig().

XRtcPsu_Config XRtcPsu_ConfigTable[]

This table contains configuration information for RTC device in the system.

Referenced by XRtcPsu_LookupConfig().