Reputation: 41
This is more a general question. How is the coupling done between the time()
c-function and the underlying hardware? Suppose that you compile for a microcontroller not containing any RTC, what value do you get back? Or if you use your own RTC that keeps running with battery on a separate chip? How do you update time()
after repowering? Is there any method for redirecting?
I did a trial in Mbed with RTC and time()
function with MCU_STM32U575xG
.
Upvotes: 1
Views: 98
Reputation: 141698
How is the coupling done between the time() c-function and the underlying hardware?
There is no coupling "done". You have to "do it".
what value do you get back?
I would expect a linking error, or maybe I would expect time()
to return (time_t)-1
with errno
set to ENOSYS
.
Returning -1 and ENOSYS is the default nosys
implementation of newlib
C standard library implementation so commonly used with GNU arm-none-eabi-gcc
compiler toolchain here https://github.com/bminor/newlib/blob/master/libgloss/libnosys/gettod.c#L18 .
I did a trial in Mbed with RTC and time() function with MCU_STM32U575xG.
In the case of mbed-os, time function is implemented here https://github.com/mbed-ce/mbed-os/blob/master/platform/source/mbed_rtc_time.cpp#L120 . The specifics of the function and what _rtc_read()
function calls is configured with mbed-os configuration. You have to configure mbed-os and provide it with the configuration and compile with mbed-os.
Bottom line, there is no coupling. You have to make the coupling if you want it.
Upvotes: 0