Sfoglia il codice sorgente

Merge pull request #55 from wwatson4506/master

Updates for MassStorageDrivver.cpp and USBHost_t36.h
main
Paul Stoffregen 3 anni fa
parent
commit
6440f550fe
Nessun account collegato all'indirizzo email del committer
2 ha cambiato i file con 13 aggiunte e 47 eliminazioni
  1. +11
    -36
      MassStorageDriver.cpp
  2. +2
    -11
      USBHost_t36.h

+ 11
- 36
MassStorageDriver.cpp Vedi File

@@ -196,9 +196,10 @@ uint8_t msController::mscInit(void) {
yield();
} while(!available());
msReset();
msReset(0); // Assume bNumInterfaces = 1 for now.
delay(500);
maxLUN = msGetMaxLun();
maxLUN = msGetMaxLun(0); // Assume bNumInterfaces = 1 for now

// msResult = msReportLUNs(&maxLUN);
//Serial.printf("maxLUN = %d\n",maxLUN);
// delay(150);
@@ -228,11 +229,11 @@ uint8_t msController::mscInit(void) {

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

//---------------------------------------------------------------------------
// Get MAX LUN
uint8_t msController::msGetMaxLun() {
uint8_t msController::msGetMaxLun(uint32_t interfaceNumber) {
#ifdef DBGprint
Serial.printf("msGetMaxLun()\n");
#endif
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);
while (!msControlCompleted) yield();
msControlCompleted = false;
@@ -559,36 +560,10 @@ uint8_t msController::msProcessError(uint8_t msStatus) {
return MS_CSW_SIG_ERROR;
break;
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:
Serial.printf("SCSI Error: %d\n",msStatus);
return msStatus;

+ 2
- 11
USBHost_t36.h Vedi File

@@ -62,15 +62,6 @@
//#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
//#define USBHDBGSerial Serial1
#ifndef USBHDBGSerial
@@ -2058,8 +2049,8 @@ public:

bool mscTransferComplete = false;
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;}
uint8_t msCurrentLun() {return currentLUN;}
bool available() { delay(0); return deviceAvailable; }

Loading…
Annulla
Salva