Browse Source

Merge pull request #57 from hathach/msc-interface

Improve MSC Reset() and GetMaxLun()
main
Paul Stoffregen 3 years ago
parent
commit
1adb9ff578
No account linked to committer's email address
2 changed files with 11 additions and 8 deletions
  1. +8
    -6
      MassStorageDriver.cpp
  2. +3
    -2
      USBHost_t36.h

+ 8
- 6
MassStorageDriver.cpp View File

if (descriptors[6] != 6) return false; // bInterfaceSubClass, 6 = SCSI transparent command set (SCSI Standards) if (descriptors[6] != 6) return false; // bInterfaceSubClass, 6 = SCSI transparent command set (SCSI Standards)
if (descriptors[7] != 80) return false; // bInterfaceProtocol, 80 = BULK-ONLY TRANSPORT if (descriptors[7] != 80) return false; // bInterfaceProtocol, 80 = BULK-ONLY TRANSPORT


bInterfaceNumber = descriptors[2];

uint8_t desc_index = 9; uint8_t desc_index = 9;
uint8_t in_index = 0xff, out_index = 0xff; uint8_t in_index = 0xff, out_index = 0xff;


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


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


//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Perform Mass Storage Reset // Perform Mass Storage Reset
void msController::msReset(uint32_t interfaceNumber) {
void msController::msReset(void) {
#ifdef DBGprint #ifdef DBGprint
Serial.printf("msReset()\n"); Serial.printf("msReset()\n");
#endif #endif
mk_setup(setup, 0x21, 0xff, 0, interfaceNumber, 0);
mk_setup(setup, 0x21, 0xff, 0, bInterfaceNumber, 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(uint32_t interfaceNumber) {
uint8_t msController::msGetMaxLun(void) {
#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, interfaceNumber, 1);
mk_setup(setup, 0xa1, 0xfe, 0, bInterfaceNumber, 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;

+ 3
- 2
USBHost_t36.h View File



bool mscTransferComplete = false; bool mscTransferComplete = false;
uint8_t mscInit(void); uint8_t mscInit(void);
void msReset(uint32_t interfaceNumber);
uint8_t msGetMaxLun(uint32_t interfaceNumber);
void msReset(void);
uint8_t msGetMaxLun(void);
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; }
uint32_t packetSizeOut; uint32_t packetSizeOut;
Pipe_t *datapipeIn; Pipe_t *datapipeIn;
Pipe_t *datapipeOut; Pipe_t *datapipeOut;
uint8_t bInterfaceNumber;
uint32_t endpointIn = 0; uint32_t endpointIn = 0;
uint32_t endpointOut = 0; uint32_t endpointOut = 0;
setup_t setup; setup_t setup;

Loading…
Cancel
Save