Add support for UART1

This commit is contained in:
Samuel Sadok
2020-09-24 19:59:14 +02:00
parent e0c34a66a4
commit e7f046d518
9 changed files with 103 additions and 43 deletions
+4 -3
View File
@@ -22,8 +22,7 @@ static uint32_t dma_last_rcv_idx;
// static thread_local uint32_t deadline_ms = 0;
osThreadId uart_thread = 0;
extern UART_HandleTypeDef* uart0;
static UART_HandleTypeDef* huart_ = uart0; // defined in board.cpp.
static UART_HandleTypeDef* huart_ = nullptr;
const uint32_t stack_size_uart_thread = 4096; // Bytes
@@ -102,7 +101,9 @@ static void uart_server_thread(void * ctx) {
}
// TODO: allow multiple UART server instances
void start_uart_server() {
void start_uart_server(UART_HandleTypeDef* huart) {
huart_ = huart;
// DMA is set up to receive in a circular buffer forever.
// We dont use interrupts to fetch the data, instead we periodically read
// data out of the circular buffer into a parse buffer, controlled by a state machine