00001 /***************************************************************************** 00002 * rtctest.c: main C entry file for NXP LPC23xx/24xx Family Microprocessors 00003 * 00004 * Copyright(C) 2006, NXP Semiconductor 00005 * All rights reserved. 00006 * 00007 * History 00008 * 2006.07.13 ver 1.00 Prelimnary version, first Release 00009 * 00010 ******************************************************************************/ 00011 #include "LPC23xx.H" /* LPC23xx/24xx definitions */ 00012 #include "type.h" 00013 #include "irq.h" 00014 #include "timer.h" 00015 #include "rtc.h" 00016 00017 extern volatile DWORD alarm_on; 00018 RTCTime local_time, alarm_time, current_time; 00019 00020 /***************************************************************************** 00021 ** Main Function main() 00022 ******************************************************************************/ 00023 int main (void) 00024 { 00025 /* Initialize RTC module */ 00026 RTCInit(); 00027 00028 local_time.RTC_Sec = 0; 00029 local_time.RTC_Min = 0; 00030 local_time.RTC_Hour = 0; 00031 local_time.RTC_Mday = 8; 00032 local_time.RTC_Wday = 3; 00033 local_time.RTC_Yday = 12; /* current date 07/12/2006 */ 00034 local_time.RTC_Mon = 07; 00035 local_time.RTC_Year = 2006; 00036 RTCSetTime( local_time ); /* Set local time */ 00037 00038 alarm_time.RTC_Sec = 0; 00039 alarm_time.RTC_Min = 0; 00040 alarm_time.RTC_Hour = 0; 00041 alarm_time.RTC_Mday = 1; 00042 alarm_time.RTC_Wday = 0; 00043 alarm_time.RTC_Yday = 1; /* alarm date 01/01/2007 */ 00044 alarm_time.RTC_Mon = 1; 00045 alarm_time.RTC_Year = 2007; 00046 RTCSetAlarm( alarm_time ); /* set alarm time */ 00047 00048 /* install RTC timer handler mainly for alarm control */ 00049 if ( install_irq( RTC_INT, (void *)RTCHandler, HIGHEST_PRIORITY ) == FALSE ) 00050 { 00051 while ( 1 ); /* very bad happened */ 00052 } 00053 00054 /* mask off alarm mask, turn on IMYEAR in the counter increment interrupt 00055 register */ 00056 RTCSetAlarmMask(AMRSEC|AMRMIN|AMRHOUR|AMRDOM|AMRDOW|AMRDOY|AMRMON|AMRYEAR); 00057 RTC_CIIR = IMMIN | IMYEAR; 00058 /* 2007/01/01/00:00:00 is the alarm on */ 00059 00060 RTCStart(); 00061 00062 while (1) 00063 { /* Loop forever */ 00064 current_time = RTCGetTime(); 00065 if ( alarm_on != 0 ) 00066 { 00067 alarm_on = 0; 00068 /* Get current time when alarm is on */ 00069 current_time = RTCGetTime(); 00070 } 00071 } 00072 return 0; 00073 } 00074 00075 /****************************************************************************** 00076 ** End Of File 00077 ******************************************************************************/