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.3)
project(Runnable_Demo)
create_simple_executable(${PROJECT_NAME} Runnable_Demo.cpp)
public:
template<size_t N>
: Runnable(stack) {
}
while (1) {
pwSyncOut.
printf(
"Hello from cog %u (0x%08X)! %u\n", cogid(), (
unsigned int)
this, CNT);
waitcnt(250 * MILLISECOND + CNT);
}
}
};
public:
template<size_t N>
: Runnable(stack),
m_mask(mask) {
}
while (1) {
waitcnt(250 * MILLISECOND + CNT);
}
}
private:
};
int main(
int argc,
char *argv[]) {
uint32_t stack[3][70];
pwSyncOut.
printf(
"Talking thread (0x%08X) started in cog %d\n", (
unsigned int) &talkingThread, cog);
pwSyncOut.
printf(
"Blink16 thread (0x%08X) started in cog %d\n", (
unsigned int) &blink16, cog);
pwSyncOut.
printf(
"Blink17 thread (0x%08X) started in cog %d\n", (
unsigned int) &blink17, cog);
while (1) {
waitcnt(250 * MILLISECOND + CNT);
}
}