T4.1 SD Card with Memory stick on USB Host

TeensyWolf

Well-known member
#include <SdFat.h>
#include <USBHost_t36.h>

Above is my include files - but I'm working on reading and writing to USB and SD Card. I haven't written the code yet, but it's throwing a warning that FILE_READ & FILE_WRITE are being redefined - which could be bad. Is there a workaround?
Compiling .pio/build/teensy41/src/sdUsbDrive.cpp.o
In file included from /Users/twolfe/.platformio/packages/framework-arduinoteensy/libraries/USBHost_t36/USBHost_t36.h:28,
from src/sdUsbDrive.cpp:5:
/Users/twolfe/.platformio/packages/framework-arduinoteensy/cores/teensy4/FS.h:37: warning: "FILE_READ" redefined
37 | #define FILE_READ 0
|
In file included from /Users/twolfe/.platformio/packages/framework-arduinoteensy/libraries/SdFat/src/ExFatLib/ExFatFile.h:821,
from /Users/twolfe/.platformio/packages/framework-arduinoteensy/libraries/SdFat/src/ExFatLib/ExFatVolume.h:27,
from /Users/twolfe/.platformio/packages/framework-arduinoteensy/libraries/SdFat/src/ExFatLib/ExFatLib.h:27,
from /Users/twolfe/.platformio/packages/framework-arduinoteensy/libraries/SdFat/src/SdFat.h:35,
from src/sdUsbDrive.cpp:1:
/Users/twolfe/.platformio/packages/framework-arduinoteensy/libraries/SdFat/src/ExFatLib/../common/ArduinoFiles.h:31: note: this is the location of the previous definition
31 | #define FILE_READ O_RDONLY
|
In file included from /Users/twolfe/.platformio/packages/framework-arduinoteensy/libraries/USBHost_t36/USBHost_t36.h:28,
from src/sdUsbDrive.cpp:5:
/Users/twolfe/.platformio/packages/framework-arduinoteensy/cores/teensy4/FS.h:38: warning: "FILE_WRITE" redefined
38 | #define FILE_WRITE 1
|
In file included from /Users/twolfe/.platformio/packages/framework-arduinoteensy/libraries/SdFat/src/ExFatLib/ExFatFile.h:821,
from /Users/twolfe/.platformio/packages/framework-arduinoteensy/libraries/SdFat/src/ExFatLib/ExFatVolume.h:27,
from /Users/twolfe/.platformio/packages/framework-arduinoteensy/libraries/SdFat/src/ExFatLib/ExFatLib.h:27,
from /Users/twolfe/.platformio/packages/framework-arduinoteensy/libraries/SdFat/src/SdFat.h:35,
from src/sdUsbDrive.cpp:1:
/Users/twolfe/.platformio/packages/framework-arduinoteensy/libraries/SdFat/src/ExFatLib/../common/ArduinoFiles.h:35: note: this is the location of the previous definition
35 | #define FILE_WRITE (O_RDWR | O_CREAT | O_AT_END)
 
I am running PlatformIO
CONFIGURATION: https://docs.platformio.org/page/boards/teensy/teensy41.html
PLATFORM: Teensy (5.0.0) > Teensy 4.1
HARDWARE: IMXRT1062 600MHz, 512KB RAM, 7.75MB Flash
DEBUG: Current (jlink) External (jlink)
PACKAGES:
- framework-arduinoteensy @ 1.159.0 (1.59)
- tool-teensy @ 1.159.0 (1.59)

If I do this, it seems to work

Code:
#include <SdFat.h>
#define FILE_READ_SD O_RDONLY
#define FILE_WRITE_SD ( O_RDWR | O_CREAT | O_AT_END )
// Hide SdFat’s macros so FS.h can redefine them cleanly:
#undef FILE_READ
#undef FILE_WRITE
#include <USBHost_t36.h>  // now FS.h defines FILE_READ/FILE_WRITE = 0/1
#define FILE_READ_USB FILE_READ
#define FILE_WRITE_USB FILE_WRITE
 
Back
Top