return true; | return true; | ||||
} | } | ||||
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ | ||||
inline bool lfnLegalChar(char c) { | |||||
inline bool lfnLegalChar(uint8_t c) { | |||||
if (c == '/' || c == '\\' || c == '"' || c == '*' || | if (c == '/' || c == '\\' || c == '"' || c == '*' || | ||||
c == ':' || c == '<' || c == '>' || c == '?' || c == '|') { | c == ':' || c == '<' || c == '>' || c == '?' || c == '|') { | ||||
return false; | return false; | ||||
break; | break; | ||||
} | } | ||||
if (!lfnLegalChar(c)) { | if (!lfnLegalChar(c)) { | ||||
return false; | |||||
DBG_FAIL_MACRO; | |||||
goto fail; | |||||
} | } | ||||
} | } | ||||
// Advance to next path component. | // Advance to next path component. | ||||
} | } | ||||
// Max length of LFN is 255. | // Max length of LFN is 255. | ||||
if (len > 255) { | if (len > 255) { | ||||
return false; | |||||
DBG_FAIL_MACRO; | |||||
goto fail; | |||||
} | } | ||||
fname->len = len; | fname->len = len; | ||||
// Blank file short name. | // Blank file short name. | ||||
} | } | ||||
} | } | ||||
if (fname->sfn[0] == ' ') { | if (fname->sfn[0] == ' ') { | ||||
return false; | |||||
DBG_FAIL_MACRO; | |||||
goto fail; | |||||
} | } | ||||
if (is83) { | if (is83) { | ||||
fname->sfn[fname->seqPos + 1] = '1'; | fname->sfn[fname->seqPos + 1] = '1'; | ||||
} | } | ||||
return true; | return true; | ||||
fail: | |||||
return false; | |||||
} | } | ||||
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ | ||||
bool FatFile::open(FatFile* dirFile, fname_t* fname, oflag_t oflag) { | bool FatFile::open(FatFile* dirFile, fname_t* fname, oflag_t oflag) { |
// add speed strength args? | // add speed strength args? | ||||
static void enableGPIO(bool enable) { | static void enableGPIO(bool enable) { | ||||
const uint32_t CLOCK_MASK = IOMUXC_SW_PAD_CTL_PAD_PKE | | const uint32_t CLOCK_MASK = IOMUXC_SW_PAD_CTL_PAD_PKE | | ||||
// IOMUXC_SW_PAD_CTL_PAD_DSE(1) | | |||||
#if defined(ARDUINO_TEENSY41) | |||||
IOMUXC_SW_PAD_CTL_PAD_DSE(1) | | |||||
#else // defined(ARDUINO_TEENSY41) | |||||
IOMUXC_SW_PAD_CTL_PAD_DSE(4) | ///// WHG | IOMUXC_SW_PAD_CTL_PAD_DSE(4) | ///// WHG | ||||
#endif // defined(ARDUINO_TEENSY41) | |||||
IOMUXC_SW_PAD_CTL_PAD_SPEED(2); | IOMUXC_SW_PAD_CTL_PAD_SPEED(2); | ||||
const uint32_t DATA_MASK = CLOCK_MASK | IOMUXC_SW_PAD_CTL_PAD_PUE | | const uint32_t DATA_MASK = CLOCK_MASK | IOMUXC_SW_PAD_CTL_PAD_PUE | |
#define ENABLE_ARDUINO_SERIAL 1 | #define ENABLE_ARDUINO_SERIAL 1 | ||||
/** For Debug - must be one */ | /** For Debug - must be one */ | ||||
#define ENABLE_ARDUINO_STRING 1 | #define ENABLE_ARDUINO_STRING 1 | ||||
//------------------------------------------------------------------------------ | |||||
/** Set USE_BLOCK_DEVICE_INTERFACE nonzero to use generic block device */ | /** Set USE_BLOCK_DEVICE_INTERFACE nonzero to use generic block device */ | ||||
#define USE_BLOCK_DEVICE_INTERFACE 0 | #define USE_BLOCK_DEVICE_INTERFACE 0 | ||||
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ | ||||
#elif defined(__arm__) | #elif defined(__arm__) | ||||
// ARM gcc defines open flags. | // ARM gcc defines open flags. | ||||
#define USE_FCNTL_H 1 | #define USE_FCNTL_H 1 | ||||
#elif defined(ESP32) | |||||
#define USE_FCNTL_H 1 | |||||
#else // defined(__AVR__) | #else // defined(__AVR__) | ||||
#define USE_FCNTL_H 0 | #define USE_FCNTL_H 0 | ||||
#endif // defined(__AVR__) | #endif // defined(__AVR__) |