XilinxProcessorIPLib/drivers/rtcpsu/src/xrtcpsu.c
s32 XRtcPsu_CfgInitialize(XRtcPsu *InstancePtr, XRtcPsu_Config *ConfigPtr,
			  UINTPTR EffectiveAddr)
{
	s32 Status;
	u32 ControlRegister;

	Xil_AssertNonvoid(InstancePtr != NULL);

	Xil_AssertNonvoid(ConfigPtr != NULL);

	/*
	 * Set some default values for instance data, don't indicate the device
	 * is ready to use until everything has been initialized successfully.
	 */
	InstancePtr->IsReady = 0U;
	InstancePtr->RtcConfig.BaseAddr = EffectiveAddr;
	InstancePtr->RtcConfig.DeviceId = ConfigPtr->DeviceId;

	if (InstancePtr->OscillatorFreq == 0U) {
		InstancePtr->CalibrationValue = XRTC_CALIBRATION_VALUE;
		InstancePtr->OscillatorFreq = XRTC_TYPICAL_OSC_FREQ;
	}

	/* Set all handlers to stub values, let user configure this
	 * data later.
	 */
	InstancePtr->Handler = (XRtcPsu_Handler)XRtcPsu_StubHandler;

	InstancePtr->IsPeriodicAlarm = 0U;

	/* Set the calibration value in calibration register. */
	XRtcPsu_WriteReg(InstancePtr->RtcConfig.BaseAddr + XRTC_CALIB_WR_OFFSET,
				InstancePtr->CalibrationValue);

	/*	Set the Oscillator crystal and Battery switch enable
	 *	in control register.
	 */
	ControlRegister = XRtcPsu_ReadReg(InstancePtr->RtcConfig.BaseAddr
		+ XRTC_CTL_OFFSET);
	XRtcPsu_WriteReg(InstancePtr->RtcConfig.BaseAddr + XRTC_CTL_OFFSET,
			(ControlRegister | (u32)XRTCPSU_CRYSTAL_OSC_EN |
				(u32)XRTC_CTL_BATTERY_EN_MASK));

	/* Clear the Interrupt Status and Disable the interrupts. */
	XRtcPsu_WriteReg(InstancePtr->RtcConfig.BaseAddr + XRTC_INT_STS_OFFSET,
			((u32)XRTC_INT_STS_ALRM_MASK |
				(u32)XRTC_INT_STS_SECS_MASK));
	XRtcPsu_WriteReg(InstancePtr->RtcConfig.BaseAddr + XRTC_INT_DIS_OFFSET,
			((u32)XRTC_INT_DIS_ALRM_MASK |
				(u32)XRTC_INT_DIS_SECS_MASK));

	/* Indicate the component is now ready to use. */
	InstancePtr->IsReady = XIL_COMPONENT_IS_READY;

	/* Clear TimeUpdated and CurrTimeUpdated */
	InstancePtr->TimeUpdated = (u32)0U;
	InstancePtr->CurrTimeUpdated = (u32)0U;

	Status = (s32)XST_SUCCESS;
	return Status;
}
/*****************************************************************************/
/**
 *
 * This function initializes a XRtcPsu instance/driver.
 *
 * The initialization entails:
 * - Initialize all members of the XRtcPsu structure.
 *
 * @param	InstancePtr is a pointer to the XRtcPsu instance.
 * @param	ConfigPtr points to the XRtcPsu device configuration structure.
 * @param	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.
 *
 * @return	XST_SUCCESS always.
 *
 * @note		None.
 *
 ******************************************************************************/
This function initializes a XRtcPsu instance/driver.
The initialization entails:
- Initialize all members of the XRtcPsu structure.

@param       InstancePtr is a pointer to the XRtcPsu instance.
@param       ConfigPtr points to the XRtcPsu device configuration structure.
@param       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.



@note                None.
This function initializes a XRtcPsu instance / driver . The initialization entails : - Initialize all members of the XRtcPsu structure . @param InstancePtr is a pointer to the XRtcPsu instance . @param ConfigPtr points to the XRtcPsu device configuration structure . @param 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 . @note None .
s32 XRtcPsu_CfgInitialize(XRtcPsu *InstancePtr, XRtcPsu_Config *ConfigPtr,
			  UINTPTR EffectiveAddr)
{
	s32 Status;
	u32 ControlRegister;
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(ConfigPtr != NULL);
	InstancePtr->IsReady = 0U;
	InstancePtr->RtcConfig.BaseAddr = EffectiveAddr;
	InstancePtr->RtcConfig.DeviceId = ConfigPtr->DeviceId;
	if (InstancePtr->OscillatorFreq == 0U) {
		InstancePtr->CalibrationValue = XRTC_CALIBRATION_VALUE;
		InstancePtr->OscillatorFreq = XRTC_TYPICAL_OSC_FREQ;
	}
	InstancePtr->Handler = (XRtcPsu_Handler)XRtcPsu_StubHandler;
	InstancePtr->IsPeriodicAlarm = 0U;
	XRtcPsu_WriteReg(InstancePtr->RtcConfig.BaseAddr + XRTC_CALIB_WR_OFFSET,
				InstancePtr->CalibrationValue);
	ControlRegister = XRtcPsu_ReadReg(InstancePtr->RtcConfig.BaseAddr
		+ XRTC_CTL_OFFSET);
	XRtcPsu_WriteReg(InstancePtr->RtcConfig.BaseAddr + XRTC_CTL_OFFSET,
			(ControlRegister | (u32)XRTCPSU_CRYSTAL_OSC_EN |
				(u32)XRTC_CTL_BATTERY_EN_MASK));
	XRtcPsu_WriteReg(InstancePtr->RtcConfig.BaseAddr + XRTC_INT_STS_OFFSET,
			((u32)XRTC_INT_STS_ALRM_MASK |
				(u32)XRTC_INT_STS_SECS_MASK));
	XRtcPsu_WriteReg(InstancePtr->RtcConfig.BaseAddr + XRTC_INT_DIS_OFFSET,
			((u32)XRTC_INT_DIS_ALRM_MASK |
				(u32)XRTC_INT_DIS_SECS_MASK));
	InstancePtr->IsReady = XIL_COMPONENT_IS_READY;
	InstancePtr->TimeUpdated = (u32)0U;
	InstancePtr->CurrTimeUpdated = (u32)0U;
	Status = (s32)XST_SUCCESS;
	return Status;
}
s32 XRtcPsu_CfgInitialize ( XRtcPsu * InstancePtr , XRtcPsu_Config * ConfigPtr , UINTPTR EffectiveAddr ) { s32 Status ; u32 ControlRegister ; Xil_AssertNonvoid ( InstancePtr != NULL ) ; Xil_AssertNonvoid ( ConfigPtr != NULL ) ; InstancePtr -> IsReady = 0U ; InstancePtr -> RtcConfig . BaseAddr = EffectiveAddr ; InstancePtr -> RtcConfig . DeviceId = ConfigPtr -> DeviceId ; if ( InstancePtr -> OscillatorFreq == 0U ) { InstancePtr -> CalibrationValue = XRTC_CALIBRATION_VALUE ; InstancePtr -> OscillatorFreq = XRTC_TYPICAL_OSC_FREQ ; } InstancePtr -> Handler = ( XRtcPsu_Handler ) XRtcPsu_StubHandler ; InstancePtr -> IsPeriodicAlarm = 0U ; XRtcPsu_WriteReg ( InstancePtr -> RtcConfig . BaseAddr + XRTC_CALIB_WR_OFFSET , InstancePtr -> CalibrationValue ) ; ControlRegister = XRtcPsu_ReadReg ( InstancePtr -> RtcConfig . BaseAddr + XRTC_CTL_OFFSET ) ; XRtcPsu_WriteReg ( InstancePtr -> RtcConfig . BaseAddr + XRTC_CTL_OFFSET , ( ControlRegister | ( u32 ) XRTCPSU_CRYSTAL_OSC_EN | ( u32 ) XRTC_CTL_BATTERY_EN_MASK ) ) ; XRtcPsu_WriteReg ( InstancePtr -> RtcConfig . BaseAddr + XRTC_INT_STS_OFFSET , ( ( u32 ) XRTC_INT_STS_ALRM_MASK | ( u32 ) XRTC_INT_STS_SECS_MASK ) ) ; XRtcPsu_WriteReg ( InstancePtr -> RtcConfig . BaseAddr + XRTC_INT_DIS_OFFSET , ( ( u32 ) XRTC_INT_DIS_ALRM_MASK | ( u32 ) XRTC_INT_DIS_SECS_MASK ) ) ; InstancePtr -> IsReady = XIL_COMPONENT_IS_READY ; InstancePtr -> TimeUpdated = ( u32 ) 0U ; InstancePtr -> CurrTimeUpdated = ( u32 ) 0U ; Status = ( s32 ) XST_SUCCESS ; return Status ; }
This function initializes a XRtcPsu instance/driver.
This function initializes a XRtcPsu instance / driver .
/*
	 * Set some default values for instance data, don't indicate the device
	 * is ready to use until everything has been initialized successfully.
	 */ /* Set all handlers to stub values, let user configure this
	 * data later.
	 */ /* Set the calibration value in calibration register. */ /*	Set the Oscillator crystal and Battery switch enable
	 *	in control register.
	 */ /* Clear the Interrupt Status and Disable the interrupts. */ /* Indicate the component is now ready to use. */ /* Clear TimeUpdated and CurrTimeUpdated */