From 50a226870acfb92f80db52c4184f76d1d96fad46 Mon Sep 17 00:00:00 2001 From: dragonmux Date: Mon, 15 Aug 2022 18:16:59 +0100 Subject: [PATCH] usb_serial: Implemented support for the GDB serial interface for the GET_LINE_CODING request --- src/platforms/common/usb_serial.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/platforms/common/usb_serial.c b/src/platforms/common/usb_serial.c index ad4f1f72..7bac1265 100644 --- a/src/platforms/common/usb_serial.c +++ b/src/platforms/common/usb_serial.c @@ -67,9 +67,20 @@ static enum usbd_request_return_codes gdb_uart_control_request(usbd_device *dev, gdb_uart_dtr = req->wValue & 1; return USBD_REQ_HANDLED; case USB_CDC_REQ_SET_LINE_CODING: - if (*len < sizeof(struct usb_cdc_line_coding)) + if (*len < sizeof(usb_cdc_line_coding_s)) return USBD_REQ_NOTSUPP; return USBD_REQ_HANDLED; /* Ignore on GDB Port */ + case USB_CDC_REQ_GET_LINE_CODING: { + if (*len < sizeof(usb_cdc_line_coding_s)) + return USBD_REQ_NOTSUPP; + usb_cdc_line_coding_s *line_coding = (usb_cdc_line_coding_s *)*buf; + /* This tells the host that we talk 1MBaud, 8-bit no parity w/ 1 stop bit */ + line_coding->dwDTERate = 1 * 1000 * 1000; + line_coding->bCharFormat = USB_CDC_1_STOP_BITS; + line_coding->bParityType = USB_CDC_NO_PARITY; + line_coding->bDataBits = 8; + return USBD_REQ_HANDLED; + } } return USBD_REQ_NOTSUPP; }