File tree Expand file tree Collapse file tree 6 files changed +45
-10
lines changed
Expand file tree Collapse file tree 6 files changed +45
-10
lines changed Original file line number Diff line number Diff line change @@ -56,15 +56,26 @@ void setup() {
5656
5757 // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
5858 if (!fatFs.init ()) {
59- Serial.println (" Could not find FAT16/FAT32 partition.\n Make sure you've formatted the card" );
59+ Serial.println (" Could not find FAT partition.\n Make sure you've formatted the card" );
6060 return ;
6161 }
6262
6363 // print the type and size of the first FAT-type volume
6464 uint64_t volumesize;
65- Serial.print (" \n Volume type is FAT" );
66- Serial.println (fatFs.fatType (), DEC);
67- Serial.println ();
65+ Serial.print (" \n Volume type is " );
66+ uint8_t fatType = fatFs.fatType ();
67+ #if defined(FAT_TYPE_EXFAT)
68+ if (fatType == FAT_TYPE_EXFAT) {
69+ Serial.println (" exFAT" );
70+ } else
71+ #endif
72+ {
73+ if (fatType != FAT_TYPE_UNK) {
74+ Serial.printf (" FAT%u\n " , fatFs.fatType ());
75+ } else {
76+ Serial.println (" unknown" );
77+ }
78+ }
6879
6980 volumesize = fatFs.blocksPerCluster (); // clusters are collections of blocks
7081 volumesize *= fatFs.clusterCount (); // we'll have a lot of clusters
Original file line number Diff line number Diff line change @@ -37,3 +37,8 @@ setDxDIR KEYWORD2
3737#######################################
3838FILE_READ LITERAL1
3939FILE_WRITE LITERAL1
40+ FAT_TYPE_EXFAT LITERAL1
41+ FAT_TYPE_FAT12 LITERAL1
42+ FAT_TYPE_FAT16 LITERAL1
43+ FAT_TYPE_FAT32 LITERAL1
44+ FAT_TYPE_UNK LITERAL1
Original file line number Diff line number Diff line change @@ -66,14 +66,24 @@ bool SdFatFs::deinit(void)
6666
6767uint8_t SdFatFs::fatType (void )
6868{
69+ uint8_t fatType = FAT_TYPE_UNK;
6970 switch (_SDFatFs.fs_type ) {
71+ #if defined(FS_EXFAT)
72+ case FS_EXFAT:
73+ fatType = FAT_TYPE_EXFAT;
74+ break ;
75+ #endif
7076 case FS_FAT12:
71- return 12 ;
77+ fatType = FAT_TYPE_FAT12;
78+ break ;
7279 case FS_FAT16:
73- return 16 ;
80+ fatType = FAT_TYPE_FAT16;
81+ break ;
7482 case FS_FAT32:
75- return 32 ;
83+ fatType = FAT_TYPE_FAT32;
84+ break ;
7685 default :
77- return 0 ;
86+ fatType = FAT_TYPE_UNK ;
7887 }
88+ return fatType;
7989}
Original file line number Diff line number Diff line change 4242/* FatFs includes component */
4343#include " FatFs.h"
4444
45+ /* Filesystem type (FATFS.fs_type) */
46+ #define FAT_TYPE_FAT12 12 // FS_FAT12
47+ #define FAT_TYPE_FAT16 16 // FS_FAT16
48+ #define FAT_TYPE_FAT32 32 // FS_FAT32
49+ #if defined(FS_EXFAT)
50+ #define FAT_TYPE_EXFAT 64 // FS_EXFAT
51+ #endif
52+ #define FAT_TYPE_UNK 0 // Unknown
53+
4554/* To match Arduino definition*/
4655#define FILE_WRITE FA_WRITE
4756#define FILE_READ FA_READ
Original file line number Diff line number Diff line change 230230/ buffer in the file system object (FATFS) is used for the file data transfer. */
231231
232232
233- #define _FS_EXFAT 0
233+ #define _FS_EXFAT 1
234234/* This option switches support of exFAT file system. (0:Disable or 1:Enable)
235235/ When enable exFAT, also LFN needs to be enabled. (_USE_LFN >= 1)
236236/ Note that enabling exFAT discards C89 compatibility. */
Original file line number Diff line number Diff line change 231231/ buffer in the filesystem object (FATFS) is used for the file data transfer. */
232232
233233
234- #define FF_FS_EXFAT 0
234+ #define FF_FS_EXFAT 1
235235/* This option switches support for exFAT filesystem. (0:Disable or 1:Enable)
236236/ To enable exFAT, also LFN needs to be enabled. (FF_USE_LFN >= 1)
237237/ Note that enabling exFAT discards ANSI C (C89) compatibility. */
You can’t perform that action at this time.
0 commit comments