CN - Adds support for a mass storage USB device in the main firmware.

By default, the firmware includes the USB joystick device, but it is possible to replace this code with a mass storage device that allows access to the SD card when running the main firmware.
To include the mass storage device and remove the joystick device, add "USB=MASS" to the command line args when making the firmware.
This commit is contained in:
Chris Nisbet
2014-06-19 16:57:17 +12:00
parent b83f95ed1a
commit 07b4be8f45
9 changed files with 3955 additions and 3865 deletions
@@ -97,7 +97,7 @@ static int8_t SCSI_ReadFormatCapacity(uint8_t lun, uint8_t *params);
static int8_t SCSI_ReadCapacity10(uint8_t lun, uint8_t *params);
static int8_t SCSI_RequestSense (uint8_t lun, uint8_t *params);
static int8_t SCSI_StartStopUnit(uint8_t lun, uint8_t *params);
static int8_t SCSI_AllowRemoval(uint8_t lun, uint8_t *params);
static int8_t SCSI_AllowRemoval(uint8_t lun, uint8_t *params);
static int8_t SCSI_ModeSense6 (uint8_t lun, uint8_t *params);
static int8_t SCSI_ModeSense10 (uint8_t lun, uint8_t *params);
static int8_t SCSI_Write10(uint8_t lun , uint8_t *params);
@@ -147,7 +147,7 @@ int8_t SCSI_ProcessCmd(USB_OTG_CORE_HANDLE *pdev,
return SCSI_StartStopUnit(lun, params);
case SCSI_ALLOW_MEDIUM_REMOVAL:
return SCSI_AllowRemoval( lun, params);
return SCSI_AllowRemoval( lun, params);
case SCSI_MODE_SENSE6:
return SCSI_ModeSense6 (lun, params);
@@ -433,24 +433,29 @@ void SCSI_SenseCode(uint8_t lun, uint8_t sKey, uint8_t ASC)
* @param params: Command parameters
* @retval status
*/
extern uint8_t lunReady[] ;
extern uint8_t lunReady[] ;
static int8_t SCSI_StartStopUnit(uint8_t lun, uint8_t *params)
{
MSC_BOT_DataLen = 0;
if (lun < 2) {
if (params[4] & 1) {
// lun to be active
lunReady[lun] = 1 ;
}
else {
// lun to be ejected
lunReady[lun] = 0 ;
}
}
#if defined(BOOT)
if (lun < 2)
#else
if (lun < 1)
#endif
{
if (params[4] & 1) {
// lun to be active
lunReady[lun] = 1 ;
}
else {
// lun to be ejected
lunReady[lun] = 0 ;
}
}
return 0;
}