1
+ /*
2
+ esp_sd_common.h - ESP3D SD support class
3
+
4
+ Copyright (c) 2014 Luc Lebosse. All rights reserved.
5
+
6
+ This code is free software; you can redistribute it and/or
7
+ modify it under the terms of the GNU Lesser General Public
8
+ License as published by the Free Software Foundation; either
9
+ version 2.1 of the License, or (at your option) any later version.
10
+
11
+ This code is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public
17
+ License along with This code; if not, write to the Free Software
18
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+
21
+ #pragma once
22
+ #include " ../../../include/esp3d_config.h"
23
+
24
+ #define ESP_SD_FS_HEADER " /SD"
25
+
26
+ #define ESP_MAX_SD_OPENHANDLE 4
27
+
28
+ namespace ESP3D_SD {
29
+
30
+ #if (SD_DEVICE == ESP_SD_NATIVE) && defined(ARDUINO_ARCH_ESP8266)
31
+ #define FS_NO_GLOBALS
32
+ #define NO_GLOBAL_SD
33
+ #include < SD.h>
34
+ using ESP3D_File = fs::File;
35
+ using ESP3D_SD_Class = SDClass;
36
+ #endif // (SD_DEVICE == ESP_SD_NATIVE) && defined(ARDUINO_ARCH_ESP8266
37
+
38
+ #if ((SD_DEVICE == ESP_SDFAT) || (SD_DEVICE == ESP_SDFAT2)) && defined(ARDUINO_ARCH_ESP8266)
39
+ #define FS_NO_GLOBALS
40
+ #define NO_GLOBAL_SD
41
+ #include < SdFat.h>
42
+ #if SDFAT_FILE_TYPE == 1
43
+ using ESP3D_File = File32;
44
+ #elif SDFAT_FILE_TYPE == 2
45
+ using ESP3D_File = ExFile;
46
+ #elif SDFAT_FILE_TYPE == 3
47
+ using ESP3D_File = FsFile;
48
+ #else // SDFAT_FILE_TYPE
49
+ #error Invalid SDFAT_FILE_TYPE
50
+ #endif // SDFAT_FILE_TYPE
51
+ using ESP3D_SD_Class = SdFat;
52
+ #endif // ((SD_DEVICE == ESP_SDFAT) || (SD_DEVICE == ESP_SDFAT2)) && defined(ARDUINO_ARCH_ESP8266
53
+
54
+ #if ((SD_DEVICE == ESP_SDFAT) || (SD_DEVICE == ESP_SDFAT2)) && defined(ARDUINO_ARCH_ESP32)
55
+ #define FS_NO_GLOBALS
56
+ #define NO_GLOBAL_SD
57
+ #include < SdFat.h>
58
+ #if SDFAT_FILE_TYPE == 1
59
+ using ESP3D_File = File32;
60
+ #elif SDFAT_FILE_TYPE == 2
61
+ using ESP3D_File = ExFile;
62
+ #elif SDFAT_FILE_TYPE == 3
63
+ using ESP3D_File = FsFile;
64
+ #else // SDFAT_FILE_TYPE
65
+ #error Invalid SDFAT_FILE_TYPE
66
+ #endif // SDFAT_FILE_TYPE
67
+ using ESP3D_SD_Class = SdFat;
68
+ #endif // ((SD_DEVICE == ESP_SDFAT) || (SD_DEVICE == ESP_SDFAT2)) && defined(ARDUINO_ARCH_ESP32
69
+
70
+ #if (SD_DEVICE == ESP_SD_NATIVE) && defined(ARDUINO_ARCH_ESP32)
71
+ #define FS_NO_GLOBALS
72
+ #define NO_GLOBAL_SD
73
+ #include < FS.h>
74
+ #include < SD.h>
75
+ using ESP3D_File = fs::File;
76
+ using ESP3D_SD_Class = SDFileSystem;
77
+ #endif // (SD_DEVICE == ESP_SD_NATIVE) && defined(ARDUINO_ARCH_ESP32
78
+
79
+ #if (SD_DEVICE == ESP_SDIO) && defined(ARDUINO_ARCH_ESP32)
80
+ #define FS_NO_GLOBALS
81
+ #define NO_GLOBAL_SD
82
+ #include < FS.h>
83
+ #include < SD_MMC.h>
84
+ using ESP3D_File = fs::File;
85
+ using ESP3D_SD_Class = SDMMCFS;
86
+ #endif // (SD_DEVICE == ESP_SDIO) && defined(ARDUINO_ARCH_ESP32
87
+
88
+
89
+ extern ESP3D_SD_Class ESP3D_SD_Card;
90
+ extern ESP3D_File tSDFile_handle[ESP_MAX_SD_OPENHANDLE];
91
+
92
+ }
0 commit comments