mirror of https://github.com/ARMmbed/mbed-os.git
Made attach_rtc with disabled irqs
parent
f0d04f5360
commit
4a184d980e
|
|
@ -70,6 +70,8 @@ extern "C" {
|
|||
void set_time(time_t t);
|
||||
|
||||
/** Attach an external RTC to be used for the C time functions
|
||||
*
|
||||
* Do not call this function from an interrupt while an RTC read/write operation may be occurring
|
||||
*
|
||||
* @param read_rtc pointer to function which returns current UNIX timestamp
|
||||
* @param write_rtc pointer to function which sets current UNIX timestamp, can be NULL
|
||||
|
|
|
|||
|
|
@ -47,11 +47,9 @@ time_t time(time_t *timer)
|
|||
}
|
||||
}
|
||||
|
||||
time_t t;
|
||||
time_t t = 0;
|
||||
if (_rtc_read != NULL) {
|
||||
t = _rtc_read();
|
||||
} else {
|
||||
t = 0;
|
||||
}
|
||||
|
||||
if (timer != NULL) {
|
||||
|
|
@ -76,10 +74,12 @@ clock_t clock() {
|
|||
}
|
||||
|
||||
void attach_rtc(time_t (*read_rtc)(void), void (*write_rtc)(time_t), void (*init_rtc)(void), int (*isenabled_rtc)(void)) {
|
||||
__disable_irq();
|
||||
_rtc_read = read_rtc;
|
||||
_rtc_write = write_rtc;
|
||||
_rtc_init = init_rtc;
|
||||
_rtc_isenabled = isenabled_rtc;
|
||||
__enable_irq();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue