uC chip interface arduino  0.9.0
A interface for async and neuromrphic IC testing
Loading...
Searching...
No Matches
core_intervaltimer_samd21.h
Go to the documentation of this file.
1/*
2 This file is part of the Firmware project to interface with small Async or Neuromorphic chips
3 Copyright (C) 2023 Ole Richter - University of Groningen
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>.
17*/
18
19#if defined(ARDUINO_ARCH_SAMD)
20// hardcoded to 48MHz should check via F_CPU flag
21#ifndef INTERVALTIMER_H
22#define INTERVALTIMER_H
23#define INTERVALTIMER_MAX_TIMERS 2
24#include <Arduino.h>
25
26typedef void (*callfunction_t) ();
27
40class IntervalTimer {
41 public:
42 IntervalTimer() {
43 counter_id = INTERVALTIMER_MAX_TIMERS;
44 last_period = 100U;
45 last_priority = 3U;
46 }
47 ~IntervalTimer() {end();}
48
58 bool begin(callfunction_t callback, uint32_t usec) volatile;
63 void update(uint32_t usec) volatile;
68 void end() volatile;
75 void priority(uint8_t priority) volatile;
76
80 static callfunction_t _TC5_callfunc;
81
85 static callfunction_t _TC4_callfunc;
86
87 private:
88 //static TcCount16* TC[INTERVALTIMER_MAX_TIMERS];
92 static bool counter_active[INTERVALTIMER_MAX_TIMERS];
93
97 uint8_t counter_id;
98
102 uint32_t last_period;
103
107 uint8_t last_priority;
108
109 bool init_ran;
110
111};
112/*
113Interrupt Service Routine for TC4
114for use by class
115*/
116extern void TC4_Handler();
117/*
118Interrupt Service Routine for TC5
119for use by class
120*/
121extern void TC5_Handler();
122
123#endif
124#endif