From 70e24f42033226b9fb0907c6f0bb369cf546b514 Mon Sep 17 00:00:00 2001 From: dragonmux Date: Thu, 18 Aug 2022 23:33:08 +0100 Subject: [PATCH] usb_serial: Moved usbuart_send_stdout() into the usb_serial code --- src/platforms/common/usb_serial.c | 15 +++++++++++++++ src/platforms/stm32/usbuart.c | 14 -------------- src/platforms/tm4c/usbuart.c | 14 -------------- 3 files changed, 15 insertions(+), 28 deletions(-) diff --git a/src/platforms/common/usb_serial.c b/src/platforms/common/usb_serial.c index 6f7439d..b8c48de 100644 --- a/src/platforms/common/usb_serial.c +++ b/src/platforms/common/usb_serial.c @@ -46,6 +46,7 @@ #endif #include "usbuart.h" +#include #include static bool gdb_uart_dtr = true; @@ -170,3 +171,17 @@ void usb_serial_set_config(usbd_device *dev, uint16_t value) initialise_monitor_handles(); #endif } + +void usbuart_send_stdout(const uint8_t *data, uint32_t len) +{ + while (len) { + uint32_t cnt = CDCACM_PACKET_SIZE; + if (cnt > len) + cnt = len; + nvic_disable_irq(USB_IRQ); + cnt = usbd_ep_write_packet(usbdev, CDCACM_UART_ENDPOINT, data, cnt); + nvic_enable_irq(USB_IRQ); + data += cnt; + len -= cnt; + } +} diff --git a/src/platforms/stm32/usbuart.c b/src/platforms/stm32/usbuart.c index f1e98de..1f37f86 100644 --- a/src/platforms/stm32/usbuart.c +++ b/src/platforms/stm32/usbuart.c @@ -192,20 +192,6 @@ void aux_serial_init(void) usart_enable_rx_dma(USBUSART); } -void usbuart_send_stdout(const uint8_t *data, uint32_t len) -{ - while (len) { - uint32_t cnt = CDCACM_PACKET_SIZE; - if (cnt > len) - cnt = len; - nvic_disable_irq(USB_IRQ); - cnt = usbd_ep_write_packet(usbdev, CDCACM_UART_ENDPOINT, data, cnt); - nvic_enable_irq(USB_IRQ); - data += cnt; - len -= cnt; - } -} - void usbuart_set_line_coding(struct usb_cdc_line_coding *coding) { usart_set_baudrate(USBUSART, coding->dwDTERate); diff --git a/src/platforms/tm4c/usbuart.c b/src/platforms/tm4c/usbuart.c index 3fcf3b2..f598363 100644 --- a/src/platforms/tm4c/usbuart.c +++ b/src/platforms/tm4c/usbuart.c @@ -76,20 +76,6 @@ void aux_serial_init(void) nvic_enable_irq(USBUART_IRQ); } -void usbuart_send_stdout(const uint8_t *data, uint32_t len) -{ - while (len) { - uint32_t cnt = CDCACM_PACKET_SIZE; - if (cnt > len) - cnt = len; - nvic_disable_irq(USBUART_IRQ); - cnt = usbd_ep_write_packet(usbdev, CDCACM_UART_ENDPOINT, data, cnt); - nvic_enable_irq(USBUART_IRQ); - data += cnt; - len -= cnt; - } -} - void usbuart_set_line_coding(struct usb_cdc_line_coding *coding) { uart_set_baudrate(USBUART, coding->dwDTERate);