硬件驱动(VCOM):增加获取USB虚拟串口连接状态的接口 (#5881)

* 硬件驱动(VCOM):增加获取USB虚拟串口连接状态的接口
This commit is contained in:
BreederBai 2022-04-28 20:30:51 +08:00 committed by GitHub
parent ec9629b5f0
commit c28b79b7d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -62,6 +62,8 @@ extern "C" {
} \ } \
}while(0) }while(0)
#define RT_USBD_CLASS_CTRL_CONNECTED (RT_DEVICE_CTRL_BASE(USBDevice) + 0)
struct ufunction; struct ufunction;
struct udevice; struct udevice;
struct uendpoint; struct uendpoint;

View File

@ -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, static rt_err_t _vcom_control(struct rt_serial_device *serial,
int cmd, void *arg) 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) switch (cmd)
{ {
case RT_DEVICE_CTRL_CLR_INT: 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: case RT_DEVICE_CTRL_SET_INT:
/* enable rx irq */ /* enable rx irq */
break; break;
case RT_USBD_CLASS_CTRL_CONNECTED:
(*(rt_bool_t*)arg) = data->connected;
break;
} }
return RT_EOK; return RT_EOK;