SatCat5
cfgbus_timer.cc
1 // Copyright 2021-2024 The Aerospace Corporation.
3 // This file is a part of SatCat5, licensed under CERN-OHL-W v2 or later.
5 
6 #include <satcat5/cfgbus_timer.h>
7 #include <satcat5/polling.h>
8 
11 
12 u32 Timer::raw() {
13  return m_ctrl[REGADDR_PERF_CTR];
14 }
15 
17  return TimeVal {this, m_ctrl[REGADDR_LAST_EVT]};
18 }
19 
20 void Timer::timer_interval(unsigned usec) {
21  m_ctrl[REGADDR_TIMER_LEN] = usec * ticks_per_usec() - 1;
22 }
23 
25  m_callback = callback;
26 }
27 
29  m_ctrl[REGADDR_WDOG] = WDOG_PAUSE;
30 }
31 
32 void Timer::wdog_update(u32 usec) {
33  m_ctrl[REGADDR_WDOG] = usec * ticks_per_usec();
34 }
35 
37  if (m_callback) m_callback->request_poll();
38 }
Driver for the ConfigBus timer.
ConfigBus Timer driver.
Definition: cfgbus_timer.h:25
satcat5::util::TimeVal last_event()
Read timestamp of the last external event signal.
Definition: cfgbus_timer.cc:16
void timer_interval(unsigned usec)
Change the timer-interrupt interval.
Definition: cfgbus_timer.cc:20
void wdog_disable()
Disable the hardware watchdog function.
Definition: cfgbus_timer.cc:28
void timer_callback(satcat5::poll::OnDemand *callback)
Set the callback for timer-interrupt notifications.
Definition: cfgbus_timer.cc:24
void irq_event() override
Interrupt service routine.
Definition: cfgbus_timer.cc:36
void wdog_update(u32 usec)
Resume or reset the watchdog countdown.
Definition: cfgbus_timer.cc:32
An "OnDemand" object is polled only on request.
Definition: polling.h:131
void request_poll()
Call this method to request polling at a later time.
Definition: polling.cc:208
u32 ticks_per_usec() const
Stable accessors for unit conversion.
Definition: timeref.h:181
Core event-processing loop for SatCat5 software.
Timestamp for measuring elapsed time.
Definition: timeref.h:48