Hi Laks,
I use the standard C time function to read the current time, and use
a system call at the start of my program to sync the internal clock
to the RTC.
printf("..Syncing time with RTC\n");
system("hwclock --hctosys");
An example of reading the time would be:
void TimeStampMenu(int Military) {
int hour,min,month;
char stringbuffer[32];
time_t now;
struct tm *TimeNow;
time(&now);
TimeNow=localtime(&now);
hour = TimeNow->tm_hour;
min = TimeNow->tm_min;
month = (TimeNow->tm_mon)+1;
if ((month<4) || (month>10)) hour-=5;
else hour-=4;
if (hour<0) hour+=24;
if (Military) sprintf(stringbuffer,"%d:%02d",hour,min);
else if (hour==0) sprintf(stringbuffer,"12:%02d AM",min);
else if (hour==12) sprintf(stringbuffer,"12:%02d PM",min);
else if (hour<12) sprintf(stringbuffer,"%d:%02d AM",hour,min);
else sprintf(stringbuffer,"%d:%02d PM",(hour-12),min);
while ((VGAregs[_vVIDCTRL] & 0x400)!=0); // Wait for last BitBlt
to finish.
Font_String(24,stringbuffer,VGAxy((_scrW-2),4),cWhite,_hTRight);
}
Hope this helps,
PJE
--- In "Laks" <> wrote:
>
> Hi
> how can i use the hwclock in my c source code?
> i need the time for my smart card reader which i am designing using
the arm board
>
> can i use the RTC base addr 0x1080_0000 as a pointer to access the
rtc registers and its memory contents?
> being a memory mapped device will it work?
>
> some of the sample codes i have seen mmap command to map the LCD /
ADC etc.,
>
> is it neceesary i have to use mmap to access the memory devices?
>
> -laks
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|