From c8b87d76eb506d374edd2631d4c29e4300be84c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Wallm=C3=A9nius?= Date: Sat, 26 Sep 2009 14:58:32 +0000 Subject: FS#10569 RTC driver cleanup Change the RTC drivers so that the rtc_(read|write)_datetime functions now deal directly with the tm struct instead of passing a string of bcd digits to/from (set|get)_time . This simplifies drivers for rtc's that do not use a bcd representation internally and cleans up some target specific code and #ifdefs in generic code. Implement simple stubs for the sim to avoid #ifdefing for that too. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22839 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/rtc.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'firmware/export/rtc.h') diff --git a/firmware/export/rtc.h b/firmware/export/rtc.h index 6d21b1f..57853f2 100644 --- a/firmware/export/rtc.h +++ b/firmware/export/rtc.h @@ -24,13 +24,19 @@ #include #include "system.h" #include "config.h" +#include "time.h" + +/* Macros used to convert to and from BCD, used in various rtc drivers + this is the wrong place but misc.h is in apps... */ +#define BCD2DEC(X) (((((X)>>4) & 0x0f) * 10) + ((X) & 0xf)) +#define DEC2BCD(X) ((((X)/10)<<4) | ((X)%10)) #if CONFIG_RTC /* Common functions for all targets */ void rtc_init(void); -int rtc_read_datetime(unsigned char* buf); -int rtc_write_datetime(unsigned char* buf); +int rtc_read_datetime(struct tm *tm); +int rtc_write_datetime(const struct tm *tm); #if CONFIG_RTC == RTC_M41ST84W @@ -53,3 +59,4 @@ bool rtc_check_alarm_flag(void); #endif /* CONFIG_RTC */ #endif + -- cgit v1.1