summaryrefslogtreecommitdiff
path: root/components/drivers/usb
diff options
context:
space:
mode:
authorGrissiom <[email protected]>2013-05-10 15:17:59 +0800
committerGrissiom <[email protected]>2013-05-10 15:17:59 +0800
commitffb1e620207942e941f2fb1b9c390404658e0cf3 (patch)
treee66c21981f019649c2855c6fbc2c142c465f3aaa /components/drivers/usb
parent778c4239b1972658e4566c2c62f91c5c8d6d88f2 (diff)
cdc_vcom: send a zero-length-packet at the end is transaction
Diffstat (limited to 'components/drivers/usb')
-rw-r--r--components/drivers/usb/usbdevice/class/cdc_vcom.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/components/drivers/usb/usbdevice/class/cdc_vcom.c b/components/drivers/usb/usbdevice/class/cdc_vcom.c
index 0e0b3c7d1a..4cb3ec5551 100644
--- a/components/drivers/usb/usbdevice/class/cdc_vcom.c
+++ b/components/drivers/usb/usbdevice/class/cdc_vcom.c
@@ -31,7 +31,9 @@ static struct serial_ringbuffer vcom_int_rx;
static struct rt_serial_device vcom_serial;
#define CDC_MaxPacketSize 64
+ALIGN(RT_ALIGN_SIZE)
static rt_uint8_t rx_buf[CDC_MaxPacketSize];
+ALIGN(RT_ALIGN_SIZE)
static rt_uint8_t tx_buf[CDC_MaxPacketSize];
static rt_bool_t vcom_connected = RT_FALSE;
@@ -148,6 +150,7 @@ const static char* _ustring[] =
"Interface",
};
+static rt_bool_t _in_sending;
/**
* This function will handle cdc bulk in endpoint request.
*
@@ -167,7 +170,14 @@ static rt_err_t _ep_in_handler(udevice_t device, uclass_t cls, rt_size_t size)
mps = eps->ep_in->ep_desc->wMaxPacketSize;
size = RT_RINGBUFFER_SIZE(&tx_ringbuffer);
if(size == 0)
+ {
+ if (_in_sending)
+ {
+ _in_sending = RT_FALSE;
+ dcd_ep_write(device->dcd, eps->ep_in, RT_NULL, 0);
+ }
return RT_EOK;
+ }
length = size > mps ? mps : size;
@@ -398,6 +408,7 @@ static rt_err_t _class_sof_handler(udevice_t device, uclass_t cls)
if(size == 0)
return -RT_EFULL;
+ _in_sending = RT_TRUE;
size = size > mps ? mps : size;
level = rt_hw_interrupt_disable();
@@ -415,7 +426,6 @@ static struct uclass_ops ops =
{
_class_run,
_class_stop,
- /*RT_NULL,*/
_class_sof_handler,
};