Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
print.h
1/*
2 * Copyright © 2015-2023 Synthstrom Audible Limited
3 *
4 * This file is part of The Synthstrom Audible Deluge Firmware.
5 *
6 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software Foundation,
8 * either version 3 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with this program.
15 * If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include <cstdint>
21
22class MIDICable;
23
24namespace Debug {
25const uint32_t sec = 400000000;
26const uint32_t mS = 400000;
27const uint32_t uS = 400;
28
29[[gnu::always_inline]] inline uint32_t readCycleCounter() {
30 uint32_t cycles = 0;
31 asm volatile("MRC p15, 0, %0, c9, c13, 0" : "=r"(cycles) :);
32 return cycles;
33}
34
35[[gnu::always_inline]] inline void readCycleCounter(uint32_t& time) {
36 asm volatile("MRC p15, 0, %0, c9, c13, 0" : "=r"(time) :);
37}
38
39void init();
40void print(char const* output);
41void println(char const* output);
42void println(int32_t number);
43void printlnfloat(float number);
44void printfloat(float number);
45void print(int32_t number);
46void ResetClock();
47
48class RTimer {
49public:
50 RTimer(const char* label);
51 ~RTimer();
52
53 virtual void reset();
54 virtual void stop();
55 virtual void stop(const char* stopLabel);
56 virtual void stop(int number);
57
58 uint32_t startTime;
59 const char* m_label;
60 bool stopped;
61};
62
63class Averager {
64public:
65 Averager(const char* label, uint32_t repeats = 0);
66
67 void setCount(uint32_t repeats);
68 void note(int32_t val);
69 void setN(uint32_t numRepeats);
70
71 const char* m_label;
72 int64_t accumulator;
73 uint32_t N;
74 uint32_t c;
75};
76
77class OneOfN {
78public:
79 OneOfN(const char* label, uint32_t repeats = 0);
80
81 void start();
82 void stop();
83
84 void split(const char* splitLabel);
85 void setN(uint32_t numRepeats);
86
87 bool active;
88 uint32_t N;
89 uint32_t c;
90 RTimer myRTimer;
91};
92
93class OnceEvery {
94public:
95 OnceEvery(const char* label, uint32_t timeBase);
96
97 void start();
98 void stop();
99
100 void split(const char* splitLabel);
101
102 bool active;
103 uint32_t timeBase;
104 uint32_t t0;
105 RTimer myRTimer;
106};
107
108class CountsPer {
109public:
110 CountsPer(const char* label, uint32_t timeBase);
111 void bump(uint32_t by = 1);
112 void clear();
113 const char* label;
114 uint32_t timeBase;
115 bool active;
116 uint32_t count;
117 uint32_t t0;
118};
119
120class AverageDT {
121public:
122 AverageDT(const char* label, uint32_t timeBase, uint32_t scaling = 1);
123 void begin();
124 void note();
125 void clear();
126 const char* label;
127 uint32_t timeBase;
128 bool active;
129 uint32_t scaling;
130 int64_t accumulator;
131 uint32_t count;
132 uint32_t t0;
133 uint32_t tnm1;
134};
135
136class AverageVOT {
137 AverageVOT(const char* label, uint32_t timeBase);
138 void note(uint32_t value);
139 void clear();
140 const char* label;
141 uint32_t timeBase;
142 bool active;
143 int64_t accumulator;
144 uint32_t count;
145 uint32_t t0;
146};
147
148extern MIDICable* midiDebugCable;
149} // namespace Debug
Definition print.h:48
A MIDI cable connection. Stores all state specific to a given cable and its contained ports and chann...
Definition midi_device.h:94