From 327e3b08ecc1e58bc7fd84159c5edd381332b3e3 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Thu, 10 Dec 2020 23:48:55 -0800 Subject: [PATCH] actually do it --- firmware/uart.cpp | 36 ++++++++++++++++++++++++++++++++++++ firmware/uart.h | 3 +++ 2 files changed, 39 insertions(+) create mode 100644 firmware/uart.cpp create mode 100644 firmware/uart.h diff --git a/firmware/uart.cpp b/firmware/uart.cpp new file mode 100644 index 0000000..b344937 --- /dev/null +++ b/firmware/uart.cpp @@ -0,0 +1,36 @@ +#include "ch.h" +#include "hal.h" +#include "chprintf.h" + +#include "uart.h" + +static const UARTConfig uartCfg = +{ + .txend1_cb = nullptr, + .txend2_cb = nullptr, + .rxend_cb = nullptr, + .rxchar_cb = nullptr, + .rxerr_cb = nullptr, + .timeout_cb = nullptr, + + .timeout = 0, + .speed = 500000, + .cr1 = 0, + .cr2 = 0, + .cr3 = 0, +}; + +static char printBuffer[200]; + +static THD_WORKING_AREA(waUartThread, 256); +static void UartThread(void*) +{ + +} + +void InitUart() +{ + uartStart(&UARTD1, &uartCfg); + + chThdCreateStatic(waUartThread, sizeof(waUartThread), NORMALPRIO, UartThread, nullptr); +} diff --git a/firmware/uart.h b/firmware/uart.h new file mode 100644 index 0000000..42637f4 --- /dev/null +++ b/firmware/uart.h @@ -0,0 +1,3 @@ +#pragma once + +void InitUart();