22extern int cdc_config_parser(
CDC_DEV_T *cdev);
34 memset((
char *)cdev, 0,
sizeof(
CDC_DEV_T));
35 cdev->ifnum_data = -1;
44static void add_new_cdc_device(
CDC_DEV_T *cdev)
46 if(g_cdev_list ==
NULL)
53 cdev->
next = g_cdev_list;
58static void remove_cdc_device(
CDC_DEV_T *cdev)
62 if(g_cdev_list == cdev)
64 g_cdev_list = g_cdev_list->
next;
78 CDC_DBGMSG(
"Warning! remove_cdc_device 0x%x not found!\n", (
int)cdev);
84static CDC_DEV_T * find_cdc_com_iface(IFACE_T *iface_data)
103static CDC_DEV_T * find_cdc_data_iface(
int ifnum)
120static int cdc_probe(IFACE_T *iface)
122 UDEV_T *udev = iface->udev;
123 ALT_IFACE_T *aif = iface->aif;
131 if((ifd->bInterfaceClass != USB_CLASS_COMM) && (ifd->bInterfaceClass != USB_CLASS_DATA))
134 CDC_DBGMSG(
"cdc_probe %s - device (vid=0x%x, pid=0x%x), interface %d.\n",
135 (ifd->bInterfaceClass == USB_CLASS_COMM) ?
"COMM" :
"DATA",
136 udev->descriptor.idVendor, udev->descriptor.idProduct, ifd->bInterfaceNumber);
138 if(ifd->bInterfaceClass == USB_CLASS_DATA)
140 cdev = find_cdc_com_iface(iface);
143 CDC_DBGMSG(
"Warning! CDC device DTAT interface %d cannot find COMM interface!\n", iface->if_num);
146 cdev = alloc_cdc_device();
151 add_new_cdc_device(cdev);
155 iface->context = cdev;
161 cdev = alloc_cdc_device();
167 iface->context = (
void *)cdev;
169 ret = cdc_config_parser(cdev);
172 CDC_DBGMSG(
"Parsing CDC desceiptor failed! 0x%x\n", ret);
173 free_cdc_device(cdev);
177 add_new_cdc_device(cdev);
185 remove_cdc_device(d);
192static void cdc_disconnect(IFACE_T *iface)
194 IFACE_T *if_cdc, *if_data;
198 CDC_DBGMSG(
"CDC device interface %d disconnected!\n", iface->if_num);
213 for(i = 0; i < if_cdc->aif->ifd->bNumEndpoints; i++)
215 if_cdc->udev->hc_driver->quit_xfer(
NULL, &(if_cdc->aif->ep[i]));
221 for(i = 0; i < if_data->aif->ifd->bNumEndpoints; i++)
223 if_data->udev->hc_driver->quit_xfer(
NULL, &(if_data->aif->ep[i]));
235 usbh_quit_utr(cdev->
utr_rx);
240 if_cdc->context =
NULL;
241 if_data->context =
NULL;
243 remove_cdc_device(cdev);
244 free_cdc_device(cdev);
248static UDEV_DRV_T cdc_driver =
267 usbh_register_driver(&cdc_driver);
NuMicro peripheral access layer header file.
#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.