Loading...
Searching...
No Matches
RP2040FifoClass Class Reference

Passes 32-bit values between the two cores: rp2040.fifo. More...

#include <RP2040.h>

Public Member Functions

void push (uint32_t value)
 Sends a value to the other core, waiting while its queue is full.
bool push_nb (uint32_t value)
 Sends a value to the other core if there is room, without waiting.
uint32_t pop ()
 Takes the next value sent by the other core, waiting until there is one.
bool pop_nb (uint32_t *value)
 Takes the next value sent by the other core if there is one, without waiting.
int available ()
 Number of values the other core has sent that this core has not popped yet.

Static Public Attributes

static constexpr unsigned kDepth = 16
 Values each direction can hold before push() waits.

Detailed Description

Passes 32-bit values between the two cores: rp2040.fifo.

There is one queue for each direction: a value pushed on core 0 is popped on core 1, and the other way round. Each queue holds kDepth values. A value can be a number or a pointer cast to uint32_t.

This is a queue in RAM, not the RP2040's hardware FIFO, which the core uses to stop the other core (idleOtherCore()) and FreeRTOS uses for scheduling. Do not use the SDK's multicore_fifo_*() functions in a sketch.

With FreeRTOS, "this core" is the core the calling task runs on: use the FIFO from loop() and loop1() (each pinned to its core) or from tasks pinned with vTaskCoreAffinitySet(). A task waiting in push() or pop() is blocked, so other tasks run meanwhile.

Member Function Documentation

◆ available()

int RP2040FifoClass::available ( )

Number of values the other core has sent that this core has not popped yet.

Returns
0 to kDepth.

◆ pop()

uint32_t RP2040FifoClass::pop ( )

Takes the next value sent by the other core, waiting until there is one.

Returns
The value.

◆ pop_nb()

bool RP2040FifoClass::pop_nb ( uint32_t * value)

Takes the next value sent by the other core if there is one, without waiting.

Parameters
valueSet to the value; unchanged if there is none.
Returns
true if a value was taken.

◆ push()

void RP2040FifoClass::push ( uint32_t value)

Sends a value to the other core, waiting while its queue is full.

Parameters
valueValue to send.

◆ push_nb()

bool RP2040FifoClass::push_nb ( uint32_t value)

Sends a value to the other core if there is room, without waiting.

Parameters
valueValue to send.
Returns
true if sent; false if the other core's queue is full.

The documentation for this class was generated from the following file: