Rockbox

Tasklist

FS#10569 - RTC driver cleanup

Attached to Project: Rockbox
Opened by Nils Wallménius (nls) - Saturday, 29 August 2009, 16:59 GMT
Last edited by Nils Wallménius (nls) - Saturday, 26 September 2009, 15:33 GMT
Task Type Patches
Category Drivers
Status Closed
Assigned To Nils Wallménius (nls)
Operating System All players
Severity Low
Priority Normal
Reported Version Version 3.3
Due in Version Future release
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

This patch moves the handling of the tm struct into the rtc drivers' rtc_(read|write)_datetime functions to avoid the rtc drivers having to encode the data into the same format used natively in some old archos rtc chip. Also a macro is now used for conversion to and from bcd in the drivers that use it, and a few random cleanups and a bit of useless whitespace changes that can be ignored ;)
This removes a lot of target specific code and all sim specific code from timerfuncs.c -- less #ifdef hell, yay :)

I've test built most of the drivers but have only tested on the gigabeast. The best test i could come up with was to install a patched build and see if time is read correctly then change it and go back to an unpatched build and see if that can read the new time.

there is one comment in the ds1339.... driver that mentions something about century and OR's the month value with 0x80 that i have no idea if it's correct but i tried to keep it as it was.

   rtc.diff (33.1 KiB)
This task depends upon

Closed by  Nils Wallménius (nls)
Saturday, 26 September 2009, 15:33 GMT
Reason for closing:  Accepted
Additional comments about closing:  commited
Comment by Bertrik Sikken (bertrik) - Saturday, 29 August 2009, 17:32 GMT
My sansa e200 and sansa clip still show the correct time, the day-of-week in the calendar plugin is also correct. Both of these targets use the rtc_as3514.c driver.
Comment by Dominik Riebeling (bluebrother) - Saturday, 29 August 2009, 20:38 GMT
H100 w/ RTC-Mod: doesn't work. Date shows up correctly when trying to set it, the time / date dialog shows "--:--:--, unknown". Trying to start the calendar plugin results in a hard hang (possibly an endless loop in the plugin?)

mrobe 100: setting time and date works, calendar plugin is correct.

Ipod Mini2G: works as mrobe 100.

Note that I haven't tried alarms.
Comment by Nils Wallménius (nls) - Saturday, 29 August 2009, 21:06 GMT
this version is closer to svn, migth it fix the h100 problems?
Comment by Nils Wallménius (nls) - Saturday, 29 August 2009, 21:27 GMT
ok, it's broken for several of the targets using bcd so i'll try to fix tomorrow
Comment by Nils Wallménius (nls) - Sunday, 30 August 2009, 08:33 GMT
This patch should fix time reading on targets using the ds1339_ds3231, e8564 and m41st84w drivers.
Hopefully time setting on ds1339_ds3231 should also be fixed.
This version also replaced the literal address constant in the e8564 driver with a #defined constant and uses the BCD macros in more places.

To summarise the status:
Confirmed working: as3514, mrobe100, mc13783, pcf50605, pcf50606

Broken but hopefully fixed in this version: ds1339_ds3231 and e8564

Not tested: m41st84w, jz4740, rx5x348ab, s3c2440, s35390a
all of these except jz4740 use internal bcd representation so it's very possible they need the same fix as ds1339_ds3231 and e8564.
Comment by Dominik Riebeling (bluebrother) - Sunday, 30 August 2009, 17:46 GMT
The updated patch works as expected on h100 RTC. Compilation however gives a warning (haven't tried to fix that for testing):

CC firmware/drivers/rtc/rtc_ds1339_ds3231.c
/home/dom/projects/rockbox/firmware/drivers/rtc/rtc_ds1339_ds3231.c: In function `rtc_read_datetime':
/home/dom/projects/rockbox/firmware/drivers/rtc/rtc_ds1339_ds3231.c:129: warning: statement with no effect
Comment by Nils Wallménius (nls) - Monday, 31 August 2009, 14:31 GMT
This patch fixes the warning and also that the previous version would fill in the wday value with 1-7 for ds1339_ds3231.
Also fix a stupid typo preventing the e8564 driver from building...
Comment by Teruaki Kawashima (teru) - Monday, 07 September 2009, 12:23 GMT
I tested rtc_4.diff on gigabeat X, r22639. both time and date menu and calendar plugin work correctly.

Loading...