3      Copyright (C) Dean Camera, 2011. 
   5   dean [at] fourwalledcubicle [dot] com 
  10   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) 
  12   Permission to use, copy, modify, distribute, and sell this 
  13   software and its documentation for any purpose is hereby granted 
  14   without fee, provided that the above copyright notice appear in 
  15   all copies and that both that the copyright notice and this 
  16   permission notice and warranty disclaimer appear in supporting 
  17   documentation, and that the name of the author not be used in 
  18   advertising or publicity pertaining to distribution of the 
  19   software without specific, written prior permission. 
  21   The author disclaim all warranties with regard to this 
  22   software, including all implied warranties of merchantability 
  23   and fitness.  In no event shall the author be liable for any 
  24   special, indirect or consequential damages or any damages 
  25   whatsoever resulting from loss of use, data or profits, whether 
  26   in an action of contract, negligence or other tortious action, 
  27   arising out of or in connection with the use or performance of 
  33 #if defined(USB_CAN_BE_HOST) 
  34 /** LUFA Mass Storage Class driver interface configuration and state information. This structure is 
  35  *  passed to all Mass Storage Class driver functions, so that multiple instances of the same class 
  36  *  within a device can be differentiated from one another. 
  38 USB_ClassInfo_MS_Host_t DiskHost_MS_Interface 
= 
  42                                 .DataINPipeNumber       
= 1, 
  43                                 .DataINPipeDoubleBank   
= false, 
  45                                 .DataOUTPipeNumber      
= 2, 
  46                                 .DataOUTPipeDoubleBank  
= false, 
  51 void DiskHost_USBTask(void) 
  53         MS_Host_USBTask(&DiskHost_MS_Interface
); 
  56 void EVENT_USB_Host_DeviceEnumerationComplete(void) 
  58         LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING
); 
  60         uint16_t ConfigDescriptorSize
; 
  61         uint8_t  ConfigDescriptorData
[512]; 
  63         if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize
, ConfigDescriptorData
, 
  64                                                                                    sizeof(ConfigDescriptorData
)) != HOST_GETCONFIG_Successful
) 
  66                 LEDs_SetAllLEDs(LEDMASK_USB_ERROR
); 
  70         if (MS_Host_ConfigurePipes(&DiskHost_MS_Interface
, 
  71                                                            ConfigDescriptorSize
, ConfigDescriptorData
) != MS_ENUMERROR_NoError
) 
  73                 LEDs_SetAllLEDs(LEDMASK_USB_ERROR
); 
  77         if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful
) 
  79                 LEDs_SetAllLEDs(LEDMASK_USB_ERROR
); 
  84         if (MS_Host_GetMaxLUN(&DiskHost_MS_Interface
, &MaxLUNIndex
)) 
  86                 LEDs_SetAllLEDs(LEDMASK_USB_ERROR
); 
  90         if (MS_Host_ResetMSInterface(&DiskHost_MS_Interface
)) 
  92                 LEDs_SetAllLEDs(LEDMASK_USB_ERROR
); 
  96         SCSI_Request_Sense_Response_t SenseData
; 
  97         if (MS_Host_RequestSense(&DiskHost_MS_Interface
, 0, &SenseData
) != 0) 
  99                 LEDs_SetAllLEDs(LEDMASK_USB_ERROR
); 
 103         pf_mount(&DiskFATState
); 
 105         LEDs_SetAllLEDs(LEDMASK_USB_READY
); 
 108 void EVENT_USB_Host_DeviceAttached(void) 
 110         LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING
); 
 113 void EVENT_USB_Host_DeviceUnattached(void) 
 115         LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY
);