23extern int cdc_config_parser(
CDC_DEV_T *cdev);
35 memset((
char *)cdev, 0,
sizeof(
CDC_DEV_T));
36 cdev->ifnum_data = -1;
45static void add_new_cdc_device(
CDC_DEV_T *cdev)
47 if (g_cdev_list ==
NULL)
54 cdev->
next = g_cdev_list;
59static void remove_cdc_device(
CDC_DEV_T *cdev)
63 if (g_cdev_list == cdev)
65 g_cdev_list = g_cdev_list->
next;
79 CDC_DBGMSG(
"Warning! remove_cdc_device 0x%x not found!\n", (
int)cdev);
85static CDC_DEV_T * find_cdc_com_iface(IFACE_T *iface_data)
104static CDC_DEV_T * find_cdc_data_iface(
int ifnum)
121static int cdc_probe(IFACE_T *iface)
123 UDEV_T *udev = iface->udev;
124 ALT_IFACE_T *aif = iface->aif;
132 if ((ifd->bInterfaceClass != USB_CLASS_COMM) && (ifd->bInterfaceClass != USB_CLASS_DATA))
135 CDC_DBGMSG(
"cdc_probe %s - device (vid=0x%x, pid=0x%x), interface %d.\n",
136 (ifd->bInterfaceClass == USB_CLASS_COMM) ?
"COMM" :
"DATA",
137 udev->descriptor.idVendor, udev->descriptor.idProduct, ifd->bInterfaceNumber);
139 if (ifd->bInterfaceClass == USB_CLASS_DATA)
141 cdev = find_cdc_com_iface(iface);
144 CDC_DBGMSG(
"Warning! CDC device DTAT interface %d cannot find COMM interface!\n", iface->if_num);
147 cdev = alloc_cdc_device();
152 add_new_cdc_device(cdev);
156 iface->context = cdev;
162 cdev = alloc_cdc_device();
168 iface->context = (
void *)cdev;
170 ret = cdc_config_parser(cdev);
173 CDC_DBGMSG(
"Parsing CDC desceiptor failed! 0x%x\n", ret);
174 free_cdc_device(cdev);
178 add_new_cdc_device(cdev);
186 remove_cdc_device(d);
193static void cdc_disconnect(IFACE_T *iface)
195 IFACE_T *if_cdc, *if_data;
199 CDC_DBGMSG(
"CDC device interface %d disconnected!\n", iface->if_num);
214 for (i = 0; i < if_cdc->aif->ifd->bNumEndpoints; i++)
216 if_cdc->udev->hc_driver->quit_xfer(
NULL, &(if_cdc->aif->ep[i]));
222 for (i = 0; i < if_data->aif->ifd->bNumEndpoints; i++)
224 if_data->udev->hc_driver->quit_xfer(
NULL, &(if_data->aif->ep[i]));
236 usbh_quit_utr(cdev->
utr_rx);
241 if_cdc->context =
NULL;
242 if_data->context =
NULL;
244 remove_cdc_device(cdev);
245 free_cdc_device(cdev);
249static UDEV_DRV_T cdc_driver =
268 usbh_register_driver(&cdc_driver);
NuMicro peripheral access layer header file.
#define NULL
NULL pointer.
#define USBH_ERR_NOT_MATCHED
#define USBH_ERR_NOT_FOUND
void usbh_cdc_init(void)
Init USB Host CDC driver.
CDC_DEV_T * usbh_cdc_get_device_list(void)
Get a list of currently connected USB Hid devices.
USB Host library header file.
USB Host CDC(Communication Device Class) driver header file.
USB Host library exported header file.