usb_serial: Renamed the debug FIFO buffer and variables

This commit is contained in:
dragonmux 2022-08-21 15:41:39 +01:00 committed by Piotr Esden-Tempski
parent 39f1604ef0
commit 7779ab36fb
1 changed files with 11 additions and 14 deletions

View File

@ -75,12 +75,9 @@ static bool aux_serial_receive_complete = true;
*/ */
void initialise_monitor_handles(void); void initialise_monitor_handles(void);
/* Debug Fifo buffer with space for copy fn overrun */ static char debug_serial_debug_buffer[AUX_UART_BUFFER_SIZE];
char usb_dbg_buf[AUX_UART_BUFFER_SIZE]; static uint8_t debug_serial_debug_write_index;
/* Debug Fifo in pointer */ static uint8_t debug_serial_debug_read_index;
uint8_t usb_dbg_in;
/* Debug Fifo out pointer */
uint8_t usb_dbg_out;
#endif #endif
static enum usbd_request_return_codes gdb_uart_control_request(usbd_device *dev, struct usb_setup_data *req, static enum usbd_request_return_codes gdb_uart_control_request(usbd_device *dev, struct usb_setup_data *req,
@ -225,7 +222,7 @@ uint32_t debug_serial_fifo_send(const char *const fifo, const uint32_t fifo_begi
#ifdef ENABLE_DEBUG #ifdef ENABLE_DEBUG
static bool debug_serial_fifo_buffer_empty(void) static bool debug_serial_fifo_buffer_empty(void)
{ {
return usb_dbg_in == usb_dbg_out; return debug_serial_debug_write_index == debug_serial_debug_read_index;
} }
#endif #endif
@ -246,13 +243,13 @@ static void debug_uart_send_aux_serial_data(void)
#endif #endif
)) { )) {
#ifdef ENABLE_DEBUG #ifdef ENABLE_DEBUG
usb_dbg_out = usb_dbg_in; debug_serial_debug_read_index = debug_serial_debug_write_index;
#endif #endif
aux_serial_drain_receive_buffer(); aux_serial_drain_receive_buffer();
aux_serial_receive_complete = true; aux_serial_receive_complete = true;
} else { } else {
#ifdef ENABLE_DEBUG #ifdef ENABLE_DEBUG
usb_dbg_out = debug_serial_fifo_send(usb_dbg_buf, usb_dbg_out, usb_dbg_in); debug_serial_debug_read_index = debug_serial_fifo_send(debug_serial_debug_buffer, debug_serial_debug_read_index, debug_serial_debug_write_index);
#endif #endif
aux_serial_stage_receive_buffer(); aux_serial_stage_receive_buffer();
} }
@ -275,9 +272,9 @@ void debug_uart_run(void)
#ifdef ENABLE_DEBUG #ifdef ENABLE_DEBUG
static void debug_serial_append_char(const char c) static void debug_serial_append_char(const char c)
{ {
usb_dbg_buf[usb_dbg_in] = c; debug_serial_debug_buffer[debug_serial_debug_write_index] = c;
++usb_dbg_in; ++debug_serial_debug_write_index;
usb_dbg_in %= AUX_UART_BUFFER_SIZE; debug_serial_debug_write_index %= AUX_UART_BUFFER_SIZE;
} }
size_t debug_uart_write(const char *buf, const size_t len) size_t debug_uart_write(const char *buf, const size_t len)
@ -287,11 +284,11 @@ size_t debug_uart_write(const char *buf, const size_t len)
CM_ATOMIC_CONTEXT(); CM_ATOMIC_CONTEXT();
for (size_t i = 0; i < len && (usb_dbg_in + 1) % AUX_UART_BUFFER_SIZE != usb_dbg_out; ++i) { for (size_t i = 0; i < len && (debug_serial_debug_write_index + 1) % AUX_UART_BUFFER_SIZE != debug_serial_debug_read_index; ++i) {
if (buf[i] == '\n') { if (buf[i] == '\n') {
debug_serial_append_char('\r'); debug_serial_append_char('\r');
if ((usb_dbg_in + 1) % AUX_UART_BUFFER_SIZE == usb_dbg_out) if ((debug_serial_debug_write_index + 1) % AUX_UART_BUFFER_SIZE == debug_serial_debug_read_index)
break; break;
} }
debug_serial_append_char(buf[i]); debug_serial_append_char(buf[i]);