Write "Hello world!" out via UART protocol
cmake_minimum_required(VERSION 3.12)
project(SimplexUART_Demo C CXX ASM)
create_simple_executable(${PROJECT_NAME} UARTTX_Demo.cpp)
static void error (const PropWare::ErrorCode err);
static const int32_t BAUD_RATE = 115200;
static const int32_t DELAY = 200;
PropWare::ErrorCode err;
UARTTX uart;
uint8_t numberPattern[] = {
0x01,
0x02,
0x03,
0x45,
0xe5,
0xaa,
0xff,
0x80,
0x00 };
char string[] = "Hello world! This is my most favoritest sentence ever!!!\r\n";
uart.set_baud_rate(BAUD_RATE);
if ((err = uart.set_data_width(8)))
error(err);
if ((err = uart.set_stop_bit_width(1)))
error(err);
uart.set_parity(UART::Parity::NO_PARITY);
while (1) {
uart.send_array((char *) numberPattern, sizeof(numberPattern));
uart.puts(string);
}
}
void error (const PropWare::ErrorCode err) {
SimplePort debugLEDs(Port::P16, 8, Pin::Dir::OUT);
while (1) {
debugLEDs.write((uint32_t) err);
debugLEDs.write(0);
}
}