For backwards compatibility, I suggest that rtcGetTime() and rtc_lld_get_time() be given a return code to indicate this.
The ST RTC has a flag INITS in RTC_ISR which is set if the year > 0 (or it would be possible to test the year directly). [N.B. it's not possible to test the year outside rtcGetTime(), since it may have an offset added]. (This is true of 32F767, which uses rtc2 driver; not checked others).
So I propose:
1. Change rtcGetTime() and rtc_lld_get_time() to return a msg_t result of MSG_OK or MSG_RESET (.src and .h file change)
2. Add the following at the bottom of rtc_lld_get_time() (or similar to reflect RTC capabilities)
Code: Select all
return (rtcp->rtc->ISR & RTC_ISR_INITS) ? MSG_OK : MSG_RESET;
3. Modify rtcGetTime() in hal_rtc.h to return the value
I've attached my update for RTCv2