Kernel: Optionally call rtc_secs() less frequently
authorWill Sowerbutts <will@sowerbutts.com>
Thu, 1 Jan 2015 14:37:48 +0000 (14:37 +0000)
committerWill Sowerbutts <will@sowerbutts.com>
Thu, 1 Jan 2015 14:50:09 +0000 (14:50 +0000)
Kernel/platform-n8vem-mark4/config.h
Kernel/platform-p112/config.h
Kernel/timer.c

index 3b6fb75..28a47cf 100644 (file)
@@ -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 */
index 316ee2a..dc46476 100644 (file)
@@ -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 */
index e9b8a3c..d97ec40 100644 (file)
@@ -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 */