Scott Lahteine 6 anni fa
parent
commit
614a86a380

+ 5
- 1
Marlin/src/sd/Sd2Card.cpp Vedi File

@@ -26,11 +26,15 @@
26 26
  *
27 27
  * This file is part of the Arduino Sd2Card Library
28 28
  */
29
-#include "Marlin.h"
29
+
30
+#include "../inc/MarlinConfig.h"
30 31
 
31 32
 #if ENABLED(SDSUPPORT)
33
+
32 34
 #include "Sd2Card.h"
33 35
 
36
+#include "../Marlin.h"
37
+
34 38
 //------------------------------------------------------------------------------
35 39
 // send command and return error code.  Return zero for OK
36 40
 uint8_t Sd2Card::cardCommand(uint8_t cmd, uint32_t arg) {

+ 6
- 7
Marlin/src/sd/Sd2Card.h Vedi File

@@ -27,17 +27,18 @@
27 27
  * This file is part of the Arduino Sd2Card Library
28 28
  */
29 29
 
30
-#include "Marlin.h"
31
-#if ENABLED(SDSUPPORT)
30
+#ifndef SD2CARD_H
31
+#define SD2CARD_H
32 32
 
33
-#ifndef Sd2Card_h
34
-#define Sd2Card_h
35 33
 /**
36 34
  * \file
37 35
  * \brief Sd2Card class for V2 SD/SDHC cards
38 36
  */
39 37
 #include "SdFatConfig.h"
40 38
 #include "SdInfo.h"
39
+
40
+#include <stdint.h>
41
+
41 42
 //------------------------------------------------------------------------------
42 43
 /** init timeout ms */
43 44
 uint16_t const SD_INIT_TIMEOUT = 2000;
@@ -239,7 +240,5 @@ class Sd2Card {
239 240
   bool waitNotBusy(uint16_t timeoutMillis);
240 241
   bool writeData(uint8_t token, const uint8_t* src);
241 242
 };
242
-#endif  // Sd2Card_h
243 243
 
244
-
245
-#endif
244
+#endif // SD2CARD_H

+ 6
- 3
Marlin/src/sd/SdBaseFile.cpp Vedi File

@@ -27,10 +27,14 @@
27 27
  * This file is part of the Arduino Sd2Card Library
28 28
  */
29 29
 
30
-#include "Marlin.h"
30
+#include "../inc/MarlinConfig.h"
31
+
31 32
 #if ENABLED(SDSUPPORT)
32 33
 
33 34
 #include "SdBaseFile.h"
35
+
36
+#include "../Marlin.h"
37
+
34 38
 //------------------------------------------------------------------------------
35 39
 // pointer to cwd directory
36 40
 SdBaseFile* SdBaseFile::cwd_ = 0;
@@ -1822,5 +1826,4 @@ int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) {
1822 1826
   void (*SdBaseFile::oldDateTime_)(uint16_t &date, uint16_t &time) = 0;  // NOLINT
1823 1827
 #endif  // ALLOW_DEPRECATED_FUNCTIONS
1824 1828
 
1825
-
1826
-#endif
1829
+#endif // SDSUPPORT

+ 7
- 7
Marlin/src/sd/SdBaseFile.h Vedi File

@@ -26,18 +26,19 @@
26 26
  *
27 27
  * This file is part of the Arduino Sd2Card Library
28 28
  */
29
-#include "Marlin.h"
30
-#if ENABLED(SDSUPPORT)
31 29
 
32
-#ifndef SdBaseFile_h
33
-#define SdBaseFile_h
30
+#ifndef SDBASEFILE_H
31
+#define SDBASEFILE_H
34 32
 /**
35 33
  * \file
36 34
  * \brief SdBaseFile class
37 35
  */
38
-#include "Marlin.h"
36
+
39 37
 #include "SdFatConfig.h"
40 38
 #include "SdVolume.h"
39
+
40
+#include <stdint.h>
41
+
41 42
 //------------------------------------------------------------------------------
42 43
 /**
43 44
  * \struct filepos_t
@@ -488,5 +489,4 @@ class SdBaseFile {
488 489
 #endif  // ALLOW_DEPRECATED_FUNCTIONS
489 490
 };
490 491
 
491
-#endif  // SdBaseFile_h
492
-#endif
492
+#endif // SDBASEFILE_H

+ 94
- 98
Marlin/src/sd/SdFatConfig.h Vedi File

@@ -26,109 +26,105 @@
26 26
  *
27 27
  * This file is part of the Arduino Sd2Card Library
28 28
  */
29
+
29 30
 /**
30 31
  * \file
31 32
  * \brief configuration definitions
32 33
  */
33
-#include "Marlin.h"
34
-#if ENABLED(SDSUPPORT)
35
-
36
-#ifndef SdFatConfig_h
37
-  #define SdFatConfig_h
38
-  #include <stdint.h>
39
-  //------------------------------------------------------------------------------
40
-  /**
41
-  * To use multiple SD cards set USE_MULTIPLE_CARDS nonzero.
42
-  *
43
-  * Using multiple cards costs 400 - 500  bytes of flash.
44
-  *
45
-  * Each card requires about 550 bytes of SRAM so use of a Mega is recommended.
46
-  */
47
-  #define USE_MULTIPLE_CARDS 0
48
-  //------------------------------------------------------------------------------
49
-  /**
50
-  * Call flush for endl if ENDL_CALLS_FLUSH is nonzero
51
-  *
52
-  * The standard for iostreams is to call flush.  This is very costly for
53
-  * SdFat.  Each call to flush causes 2048 bytes of I/O to the SD.
54
-  *
55
-  * SdFat has a single 512 byte buffer for SD I/O so it must write the current
56
-  * data block to the SD, read the directory block from the SD, update the
57
-  * directory entry, write the directory block to the SD and read the data
58
-  * block back into the buffer.
59
-  *
60
-  * The SD flash memory controller is not designed for this many rewrites
61
-  * so performance may be reduced by more than a factor of 100.
62
-  *
63
-  * If ENDL_CALLS_FLUSH is zero, you must call flush and/or close to force
64
-  * all data to be written to the SD.
65
-  */
66
-  #define ENDL_CALLS_FLUSH 0
67
-  //------------------------------------------------------------------------------
68
-  /**
69
-  * Allow use of deprecated functions if ALLOW_DEPRECATED_FUNCTIONS is nonzero
70
-  */
71
-  #define ALLOW_DEPRECATED_FUNCTIONS 1
72
-  //------------------------------------------------------------------------------
73
-  /**
74
-  * Allow FAT12 volumes if FAT12_SUPPORT is nonzero.
75
-  * FAT12 has not been well tested.
76
-  */
77
-  #define FAT12_SUPPORT 0
78
-  //------------------------------------------------------------------------------
79
-  /**
80
-  * SPI init rate for SD initialization commands. Must be 5 (F_CPU/64)
81
-  * or 6 (F_CPU/128).
82
-  */
83
-  #define SPI_SD_INIT_RATE 5
84
-  //------------------------------------------------------------------------------
85
-  /**
86
-  * Set the SS pin high for hardware SPI.  If SS is chip select for another SPI
87
-  * device this will disable that device during the SD init phase.
88
-  */
89
-  #define SET_SPI_SS_HIGH 1
90
-  //------------------------------------------------------------------------------
91
-  /**
92
-  * Define MEGA_SOFT_SPI nonzero to use software SPI on Mega Arduinos.
93
-  * Pins used are SS 10, MOSI 11, MISO 12, and SCK 13.
94
-  *
95
-  * MEGA_SOFT_SPI allows an unmodified Adafruit GPS Shield to be used
96
-  * on Mega Arduinos.  Software SPI works well with GPS Shield V1.1
97
-  * but many SD cards will fail with GPS Shield V1.0.
98
-  */
99
-  #define MEGA_SOFT_SPI 0
100
-  //------------------------------------------------------------------------------
101
-  /**
102
-  * Set USE_SOFTWARE_SPI nonzero to always use software SPI.
103
-  */
104
-  #define USE_SOFTWARE_SPI 0
105
-  // define software SPI pins so Mega can use unmodified 168/328 shields
106
-  /** Software SPI chip select pin for the SD */
107
-  #define SOFT_SPI_CS_PIN 10
108
-  /** Software SPI Master Out Slave In pin */
109
-  #define SOFT_SPI_MOSI_PIN 11
110
-  /** Software SPI Master In Slave Out pin */
111
-  #define SOFT_SPI_MISO_PIN 12
112
-  /** Software SPI Clock pin */
113
-  #define SOFT_SPI_SCK_PIN 13
114
-  //------------------------------------------------------------------------------
115
-  /**
116
-  * The __cxa_pure_virtual function is an error handler that is invoked when
117
-  * a pure virtual function is called.
118
-  */
119
-  #define USE_CXA_PURE_VIRTUAL 1
34
+#ifndef SDFATCONFIG_H
35
+#define SDFATCONFIG_H
120 36
 
121
-  /** Number of UTF-16 characters per entry */
122
-  #define FILENAME_LENGTH 13
37
+//------------------------------------------------------------------------------
38
+/**
39
+ * To use multiple SD cards set USE_MULTIPLE_CARDS nonzero.
40
+ *
41
+ * Using multiple cards costs 400 - 500  bytes of flash.
42
+ *
43
+ * Each card requires about 550 bytes of SRAM so use of a Mega is recommended.
44
+ */
45
+#define USE_MULTIPLE_CARDS 0
46
+//------------------------------------------------------------------------------
47
+/**
48
+ * Call flush for endl if ENDL_CALLS_FLUSH is nonzero
49
+ *
50
+ * The standard for iostreams is to call flush.  This is very costly for
51
+ * SdFat.  Each call to flush causes 2048 bytes of I/O to the SD.
52
+ *
53
+ * SdFat has a single 512 byte buffer for SD I/O so it must write the current
54
+ * data block to the SD, read the directory block from the SD, update the
55
+ * directory entry, write the directory block to the SD and read the data
56
+ * block back into the buffer.
57
+ *
58
+ * The SD flash memory controller is not designed for this many rewrites
59
+ * so performance may be reduced by more than a factor of 100.
60
+ *
61
+ * If ENDL_CALLS_FLUSH is zero, you must call flush and/or close to force
62
+ * all data to be written to the SD.
63
+ */
64
+#define ENDL_CALLS_FLUSH 0
65
+//------------------------------------------------------------------------------
66
+/**
67
+ * Allow use of deprecated functions if ALLOW_DEPRECATED_FUNCTIONS is nonzero
68
+ */
69
+#define ALLOW_DEPRECATED_FUNCTIONS 1
70
+//------------------------------------------------------------------------------
71
+/**
72
+ * Allow FAT12 volumes if FAT12_SUPPORT is nonzero.
73
+ * FAT12 has not been well tested.
74
+ */
75
+#define FAT12_SUPPORT 0
76
+//------------------------------------------------------------------------------
77
+/**
78
+ * SPI init rate for SD initialization commands. Must be 5 (F_CPU/64)
79
+ * or 6 (F_CPU/128).
80
+ */
81
+#define SPI_SD_INIT_RATE 5
82
+//------------------------------------------------------------------------------
83
+/**
84
+ * Set the SS pin high for hardware SPI.  If SS is chip select for another SPI
85
+ * device this will disable that device during the SD init phase.
86
+ */
87
+#define SET_SPI_SS_HIGH 1
88
+//------------------------------------------------------------------------------
89
+/**
90
+ * Define MEGA_SOFT_SPI nonzero to use software SPI on Mega Arduinos.
91
+ * Pins used are SS 10, MOSI 11, MISO 12, and SCK 13.
92
+ *
93
+ * MEGA_SOFT_SPI allows an unmodified Adafruit GPS Shield to be used
94
+ * on Mega Arduinos.  Software SPI works well with GPS Shield V1.1
95
+ * but many SD cards will fail with GPS Shield V1.0.
96
+ */
97
+#define MEGA_SOFT_SPI 0
98
+//------------------------------------------------------------------------------
99
+/**
100
+ * Set USE_SOFTWARE_SPI nonzero to always use software SPI.
101
+ */
102
+#define USE_SOFTWARE_SPI 0
103
+// define software SPI pins so Mega can use unmodified 168/328 shields
104
+/** Software SPI chip select pin for the SD */
105
+#define SOFT_SPI_CS_PIN 10
106
+/** Software SPI Master Out Slave In pin */
107
+#define SOFT_SPI_MOSI_PIN 11
108
+/** Software SPI Master In Slave Out pin */
109
+#define SOFT_SPI_MISO_PIN 12
110
+/** Software SPI Clock pin */
111
+#define SOFT_SPI_SCK_PIN 13
112
+//------------------------------------------------------------------------------
113
+/**
114
+ * The __cxa_pure_virtual function is an error handler that is invoked when
115
+ * a pure virtual function is called.
116
+ */
117
+#define USE_CXA_PURE_VIRTUAL 1
123 118
 
124
-  /**
125
-  * Defines for long (vfat) filenames
126
-  */
127
-  /** Number of VFAT entries used. Every entry has 13 UTF-16 characters */
128
-  #define MAX_VFAT_ENTRIES (2)
129
-  /** Total size of the buffer used to store the long filenames */
130
-  #define LONG_FILENAME_LENGTH (FILENAME_LENGTH*MAX_VFAT_ENTRIES+1)
131
-#endif  // SdFatConfig_h
119
+/** Number of UTF-16 characters per entry */
120
+#define FILENAME_LENGTH 13
132 121
 
122
+/**
123
+ * Defines for long (vfat) filenames
124
+ */
125
+/** Number of VFAT entries used. Every entry has 13 UTF-16 characters */
126
+#define MAX_VFAT_ENTRIES (2)
127
+/** Total size of the buffer used to store the long filenames */
128
+#define LONG_FILENAME_LENGTH (FILENAME_LENGTH*MAX_VFAT_ENTRIES+1)
133 129
 
134
-#endif
130
+#endif // SDFATCONFIG_H

+ 5
- 7
Marlin/src/sd/SdFatStructs.h Vedi File

@@ -26,11 +26,11 @@
26 26
  *
27 27
  * This file is part of the Arduino Sd2Card Library
28 28
  */
29
-#include "Marlin.h"
30
-#if ENABLED(SDSUPPORT)
31 29
 
32
-#ifndef SdFatStructs_h
33
-#define SdFatStructs_h
30
+#ifndef SDFATSTRUCTS_H
31
+#define SDFATSTRUCTS_H
32
+
33
+#include <stdint.h>
34 34
 
35 35
 #define PACKED __attribute__((__packed__))
36 36
 /**
@@ -649,7 +649,5 @@ static inline uint8_t DIR_IS_SUBDIR(const dir_t* dir) {
649 649
 static inline uint8_t DIR_IS_FILE_OR_SUBDIR(const dir_t* dir) {
650 650
   return (dir->attributes & DIR_ATT_VOLUME_ID) == 0;
651 651
 }
652
-#endif  // SdFatStructs_h
653
-
654 652
 
655
-#endif
653
+#endif // SDFATSTRUCTS_H

+ 5
- 2
Marlin/src/sd/SdFatUtil.cpp Vedi File

@@ -26,9 +26,11 @@
26 26
  *
27 27
  * This file is part of the Arduino Sd2Card Library
28 28
  */
29
-#include "Marlin.h"
29
+
30
+#include "../inc/MarlinConfig.h"
30 31
 
31 32
 #if ENABLED(SDSUPPORT)
33
+
32 34
 #include "SdFatUtil.h"
33 35
 
34 36
 //------------------------------------------------------------------------------
@@ -88,4 +90,5 @@ void SdFatUtil::SerialPrint_P(PGM_P str) {
88 90
 void SdFatUtil::SerialPrintln_P(PGM_P str) {
89 91
   println_P(str);
90 92
 }
91
-#endif
93
+
94
+#endif // SDSUPPORT

+ 4
- 7
Marlin/src/sd/SdFatUtil.h Vedi File

@@ -26,11 +26,10 @@
26 26
  *
27 27
  * This file is part of the Arduino Sd2Card Library
28 28
  */
29
-#ifndef SdFatUtil_h
30
-#define SdFatUtil_h
29
+#ifndef SDFATUTIL_H
30
+#define SDFATUTIL_H
31 31
 
32
-#include "Marlin.h"
33
-#if ENABLED(SDSUPPORT)
32
+#include <string.h>
34 33
 
35 34
 /**
36 35
  * \file
@@ -51,6 +50,4 @@ namespace SdFatUtil {
51 50
 
52 51
 using namespace SdFatUtil;  // NOLINT
53 52
 
54
-#endif // SDSUPPORT
55
-
56
-#endif // SdFatUtil_h
53
+#endif // SDFATUTIL_H

+ 4
- 1
Marlin/src/sd/SdFile.cpp Vedi File

@@ -26,10 +26,13 @@
26 26
  *
27 27
  * This file is part of the Arduino Sd2Card Library
28 28
  */
29
-#include "Marlin.h"
29
+
30
+#include "../inc/MarlinConfig.h"
30 31
 
31 32
 #if ENABLED(SDSUPPORT)
33
+
32 34
 #include "SdFile.h"
35
+
33 36
 /**  Create a file object and open it in the current working directory.
34 37
  *
35 38
  * \param[in] path A path with a valid 8.3 DOS name for a file to be opened.

+ 9
- 9
Marlin/src/sd/SdFile.h Vedi File

@@ -26,18 +26,20 @@
26 26
  *
27 27
  * This file is part of the Arduino Sd2Card Library
28 28
  */
29
+
29 30
 /**
30 31
  * \file
31 32
  * \brief SdFile class
32 33
  */
33
-#include "Marlin.h"
34 34
 
35
-#if ENABLED(SDSUPPORT)
35
+#ifndef SDFILE_H
36
+#define SDFILE_H
37
+
36 38
 #include "SdBaseFile.h"
37
-//todo: HAL: create wrapper for Print?
38
-//#include <Print.h>
39
-#ifndef SdFile_h
40
-#define SdFile_h
39
+
40
+#include <stdint.h>
41
+#include <string.h>
42
+
41 43
 //------------------------------------------------------------------------------
42 44
 /**
43 45
  * \class SdFile
@@ -58,7 +60,5 @@ class SdFile : public SdBaseFile/*, public Print*/ {
58 60
   void write_P(PGM_P str);
59 61
   void writeln_P(PGM_P str);
60 62
 };
61
-#endif  // SdFile_h
62
-
63 63
 
64
-#endif
64
+#endif // SDFILE_H

+ 4
- 6
Marlin/src/sd/SdInfo.h Vedi File

@@ -26,12 +26,11 @@
26 26
  *
27 27
  * This file is part of the Arduino Sd2Card Library
28 28
  */
29
-#include "Marlin.h"
30
-#if ENABLED(SDSUPPORT)
29
+#ifndef SDINFO_H
30
+#define SDINFO_H
31 31
 
32
-#ifndef SdInfo_h
33
-#define SdInfo_h
34 32
 #include <stdint.h>
33
+
35 34
 // Based on the document:
36 35
 //
37 36
 // SD Specifications
@@ -284,6 +283,5 @@ union csd_t {
284 283
   csd1_t v1;
285 284
   csd2_t v2;
286 285
 };
287
-#endif  // SdInfo_h
288 286
 
289
-#endif
287
+#endif  // SDINFO_H

+ 8
- 2
Marlin/src/sd/SdVolume.cpp Vedi File

@@ -26,10 +26,15 @@
26 26
  *
27 27
  * This file is part of the Arduino Sd2Card Library
28 28
  */
29
-#include "Marlin.h"
29
+
30
+#include "../inc/MarlinConfig.h"
31
+
30 32
 #if ENABLED(SDSUPPORT)
31 33
 
32 34
 #include "SdVolume.h"
35
+
36
+#include "../Marlin.h"
37
+
33 38
 //------------------------------------------------------------------------------
34 39
 #if !USE_MULTIPLE_CARDS
35 40
   // raw block cache
@@ -417,4 +422,5 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
417 422
   FAIL:
418 423
   return false;
419 424
 }
420
-#endif
425
+
426
+#endif // SDSUPPORT

+ 43
- 42
Marlin/src/sd/SdVolume.h Vedi File

@@ -26,10 +26,9 @@
26 26
  *
27 27
  * This file is part of the Arduino Sd2Card Library
28 28
  */
29
-#include "Marlin.h"
30
-#if ENABLED(SDSUPPORT)
31
-#ifndef SdVolume_h
32
-#define SdVolume_h
29
+#ifndef SDVOLUME_H
30
+#define SDVOLUME_H
31
+
33 32
 /**
34 33
  * \file
35 34
  * \brief SdVolume class
@@ -38,6 +37,8 @@
38 37
 #include "Sd2Card.h"
39 38
 #include "SdFatStructs.h"
40 39
 
40
+#include <stdint.h>
41
+
41 42
 //==============================================================================
42 43
 // SdVolume class
43 44
 /**
@@ -136,19 +137,19 @@ class SdVolume {
136 137
   // value for dirty argument in cacheRawBlock to indicate write to cache
137 138
   static bool const CACHE_FOR_WRITE = true;
138 139
 
139
-#if USE_MULTIPLE_CARDS
140
-  cache_t cacheBuffer_;        // 512 byte cache for device blocks
141
-  uint32_t cacheBlockNumber_;  // Logical number of block in the cache
142
-  Sd2Card* sdCard_;            // Sd2Card object for cache
143
-  bool cacheDirty_;            // cacheFlush() will write block if true
144
-  uint32_t cacheMirrorBlock_;  // block number for mirror FAT
145
-#else  // USE_MULTIPLE_CARDS
146
-  static cache_t cacheBuffer_;        // 512 byte cache for device blocks
147
-  static uint32_t cacheBlockNumber_;  // Logical number of block in the cache
148
-  static Sd2Card* sdCard_;            // Sd2Card object for cache
149
-  static bool cacheDirty_;            // cacheFlush() will write block if true
150
-  static uint32_t cacheMirrorBlock_;  // block number for mirror FAT
151
-#endif  // USE_MULTIPLE_CARDS
140
+  #if USE_MULTIPLE_CARDS
141
+    cache_t cacheBuffer_;        // 512 byte cache for device blocks
142
+    uint32_t cacheBlockNumber_;  // Logical number of block in the cache
143
+    Sd2Card* sdCard_;            // Sd2Card object for cache
144
+    bool cacheDirty_;            // cacheFlush() will write block if true
145
+    uint32_t cacheMirrorBlock_;  // block number for mirror FAT
146
+  #else  // USE_MULTIPLE_CARDS
147
+    static cache_t cacheBuffer_;        // 512 byte cache for device blocks
148
+    static uint32_t cacheBlockNumber_;  // Logical number of block in the cache
149
+    static Sd2Card* sdCard_;            // Sd2Card object for cache
150
+    static bool cacheDirty_;            // cacheFlush() will write block if true
151
+    static uint32_t cacheMirrorBlock_;  // block number for mirror FAT
152
+  #endif  // USE_MULTIPLE_CARDS
152 153
   uint32_t allocSearchStart_;   // start cluster for alloc search
153 154
   uint8_t blocksPerCluster_;    // cluster size in blocks
154 155
   uint32_t blocksPerFat_;       // FAT size in blocks
@@ -173,13 +174,13 @@ class SdVolume {
173 174
   }
174 175
   cache_t* cache() {return &cacheBuffer_;}
175 176
   uint32_t cacheBlockNumber() {return cacheBlockNumber_;}
176
-#if USE_MULTIPLE_CARDS
177
-  bool cacheFlush();
178
-  bool cacheRawBlock(uint32_t blockNumber, bool dirty);
179
-#else  // USE_MULTIPLE_CARDS
180
-  static bool cacheFlush();
181
-  static bool cacheRawBlock(uint32_t blockNumber, bool dirty);
182
-#endif  // USE_MULTIPLE_CARDS
177
+  #if USE_MULTIPLE_CARDS
178
+    bool cacheFlush();
179
+    bool cacheRawBlock(uint32_t blockNumber, bool dirty);
180
+  #else  // USE_MULTIPLE_CARDS
181
+    static bool cacheFlush();
182
+    static bool cacheRawBlock(uint32_t blockNumber, bool dirty);
183
+  #endif  // USE_MULTIPLE_CARDS
183 184
   // used by SdBaseFile write to assign cache to SD location
184 185
   void cacheSetBlockNumber(uint32_t blockNumber, bool dirty) {
185 186
     cacheDirty_ = dirty;
@@ -206,22 +207,22 @@ class SdVolume {
206 207
   }
207 208
   //------------------------------------------------------------------------------
208 209
   // Deprecated functions  - suppress cpplint warnings with NOLINT comment
209
-#if ALLOW_DEPRECATED_FUNCTIONS && !defined(DOXYGEN)
210
- public:
211
-  /** \deprecated Use: bool SdVolume::init(Sd2Card* dev);
212
-   * \param[in] dev The SD card where the volume is located.
213
-   * \return true for success or false for failure.
214
-   */
215
-  bool init(Sd2Card& dev) {return init(&dev);}  // NOLINT
216
-  /** \deprecated Use: bool SdVolume::init(Sd2Card* dev, uint8_t vol);
217
-   * \param[in] dev The SD card where the volume is located.
218
-   * \param[in] part The partition to be used.
219
-   * \return true for success or false for failure.
220
-   */
221
-  bool init(Sd2Card& dev, uint8_t part) {  // NOLINT
222
-    return init(&dev, part);
223
-  }
224
-#endif  // ALLOW_DEPRECATED_FUNCTIONS
210
+  #if ALLOW_DEPRECATED_FUNCTIONS && !defined(DOXYGEN)
211
+    public:
212
+      /** \deprecated Use: bool SdVolume::init(Sd2Card* dev);
213
+       * \param[in] dev The SD card where the volume is located.
214
+       * \return true for success or false for failure.
215
+       */
216
+      bool init(Sd2Card& dev) {return init(&dev);}  // NOLINT
217
+      /** \deprecated Use: bool SdVolume::init(Sd2Card* dev, uint8_t vol);
218
+       * \param[in] dev The SD card where the volume is located.
219
+       * \param[in] part The partition to be used.
220
+       * \return true for success or false for failure.
221
+       */
222
+      bool init(Sd2Card& dev, uint8_t part) {  // NOLINT
223
+        return init(&dev, part);
224
+      }
225
+  #endif  // ALLOW_DEPRECATED_FUNCTIONS
225 226
 };
