//***************************************************************************** // // Clean up and release all USB hardware resources. // //***************************************************************************** void ScopeUSBHostTerm(void) { // // If necessary, unmount the USB flash drive. // if((g_eState == STATE_DEVICE_ENUM) || (g_eState == STATE_DEVICE_READY)) { FileMountUSB(false); } // // Nothing is connected any more. // g_eState = STATE_NO_DEVICE; // // Close our MSC drive instance. // USBHMSCDriveClose(g_ulMSCInstance); g_ulMSCInstance = 0; // // Tell the USB library that we are finished using the host controller. // USBHCDTerm(0); }
//***************************************************************************** // // This is the callback from the MSC driver. // // \param ulInstance is the driver instance which is needed when communicating // with the driver. // \param ulEvent is one of the events defined by the driver. // \param pvData is a pointer to data passed into the initial call to register // the callback. // // This function handles callback events from the MSC driver. The only events // currently handled are the MSC_EVENT_OPEN and MSC_EVENT_CLOSE. This allows // the main routine to know when an MSC device has been detected and // enumerated and when an MSC device has been removed from the system. // // \return Returns \e true on success or \e false on failure. // //***************************************************************************** void MSCCallback(unsigned long ulInstance, unsigned long ulEvent, void *pvData) { // // Determine the event. // switch(ulEvent) { // // Called when the device driver has successfully enumerated an MSC // device. // case MSC_EVENT_OPEN: { // // Mount the USB flash stick as logical drive 1 in the file system. // FileMountUSB(true); // // Proceed to the enumeration state. // g_eState = STATE_DEVICE_ENUM; break; } // // Called when the device driver has been unloaded due to error or // the device is no longer present. // case MSC_EVENT_CLOSE: { // // Remove the USB stick from the file system. // FileMountUSB(false); // // Close our MSC drive instance. // USBHMSCDriveClose(g_ulMSCInstance); g_ulMSCInstance = 0; // // Go back to the "no device" state and wait for a new connection. // g_eState = STATE_NO_DEVICE; RendererSetAlert("USB drive\nremoved.", 200); break; } default: { break; } } }
/* * ======== USBMSCHFatFsTiva_close ======== */ void USBMSCHFatFsTiva_close(USBMSCHFatFs_Handle handle) { unsigned int key; DRESULT dresult; FRESULT fresult; USBMSCHFatFsTiva_Object *object = handle->object; /* Unmount the FatFs drive */ fresult = f_mount(object->driveNumber, NULL); if (fresult != FR_OK) { Log_print0(Diags_USER1, "USBMSCHFatFs: could not unmount FatFs volume"); } /* Close USB Drive */ USBHMSCDriveClose(object->MSCInstance); /* Unregister the disk_*() functions */ dresult = disk_unregister(object->driveNumber); if (dresult != RES_OK) { Log_print0(Diags_USER1, "USBMSCHFatFs: error unregistering disk " "functions"); } /* Delete the HCDMain service task*/ Task_destruct(&(object->taskHCDMain)); /* Delete the semaphore */ Semaphore_destruct(&(object->semUSBConnected)); /* Delete the gate */ GateMutex_destruct(&(object->gateUSBLibAccess)); /* Delete the gate */ GateMutex_destruct(&(object->gateUSBWait)); /* Delete the hwi */ Hwi_destruct(&(object->hwi)); Log_print1(Diags_USER1, "USBMSCHFatFs: drive %d closed", object->driveNumber); key = Hwi_disable(); object->driveNumber = DRIVE_NOT_MOUNTED; Hwi_restore(key); }
//***************************************************************************** // // Clean up and release all USB hardware resources. // //***************************************************************************** void ScopeUSBHostTerm(void) { // // If necessary, unmount the USB flash drive. // if((g_eState == STATE_DEVICE_ENUM) || (g_eState == STATE_DEVICE_READY)) { FileMountUSB(false); } // // Nothing is connected any more. // g_eState = STATE_NO_DEVICE; // // Close our MSC drive instance. // USBHMSCDriveClose(g_ulMSCInstance); g_ulMSCInstance = 0; // // Tell the USB library that we are finished using the host controller. // USBHCDTerm(0); // // Turn off USB Phy clock. // SysCtlUSBPLLDisable(); // // Disable the USB peripheral // SysCtlPeripheralDisable(SYSCTL_PERIPH_USB0); }