I need to get an information about current time with milliseconds resolution. I use function rtcGetTimeTm() and see in docs that tm structure has only field for seconds, not millisecond. It makes me think that I can't get milliseconds. But suddenly I have know that my stm32f103 has an ability to get what I need. Searching in ChibiOS code gives me a definition of STM32_RTC_HAS_SUBSECONDS. But I see no abilities to get milliseconds without creating custom version of rtcGetTimeTm().
It may be implemented like this:
Code: Select all
#if STM32_RTC_HAS_SUBSECONDS
uint32_t rtcGetTimeTmMilli(RTCDriver *rtcp, struct tm *timp) {
RTCTime timespec = {0, 0,FALSE,0};
rtcGetTime(rtcp, ×pec);
stm32_rtc_bcd2tm(timp, ×pec);
return timespec.tv_msec;
}
#endifWhat do you think about?