Made attach_rtc with disabled irqs

pull/926/head
Sissors 2015-02-28 12:21:55 +01:00
parent f0d04f5360
commit 4a184d980e
2 changed files with 5 additions and 3 deletions

View File

@ -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

View File

@ -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();
}