XilinxProcessorIPLib/drivers/rtcpsu/examples/xrtcpsu_alarm_polled_example.c
int RtcPsuAlarmPolledExample(u16 DeviceId)
{
	int Status;
	XRtcPsu_Config *Config;
	u32 CurrentTime, AlarmTime;
	XRtcPsu_DT dt0;

	/*
	 * Initialize the RTC driver so that it's ready to use.
	 * Look up the configuration in the config table, then initialize it.
	 */
	Config = XRtcPsu_LookupConfig(DeviceId);
	if (NULL == Config) {
		return XST_FAILURE;
	}

	Status = XRtcPsu_CfgInitialize(&Rtc_Psu, Config, Config->BaseAddr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/* Check hardware build. */
	Status = XRtcPsu_SelfTest(&Rtc_Psu);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	xil_printf("\n\rDay Convention : 0-Fri, 1-Sat, 2-Sun, 3-Mon, 4-Tue, 5-Wed, 6-Thur\n\r");
	xil_printf("Current RTC time is..\n\r");
	CurrentTime = XRtcPsu_GetCurrentTime(&Rtc_Psu);
	XRtcPsu_SecToDateTime(CurrentTime,&dt0);
	xil_printf("YEAR:MM:DD HR:MM:SS \t %04d:%02d:%02d %02d:%02d:%02d\t Day = %d\n\r",
			dt0.Year,dt0.Month,dt0.Day,dt0.Hour,dt0.Min,dt0.Sec,dt0.WeekDay);

	CurrentTime = XRtcPsu_GetCurrentTime(&Rtc_Psu);
	AlarmTime = CurrentTime + ALARM_PERIOD;
	XRtcPsu_SetAlarm(&Rtc_Psu,AlarmTime,0U);

	/*
	 * If Alarm was not generated, then the processor goes into an infinite
	 * loop. This represents a failure case of alarm example.
	 */
	while (!XRtcPsu_IsAlarmEventGenerated(&Rtc_Psu));
	xil_printf("Alarm generated.\n\r");

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function does a minimal Alarm test on the XRtcPsu device in polled mode.
*
* This function sets one time alarm from the current time to a specified time.
*
* @param	DeviceId is the unique device id from hardware build.
*
* @return	XST_SUCCESS if successful, XST_FAILURE if unsuccessful
*
* @note
* This function polls the RTC, it may hang if the hardware is not
* working correctly.
*
****************************************************************************/
This function does a minimal Alarm test on the XRtcPsu device in polled mode.
This function sets one time alarm from the current time to a specified time.
This function does a minimal Alarm test on the XRtcPsu device in polled mode . This function sets one time alarm from the current time to a specified time .
int RtcPsuAlarmPolledExample(u16 DeviceId)
{
	int Status;
	XRtcPsu_Config *Config;
	u32 CurrentTime, AlarmTime;
	XRtcPsu_DT dt0;
	Config = XRtcPsu_LookupConfig(DeviceId);
	if (NULL == Config) {
		return XST_FAILURE;
	}
	Status = XRtcPsu_CfgInitialize(&Rtc_Psu, Config, Config->BaseAddr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = XRtcPsu_SelfTest(&Rtc_Psu);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	xil_printf("\n\rDay Convention : 0-Fri, 1-Sat, 2-Sun, 3-Mon, 4-Tue, 5-Wed, 6-Thur\n\r");
	xil_printf("Current RTC time is..\n\r");
	CurrentTime = XRtcPsu_GetCurrentTime(&Rtc_Psu);
	XRtcPsu_SecToDateTime(CurrentTime,&dt0);
	xil_printf("YEAR:MM:DD HR:MM:SS \t %04d:%02d:%02d %02d:%02d:%02d\t Day = %d\n\r",
			dt0.Year,dt0.Month,dt0.Day,dt0.Hour,dt0.Min,dt0.Sec,dt0.WeekDay);
	CurrentTime = XRtcPsu_GetCurrentTime(&Rtc_Psu);
	AlarmTime = CurrentTime + ALARM_PERIOD;
	XRtcPsu_SetAlarm(&Rtc_Psu,AlarmTime,0U);
	while (!XRtcPsu_IsAlarmEventGenerated(&Rtc_Psu));
	xil_printf("Alarm generated.\n\r");
	return XST_SUCCESS;
}
int RtcPsuAlarmPolledExample ( u16 DeviceId ) { int Status ; XRtcPsu_Config * Config ; u32 CurrentTime , AlarmTime ; XRtcPsu_DT dt0 ; Config = XRtcPsu_LookupConfig ( DeviceId ) ; if ( NULL == Config ) { return XST_FAILURE ; } Status = XRtcPsu_CfgInitialize ( & Rtc_Psu , Config , Config -> BaseAddr ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = XRtcPsu_SelfTest ( & Rtc_Psu ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } xil_printf ( " \n \r \n \r " ) ; xil_printf ( " \n \r " ) ; CurrentTime = XRtcPsu_GetCurrentTime ( & Rtc_Psu ) ; XRtcPsu_SecToDateTime ( CurrentTime , & dt0 ) ; xil_printf ( " \t \t \n \r " , dt0 . Year , dt0 . Month , dt0 . Day , dt0 . Hour , dt0 . Min , dt0 . Sec , dt0 . WeekDay ) ; CurrentTime = XRtcPsu_GetCurrentTime ( & Rtc_Psu ) ; AlarmTime = CurrentTime + ALARM_PERIOD ; XRtcPsu_SetAlarm ( & Rtc_Psu , AlarmTime , 0U ) ; while ( ! XRtcPsu_IsAlarmEventGenerated ( & Rtc_Psu ) ) ; xil_printf ( " \n \r " ) ; return XST_SUCCESS ; }
This function does a minimal Alarm test on the XRtcPsu device in polled mode.
This function does a minimal Alarm test on the XRtcPsu device in polled mode .
/*
	 * Initialize the RTC driver so that it's ready to use.
	 * Look up the configuration in the config table, then initialize it.
	 */ /* Check hardware build. */ /*
	 * If Alarm was not generated, then the processor goes into an infinite
	 * loop. This represents a failure case of alarm example.
	 */