From 87be8fdba877f6416392391a640895699773f0c1 Mon Sep 17 00:00:00 2001 From: myshow2258 <296570182@qq.com> Date: Tue, 1 Nov 2022 11:37:07 +0800 Subject: [PATCH] =?UTF-8?q?Modified=20=20=20bsp/stm32/libraries/HAL=5FDriv?= =?UTF-8?q?ers/drv=5Fusbd.c=20Modified=20=20=20components/drivers/usb/usbd?= =?UTF-8?q?evice/class/cdc=5Fvcom.c=20=E4=BF=AE=E5=A4=8Dcdc=E5=9C=A8v1v2?= =?UTF-8?q?=E7=9A=84serial=E6=A1=86=E6=9E=B6=E4=B8=8B=E6=8E=A5=E6=94=B6?= =?UTF-8?q?=E5=8F=91=E9=80=81=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?.stm32=E4=B8=8Busbd=E6=B7=BB=E5=8A=A0=E6=9B=B4=E5=A4=9A?= =?UTF-8?q?=E7=9A=84ep=5Fid,=E4=BB=A5=E6=94=AF=E6=8C=81=E5=A4=8D=E5=90=88?= =?UTF-8?q?=E8=AE=BE=E5=A4=87.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/stm32/libraries/HAL_Drivers/drv_usbd.c | 18 ++++++++++++++---- .../drivers/usb/usbdevice/class/cdc_vcom.c | 16 +++++++++++++++- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_usbd.c b/bsp/stm32/libraries/HAL_Drivers/drv_usbd.c index 9c29966ed0..182dd3a2d4 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_usbd.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_usbd.c @@ -28,12 +28,22 @@ static struct ep_id _ep_pool[] = #else {0x1, USB_EP_ATTR_BULK, USB_DIR_IN, 64, ID_UNASSIGNED}, {0x1, USB_EP_ATTR_BULK, USB_DIR_OUT, 64, ID_UNASSIGNED}, -#endif - {0x2, USB_EP_ATTR_INT, USB_DIR_IN, 64, ID_UNASSIGNED}, - {0x2, USB_EP_ATTR_INT, USB_DIR_OUT, 64, ID_UNASSIGNED}, + {0x2, USB_EP_ATTR_BULK, USB_DIR_IN, 64, ID_UNASSIGNED}, + {0x2, USB_EP_ATTR_BULK, USB_DIR_OUT, 64, ID_UNASSIGNED}, {0x3, USB_EP_ATTR_BULK, USB_DIR_IN, 64, ID_UNASSIGNED}, -#if !defined(SOC_SERIES_STM32F1) {0x3, USB_EP_ATTR_BULK, USB_DIR_OUT, 64, ID_UNASSIGNED}, +#endif + {0x4, USB_EP_ATTR_INT, USB_DIR_IN, 64, ID_UNASSIGNED}, + {0x4, USB_EP_ATTR_INT, USB_DIR_OUT, 64, ID_UNASSIGNED}, + {0x5, USB_EP_ATTR_INT, USB_DIR_IN, 64, ID_UNASSIGNED}, + {0x5, USB_EP_ATTR_INT, USB_DIR_OUT, 64, ID_UNASSIGNED}, + {0x6, USB_EP_ATTR_INT, USB_DIR_IN, 64, ID_UNASSIGNED}, + {0x6, USB_EP_ATTR_INT, USB_DIR_OUT, 64, ID_UNASSIGNED}, + {0x7, USB_EP_ATTR_BULK, USB_DIR_IN, 64, ID_UNASSIGNED}, + {0x8, USB_EP_ATTR_BULK, USB_DIR_IN, 64, ID_UNASSIGNED}, + {0x9, USB_EP_ATTR_BULK, USB_DIR_IN, 64, ID_UNASSIGNED}, +#if !defined(SOC_SERIES_STM32F1) + {0x9, USB_EP_ATTR_BULK, USB_DIR_OUT, 64, ID_UNASSIGNED}, #endif {0xFF, USB_EP_ATTR_TYPE_MASK, USB_DIR_MASK, 0, ID_ASSIGNED }, }; diff --git a/components/drivers/usb/usbdevice/class/cdc_vcom.c b/components/drivers/usb/usbdevice/class/cdc_vcom.c index df5e03f54c..91b49d47de 100644 --- a/components/drivers/usb/usbdevice/class/cdc_vcom.c +++ b/components/drivers/usb/usbdevice/class/cdc_vcom.c @@ -100,7 +100,7 @@ static struct udevice_descriptor dev_desc = USB_CLASS_CDC, //bDeviceClass; 0x00, //bDeviceSubClass; 0x00, //bDeviceProtocol; - CDC_MAX_PACKET_SIZE, //bMaxPacketSize0; + CDC_MAX_PACKET_SIZE, //bMaxPacketSize0; _VENDOR_ID, //idVendor; _PRODUCT_ID, //idProduct; USB_BCD_DEVICE, //bcdDevice; @@ -498,6 +498,10 @@ static rt_err_t _function_enable(ufunction_t func) data->ep_out->buffer = rt_malloc(CDC_RX_BUFSIZE); RT_ASSERT(data->ep_out->buffer != RT_NULL); +#ifdef RT_USING_SERIAL_V2 + data->serial.serial_rx = &data->rx_ringbuffer; +#endif + data->ep_out->request.buffer = data->ep_out->buffer; data->ep_out->request.size = EP_MAXPACKET(data->ep_out); @@ -882,10 +886,15 @@ static void vcom_tx_thread_entry(void* parameter) if (!data->connected) { if(data->serial.parent.open_flag & +#ifdef RT_USING_SERIAL_V1 #ifndef VCOM_TX_USE_DMA RT_DEVICE_FLAG_INT_TX #else RT_DEVICE_FLAG_DMA_TX +#endif +#endif +#ifdef RT_USING_SERIAL_V2 + RT_DEVICE_FLAG_TX_BLOCKING #endif ) { @@ -911,10 +920,15 @@ static void vcom_tx_thread_entry(void* parameter) RT_DEBUG_LOG(RT_DEBUG_USB, ("vcom tx timeout\n")); } if(data->serial.parent.open_flag & +#ifdef RT_USING_SERIAL_V1 #ifndef VCOM_TX_USE_DMA RT_DEVICE_FLAG_INT_TX #else RT_DEVICE_FLAG_DMA_TX +#endif +#endif +#ifdef RT_USING_SERIAL_V2 + RT_DEVICE_FLAG_TX_BLOCKING #endif ) {