diff --git a/src/stm32/cdcacm.c b/src/stm32/cdcacm.c index 5c61eb78..7107b930 100644 --- a/src/stm32/cdcacm.c +++ b/src/stm32/cdcacm.c @@ -83,14 +83,14 @@ static const struct usb_endpoint_descriptor gdb_data_endp[] = {{ .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = 0x01, .bmAttributes = USB_ENDPOINT_ATTR_BULK, - .wMaxPacketSize = 64, + .wMaxPacketSize = CDCACM_PACKET_SIZE, .bInterval = 1, }, { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = 0x81, .bmAttributes = USB_ENDPOINT_ATTR_BULK, - .wMaxPacketSize = 64, + .wMaxPacketSize = CDCACM_PACKET_SIZE, .bInterval = 1, }}; @@ -187,14 +187,14 @@ static const struct usb_endpoint_descriptor uart_data_endp[] = {{ .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = 0x03, .bmAttributes = USB_ENDPOINT_ATTR_BULK, - .wMaxPacketSize = 64, + .wMaxPacketSize = CDCACM_PACKET_SIZE, .bInterval = 1, }, { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = 0x83, .bmAttributes = USB_ENDPOINT_ATTR_BULK, - .wMaxPacketSize = 64, + .wMaxPacketSize = CDCACM_PACKET_SIZE, .bInterval = 1, }}; @@ -459,8 +459,8 @@ static void cdcacm_data_rx_cb(u8 ep) { (void)ep; - char buf[64]; - int len = usbd_ep_read_packet(0x03, buf, 64); + char buf[CDCACM_PACKET_SIZE]; + int len = usbd_ep_read_packet(0x03, buf, CDCACM_PACKET_SIZE); for(int i = 0; i < len; i++) usart_send_blocking(USART1, buf[i]); } @@ -471,14 +471,14 @@ static void cdcacm_set_config(u16 wValue) configured = wValue; /* GDB interface */ - usbd_ep_setup(0x01, USB_ENDPOINT_ATTR_BULK, 64, NULL); - usbd_ep_setup(0x81, USB_ENDPOINT_ATTR_BULK, 64, NULL); + usbd_ep_setup(0x01, USB_ENDPOINT_ATTR_BULK, CDCACM_PACKET_SIZE, NULL); + usbd_ep_setup(0x81, USB_ENDPOINT_ATTR_BULK, CDCACM_PACKET_SIZE, NULL); usbd_ep_setup(0x82, USB_ENDPOINT_ATTR_INTERRUPT, 16, NULL); #ifdef INCLUDE_UART_INTERFACE /* Serial interface */ - usbd_ep_setup(0x03, USB_ENDPOINT_ATTR_BULK, 64, cdcacm_data_rx_cb); - usbd_ep_setup(0x83, USB_ENDPOINT_ATTR_BULK, 64, NULL); + usbd_ep_setup(0x03, USB_ENDPOINT_ATTR_BULK, CDCACM_PACKET_SIZE, cdcacm_data_rx_cb); + usbd_ep_setup(0x83, USB_ENDPOINT_ATTR_BULK, CDCACM_PACKET_SIZE, NULL); usbd_ep_setup(0x84, USB_ENDPOINT_ATTR_INTERRUPT, 16, NULL); #endif diff --git a/src/stm32/gdb_if.c b/src/stm32/gdb_if.c index 59e9c2b7..aa43293c 100644 --- a/src/stm32/gdb_if.c +++ b/src/stm32/gdb_if.c @@ -27,18 +27,16 @@ #include "gdb_if.h" -#define VIRTUAL_COM_PORT_DATA_SIZE 64 - static uint32_t count_out; static uint32_t count_in; static uint32_t out_ptr; -static uint8_t buffer_out[VIRTUAL_COM_PORT_DATA_SIZE]; -static uint8_t buffer_in[VIRTUAL_COM_PORT_DATA_SIZE]; +static uint8_t buffer_out[CDCACM_PACKET_SIZE]; +static uint8_t buffer_in[CDCACM_PACKET_SIZE]; void gdb_if_putchar(unsigned char c, int flush) { buffer_in[count_in++] = c; - if(flush || (count_in == VIRTUAL_COM_PORT_DATA_SIZE)) { + 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()) { @@ -59,7 +57,7 @@ unsigned char gdb_if_getchar(void) while(cdcacm_get_config() != 1); count_out = usbd_ep_read_packet(1, buffer_out, - VIRTUAL_COM_PORT_DATA_SIZE); + CDCACM_PACKET_SIZE); out_ptr = 0; } @@ -76,7 +74,7 @@ unsigned char gdb_if_getchar_to(int timeout) return 0x04; count_out = usbd_ep_read_packet(1, buffer_out, - VIRTUAL_COM_PORT_DATA_SIZE); + CDCACM_PACKET_SIZE); out_ptr = 0; } while(timeout_counter && !(out_ptr < count_out)); diff --git a/src/stm32/platform.h b/src/stm32/platform.h index a9a1ccae..85ade4f0 100644 --- a/src/stm32/platform.h +++ b/src/stm32/platform.h @@ -33,6 +33,7 @@ #define INCLUDE_UART_INTERFACE #define INLINE_GPIO +#define CDCACM_PACKET_SIZE 64 /* Important pin mappings for STM32 implementation: *