/* * ======== 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); }
/* * ======== ramdisk_stop ======== * */ DRESULT ramdisk_stop(BYTE drive) { DRESULT result; /* ensure 'drive' is a valid index */ if (drive >= _VOLUMES) { return RES_PARERR; } diskMem[drive] = NULL; numSectors[drive] = 0; if ((result = disk_unregister(drive)) != RES_OK) { return result; } /* un-mount the drive */ if (f_mount(drive, NULL) != FR_OK) { return RES_ERROR; } return RES_OK; }