|
23 | 23 | static SingletonPtr<PlatformMutex> _mutex;
|
24 | 24 |
|
25 | 25 | #if DEVICE_RTC
|
| 26 | + |
26 | 27 | static void (*_rtc_init)(void) = rtc_init;
|
27 | 28 | static int (*_rtc_isenabled)(void) = rtc_isenabled;
|
28 | 29 | static time_t (*_rtc_read)(void) = rtc_read;
|
29 | 30 | static void (*_rtc_write)(time_t t) = rtc_write;
|
30 |
| -#else |
| 31 | + |
| 32 | +#elif DEVICE_LOWPOWERTIMER |
| 33 | + |
| 34 | +#include "drivers/LowPowerTimer.h" |
| 35 | + |
| 36 | +static SingletonPtr<mbed::LowPowerTimer> _rtc_lp_timer; |
| 37 | +static uint64_t _rtc_lp_base; |
| 38 | +static bool _rtc_enabled; |
| 39 | + |
| 40 | +static void _rtc_lpticker_init(void) |
| 41 | +{ |
| 42 | + _rtc_lp_timer->start(); |
| 43 | + _rtc_enabled = true; |
| 44 | +} |
| 45 | + |
| 46 | +static int _rtc_lpticker_isenabled(void) |
| 47 | +{ |
| 48 | + return (_rtc_enabled == true); |
| 49 | +} |
| 50 | + |
| 51 | +static time_t _rtc_lpticker_read(void) |
| 52 | +{ |
| 53 | + return (uint64_t)_rtc_lp_timer->read() + _rtc_lp_base; |
| 54 | +} |
| 55 | + |
| 56 | +static void _rtc_lpticker_write(time_t t) |
| 57 | +{ |
| 58 | + _rtc_lp_base = t; |
| 59 | +} |
| 60 | + |
| 61 | +static void (*_rtc_init)(void) = _rtc_lpticker_init; |
| 62 | +static int (*_rtc_isenabled)(void) = _rtc_lpticker_isenabled; |
| 63 | +static time_t (*_rtc_read)(void) = _rtc_lpticker_read; |
| 64 | +static void (*_rtc_write)(time_t t) = _rtc_lpticker_write; |
| 65 | + |
| 66 | +#else /* DEVICE_LOWPOWERTIMER */ |
| 67 | + |
31 | 68 | static void (*_rtc_init)(void) = NULL;
|
32 | 69 | static int (*_rtc_isenabled)(void) = NULL;
|
33 | 70 | static time_t (*_rtc_read)(void) = NULL;
|
34 | 71 | static void (*_rtc_write)(time_t t) = NULL;
|
35 |
| -#endif |
| 72 | +#endif /* DEVICE_LOWPOWERTIMER */ |
36 | 73 |
|
37 | 74 | #ifdef __cplusplus
|
38 | 75 | extern "C" {
|
|
0 commit comments