Open rogerclarkmelbourne opened 9 years ago
I haven't tried this library out in a very long time. I've since moved on from using Maples and have been using STM32 development boards instead. From what I remember I did not need to change premain or overide main. This should be all you need...
uint32_t MAL_massBlockCount[2];
uint32_t MAL_massBlockSize[2];
void setup() {
MAL_massBlockCount[0] = 100;
MAL_massBlockCount[1] = 0;
MAL_massBlockSize[0] = 512;
MAL_massBlockSize[1] = 0;
USBMassStorage.begin();
}
void loop() {
USBMassStorage.loop();
}
extern "C" uint16_t usb_mass_mal_write_memory(uint8_t lun, uint32_t memoryOffset, uint8_t *writebuff, uint16_t transferLength) {
uint32_t block = memoryOffset / 512;
if (lun != 0) {
return USB_MASS_MAL_FAIL;
}
if (sdcard.writeBlock(block, writebuff)) {
return USB_MASS_MAL_SUCCESS;
}
return USB_MASS_MAL_FAIL;
}
extern "C" uint16_t usb_mass_mal_read_memory(uint8_t lun, uint32_t memoryOffset, uint8_t *readbuff, uint16_t transferLength) {
if (lun != 0) {
return USB_MASS_MAL_FAIL;
}
if (sdcard.readBlock(memoryOffset / 512, readbuff)) {
return USB_MASS_MAL_SUCCESS;
}
return USB_MASS_MAL_FAIL;
}
Thanks Joe,
I'm using an updated version of libmaple that is compatible with the new version of the Arduino IDE, now that it has support for ARM processors by default (because of the Due / SAM product)
There are also some other clean room developments to bring Arduino IDE to the F3 and other variants - so there seems to be a bit of a resergence in interest, especially as Maple mini clones are only only $5 on eBay and AliExpress etc, and I even managed to pick up an enhanced Maple board from iTeadStudio for $13 - which is a pretty good deal.
Anyway, I'll give you example code a try, but think the extern C declarations now have issues compiling (not sure precisely why at the moment)
Thanks again
Roger
Hi,
I have tried to use the library, but looking at the example, it appears to be necessary to override the core of the Arduino system by replacing main() and premain() etc
e.g. if I try to add premain() to a normal sketch I get the error
multiple definition of `premain()'
Also. It doesnt seem to be possible to put the helper functions inside the main sketch file
e.g. adding
extern "C" uint16_t usb_mass_mal_init(uint8_t lun) { return 0; }
gives the error
massStorage.ino:7:21: error: previous declaration of 'uint16_t usb_mass_mal_init(uint8_t)' with 'C++' linkage massStorage.ino:6:50: error: conflicts with new declaration with 'C' linkage
Thanks