Demonstrate multiple cogs printing to the same serial terminal simultaneously
cmake_minimum_required(VERSION 3.12)
project(SynchronousPrinter_Demo)
create_simple_executable(${PROJECT_NAME} SynchronousPrinter_Demo.cpp)
static const uint16_t COGS = 8;
static const uint16_t STACK_SIZE = 128;
static const unsigned int DELAY_IN_SECONDS = 2;
static const uint32_t WAIT_TIME = DELAY_IN_SECONDS * SECOND;
public:
template<size_t N>
: Runnable(stack) {
}
const Port::Mask pinMaskOfCogId = (Port::Mask) (1 << (
cogid() + 16));
uint32_t nextCnt;
nextCnt = WAIT_TIME +
CNT;
while (1) {
Pin::flash_pin(pinMaskOfCogId, 3);
}
}
};
int main(
int argc,
char *argv[]) {
const uint32_t stacks[COGS][STACK_SIZE] = {{0}};
};
while (1)
Port::flash_port(PropWare::BYTE_2, PropWare::BYTE_2);
for (uint8_t n = 1; n < COGS; n++)
Runnable::invoke(syncedPrinterCogs[n]);
syncedPrinterCogs[0].
run();
}