Go to the source code of this file.
Data Structures | |
| struct | RTC_CONTROL |
Defines | |
| #define | RTC_ADDRESS_PORT 0x70 |
| #define | RTC_DATA_PORT 0x71 |
| #define | RTC_CLOCK_SECOND 0x00 |
| #define | RTC_ALARM_SECOND 0x01 |
| #define | RTC_CLOCK_MINUTE 0x02 |
| #define | RTC_ALARM_MINUTE 0x03 |
| #define | RTC_CLOCK_HOUR 0x04 |
| #define | RTC_ALARM_HOUR 0x05 |
| #define | RTC_CLOCK_DAY 0x06 |
| #define | RTC_CLOCK_DATE 0x07 |
| #define | RTC_CLOCK_MONTH 0x08 |
| #define | RTC_CLOCK_YEAR 0x09 |
| #define | RTC_REG_A 0x0A |
| #define | RTC_REG_B 0x0B |
| #define | RTC_REG_C 0x0C |
| #define | RTC_REG_D 0x0D |
| #define | RTC_PF 0x80 |
| #define | RTC_PF 0x40 |
| #define | RTC_AF 0x20 |
| #define | RTC_UF 0x10 |
| #define | PERIODIC_DELAY_TIME 10 |
Functions | |
| void | RtcInit (void) |
| void | RtcHandler (void) |
| void | RtcByteWrite (U8 Address, U8 Data) |
| U8 | RtcByteRead (U8 Address) |
Variables | |
| RTC_CONTROL | RtcCtrl |
Definition at line 67 of file rtc.c.
00067 { 00068 OutByte(RTC_ADDRESS_PORT,Address); 00069 return InByte(RTC_DATA_PORT); 00070 }
Definition at line 62 of file rtc.c.
00062 { 00063 OutByte(RTC_ADDRESS_PORT,Address); 00064 OutByte(RTC_DATA_PORT,Data); 00065 }
| void RtcHandler | ( | void | ) |
Definition at line 39 of file rtc.c.
00039 { 00040 U8 i; 00041 00042 i=RtcByteRead(RTC_REG_C); 00043 if(i&RTC_PF){ //periodic interrupt...for real time system use 00044 RtcCtrl.HasPeriodic=true; 00045 if(RtcCtrl.PeriodicCounter!=0) RtcCtrl.PeriodicCounter--; 00046 } 00047 if(i&RTC_AF){ // alarm flag interrupt 00048 RtcCtrl.HasAlarm=true; 00049 } 00050 if(i&RTC_UF){ // update cycle interrupt...per second 00051 RtcCtrl.HasUpdate=true; 00052 RtcCtrl.Second=RtcByteRead(RTC_CLOCK_SECOND); 00053 RtcCtrl.Minute=RtcByteRead(RTC_CLOCK_MINUTE); 00054 RtcCtrl.Hour=RtcByteRead(RTC_CLOCK_HOUR); 00055 RtcCtrl.Day=RtcByteRead(RTC_CLOCK_DAY); 00056 RtcCtrl.Date=RtcByteRead(RTC_CLOCK_DATE); 00057 RtcCtrl.Month=RtcByteRead(RTC_CLOCK_MONTH); 00058 RtcCtrl.Year=RtcByteRead(RTC_CLOCK_YEAR); 00059 } 00060 }
| void RtcInit | ( | void | ) |
Definition at line 15 of file rtc.c.
00015 { 00016 PicIrqDisable(IRQ8_RTC); 00017 RtcCtrl.HasUpdate=false; 00018 RtcCtrl.HasAlarm=false; 00019 RtcCtrl.HasPeriodic=false; 00020 RtcCtrl.PeriodicCounter=PERIODIC_DELAY_TIME; 00021 RtcCtrl.Second=0; 00022 RtcCtrl.Minute=0; 00023 RtcCtrl.Hour=0; 00024 RtcCtrl.Day=0; 00025 RtcCtrl.Date=0; 00026 RtcCtrl.Month=0; 00027 RtcCtrl.Year=0; 00028 RtcCtrl.RegisterA=0x2f; // divider 32.768K,periodic interrupt 500 ms 00029 RtcCtrl.RegisterB=0x50; // update int,binary,24 hour, 00030 RtcCtrl.RegisterC=0; 00031 RtcCtrl.RegisterD=0; 00032 RtcByteWrite(RTC_REG_A,RtcCtrl.RegisterA); 00033 RtcByteWrite(RTC_REG_B,RtcCtrl.RegisterB); 00034 OsEventAdd(&RtcCtrl.RtcEvent,&RtcName,OS_EVENT_RTC); 00035 InterruptIrqHandlerSet(IRQ8_RTC,RtcHandler); 00036 PicIrqEnable(IRQ8_RTC); 00037 }
1.5.9