32 const char TEST_STRING[] =
"Hello, world!\n";
33 const uint32_t BAUD_RATE = 115200;
41 Listener (
const uint32_t (&stack)[N])
51 char m_buffer[
sizeof(TEST_STRING)];
54 void error (
const PropWare::ErrorCode err);
64 uint32_t threadStack[256];
74 waitcnt(200 * MILLISECOND + CNT);
75 speaker.
puts(TEST_STRING);
79 void error (
const PropWare::ErrorCode err) {
85 debugLEDs.
write((uint32_t) err);
86 waitcnt(100 * MILLISECOND);
88 waitcnt(100 * MILLISECOND);
93 PropWare::ErrorCode err;
94 int32_t receivedLength;
100 receivedLength =
sizeof(this->m_buffer);
101 if ((err = this->m_listener.
fgets(this->m_buffer, &receivedLength)))
104 pwSyncOut.
printf(
"Data (%d chars): \"%s\"\n", receivedLength, this->m_buffer);
108 void Listener::init () {
112 memset(m_buffer, 0,
sizeof(m_buffer));
116 waitcnt(10 * MILLISECOND + CNT);
The PropWare::SimplePort is the recommended way to use data ports on the Propeller. All pins are consecutive, which allows for some simple shortcuts in reading, writing, and initialization.
static int8_t invoke(T &runnable)
Start a new cog running the given object.
void run()
Invoked in the new cog, this method should be the root of the business logic.
void puts(const char string[])
Send a null-terminated character array. Though this method could be created using put_char...
const PropWare::SynchronousPrinter pwSyncOut
Global and shared instance for easy printing to the terminal (thread safe)
PropWare::ErrorCode fgets(char string[], int32_t *bufferSize) const
Read words from the bus until a newline character (\\n) is received or the buffer is filled...
Simple wrapper for full duplex that provides half duplex capability.
void set_baud_rate(const int32_t baudRate)
Set the baud rate.
virtual void set_parity(const UART::Parity parity)
Set the parity configuration.
void write(uint32_t value) const
Allow easy writing to a port w/o destroying data elsewhere in the port; A shift is performed before w...
void printf(const char fmt[]) const
Helper class for creating easy parallel applications.
virtual void set_parity(const UART::Parity parity)
Set the parity configuration.
void set_rx_mask(const Port::Mask rx)
Set the pin mask for RX pin.
An easy-to-use class for simplex (transmit only) UART communication.