18
18
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
19
*/
20
20
21
+ #pragma once
22
+
21
23
#include < hardware/clocks.h>
22
24
#include < hardware/irq.h>
23
25
#include < hardware/pio.h>
45
47
46
48
extern " C" volatile bool __otherCoreIdled;
47
49
50
+ extern " C" {
51
+ #ifdef __PROFILE
52
+ typedef int (*profileWriteCB)(const void *data, int len);
53
+ extern void _writeProfile (profileWriteCB writeCB);
54
+ #endif
55
+ }
56
+
48
57
class _MFIFO {
49
58
public:
50
59
_MFIFO () { /* noop */ };
@@ -180,7 +189,7 @@ class RP2040 {
180
189
181
190
void begin () {
182
191
_epoch = 0 ;
183
- #if !defined(__riscv)
192
+ #if !defined(__riscv) && !defined(__PROFILE)
184
193
if (!__isFreeRTOS) {
185
194
// Enable SYSTICK exception
186
195
exception_set_exclusive_handler (SYSTICK_EXCEPTION, _SystickHandler);
@@ -193,7 +202,7 @@ class RP2040 {
193
202
_ccountPgm->prepare (&_pio, &_sm, &off);
194
203
ccount_program_init (_pio, _sm, off);
195
204
pio_sm_set_enabled (_pio, _sm, true );
196
- #if !defined(__riscv)
205
+ #if !defined(__riscv) && !defined(__PROFILE)
197
206
}
198
207
#endif
199
208
}
@@ -217,7 +226,7 @@ class RP2040 {
217
226
// Get CPU cycle count. Needs to do magic to extens 24b HW to something longer
218
227
volatile uint64_t _epoch = 0 ;
219
228
inline uint32_t getCycleCount () {
220
- #if !defined(__riscv)
229
+ #if !defined(__riscv) && !defined(__PROFILE)
221
230
if (!__isFreeRTOS) {
222
231
uint32_t epoch;
223
232
uint32_t ctr;
@@ -229,13 +238,13 @@ class RP2040 {
229
238
} else {
230
239
#endif
231
240
return ccount_read (_pio, _sm);
232
- #if !defined(__riscv)
241
+ #if !defined(__riscv) && !defined(__PROFILE)
233
242
}
234
243
#endif
235
244
}
236
245
237
246
inline uint64_t getCycleCount64 () {
238
- #if !defined(__riscv)
247
+ #if !defined(__riscv) && !defined(__PROFILE)
239
248
if (!__isFreeRTOS) {
240
249
uint64_t epoch;
241
250
uint64_t ctr;
@@ -247,7 +256,7 @@ class RP2040 {
247
256
} else {
248
257
#endif
249
258
return ccount_read (_pio, _sm);
250
- #if !defined(__riscv)
259
+ #if !defined(__riscv) && !defined(__PROFILE)
251
260
}
252
261
#endif
253
262
}
@@ -473,6 +482,21 @@ class RP2040 {
473
482
#endif
474
483
}
475
484
485
+ #ifdef __PROFILE
486
+ void writeProfiling (Stream *f) {
487
+ extern Stream *__profileFile;
488
+ extern int __writeProfileCB (const void *data, int len);
489
+ __profileFile = f;
490
+ _writeProfile (__writeProfileCB);
491
+ }
492
+
493
+ size_t getProfileMemoryUsage () {
494
+ extern int __profileMemSize;
495
+ return (size_t ) __profileMemSize;
496
+ }
497
+ #endif
498
+
499
+
476
500
477
501
private:
478
502
static void _SystickHandler () {
0 commit comments