226
-#endif  // SdVolume
227
-#endif
227
+
228
+#endif // SDVOLUME_H

+ 20
- 14
Marlin/src/sd/cardreader.cpp Vedi File

@@ -20,16 +20,19 @@
20 20
  *
21 21
  */
22 22
 
23
-#include <ctype.h>
24
-#include "cardreader.h"
23
+#include "../inc/MarlinConfig.h"
25 24
 
26
-#include "ultralcd.h"
27
-#include "stepper.h"
28
-#include "language.h"
25
+#if ENABLED(SDSUPPORT)
29 26
 
30
-#include "Marlin.h"
27
+#include "cardreader.h"
31 28
 
32
-#if ENABLED(SDSUPPORT)
29
+#include "../Marlin.h"
30
+#include "../lcd/ultralcd.h"
31
+#include "../module/stepper.h"
32
+#include "../module/printcounter.h"
33
+#include "../core/language.h"
34
+
35
+#include <ctype.h>
33 36
 
34 37
 #define LONGEST_FILENAME (longFilename[0] ? longFilename : filename)
35 38
 
@@ -77,7 +80,7 @@ char *createFilename(char *buffer, const dir_t &p) { //buffer > 12characters
77 80
  *   LS_GetFilename - Get the filename of the file indexed by nrFile_index
78 81
  *   LS_SerialPrint - Print the full path and size of each file to serial output
79 82
  */
80
- 
83
+
81 84
 uint16_t nrFile_index;
82 85
 
83 86
 void CardReader::lsDive(const char *prepend, SdFile parent, const char * const match/*=NULL*/) {
@@ -864,12 +867,15 @@ void CardReader::updir() {
864 867
 
865 868
 #endif // SDCARD_SORT_ALPHA
866 869
 
867
-#if (ENABLED(SDCARD_SORT_ALPHA) && SDSORT_USES_RAM && SDSORT_CACHE_NAMES)  
868
- // if true - don't need to access the SD card for file names
869
-  uint16_t CardReader::get_num_Files() {return nrFiles;}
870
-#else
871
-  uint16_t CardReader::get_num_Files() {return getnrfilenames(); } 
872
-#endif
870
+uint16_t CardReader::get_num_Files() {
871
+  return
872
+    #if ENABLED(SDCARD_SORT_ALPHA) && SDSORT_USES_RAM && SDSORT_CACHE_NAMES
873
+      nrFiles // no need to access the SD card for filenames
874
+    #else
875
+      getnrfilenames()
876
+    #endif
877
+  ;
878
+}
873 879
 
874 880
 void CardReader::printingHasFinished() {
875 881
   stepper.synchronize();

+ 12
- 19
Marlin/src/sd/cardreader.h Vedi File

@@ -23,16 +23,11 @@
23 23
 #ifndef CARDREADER_H
24 24
 #define CARDREADER_H
25 25
 
26
-#include "MarlinConfig.h"
27
-
28
-#if ENABLED(SDSUPPORT)
29
-
30 26
 #define MAX_DIR_DEPTH 10          // Maximum folder depth
31 27
 
32 28
 #include "SdFile.h"
33 29
 
34
-#include "types.h"
35
-#include "enum.h"
30
+#include "../inc/MarlinConfig.h"
36 31
 
37 32
 class CardReader {
38 33
 public:
@@ -70,7 +65,7 @@ public:
70 65
   void setroot();
71 66
 
72 67
   uint16_t get_num_Files();
73
-  
68
+
74 69
   #if ENABLED(SDCARD_SORT_ALPHA)
75 70
     void presort();
76 71
     void getfilename_sorted(const uint16_t nr);
@@ -166,27 +161,25 @@ private:
166 161
   #endif
167 162
 };
168 163
 
169
-extern CardReader card;
170
-
171
-#define IS_SD_PRINTING (card.sdprinting)
172
-#define IS_SD_FILE_OPEN (card.isFileOpen())
173
-
174 164
 #if PIN_EXISTS(SD_DETECT)
175 165
   #if ENABLED(SD_DETECT_INVERTED)
176
-    #define IS_SD_INSERTED (READ(SD_DETECT_PIN) != 0)
166
+    #define IS_SD_INSERTED (READ(SD_DETECT_PIN) == HIGH)
177 167
   #else
178
-    #define IS_SD_INSERTED (READ(SD_DETECT_PIN) == 0)
168
+    #define IS_SD_INSERTED (READ(SD_DETECT_PIN) == LOW)
179 169
   #endif
180 170
 #else
181 171
   //No card detect line? Assume the card is inserted.
182 172
   #define IS_SD_INSERTED true
183 173
 #endif
184 174
 
175
+#if ENABLED(SDSUPPORT)
176
+  #define IS_SD_PRINTING (card.sdprinting)
177
+  #define IS_SD_FILE_OPEN (card.isFileOpen())
185 178
 #else
179
+  #define IS_SD_PRINTING (false)
180
+  #define IS_SD_FILE_OPEN (false)
181
+#endif
186 182
 
187
-#define IS_SD_PRINTING (false)
188
-#define IS_SD_FILE_OPEN (false)
189
-
190
-#endif // SDSUPPORT
183
+extern CardReader card;
191 184
 
192
-#endif // __CARDREADER_H
185
+#endif // CARDREADER_H

Loading…
Annulla
Salva