Skip to content

Commit cfefe5c

Browse files
authored
Merge pull request #7 from fpistm/0.12c
Add compatibility with FatFs 0.12c
2 parents a9922f4 + 667c50d commit cfefe5c

File tree

5 files changed

+381
-5
lines changed

5 files changed

+381
-5
lines changed

Diff for: src/SD.cpp

+46-4
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,11 @@ File SDClass::openRoot(void)
186186

187187
if(f_opendir(&file._dir, _fatFs.getRoot()) != FR_OK)
188188
{
189+
#if _FATFS == 68300
190+
file._dir.obj.fs = 0;
191+
#else
189192
file._dir.fs = 0;
193+
#endif
190194
}
191195
return file;
192196
}
@@ -196,8 +200,13 @@ File::File()
196200
_name = NULL;
197201
_fil = (FIL*)malloc(sizeof(FIL));
198202
assert(_fil != NULL );
203+
#if _FATFS == 68300
204+
_fil->obj.fs = 0;
205+
_dir.obj.fs = 0;
206+
#else
199207
_fil->fs = 0;
200208
_dir.fs = 0;
209+
#endif
201210
}
202211

203212
File::File(const char* name)
@@ -207,8 +216,13 @@ File::File(const char* name)
207216
sprintf(_name, "%s", name);
208217
_fil = (FIL*)malloc(sizeof(FIL));
209218
assert(_fil != NULL );
219+
#if _FATFS == 68300
220+
_fil->obj.fs = 0;
221+
_dir.obj.fs = 0;
222+
#else
210223
_fil->fs = 0;
211224
_dir.fs = 0;
225+
#endif
212226
}
213227

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

232246
#if _USE_LFN
247+
#if _FATFS == 68300
248+
/* altname */
249+
#else
233250
static char lfn[_MAX_LFN];
234251
fno.lfname = lfn;
235252
fno.lfsize = sizeof(lfn);
253+
#endif
236254
#endif
237255

238256
while(1)
@@ -246,7 +264,7 @@ void File::ls(uint8_t flags, uint8_t indent) {
246264
{
247265
continue;
248266
}
249-
#if _USE_LFN
267+
#if _USE_LFN && _FATFS != 68300
250268
fn = *fno.lfname ? fno.lfname : fno.fname;
251269
#else
252270
fn = fno.fname;
@@ -377,7 +395,11 @@ void File::close()
377395
{
378396
if(_name)
379397
{
398+
#if _FATFS == 68300
399+
if(_fil && _fil->obj.fs != 0) {
400+
#else
380401
if(_fil && _fil->fs != 0) {
402+
#endif
381403
/* Flush the file before close */
382404
f_sync(_fil);
383405

@@ -386,7 +408,11 @@ void File::close()
386408
free(_fil);
387409
}
388410

411+
#if _FATFS == 68300
412+
if(_dir.obj.fs != 0) {
413+
#else
389414
if(_dir.fs != 0) {
415+
#endif
390416
f_closedir(&_dir);
391417
}
392418

@@ -468,7 +494,11 @@ uint32_t File::size()
468494
}
469495

470496
File::operator bool() {
497+
#if _FATFS == 68300
498+
return ((_name == NULL) || ((_fil == NULL) && (_dir.obj.fs == 0)) || ((_fil != NULL) && (_fil->obj.fs == 0) && (_dir.obj.fs == 0))) ? FALSE : TRUE;
499+
#else
471500
return ((_name == NULL) || ((_fil == NULL) && (_dir.fs == 0)) || ((_fil != NULL) && (_fil->fs == 0) && (_dir.fs == 0))) ? FALSE : TRUE;
501+
#endif
472502
}
473503
/**
474504
* @brief Write data to the file
@@ -566,9 +596,17 @@ uint8_t File::isDirectory()
566596
{
567597
FILINFO fno;
568598
assert(_name != NULL );
569-
if (_dir.fs != 0)
599+
#if _FATFS == 68300
600+
if(_dir.obj.fs != 0)
601+
#else
602+
if(_dir.fs != 0)
603+
#endif
570604
return TRUE;
605+
#if _FATFS == 68300
606+
else if (_fil->obj.fs != 0)
607+
#else
571608
else if (_fil->fs != 0)
609+
#endif
572610
return FALSE;
573611
// if not init get info
574612
if (f_stat(_name, &fno) == FR_OK)
@@ -590,7 +628,7 @@ File File::openNextFile(uint8_t mode)
590628
char *fullPath = NULL;
591629
size_t name_len= strlen(_name);
592630
size_t len = name_len;
593-
#if _USE_LFN
631+
#if _USE_LFN && _FATFS != 68300
594632
static char lfn[_MAX_LFN];
595633
fno.lfname = lfn;
596634
fno.lfsize = sizeof(lfn);
@@ -606,7 +644,7 @@ File File::openNextFile(uint8_t mode)
606644
{
607645
continue;
608646
}
609-
#if _USE_LFN
647+
#if _USE_LFN && _FATFS != 68300
610648
fn = *fno.lfname ? fno.lfname : fno.fname;
611649
#else
612650
fn = fno.fname;
@@ -634,7 +672,11 @@ void File::rewindDirectory(void)
634672
{
635673
if(isDirectory())
636674
{
675+
#if _FATFS == 68300
676+
if(_dir.obj.fs != 0) {
677+
#else
637678
if(_dir.fs != 0) {
679+
#endif
638680
f_closedir(&_dir);
639681
}
640682
f_opendir(&_dir, _name);

Diff for: src/bsp_sd.c

+4
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@
9191
#define SD_CLK_PWR_SAVE SDMMC_CLOCK_POWER_SAVE_DISABLE
9292
#define SD_BUS_WIDE_1B SDMMC_BUS_WIDE_1B
9393
#define SD_BUS_WIDE_4B SDMMC_BUS_WIDE_4B
94+
#ifndef SD_HW_FLOW_CTRL
9495
#define SD_HW_FLOW_CTRL SDMMC_HARDWARE_FLOW_CONTROL_DISABLE
96+
#endif
9597
#define SD_CLK_DIV SDMMC_TRANSFER_CLK_DIV
9698
/* Definition for MSP SD */
9799
#define SD_AF GPIO_AF12_SDMMC1
@@ -105,7 +107,9 @@
105107
#define SD_CLK_PWR_SAVE SDIO_CLOCK_POWER_SAVE_DISABLE
106108
#define SD_BUS_WIDE_1B SDIO_BUS_WIDE_1B
107109
#define SD_BUS_WIDE_4B SDIO_BUS_WIDE_4B
110+
#ifndef SD_HW_FLOW_CTRL
108111
#define SD_HW_FLOW_CTRL SDIO_HARDWARE_FLOW_CONTROL_DISABLE
112+
#endif
109113
#define SD_CLK_DIV SDIO_TRANSFER_CLK_DIV
110114
/* Definition for MSP SD */
111115
#define SD_AF GPIO_AF12_SDIO

Diff for: src/ffconf.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
#if __has_include("ffconf_custom.h")
1313
#include "ffconf_custom.h"
1414
#else
15-
#include "ffconf_default.h"
15+
#if _FATFS == 68300
16+
#include "ffconf_default_68300.h"
17+
#else
18+
#include "ffconf_default_32020.h"
19+
#endif
1620
#endif
1721
#endif /* _ARDUINO_FFCONF_H */
File renamed without changes.

0 commit comments

Comments
 (0)