From: Will Sowerbutts Date: Thu, 1 Jan 2015 14:37:48 +0000 (+0000) Subject: Kernel: Optionally call rtc_secs() less frequently X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=4cb1397f416bd89530635c2db3289e7232af5a86;p=FUZIX.git Kernel: Optionally call rtc_secs() less frequently --- diff --git a/Kernel/platform-n8vem-mark4/config.h b/Kernel/platform-n8vem-mark4/config.h index 3b6fb756..28a47cf2 100644 --- a/Kernel/platform-n8vem-mark4/config.h +++ b/Kernel/platform-n8vem-mark4/config.h @@ -60,3 +60,4 @@ /* We have a DS1302, we can read the time of day from it */ #define CONFIG_RTC +#define CONFIG_RTC_INTERVAL 30 /* deciseconds between reading RTC seconds counter */ diff --git a/Kernel/platform-p112/config.h b/Kernel/platform-p112/config.h index 316ee2a0..dc464760 100644 --- a/Kernel/platform-p112/config.h +++ b/Kernel/platform-p112/config.h @@ -57,3 +57,4 @@ /* We have a DS1302, we can read the time of day from it */ #define CONFIG_RTC +#define CONFIG_RTC_INTERVAL 30 /* deciseconds between reading RTC seconds counter */ diff --git a/Kernel/timer.c b/Kernel/timer.c index e9b8a3c3..d97ec406 100644 --- a/Kernel/timer.c +++ b/Kernel/timer.c @@ -65,6 +65,9 @@ void updatetod(void) #else static uint8_t rtcsec; +#ifdef CONFIG_RTC_INTERVAL +static uint8_t tod_deci; +#endif /* * We use the seconds counter on the RTC as a time counter and lock our @@ -77,9 +80,19 @@ static uint8_t rtcsec; */ void updatetod(void) { - uint8_t rtcnew = rtc_secs(); /* platform function */ + uint8_t rtcnew; int8_t slide; +#ifdef CONFIG_RTC_INTERVAL + /* on some platforms reading the RTC is expensive so we don't do it + every decisecond. */ + if(++tod_deci != CONFIG_RTC_INTERVAL) + return; + tod_deci = 0; +#endif + + rtcnew = rtc_secs(); /* platform function */ + if (rtcnew == rtcsec) return; slide = rtcnew - rtcsec; /* Seconds elapsed */