Run code in a total of four cogs. Two of them will simply blink LEDs. The other two demonstrate a thread-safe way to use a serial terminal simultaneously from two different cogs.
cmake_minimum_required(VERSION 3.12)
project(Runnable_Demo)
create_simple_executable(${PROJECT_NAME} Runnable_Demo.cpp)
public:
template<size_t N>
: Runnable(stack) {
}
while (1) {
}
}
};
public:
template<size_t N>
: Runnable(stack),
m_mask(mask) {
}
const Pin pin(this->m_mask, Pin::Dir::OUT);
while (1) {
pin.toggle();
}
}
private:
const Pin::Mask m_mask;
};
int main(
int argc,
char *argv[]) {
uint32_t stack[3][70];
int8_t cog = Runnable::invoke(talkingThread);
pwSyncOut.
printf(
"Talking thread (0x%08X) started in cog %d\n", (
unsigned int) &talkingThread, cog);
cog = Runnable::invoke(blink16);
pwSyncOut.
printf(
"Blink16 thread (0x%08X) started in cog %d\n", (
unsigned int) &blink16, cog);
cog = Runnable::invoke(blink17);
pwSyncOut.
printf(
"Blink17 thread (0x%08X) started in cog %d\n", (
unsigned int) &blink17, cog);
while (1) {
}
}