Browse Source

Merge pull request #55 from wwatson4506/master

Updates for MassStorageDrivver.cpp and USBHost_t36.h
main
Paul Stoffregen 3 years ago
parent
commit
6440f550fe
No account linked to committer's email address
2 changed files with 13 additions and 47 deletions
  1. +11
    -36
      MassStorageDriver.cpp
  2. +2
    -11
      USBHost_t36.h

+ 11
- 36
MassStorageDriver.cpp View File

yield(); yield();
} while(!available()); } while(!available());
msReset();
msReset(0); // Assume bNumInterfaces = 1 for now.
delay(500); delay(500);
maxLUN = msGetMaxLun();
maxLUN = msGetMaxLun(0); // Assume bNumInterfaces = 1 for now

// msResult = msReportLUNs(&maxLUN); // msResult = msReportLUNs(&maxLUN);
//Serial.printf("maxLUN = %d\n",maxLUN); //Serial.printf("maxLUN = %d\n",maxLUN);
// delay(150); // delay(150);


//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Perform Mass Storage Reset // Perform Mass Storage Reset
void msController::msReset() {
void msController::msReset(uint32_t interfaceNumber) {
#ifdef DBGprint #ifdef DBGprint
Serial.printf("msReset()\n"); Serial.printf("msReset()\n");
#endif #endif
mk_setup(setup, 0x21, 0xff, 0, 0, 0);
mk_setup(setup, 0x21, 0xff, 0, interfaceNumber, 0);
queue_Control_Transfer(device, &setup, NULL, this); queue_Control_Transfer(device, &setup, NULL, this);
while (!msControlCompleted) yield(); while (!msControlCompleted) yield();
msControlCompleted = false; msControlCompleted = false;


//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Get MAX LUN // Get MAX LUN
uint8_t msController::msGetMaxLun() {
uint8_t msController::msGetMaxLun(uint32_t interfaceNumber) {
#ifdef DBGprint #ifdef DBGprint
Serial.printf("msGetMaxLun()\n"); Serial.printf("msGetMaxLun()\n");
#endif #endif
report[0] = 0; report[0] = 0;
mk_setup(setup, 0xa1, 0xfe, 0, 0, 1);
mk_setup(setup, 0xa1, 0xfe, 0, interfaceNumber, 1);
queue_Control_Transfer(device, &setup, report, this); queue_Control_Transfer(device, &setup, report, this);
while (!msControlCompleted) yield(); while (!msControlCompleted) yield();
msControlCompleted = false; msControlCompleted = false;
return MS_CSW_SIG_ERROR; return MS_CSW_SIG_ERROR;
break; break;
case MS_CBW_FAIL: case MS_CBW_FAIL:
msResult = msRequestSense(&msSense);
if(msResult) return msResult;
switch(msSense.SenseKey) {
case MS_UNIT_ATTENTION:
switch(msSense.AdditionalSenseCode) {
case MS_MEDIA_CHANGED:
return MS_MEDIA_CHANGED_ERR;
break;
default:
msStatus = MS_UNIT_NOT_READY;
}
case MS_NOT_READY:
switch(msSense.AdditionalSenseCode) {
case MS_MEDIUM_NOT_PRESENT:
msStatus = MS_NO_MEDIA_ERR;
break;
default:
msStatus = MS_UNIT_NOT_READY;
}
case MS_ILLEGAL_REQUEST:
switch(msSense.AdditionalSenseCode) {
case MS_LBA_OUT_OF_RANGE:
msStatus = MS_BAD_LBA_ERR;
break;
default:
msStatus = MS_CMD_ERR;
}
default:
msStatus = MS_SCSI_ERROR;
}
if(msResult = msRequestSense(&msSense))
Serial.printf("Failed to get sense codes. Returned code: %d\n",msResult);
return MS_CBW_FAIL;
break;
default: default:
Serial.printf("SCSI Error: %d\n",msStatus); Serial.printf("SCSI Error: %d\n",msStatus);
return msStatus; return msStatus;

+ 2
- 11
USBHost_t36.h View File

//#define USBHOST_PRINT_DEBUG //#define USBHOST_PRINT_DEBUG




// When developing a new driver, please edit ehci.cpp to set
// USBHS_USBCMD_ITC to zero. Today we set USBHS_USBCMD_ITC(1)
// because some drivers have race conditions exposed by
// non-delayed interrupts. Eventually USBHS_USBCMD_ITC will
// be changed to 0. Please test any new driver code with
// USBHS_USBCMD_ITC(0) so it won't break in the future when
// this change is made!


// This can let you control where to send the debugging messages // This can let you control where to send the debugging messages
//#define USBHDBGSerial Serial1 //#define USBHDBGSerial Serial1
#ifndef USBHDBGSerial #ifndef USBHDBGSerial


bool mscTransferComplete = false; bool mscTransferComplete = false;
uint8_t mscInit(void); uint8_t mscInit(void);
void msReset();
uint8_t msGetMaxLun();
void msReset(uint32_t interfaceNumber);
uint8_t msGetMaxLun(uint32_t interfaceNumber);
void msCurrentLun(uint8_t lun) {currentLUN = lun;} void msCurrentLun(uint8_t lun) {currentLUN = lun;}
uint8_t msCurrentLun() {return currentLUN;} uint8_t msCurrentLun() {return currentLUN;}
bool available() { delay(0); return deviceAvailable; } bool available() { delay(0); return deviceAvailable; }

Loading…
Cancel
Save