usb_serial: Moved usbuart_send_stdout() into the usb_serial code

This commit is contained in:
dragonmux 2022-08-18 23:33:08 +01:00 committed by Piotr Esden-Tempski
parent 099540cccb
commit 70e24f4203
3 changed files with 15 additions and 28 deletions

View File

@ -46,6 +46,7 @@
#endif #endif
#include "usbuart.h" #include "usbuart.h"
#include <libopencm3/cm3/nvic.h>
#include <libopencm3/usb/cdc.h> #include <libopencm3/usb/cdc.h>
static bool gdb_uart_dtr = true; static bool gdb_uart_dtr = true;
@ -170,3 +171,17 @@ void usb_serial_set_config(usbd_device *dev, uint16_t value)
initialise_monitor_handles(); initialise_monitor_handles();
#endif #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;
}
}

View File

@ -192,20 +192,6 @@ void aux_serial_init(void)
usart_enable_rx_dma(USBUSART); 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) void usbuart_set_line_coding(struct usb_cdc_line_coding *coding)
{ {
usart_set_baudrate(USBUSART, coding->dwDTERate); usart_set_baudrate(USBUSART, coding->dwDTERate);

View File

@ -76,20 +76,6 @@ void aux_serial_init(void)
nvic_enable_irq(USBUART_IRQ); 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) void usbuart_set_line_coding(struct usb_cdc_line_coding *coding)
{ {
uart_set_baudrate(USBUART, coding->dwDTERate); uart_set_baudrate(USBUART, coding->dwDTERate);