Loading...
Searching...
No Matches
RP2040.h
Go to the documentation of this file.
1
14#pragma once
15
16#include <stddef.h>
17#include <stdint.h>
18
19#include "pico/util/queue.h"
20
39public:
41 static constexpr unsigned kDepth = 16;
42
47 void push(uint32_t value);
48
54 bool push_nb(uint32_t value);
55
60 uint32_t pop();
61
67 bool pop_nb(uint32_t* value);
68
73 int available();
74
76 void begin();
77
78private:
79 queue_t queues_[2]; // queues_[c] holds the values sent to core c
80 bool started_ = false;
81};
82
88public:
91
106
109
117
122 int cpuid();
123
128 uint32_t f_cpu();
129
135
141
148
149private:
150 bool idling_other_ = false;
151};
152
155extern RP2040Class rp2040;
156
157extern "C" {
165void setup1(void) __attribute__((weak));
166
171void loop1(void) __attribute__((weak));
172}
The second core and the chip: rp2040.
Definition RP2040.h:87
void resumeOtherCore()
Lets the core stopped by idleOtherCore() carry on. Does nothing if none is stopped.
void idleOtherCore()
Stops the other core until resumeOtherCore(), and returns once it has stopped.
void restartCore1()
Resets core 1 and starts it again from setup1().
int getTotalHeap()
Size of the heap (memory for new, malloc(), String and, with FreeRTOS, tasks and queues).
int getFreeHeap()
Heap memory still free: getTotalHeap() - getUsedHeap().
uint32_t f_cpu()
CPU clock (Tools > CPU Speed).
int getUsedHeap()
Heap memory in use.
RP2040FifoClass fifo
Inter-core FIFO: see RP2040FifoClass.
Definition RP2040.h:90
int cpuid()
Which core the calling code runs on.
Passes 32-bit values between the two cores: rp2040.fifo.
Definition RP2040.h:38
bool push_nb(uint32_t value)
Sends a value to the other core if there is room, without waiting.
void push(uint32_t value)
Sends a value to the other core, waiting while its queue is full.
static constexpr unsigned kDepth
Values each direction can hold before push() waits.
Definition RP2040.h:41
uint32_t pop()
Takes the next value sent by the other core, waiting until there is one.
int available()
Number of values the other core has sent that this core has not popped yet.
bool pop_nb(uint32_t *value)
Takes the next value sent by the other core if there is one, without waiting.
void setup1(void) __attribute__((weak))
Written by the sketch (optional): runs once on core 1, at the same time as setup() on core 0.
RP2040Class rp2040
void loop1(void) __attribute__((weak))
Written by the sketch (optional): runs over and over on core 1 after setup1().