Huge refactoring for C++ and low-power mode
The display currently shows the time, with hours and minutes, and is capable of receiving input with buttons (though does nothing). It sleeps during intervals where nothing is happening. The display task runs once per second, and RTC alarm A is used for periodic alarms to update the system time.
This commit is contained in:
26
SystemTime.h
26
SystemTime.h
@@ -30,24 +30,20 @@
|
||||
|
||||
namespace BSP {
|
||||
|
||||
class SystemTimer {
|
||||
class SystemTimerImpl {
|
||||
public:
|
||||
static Common::ReturnCode init(RTC_TypeDef *rtc);
|
||||
virtual Common::time_t get_time() = 0;
|
||||
};
|
||||
|
||||
class SystemTimer final {
|
||||
public:
|
||||
SystemTimer() = delete;
|
||||
~SystemTimer() = delete;
|
||||
|
||||
static Common::ReturnCode get_time(Common::time_t &time);
|
||||
static void increment_seconds();
|
||||
static void set_timer(SystemTimerImpl& timer);
|
||||
private:
|
||||
|
||||
static Common::ReturnCode init_hw();
|
||||
static void enable_rtc_write();
|
||||
static void disable_rtc_write();
|
||||
static void enable_rtc_wakeup_interrupt();
|
||||
|
||||
static constexpr uint32_t LSE_CLOCK_FREQ = 32768;
|
||||
|
||||
/** I'll be dead before this rolls over */
|
||||
/** FIXME FIXME FIXME: XXX This should be an atomic */
|
||||
static uint32_t m_seconds;
|
||||
static RTC_TypeDef *m_rtc;
|
||||
static SystemTimerImpl *m_impl;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user