From 2ea318cc03e53f5104c8399d58ba462c50600fa1 Mon Sep 17 00:00:00 2001 From: ChunfengMu Date: Tue, 30 Jan 2018 01:24:00 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1:=E8=A7=A3=E5=86=B3=E6=9C=AA=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E4=B8=B2=E5=8F=A3=E8=AE=BE=E5=A4=87=E6=97=B6=EF=BC=8C?= =?UTF-8?q?bulkout=E7=AB=AF=E7=82=B9=E6=8E=A5=E6=94=B6=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E6=96=AD=E8=A8=80=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../drivers/usb/usbdevice/class/cdc_vcom.c | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/components/drivers/usb/usbdevice/class/cdc_vcom.c b/components/drivers/usb/usbdevice/class/cdc_vcom.c index 7940e4c059..35a60cb60f 100644 --- a/components/drivers/usb/usbdevice/class/cdc_vcom.c +++ b/components/drivers/usb/usbdevice/class/cdc_vcom.c @@ -74,14 +74,14 @@ static struct ucdc_line_coding line_coding; struct vcom { - struct rt_serial_device serial; + struct rt_serial_device serial; uep_t ep_out; uep_t ep_in; uep_t ep_cmd; rt_bool_t connected; rt_bool_t in_sending; struct rt_completion wait; - rt_uint8_t rx_rbp[CDC_RX_BUFSIZE]; + rt_uint8_t rx_rbp[CDC_RX_BUFSIZE]; struct rt_ringbuffer rx_ringbuffer; rt_uint8_t tx_rbp[CDC_TX_BUFSIZE]; struct rt_ringbuffer tx_ringbuffer; @@ -176,7 +176,7 @@ const static struct ucdc_comm_descriptor _comm_desc = USB_DESC_TYPE_ENDPOINT, USB_DYNAMIC | USB_DIR_IN, USB_EP_ATTR_INT, - 0x08, + 0x0008, 0xFF, }; @@ -298,16 +298,20 @@ static rt_err_t _ep_out_handler(ufunction_t func, rt_size_t size) RT_ASSERT(func != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("_ep_out_handler %d\n", size)); - + data = (struct vcom*)func->user_data; - /* receive data from USB VCOM */ - level = rt_hw_interrupt_disable(); + /* ensure serial is active */ + if(data->serial.parent.open_flag & RT_DEVICE_FLAG_ACTIVATED) + { + /* receive data from USB VCOM */ + level = rt_hw_interrupt_disable(); - rt_ringbuffer_put(&data->rx_ringbuffer, data->ep_out->buffer, size); - rt_hw_interrupt_enable(level); + rt_ringbuffer_put(&data->rx_ringbuffer, data->ep_out->buffer, size); + rt_hw_interrupt_enable(level); - /* notify receive data */ - rt_hw_serial_isr(&data->serial,RT_SERIAL_EVENT_RX_IND); + /* notify receive data */ + rt_hw_serial_isr(&data->serial,RT_SERIAL_EVENT_RX_IND); + } data->ep_out->request.buffer = data->ep_out->buffer; data->ep_out->request.size = EP_MAXPACKET(data->ep_out); @@ -879,7 +883,7 @@ static void rt_usb_vcom_init(struct ufunction *func) rt_ringbuffer_init(&data->rx_ringbuffer, data->rx_rbp, CDC_RX_BUFSIZE); rt_ringbuffer_init(&data->tx_ringbuffer, data->tx_rbp, CDC_TX_BUFSIZE); - rt_event_init(&data->tx_event, "vom", RT_IPC_FLAG_FIFO); + rt_event_init(&data->tx_event, "vcom", RT_IPC_FLAG_FIFO); config.baud_rate = BAUD_RATE_115200; config.data_bits = DATA_BITS_8; From 263e9faae499654fc74520c2a3cc16b444fe386d Mon Sep 17 00:00:00 2001 From: ChunfengMu Date: Tue, 30 Jan 2018 10:19:40 +0800 Subject: [PATCH 2/2] Update cdc_vcom.c --- components/drivers/usb/usbdevice/class/cdc_vcom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/drivers/usb/usbdevice/class/cdc_vcom.c b/components/drivers/usb/usbdevice/class/cdc_vcom.c index 35a60cb60f..5188d98102 100644 --- a/components/drivers/usb/usbdevice/class/cdc_vcom.c +++ b/components/drivers/usb/usbdevice/class/cdc_vcom.c @@ -176,7 +176,7 @@ const static struct ucdc_comm_descriptor _comm_desc = USB_DESC_TYPE_ENDPOINT, USB_DYNAMIC | USB_DIR_IN, USB_EP_ATTR_INT, - 0x0008, + 0x08, 0xFF, };