From 8e293b49489f8bb474e5128e8e831e540a65fee6 Mon Sep 17 00:00:00 2001 From: Vencislav Atanasov Date: Fri, 17 Jan 2025 01:05:10 +0200 Subject: [PATCH] serial: Add serial_tx_raw() function for sending raw bytes to the serial port serial_tx() can only be used for NULL-terminated strings, and also adds CR before every LF. Change-Id: I8c3eafa5bc152bb54abf4629ee76396dc1cb9b8c --- firmware/drivers/serial.c | 8 ++++++++ firmware/export/serial.h | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/firmware/drivers/serial.c b/firmware/drivers/serial.c index 0fab570fdc..70f395bc32 100644 --- a/firmware/drivers/serial.c +++ b/firmware/drivers/serial.c @@ -52,3 +52,11 @@ void serial_tx(const unsigned char * buf) } } } + +void serial_tx_raw(const unsigned char * buf, int len) +{ + for (int i = 0; i < len; i++) { + while (!tx_rdy()); + tx_writec(buf[i]); + } +} \ No newline at end of file diff --git a/firmware/export/serial.h b/firmware/export/serial.h index 8a4780c3f1..3ca0ce08a8 100644 --- a/firmware/export/serial.h +++ b/firmware/export/serial.h @@ -25,7 +25,8 @@ extern void serial_setup(void); extern void serial_bitrate(int rate); extern int remote_control_rx(void); -extern void serial_tx(const unsigned char *buf); +extern void serial_tx(const unsigned char * buf); +extern void serial_tx_raw(const unsigned char *buf, int len); extern void tx_writec(unsigned char c); extern int tx_rdy(void);