From 5e25bc891edf0e63e816db8ac608be690ad75a35 Mon Sep 17 00:00:00 2001 From: Rahix <rahix@rahix.de> Date: Fri, 4 Oct 2019 13:02:30 +0200 Subject: [PATCH] feat(serial): Add function to switch serial to synchronous In severe error conditions, asynchronous prints will never work. For such cases we need a way to make prints happen synchronously again, the same way it works during early boot. Add a serial_return_to_synchronous() function which unconditionally switches the serial driver code to synchronous mode. Only use this function in unrecoverable error conditions! Signed-off-by: Rahix <rahix@rahix.de> --- epicardium/modules/modules.h | 2 ++ epicardium/modules/serial.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/epicardium/modules/modules.h b/epicardium/modules/modules.h index d5087864..465c78a4 100644 --- a/epicardium/modules/modules.h +++ b/epicardium/modules/modules.h @@ -31,6 +31,8 @@ void vSerialTask(void *pvParameters); void serial_enqueue_char(char chr); void serial_flush(void); extern TaskHandle_t serial_task_id; +/* Turn off the print queue and do prints synchroneous from now on. */ +void serial_return_to_synchronous(); // For the eSetBit xTaskNotify task semaphore trigger enum serial_notify{ diff --git a/epicardium/modules/serial.c b/epicardium/modules/serial.c index 396d628d..ef5b65ed 100644 --- a/epicardium/modules/serial.c +++ b/epicardium/modules/serial.c @@ -46,6 +46,11 @@ void serial_init() ); } +void serial_return_to_synchronous() +{ + write_stream_buffer = NULL; +} + /* * API-call to write a string. Output goes to both CDCACM and UART */ -- GitLab