From 82c83bb77e11aff2b33a95bfba942c3bf65339b4 Mon Sep 17 00:00:00 2001 From: dragonmux Date: Wed, 10 Aug 2022 09:42:54 +0100 Subject: [PATCH] usb_gdb_uart: Renamed cdcacm_get_dtr() -> gdb_uart_get_dtr() --- src/platforms/common/cdcacm.c | 9 +++++---- src/platforms/common/cdcacm.h | 3 ++- src/platforms/stm32/gdb_if.c | 6 +++--- src/platforms/stm32/rtt_if.c | 2 +- src/platforms/stm32/traceswodecode.c | 2 +- src/platforms/tm4c/gdb_if.c | 9 ++++----- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/platforms/common/cdcacm.c b/src/platforms/common/cdcacm.c index 568d115..ec052e6 100644 --- a/src/platforms/common/cdcacm.c +++ b/src/platforms/common/cdcacm.c @@ -49,7 +49,8 @@ #include static int configured; -static int cdcacm_gdb_dtr = 1; + +static int gdb_uart_dtr = 1; static void cdcacm_set_modem_state(usbd_device *dev, uint16_t iface, uint8_t ep); @@ -65,7 +66,7 @@ static enum usbd_request_return_codes gdb_uart_control_request(usbd_device *dev, switch (req->bRequest) { case USB_CDC_REQ_SET_CONTROL_LINE_STATE: cdcacm_set_modem_state(dev, req->wIndex, CDCACM_GDB_ENDPOINT); - cdcacm_gdb_dtr = req->wValue & 1; + 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)) @@ -107,9 +108,9 @@ int cdcacm_get_config(void) return configured; } -int cdcacm_get_dtr(void) +int gdb_uart_get_dtr(void) { - return cdcacm_gdb_dtr; + return gdb_uart_dtr; } static void cdcacm_set_modem_state(usbd_device *dev, const uint16_t iface, const uint8_t ep) diff --git a/src/platforms/common/cdcacm.h b/src/platforms/common/cdcacm.h index 37df0b9..9a2f571 100644 --- a/src/platforms/common/cdcacm.h +++ b/src/platforms/common/cdcacm.h @@ -33,6 +33,7 @@ void cdcacm_set_config(usbd_device *dev, uint16_t wValue); /* Returns current usb configuration, or 0 if not configured. */ int cdcacm_get_config(void); -int cdcacm_get_dtr(void); + +int gdb_uart_get_dtr(void); #endif diff --git a/src/platforms/stm32/gdb_if.c b/src/platforms/stm32/gdb_if.c index 87d3286..c35bb97 100644 --- a/src/platforms/stm32/gdb_if.c +++ b/src/platforms/stm32/gdb_if.c @@ -43,7 +43,7 @@ void gdb_if_putchar(unsigned char c, int flush) if(flush || (count_in == CDCACM_PACKET_SIZE)) { /* Refuse to send if USB isn't configured, and * don't bother if nobody's listening */ - if((cdcacm_get_config() != 1) || !cdcacm_get_dtr()) { + if((cdcacm_get_config() != 1) || !gdb_uart_get_dtr()) { count_in = 0; return; } @@ -105,7 +105,7 @@ unsigned char gdb_if_getchar(void) while (!(out_ptr < count_out)) { /* Detach if port closed */ - if (!cdcacm_get_dtr()) { + if (!gdb_uart_get_dtr()) { __WFI(); return 0x04; } @@ -123,7 +123,7 @@ unsigned char gdb_if_getchar_to(int timeout) if (!(out_ptr < count_out)) do { /* Detach if port closed */ - if (!cdcacm_get_dtr()) { + if (!gdb_uart_get_dtr()) { __WFI(); /* systick will wake up too!*/ return 0x04; } diff --git a/src/platforms/stm32/rtt_if.c b/src/platforms/stm32/rtt_if.c index b6f4ccc..0816ce7 100644 --- a/src/platforms/stm32/rtt_if.c +++ b/src/platforms/stm32/rtt_if.c @@ -121,7 +121,7 @@ bool rtt_nodata() /* rtt target to host: write string */ uint32_t rtt_write(const char *buf, uint32_t len) { - if (len != 0 && usbdev && cdcacm_get_config() && cdcacm_get_dtr()) { + if (len != 0 && usbdev && cdcacm_get_config() && gdb_uart_get_dtr()) { for (uint32_t p = 0; p < len; p += CDCACM_PACKET_SIZE) { uint32_t plen = MIN(CDCACM_PACKET_SIZE, len - p); while(usbd_ep_write_packet(usbdev, CDCACM_UART_ENDPOINT, buf + p, plen) <= 0); diff --git a/src/platforms/stm32/traceswodecode.c b/src/platforms/stm32/traceswodecode.c index 3d5b052..24ae2ff 100644 --- a/src/platforms/stm32/traceswodecode.c +++ b/src/platforms/stm32/traceswodecode.c @@ -47,7 +47,7 @@ uint16_t traceswo_decode(usbd_device *usbd_dev, uint8_t addr, if (swo_print) { swo_buf[swo_buf_len++]=ch; if (swo_buf_len == sizeof(swo_buf)) { - if (cdcacm_get_config() && cdcacm_get_dtr()) /* silently drop if usb not ready */ + if (cdcacm_get_config() && gdb_uart_get_dtr()) /* silently drop if usb not ready */ usbd_ep_write_packet(usbd_dev, addr, swo_buf, swo_buf_len); swo_buf_len=0; } diff --git a/src/platforms/tm4c/gdb_if.c b/src/platforms/tm4c/gdb_if.c index 4238a02..8694e7d 100644 --- a/src/platforms/tm4c/gdb_if.c +++ b/src/platforms/tm4c/gdb_if.c @@ -40,7 +40,7 @@ void gdb_if_putchar(unsigned char c, int flush) if(flush || (count_in == CDCACM_PACKET_SIZE)) { /* Refuse to send if USB isn't configured, and * don't bother if nobody's listening */ - if((cdcacm_get_config() != 1) || !cdcacm_get_dtr()) { + if((cdcacm_get_config() != 1) || !gdb_uart_get_dtr()) { count_in = 0; return; } @@ -59,7 +59,7 @@ void gdb_usb_out_cb(usbd_device *dev, uint8_t ep) uint32_t count = usbd_ep_read_packet(dev, CDCACM_GDB_ENDPOINT, (uint8_t *)buf, CDCACM_PACKET_SIZE); - + uint32_t idx; for (idx=0; idx