diff options
| author | BreederBai <[email protected]> | 2022-04-28 20:30:51 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-04-28 20:30:51 +0800 |
| commit | c28b79b7d79df6f2f5037a00a844293052b096cd (patch) | |
| tree | e7778729fd39b37b9d48c6897053dd4a7d1a871b /components | |
| parent | ec9629b5f081a7d478609c06fc8a726dc4f1ce77 (diff) | |
硬件驱动(VCOM):增加获取USB虚拟串口连接状态的接口 (#5881)
* 硬件驱动(VCOM):增加获取USB虚拟串口连接状态的接口
Diffstat (limited to 'components')
| -rw-r--r-- | components/drivers/include/drivers/usb_device.h | 2 | ||||
| -rw-r--r-- | components/drivers/usb/usbdevice/class/cdc_vcom.c | 9 |
2 files changed, 11 insertions, 0 deletions
diff --git a/components/drivers/include/drivers/usb_device.h b/components/drivers/include/drivers/usb_device.h index 3ce051dfaa..af978e870c 100644 --- a/components/drivers/include/drivers/usb_device.h +++ b/components/drivers/include/drivers/usb_device.h @@ -62,6 +62,8 @@ extern "C" { } \ }while(0) +#define RT_USBD_CLASS_CTRL_CONNECTED (RT_DEVICE_CTRL_BASE(USBDevice) + 0) + struct ufunction; struct udevice; struct uendpoint; diff --git a/components/drivers/usb/usbdevice/class/cdc_vcom.c b/components/drivers/usb/usbdevice/class/cdc_vcom.c index 125fb7a200..df5e03f54c 100644 --- a/components/drivers/usb/usbdevice/class/cdc_vcom.c +++ b/components/drivers/usb/usbdevice/class/cdc_vcom.c @@ -670,6 +670,12 @@ static rt_err_t _vcom_configure(struct rt_serial_device *serial, static rt_err_t _vcom_control(struct rt_serial_device *serial, int cmd, void *arg) { + struct ufunction *func; + struct vcom *data; + + func = (struct ufunction*)serial->parent.user_data; + data = (struct vcom*)func->user_data; + switch (cmd) { case RT_DEVICE_CTRL_CLR_INT: @@ -678,6 +684,9 @@ static rt_err_t _vcom_control(struct rt_serial_device *serial, case RT_DEVICE_CTRL_SET_INT: /* enable rx irq */ break; + case RT_USBD_CLASS_CTRL_CONNECTED: + (*(rt_bool_t*)arg) = data->connected; + break; } return RT_EOK; |
