3      Copyright (C) Dean Camera, 2009. 
   5   dean [at] fourwalledcubicle [dot] com 
   6       www.fourwalledcubicle.com 
  10   Copyright 2009  Dean Camera (dean [at] fourwalledcubicle [dot] com) 
  12   Permission to use, copy, modify, and distribute this software 
  13   and its documentation for any purpose and without fee is hereby 
  14   granted, provided that the above copyright notice appear in all 
  15   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 
  31 #include "DiskDevice.h" 
  33 #if defined(USB_CAN_BE_DEVICE) 
  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_Device_t DiskDevice_MS_Interface 
= 
  44                                 .DataINEndpointNumber      
= MASS_STORAGE_IN_EPNUM
, 
  45                                 .DataINEndpointSize        
= MASS_STORAGE_IO_EPSIZE
, 
  46                                 .DataINEndpointDoubleBank  
= false, 
  48                                 .DataOUTEndpointNumber     
= MASS_STORAGE_OUT_EPNUM
, 
  49                                 .DataOUTEndpointSize       
= MASS_STORAGE_IO_EPSIZE
, 
  50                                 .DataOUTEndpointDoubleBank 
= false, 
  56 void DiskDevice_USBTask(void) 
  58         MS_Device_USBTask(&DiskDevice_MS_Interface
); 
  61 /** Event handler for the library USB Connection event. */ 
  62 void EVENT_USB_Device_Connect(void) 
  64         LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING
); 
  67 /** Event handler for the library USB Disconnection event. */ 
  68 void EVENT_USB_Device_Disconnect(void) 
  70         LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY
); 
  73 /** Event handler for the library USB Configuration Changed event. */ 
  74 void EVENT_USB_Device_ConfigurationChanged(void) 
  76         LEDs_SetAllLEDs(LEDMASK_USB_READY
); 
  78         if (!(MS_Device_ConfigureEndpoints(&DiskDevice_MS_Interface
))) 
  79           LEDs_SetAllLEDs(LEDMASK_USB_ERROR
); 
  82 /** Event handler for the library USB Unhandled Control Request event. */ 
  83 void EVENT_USB_Device_UnhandledControlRequest(void) 
  85         MS_Device_ProcessControlRequest(&DiskDevice_MS_Interface
); 
  88 /** Mass Storage class driver callback function the reception of SCSI commands from the host, which must be processed. 
  90  *  \param[in] MSInterfaceInfo  Pointer to the Mass Storage class interface configuration structure being referenced 
  92 bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t
* MSInterfaceInfo
) 
  96         LEDs_SetAllLEDs(LEDMASK_USB_BUSY
); 
  97         CommandSuccess 
= SCSI_DecodeSCSICommand(MSInterfaceInfo
); 
  98         LEDs_SetAllLEDs(LEDMASK_USB_READY
); 
 100         return CommandSuccess
;