usbuart: Moved the debug FIFO buffer definitions into usb_serial.c

This commit is contained in:
dragonmux 2022-08-21 15:19:14 +01:00 committed by Piotr Esden-Tempski
parent a1e0a9c645
commit 9ca1b645bb
4 changed files with 23 additions and 27 deletions

View File

@ -306,18 +306,11 @@ void aux_serial_update_receive_buffer_fullness(void)
bool aux_serial_receive_has_data(void)
{
return
#ifdef ENABLE_DEBUG
usb_dbg_in != usb_dbg_out ||
#endif
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)
{
#ifdef ENABLE_DEBUG
usb_dbg_out = usb_dbg_in;
#endif
aux_serial_receive_read_index = aux_serial_receive_write_index;
/* Turn off LED */
usbuart_set_led_state(RX_LED_ACT, false);

View File

@ -74,6 +74,13 @@ static bool aux_serial_receive_complete = true;
* https://github.com/mirror/newlib-cygwin/blob/master/newlib/libc/sys/arm/syscalls.c#L115
*/
void initialise_monitor_handles(void);
/* Debug Fifo buffer with space for copy fn overrun */
char usb_dbg_buf[AUX_UART_BUFFER_SIZE];
/* Debug Fifo in pointer */
uint8_t usb_dbg_in;
/* Debug Fifo out pointer */
uint8_t usb_dbg_out;
#endif
static enum usbd_request_return_codes gdb_uart_control_request(usbd_device *dev, struct usb_setup_data *req,
@ -215,6 +222,13 @@ uint32_t debug_serial_fifo_send(const char *const fifo, const uint32_t fifo_begi
return fifo_begin;
}
#ifdef ENABLE_DEBUG
static bool debug_serial_fifo_has_data(void)
{
return usb_dbg_in != usb_dbg_out;
}
#endif
/*
* Runs deferred processing for AUX serial RX, draining RX FIFO by sending
* characters to host PC via the debug serial interface.
@ -226,7 +240,14 @@ 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_has_data()
#ifdef ENABLE_DEBUG
&& !debug_serial_fifo_has_data())
#endif
) {
#ifdef ENABLE_DEBUG
usb_dbg_out = usb_dbg_in;
#endif
aux_serial_drain_receive_buffer();
aux_serial_receive_complete = true;
} else {

View File

@ -39,15 +39,6 @@ uint32_t debug_serial_fifo_send(const char *const fifo, const uint32_t fifo_begi
#define USART_DMA_BUF_SIZE (1U << USART_DMA_BUF_SHIFT)
#define AUX_UART_BUFFER_SIZE (USART_DMA_BUF_SIZE)
#ifdef ENABLE_DEBUG
/* Debug Fifo buffer with space for copy fn overrun */
extern char usb_dbg_buf[AUX_UART_BUFFER_SIZE];
/* Debug Fifo in pointer */
extern uint8_t usb_dbg_in;
/* Debug Fifo out pointer */
extern uint8_t usb_dbg_out;
#endif
#elif defined(LM4F)
#define AUX_UART_BUFFER_SIZE 128
#endif

View File

@ -31,12 +31,3 @@
#include "usbuart.h"
#include "usb.h"
#include "aux_serial.h"
#ifdef ENABLE_DEBUG
/* Debug Fifo buffer with space for copy fn overrun */
char usb_dbg_buf[AUX_UART_BUFFER_SIZE];
/* Debug Fifo in pointer */
uint8_t usb_dbg_in;
/* Debug Fifo out pointer */
uint8_t usb_dbg_out;
#endif