Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 46 additions & 4 deletions src/SD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ File SDClass::openRoot(void)

if(f_opendir(&file._dir, _fatFs.getRoot()) != FR_OK)
{
#if _FATFS == 68300
file._dir.obj.fs = 0;
#else
file._dir.fs = 0;
#endif
}
return file;
}
Expand All @@ -196,8 +200,13 @@ File::File()
_name = NULL;
_fil = (FIL*)malloc(sizeof(FIL));
assert(_fil != NULL );
#if _FATFS == 68300
_fil->obj.fs = 0;
_dir.obj.fs = 0;
#else
_fil->fs = 0;
_dir.fs = 0;
#endif
}

File::File(const char* name)
Expand All @@ -207,8 +216,13 @@ File::File(const char* name)
sprintf(_name, "%s", name);
_fil = (FIL*)malloc(sizeof(FIL));
assert(_fil != NULL );
#if _FATFS == 68300
_fil->obj.fs = 0;
_dir.obj.fs = 0;
#else
_fil->fs = 0;
_dir.fs = 0;
#endif
}

/** List directory contents to Serial.
Expand All @@ -230,9 +244,13 @@ void File::ls(uint8_t flags, uint8_t indent) {
char *fn;

#if _USE_LFN
#if _FATFS == 68300
/* altname */
#else
static char lfn[_MAX_LFN];
fno.lfname = lfn;
fno.lfsize = sizeof(lfn);
#endif
#endif

while(1)
Expand All @@ -246,7 +264,7 @@ void File::ls(uint8_t flags, uint8_t indent) {
{
continue;
}
#if _USE_LFN
#if _USE_LFN && _FATFS != 68300
fn = *fno.lfname ? fno.lfname : fno.fname;
#else
fn = fno.fname;
Expand Down Expand Up @@ -377,7 +395,11 @@ void File::close()
{
if(_name)
{
#if _FATFS == 68300
if(_fil && _fil->obj.fs != 0) {
#else
if(_fil && _fil->fs != 0) {
#endif
/* Flush the file before close */
f_sync(_fil);

Expand All @@ -386,7 +408,11 @@ void File::close()
free(_fil);
}

#if _FATFS == 68300
if(_dir.obj.fs != 0) {
#else
if(_dir.fs != 0) {
#endif
f_closedir(&_dir);
}

Expand Down Expand Up @@ -468,7 +494,11 @@ uint32_t File::size()
}

File::operator bool() {
#if _FATFS == 68300
return ((_name == NULL) || ((_fil == NULL) && (_dir.obj.fs == 0)) || ((_fil != NULL) && (_fil->obj.fs == 0) && (_dir.obj.fs == 0))) ? FALSE : TRUE;
#else
return ((_name == NULL) || ((_fil == NULL) && (_dir.fs == 0)) || ((_fil != NULL) && (_fil->fs == 0) && (_dir.fs == 0))) ? FALSE : TRUE;
#endif
}
/**
* @brief Write data to the file
Expand Down Expand Up @@ -566,9 +596,17 @@ uint8_t File::isDirectory()
{
FILINFO fno;
assert(_name != NULL );
if (_dir.fs != 0)
#if _FATFS == 68300
if(_dir.obj.fs != 0)
#else
if(_dir.fs != 0)
#endif
return TRUE;
#if _FATFS == 68300
else if (_fil->obj.fs != 0)
#else
else if (_fil->fs != 0)
#endif
return FALSE;
// if not init get info
if (f_stat(_name, &fno) == FR_OK)
Expand All @@ -590,7 +628,7 @@ File File::openNextFile(uint8_t mode)
char *fullPath = NULL;
size_t name_len= strlen(_name);
size_t len = name_len;
#if _USE_LFN
#if _USE_LFN && _FATFS != 68300
static char lfn[_MAX_LFN];
fno.lfname = lfn;
fno.lfsize = sizeof(lfn);
Expand All @@ -606,7 +644,7 @@ File File::openNextFile(uint8_t mode)
{
continue;
}
#if _USE_LFN
#if _USE_LFN && _FATFS != 68300
fn = *fno.lfname ? fno.lfname : fno.fname;
#else
fn = fno.fname;
Expand Down Expand Up @@ -634,7 +672,11 @@ void File::rewindDirectory(void)
{
if(isDirectory())
{
#if _FATFS == 68300
if(_dir.obj.fs != 0) {
#else
if(_dir.fs != 0) {
#endif
f_closedir(&_dir);
}
f_opendir(&_dir, _name);
Expand Down
4 changes: 4 additions & 0 deletions src/bsp_sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@
#define SD_CLK_PWR_SAVE SDMMC_CLOCK_POWER_SAVE_DISABLE
#define SD_BUS_WIDE_1B SDMMC_BUS_WIDE_1B
#define SD_BUS_WIDE_4B SDMMC_BUS_WIDE_4B
#ifndef SD_HW_FLOW_CTRL
#define SD_HW_FLOW_CTRL SDMMC_HARDWARE_FLOW_CONTROL_DISABLE
#endif
#define SD_CLK_DIV SDMMC_TRANSFER_CLK_DIV
/* Definition for MSP SD */
#define SD_AF GPIO_AF12_SDMMC1
Expand All @@ -105,7 +107,9 @@
#define SD_CLK_PWR_SAVE SDIO_CLOCK_POWER_SAVE_DISABLE
#define SD_BUS_WIDE_1B SDIO_BUS_WIDE_1B
#define SD_BUS_WIDE_4B SDIO_BUS_WIDE_4B
#ifndef SD_HW_FLOW_CTRL
#define SD_HW_FLOW_CTRL SDIO_HARDWARE_FLOW_CONTROL_DISABLE
#endif
#define SD_CLK_DIV SDIO_TRANSFER_CLK_DIV
/* Definition for MSP SD */
#define SD_AF GPIO_AF12_SDIO
Expand Down
6 changes: 5 additions & 1 deletion src/ffconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#if __has_include("ffconf_custom.h")
#include "ffconf_custom.h"
#else
#include "ffconf_default.h"
#if _FATFS == 68300
#include "ffconf_default_68300.h"
#else
#include "ffconf_default_32020.h"
#endif
#endif
#endif /* _ARDUINO_FFCONF_H */
File renamed without changes.
Loading