RTC

10 views
Skip to first unread message

rd...@iinet.net.au

unread,
Apr 30, 2013, 2:09:30 PM4/30/13
to rt-thre...@googlegroups.com
Hi!
 
libcpu\arm\s3c2440\rtc.c
 
The functions rt_hw_rtc_get and rt_hw_rtc_set assign the RTC values directly to/from the struct tm structure however the values used in the tm struct are not compatible with the S3C2440 RTC. tm_wday uses values 0 - 6 but the RTC uses 1-7 and tm_mon uses values 0-11 where the RTC uses 1-12. Also, depending on the C library used, the tm struct can have an epoch of 1900, 1970 ... but the RTC uses 2000 (the value 00 represents the year 2000).
 
The RTC uses the month value to determine the number of days in each month, and the year value to determine leap years.
 
My solution:
 
#define EPOCH  1900  /* Epoch used by CodeSourcery newLib C Library */
 
void rt_hw_rtc_get(struct tm *ti)
{
   ...
   ti->tm_mon     = BCD2BIN(mon & 0x1F) - 1;
   ti->tm_year    = BCD2BIN(year) + 2000 - EPOCH;
   ti->tm_wday    = BCD2BIN(wday & 0x07) - 1;
   ...
}
void rt_hw_rtc_set(struct tm *ti)
{
   ...
   year  = BIN2BCD(ti->tm_year + EPOCH - 2000);
   mon   = BIN2BCD(ti->tm_mon + 1);
   wday  = BIN2BCD(ti->tm_wday + 1);
   ...
}
 
Regards,
Rob

 

rogerz

unread,
May 9, 2013, 3:28:09 PM5/9/13
to rt-thre...@googlegroups.com
You may try to report the issue on Github: https://github.com/RT-Thread/rt-thread/issues
And send your patch as pull request https://github.com/RT-Thread/rt-thread/pulls

It is easier to track issues and merge changes on Github.
--
--
You received this message because you are subscribed to the Google
Groups "rt-thread-users" group.
To post to this group, send email to rt-thre...@googlegroups.com
To unsubscribe from this group, send email to
rt-thread-use...@googlegroups.com
 
---
You received this message because you are subscribed to the Google Groups "rt-thread-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rt-thread-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


--
 ,---.  Rogerz Zhang
( @ @ ) Human, not octopus
 ).-.(  Chase what you love and only that
'/|||\` 人非章鱼·爱吾所爱
  '|`   AsciiArt < Shimrod(hh)

rd...@iinet.net.au

unread,
May 10, 2013, 9:19:57 AM5/10/13
to rt-thre...@googlegroups.com
Hi Rogerz,
 
You may try to report the issue on Github: https://github.com/RT-Thread/rt-thread/issues
And send your patch as pull request https://github.com/RT-Thread/rt-thread/pulls
I have been looking into using Github since I noticed that NONE of the bugs I have reported in the past (and provided code for) have been corrected in 1.1.0 RC.
 
It is easier to track issues and merge changes on Github.
 
Regards,
Rob
 

rogerz

unread,
May 10, 2013, 9:53:01 AM5/10/13
to rt-thre...@googlegroups.com
On Fri, May 10, 2013 at 9:19 PM, <rd...@iinet.net.au> wrote:
Hi Rogerz,
 
You may try to report the issue on Github: https://github.com/RT-Thread/rt-thread/issues
And send your patch as pull request https://github.com/RT-Thread/rt-thread/pulls
I have been looking into using Github since I noticed that NONE of the bugs I have reported in the past (and provided code for) have been corrected in 1.1.0 RC.

Pity to hear that. Did you report issues on mailing list? 

It seems on Github, 79 out of 84 issues have been closed. Only a few are left open. All pull request have been merged or closed so far. And most of them are in English. Why not give it a try?
Reply all
Reply to author
Forward
0 new messages