SatCat5
systick_timer.h
1 // Copyright 2024-2025 The Aerospace Corporation.
3 // This file is a part of SatCat5, licensed under CERN-OHL-W v2 or later.
5 // Microchip SAM V71 implementation of the "TimeRef" API.
6 
7 #pragma once
8 
9 #include <satcat5/timeref.h>
10 #include <satcat5/cfgbus_core.h>
11 #include <hal_samv71/interrupt_handler.h>
12 
13 namespace satcat5 {
14  namespace sam {
22  : public satcat5::util::TimeRef
24  public:
27  const u32 cpu_freq_hz,
28  const u32 tick_rate_hz);
29 
31  u32 raw() override;
32 
36 
37  protected:
38  // SysTick ISR
39  void irq_event() override;
40 
41  // SysTick Registers
42  u32* m_ctrl;
43 
44  // Tick Count
45  unsigned int m_tick_num = 0;
46 
47  // Callback Function
48  satcat5::poll::OnDemand* m_callback;
49  };
50  } // namespace sam
51 } // namespace satcat5
ConfigBus core definitions.
An "OnDemand" object is polled only on request.
Definition: polling.h:131
Interrupt handler interface for the Microchip SAM V71.
Microchip SAM V71 implementation of the "TimeRef" API.
Definition: systick_timer.h:23
u32 raw() override
Get raw tick-count,.
void irq_event() override
Method called whenever an interrupt is triggered.
SysTickTimer(const u32 cpu_freq_hz, const u32 tick_rate_hz)
Constructor requires the CPU frequency and timer tick-rate.
void timer_callback(satcat5::poll::OnDemand *callback)
Set callback for timer events.
The TimeRef API provides access to a monotonic time-counter.
Definition: timeref.h:142
TimeRef and TimeVal define the API for monotonic timers.