From 39f1604ef02c4cef57450be49766cc73f01879b7 Mon Sep 17 00:00:00 2001 From: dragonmux Date: Sun, 21 Aug 2022 15:30:46 +0100 Subject: [PATCH] usb_serial: Cleaned up a bit more in debug_uart_send_aux_serial_data() --- src/platforms/common/aux_serial.c | 4 ++-- src/platforms/common/aux_serial.h | 2 +- src/platforms/common/usb_serial.c | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/platforms/common/aux_serial.c b/src/platforms/common/aux_serial.c index 2cd79bd..ef679f1 100644 --- a/src/platforms/common/aux_serial.c +++ b/src/platforms/common/aux_serial.c @@ -304,9 +304,9 @@ void aux_serial_update_receive_buffer_fullness(void) aux_serial_receive_write_index %= AUX_UART_BUFFER_SIZE; } -bool aux_serial_receive_has_data(void) +bool aux_serial_receive_buffer_empty(void) { - return aux_serial_receive_write_index != aux_serial_receive_read_index; + return aux_serial_receive_write_index == aux_serial_receive_read_index; } void aux_serial_drain_receive_buffer(void) diff --git a/src/platforms/common/aux_serial.h b/src/platforms/common/aux_serial.h index d787e0c..40cee10 100644 --- a/src/platforms/common/aux_serial.h +++ b/src/platforms/common/aux_serial.h @@ -42,7 +42,7 @@ void aux_serial_send(size_t len); #if defined(STM32F0) || defined(STM32F1) || defined(STM32F3) || defined(STM32F4) void aux_serial_update_receive_buffer_fullness(void); -bool aux_serial_receive_has_data(void); +bool aux_serial_receive_buffer_empty(void); void aux_serial_drain_receive_buffer(void); #ifdef ENABLE_DEBUG void aux_serial_stage_debug_buffer(void); diff --git a/src/platforms/common/usb_serial.c b/src/platforms/common/usb_serial.c index 53c7c07..7d55d4a 100644 --- a/src/platforms/common/usb_serial.c +++ b/src/platforms/common/usb_serial.c @@ -223,9 +223,9 @@ uint32_t debug_serial_fifo_send(const char *const fifo, const uint32_t fifo_begi } #ifdef ENABLE_DEBUG -static bool debug_serial_fifo_has_data(void) +static bool debug_serial_fifo_buffer_empty(void) { - return usb_dbg_in != usb_dbg_out; + return usb_dbg_in == usb_dbg_out; } #endif @@ -240,11 +240,11 @@ static void debug_uart_send_aux_serial_data(void) /* Forcibly empty fifo if no USB endpoint. * If fifo empty, nothing further to do. */ - if (usb_get_config() != 1 || (!aux_serial_receive_has_data() + if (usb_get_config() != 1 || (aux_serial_receive_buffer_empty() #ifdef ENABLE_DEBUG - && !debug_serial_fifo_has_data()) + && debug_serial_fifo_buffer_empty() #endif - ) { + )) { #ifdef ENABLE_DEBUG usb_dbg_out = usb_dbg_in; #endif