| Description | The UnConfig function is used for unconfiguration of resources used by the device instance of class. It will be called automatically by the USB Host Core when device is disconnected form the USB Host controller bus and uninitialized. The argument ctrl specifies the controller index. The argument dev_idx specifies the device instance index. Unconfiguration function has to clear Device Class Instance (USBH_DCI) structure and it also has to clear any class specific details needed for class specific handling (in example below these parameters are in structure USBH_MSC). You can modify this function to suit different class driver. This function will need to be changed for class that does not have driver provided. |
| Example |
/* MSC Class Driver Control Block */
USBH_DCD usbh_dcd_cls = {
USB_DEVICE_CLASS_STORAGE,
Config,
UnConfig,
Init,
UnInit,
GetLastError
};
static BOOL UnConfig (U8 ctrl, U8 dev_idx) {
USBH_HCD *ptrHCD;
USBH_DCI *ptrDCI;
USBH_MSC *ptrMSC;
BOOL ok;
ptrHCD = usbh_hcd_ptr[ctrl];
ptrDCI = &usbh_dci_msc[ctrl*usbh_msc_num+dev_idx];
ptrMSC = &usbh_msc[ctrl*usbh_msc_num+dev_idx];
if (ptrDCI->DevCfg) {
ok = ptrHCD->ep_remove (ptrMSC->HndlBulkOut);
if (!ok)
USBH_MSC_SetLastError (ctrl, dev_idx, ERROR_USBH_EP_REMOVE);
ok &= ptrHCD->ep_remove (ptrMSC->HndlBulkIn);
if (!ok)
USBH_MSC_SetLastError (ctrl, dev_idx, ERROR_USBH_EP_REMOVE);
if (!ok)
return (__FALSE);
}
memset (ptrMSC, 0, sizeof (USBH_MSC));
memset (ptrDCI, 0, sizeof (USBH_DCI));
ptrDCI->Config = 0;
return (__TRUE);
}
|