#include "includes.h"Go to the source code of this file.
Functions | |
| void | RtcInit (void) |
| void | RtcHandler (void) |
| void | RtcByteWrite (U8 Address, U8 Data) |
| U8 | RtcByteRead (U8 Address) |
| void | RtcSvc (void) |
Variables | |
| const U8 | RtcName [] = "RTC" |
| 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 }
| void RtcSvc | ( | void | ) |
Definition at line 72 of file rtc.c.
00072 { 00073 if(RtcCtrl.HasUpdate==true){ 00074 RtcCtrl.HasUpdate=false; 00075 GuiStringPrint("\nrtc time is "); 00076 GuiU8Print(RtcCtrl.Year); 00077 GuiStringPrint(":"); 00078 GuiU8Print(RtcCtrl.Month); 00079 GuiStringPrint(":"); 00080 GuiU8Print(RtcCtrl.Date); 00081 GuiStringPrint(":"); 00082 GuiU8Print(RtcCtrl.Hour); 00083 GuiStringPrint(":"); 00084 GuiU8Print(RtcCtrl.Minute); 00085 GuiStringPrint(":"); 00086 GuiU8Print(RtcCtrl.Second); 00087 GuiStringPrint(":"); 00088 GuiU8Print(RtcCtrl.RegisterC); 00089 GuiStringPrint(":"); 00090 GuiU8Print(RtcCtrl.RegisterD); 00091 } 00092 if(RtcCtrl.HasPeriodic==true){ 00093 RtcCtrl.HasPeriodic=false; 00094 GuiStringPrint("\nsee rtc periodic interrupt."); 00095 } 00096 if(RtcCtrl.PeriodicCounter==0){ 00097 RtcCtrl.PeriodicCounter=PERIODIC_DELAY_TIME; 00098 GuiStringPrint("\nsee rtc periodic delay time up."); 00099 } 00100 }
1.5.9