From 6dbbc8f33a625f007c1ec752d400ee08c27f0f20 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Wed, 4 Dec 2019 03:10:16 +0100 Subject: [PATCH] cpu/lpc2387: rtc: remove _rtc_set() Calling localtime() adds considerable overhead. There are easier ways to set the date to 1970. For tests/periph_rtc this results in this ROM change: master: text data bss dec hex 31328 240 98064 129632 1fa60 with this patch: text data bss dec hex 20036 140 98168 118344 1ce48 --- cpu/lpc2387/periph/rtc.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/cpu/lpc2387/periph/rtc.c b/cpu/lpc2387/periph/rtc.c index e17f24291c..0dd2c45cfc 100644 --- a/cpu/lpc2387/periph/rtc.c +++ b/cpu/lpc2387/periph/rtc.c @@ -40,9 +40,6 @@ static rtc_alarm_cb_t _cb; /* Argument to alarm callback */ static void *_cb_arg; -/* internal function to set time based on time_t */ -static void _rtc_set(time_t time); - void RTC_IRQHandler(void) __attribute__((interrupt("IRQ"))); void rtc_init(void) @@ -56,10 +53,10 @@ void rtc_init(void) RTC_CCR = CCR_CLKSRC; /* Clock from external 32 kHz Osc. */ - /* initialize clock with valid unix compatible values - * If RTC_YEAR contains an value larger unix time_t we must reset. */ + /* initialize clock with valid unix compatible values */ if (RTC_YEAR > 2037) { - _rtc_set(0); + struct tm localt = { .tm_year = 70 }; + rtc_set_time(&localt); } rtc_poweron(); @@ -201,10 +198,3 @@ void RTC_IRQHandler(void) VICVectAddr = 0; /* Acknowledge Interrupt */ } - -static void _rtc_set(time_t time) -{ - struct tm *localt; - localt = localtime(&time); /* convert seconds to broken-down time */ - rtc_set_time(localt); -}