Skip to content

Commit

Permalink
support mass storage above 4gb
Browse files Browse the repository at this point in the history
  • Loading branch information
arpruss committed Aug 18, 2018
1 parent 62a8984 commit 440732d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions examples/mass/mass.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ USBCompositeSerial CompositeSerial;

#include "image.h"

bool write(uint32_t memoryOffset, const uint8_t *writebuff, uint16_t transferLength) {
memcpy(image+memoryOffset, writebuff, transferLength);
bool write(const uint8_t *writebuff, uint32_t memoryOffset, uint16_t transferLength) {
memcpy(image+SCSI_BLOCK_SIZE*memoryOffset, writebuff, SCSI_BLOCK_SIZE*transferLength);

return true;
}

bool read(uint32_t memoryOffset, uint8_t *readbuff, uint16_t transferLength) {
memcpy(readbuff, image+memoryOffset, transferLength);
bool read(uint8_t *readbuff, uint32_t memoryOffset, uint16_t transferLength) {
memcpy(readbuff, image+SCSI_BLOCK_SIZE*memoryOffset, SCSI_BLOCK_SIZE*transferLength);

return true;
}
Expand Down Expand Up @@ -55,7 +55,7 @@ void dumpDrive() {

void setup() {
USBComposite.setProductId(PRODUCT_ID);
MassStorage.setDrive(0, sizeof(image), read, write);
MassStorage.setDriveData(0, sizeof(image)/SCSI_BLOCK_SIZE, read, write);
MassStorage.registerComponent();
CompositeSerial.registerComponent();
USBComposite.begin();
Expand All @@ -68,4 +68,4 @@ void loop() {
dumpDrive();
}
}


12 changes: 6 additions & 6 deletions examples/sdreader/sdreader.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ const uint8_t SD_CHIP_SELECT = SS;
bool enabled = false;
uint32 cardSize;

bool write(uint32_t memoryOffset, const uint8_t *writebuff, uint16_t transferLength) {
return sd.card()->writeBlocks(memoryOffset/512, writebuff, transferLength/512);
bool write(const uint8_t *writebuff, uint32_t startSector, uint16_t numSectors) {
return sd.card()->writeBlocks(startSector, writebuff, numSectors);
}

bool read(uint32_t memoryOffset, uint8_t *readbuff, uint16_t transferLength) {
return sd.card()->readBlocks(memoryOffset/512, readbuff, transferLength/512);
bool read(uint8_t *readbuff, uint32_t startSector, uint16_t numSectors) {
return sd.card()->readBlocks(startSector, readbuff, numSectors);
}

void setup() {
Expand All @@ -34,7 +34,7 @@ void setup() {
void initReader() {
digitalWrite(LED_PIN,0);
cardSize = sd.card()->cardSize();
MassStorage.setDrive(0, cardSize*512, read, write);
MassStorage.setDriveData(0, cardSize, read, write);
MassStorage.registerComponent();
CompositeSerial.registerComponent();
USBComposite.begin();
Expand All @@ -54,4 +54,4 @@ void loop() {
MassStorage.loop();
}
}


0 comments on commit 440732d

Please sign in to comment.