diff --git a/src/platforms/common/cdcacm.c b/src/platforms/common/cdcacm.c index 568d1151..ec052e6a 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 37df0b97..9a2f571b 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 87d32861..c35bb978 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 b6f4ccc1..0816ce7d 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 3d5b0523..24ae2ff2 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 4238a02a..8694e7db 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