Bladeren bron

Use "mount" as card verb

Scott Lahteine 4 jaren geleden
bovenliggende
commit
d5f5203880

+ 5
- 5
Marlin/src/HAL/HAL_DUE/usb/sd_mmc_spi_mem.cpp Bestand weergeven

@@ -19,7 +19,7 @@ void sd_mmc_spi_mem_init(void) {
19 19
 }
20 20
 
21 21
 Ctrl_status sd_mmc_spi_test_unit_ready(void) {
22
-  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
22
+  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
23 23
     return CTRL_NO_PRESENT;
24 24
   return CTRL_GOOD;
25 25
 }
@@ -27,7 +27,7 @@ Ctrl_status sd_mmc_spi_test_unit_ready(void) {
27 27
 // NOTE: This function is defined as returning the address of the last block
28 28
 // in the card, which is cardSize() - 1
29 29
 Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector) {
30
-  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
30
+  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
31 31
     return CTRL_NO_PRESENT;
32 32
   *nb_sector = card.getSd2Card().cardSize() - 1;
33 33
   return CTRL_GOOD;
@@ -43,7 +43,7 @@ bool sd_mmc_spi_wr_protect(void) {
43 43
 }
44 44
 
45 45
 bool sd_mmc_spi_removal(void) {
46
-  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
46
+  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
47 47
     return true;
48 48
   return false;
49 49
 }
@@ -62,7 +62,7 @@ uint8_t sector_buf[SD_MMC_BLOCK_SIZE];
62 62
 // #define DEBUG_MMC
63 63
 
64 64
 Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) {
65
-  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
65
+  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
66 66
     return CTRL_NO_PRESENT;
67 67
 
68 68
   #ifdef DEBUG_MMC
@@ -99,7 +99,7 @@ Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) {
99 99
 }
100 100
 
101 101
 Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector) {
102
-  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
102
+  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
103 103
     return CTRL_NO_PRESENT;
104 104
 
105 105
   #ifdef DEBUG_MMC

+ 1
- 1
Marlin/src/HAL/HAL_LPC1768/main.cpp Bestand weergeven

@@ -158,7 +158,7 @@ void HAL_idletask(void) {
158 158
     // the disk if Marlin has it mounted. Unfortuately there is currently no way
159 159
     // to unmount the disk from the LCD menu.
160 160
     // if (IS_SD_PRINTING() || IS_SD_FILE_OPEN())
161
-    if (card.isDetected())
161
+    if (card.isMounted())
162 162
       MSC_Aquire_Lock();
163 163
     else
164 164
       MSC_Release_Lock();

+ 2
- 2
Marlin/src/HAL/HAL_STM32/persistent_store_sdcard.cpp Bestand weergeven

@@ -47,7 +47,7 @@ static char _ALIGN(4) HAL_eeprom_data[HAL_EEPROM_SIZE];
47 47
   #define EEPROM_FILENAME "eeprom.dat"
48 48
 
49 49
   bool PersistentStore::access_start() {
50
-    if (!card.isDetected()) return false;
50
+    if (!card.isMounted()) return false;
51 51
 
52 52
     SdFile file, root = card.getroot();
53 53
     if (!file.open(&root, EEPROM_FILENAME, O_RDONLY))
@@ -62,7 +62,7 @@ static char _ALIGN(4) HAL_eeprom_data[HAL_EEPROM_SIZE];
62 62
   }
63 63
 
64 64
   bool PersistentStore::access_finish() {
65
-    if (!card.isDetected()) return false;
65
+    if (!card.isMounted()) return false;
66 66
 
67 67
     SdFile file, root = card.getroot();
68 68
     int bytes_written = 0;

+ 2
- 2
Marlin/src/HAL/HAL_STM32F1/persistent_store_sdcard.cpp Bestand weergeven

@@ -48,7 +48,7 @@ static char _ALIGN(4) HAL_eeprom_data[HAL_EEPROM_SIZE];
48 48
   #define EEPROM_FILENAME "eeprom.dat"
49 49
 
50 50
   bool PersistentStore::access_start() {
51
-    if (!card.isDetected()) return false;
51
+    if (!card.isMounted()) return false;
52 52
 
53 53
     SdFile file, root = card.getroot();
54 54
     if (!file.open(&root, EEPROM_FILENAME, O_RDONLY))
@@ -63,7 +63,7 @@ static char _ALIGN(4) HAL_eeprom_data[HAL_EEPROM_SIZE];
63 63
   }
64 64
 
65 65
   bool PersistentStore::access_finish() {
66
-    if (!card.isDetected()) return false;
66
+    if (!card.isMounted()) return false;
67 67
 
68 68
     SdFile file, root = card.getroot();
69 69
     int bytes_written = 0;

+ 1
- 2
Marlin/src/Marlin.cpp Bestand weergeven

@@ -982,8 +982,7 @@ void setup() {
982 982
   #endif
983 983
 
984 984
   #if ENABLED(SDSUPPORT)
985
-    // Auto-mount the SD
986
-    card.initsd();
985
+    card.mount(); // Mount the SD card before settings.first_load
987 986
   #endif
988 987
 
989 988
   // Load data from EEPROM if available (or use defaults)

+ 1
- 1
Marlin/src/feature/binary_protocol.h Bestand weergeven

@@ -76,7 +76,7 @@ private:
76 76
 
77 77
   static bool file_open(char* filename) {
78 78
     if (!dummy_transfer) {
79
-      card.initsd();
79
+      card.mount();
80 80
       card.openFile(filename, false);
81 81
       if (!card.isFileOpen()) return false;
82 82
     }

+ 2
- 2
Marlin/src/feature/power_loss_recovery.cpp Bestand weergeven

@@ -98,8 +98,8 @@ void PrintJobRecovery::changed() {
98 98
  */
99 99
 void PrintJobRecovery::check() {
100 100
   if (enabled) {
101
-    if (!card.isDetected()) card.initsd();
102
-    if (card.isDetected()) {
101
+    if (!card.isMounted()) card.mount();
102
+    if (card.isMounted()) {
103 103
       load();
104 104
       if (!valid()) return purge();
105 105
       queue.inject_P(PSTR("M1000 S"));

+ 1
- 1
Marlin/src/gcode/sdcard/M21_M22.cpp Bestand weergeven

@@ -30,7 +30,7 @@
30 30
 /**
31 31
  * M21: Init SD Card
32 32
  */
33
-void GcodeSuite::M21() { card.initsd(); }
33
+void GcodeSuite::M21() { card.mount(); }
34 34
 
35 35
 /**
36 36
  * M22: Release SD Card

+ 1
- 1
Marlin/src/gcode/sdcard/M26.cpp Bestand weergeven

@@ -31,7 +31,7 @@
31 31
  * M26: Set SD Card file index
32 32
  */
33 33
 void GcodeSuite::M26() {
34
-  if (card.isDetected() && parser.seenval('S'))
34
+  if (card.isMounted() && parser.seenval('S'))
35 35
     card.setIndex(parser.value_long());
36 36
 }
37 37
 

+ 1
- 1
Marlin/src/gcode/sdcard/M30.cpp Bestand weergeven

@@ -31,7 +31,7 @@
31 31
  * M30 <filename>: Delete SD Card file
32 32
  */
33 33
 void GcodeSuite::M30() {
34
-  if (card.isDetected()) {
34
+  if (card.isMounted()) {
35 35
     card.closefile();
36 36
     card.removeFile(parser.string_arg);
37 37
   }

+ 1
- 1
Marlin/src/gcode/sdcard/M32.cpp Bestand weergeven

@@ -42,7 +42,7 @@
42 42
 void GcodeSuite::M32() {
43 43
   if (IS_SD_PRINTING()) planner.synchronize();
44 44
 
45
-  if (card.isDetected()) {
45
+  if (card.isMounted()) {
46 46
     const bool call_procedure = parser.boolval('P');
47 47
 
48 48
     card.openFile(parser.string_arg, true, call_procedure);

+ 4
- 4
Marlin/src/lcd/extensible_ui/ui_api.cpp Bestand weergeven

@@ -911,7 +911,7 @@ namespace ExtUI {
911 911
   }
912 912
 
913 913
   bool isMediaInserted() {
914
-    return IFSD(IS_SD_INSERTED() && card.isDetected(), false);
914
+    return IFSD(IS_SD_INSERTED() && card.isMounted(), false);
915 915
   }
916 916
 
917 917
   void pausePrint() {
@@ -1008,14 +1008,14 @@ void MarlinUI::update() {
1008 1008
     if (sd_status != last_sd_status) {
1009 1009
       last_sd_status = sd_status;
1010 1010
       if (sd_status) {
1011
-        card.initsd();
1012
-        if (card.isDetected())
1011
+        card.mount();
1012
+        if (card.isMounted())
1013 1013
           ExtUI::onMediaInserted();
1014 1014
         else
1015 1015
           ExtUI::onMediaError();
1016 1016
       }
1017 1017
       else {
1018
-        const bool ok = card.isDetected();
1018
+        const bool ok = card.isMounted();
1019 1019
         card.release();
1020 1020
         if (ok) ExtUI::onMediaRemoved();
1021 1021
       }

+ 1
- 1
Marlin/src/lcd/extui_malyan_lcd.cpp Bestand weergeven

@@ -298,7 +298,7 @@ void process_lcd_s_command(const char* command) {
298 298
 
299 299
     case 'L': {
300 300
       #if ENABLED(SDSUPPORT)
301
-        if (!card.isDetected()) card.initsd();
301
+        if (!card.isMounted()) card.mount();
302 302
 
303 303
         // A more efficient way to do this would be to
304 304
         // implement a callback in the ls_SerialPrint code, but

+ 1
- 1
Marlin/src/lcd/menu/menu_main.cpp Bestand weergeven

@@ -101,7 +101,7 @@ void menu_main() {
101 101
 
102 102
   const bool busy = IS_SD_PRINTING() || print_job_timer.isRunning()
103 103
     #if ENABLED(SDSUPPORT)
104
-      , card_detected = card.isDetected()
104
+      , card_detected = card.isMounted()
105 105
       , card_open = card_detected && card.isFileOpen()
106 106
     #endif
107 107
   ;

+ 2
- 2
Marlin/src/lcd/menu/menu_media.cpp Bestand weergeven

@@ -34,7 +34,7 @@
34 34
 #if !PIN_EXISTS(SD_DETECT)
35 35
   void lcd_sd_refresh() {
36 36
     encoderTopLine = 0;
37
-    card.initsd();
37
+    card.mount();
38 38
   }
39 39
 #endif
40 40
 
@@ -146,7 +146,7 @@ void menu_media() {
146 146
       MENU_ITEM(function, LCD_STR_REFRESH MSG_REFRESH, lcd_sd_refresh);
147 147
     #endif
148 148
   }
149
-  else if (card.isDetected())
149
+  else if (card.isMounted())
150 150
     MENU_ITEM(function, LCD_STR_FOLDER "..", lcd_sd_updir);
151 151
 
152 152
   if (ui.should_draw()) for (uint16_t i = 0; i < fileCnt; i++) {

+ 1
- 1
Marlin/src/lcd/ultralcd.cpp Bestand weergeven

@@ -842,7 +842,7 @@ void MarlinUI::update() {
842 842
 
843 843
       if (sd_status) {
844 844
         safe_delay(500); // Some boards need a delay to get settled
845
-        card.initsd();
845
+        card.mount();
846 846
         if (old_sd_status == 2)
847 847
           card.beginautostart();  // Initial boot
848 848
         else

+ 11
- 11
Marlin/src/sd/cardreader.cpp Bestand weergeven

@@ -123,7 +123,7 @@ CardReader::CardReader() {
123 123
       //sort_reverse = false;
124 124
     #endif
125 125
   #endif
126
-  flag.sdprinting = flag.detected = flag.saving = flag.logging = false;
126
+  flag.sdprinting = flag.mounted = flag.saving = flag.logging = false;
127 127
   filesize = sdpos = 0;
128 128
   file_subcall_ctr = 0;
129 129
 
@@ -329,8 +329,8 @@ void CardReader::printFilename() {
329 329
   SERIAL_EOL();
330 330
 }
331 331
 
332
-void CardReader::initsd() {
333
-  flag.detected = false;
332
+void CardReader::mount() {
333
+  flag.mounted = false;
334 334
   if (root.isOpen()) root.close();
335 335
 
336 336
   #ifndef SPI_SPEED
@@ -350,7 +350,7 @@ void CardReader::initsd() {
350 350
   else if (!root.openRoot(&volume))
351 351
     SERIAL_ERROR_MSG(MSG_SD_OPENROOT_FAIL);
352 352
   else {
353
-    flag.detected = true;
353
+    flag.mounted = true;
354 354
     SERIAL_ECHO_MSG(MSG_SD_CARD_OK);
355 355
     #if ENABLED(EEPROM_SETTINGS) && NONE(FLASH_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)
356 356
       settings.first_load();
@@ -363,7 +363,7 @@ void CardReader::initsd() {
363 363
 
364 364
 void CardReader::release() {
365 365
   stopSDPrint();
366
-  flag.detected = false;
366
+  flag.mounted = false;
367 367
 }
368 368
 
369 369
 void CardReader::openAndPrintFile(const char *name) {
@@ -375,7 +375,7 @@ void CardReader::openAndPrintFile(const char *name) {
375 375
 }
376 376
 
377 377
 void CardReader::startFileprint() {
378
-  if (isDetected()) {
378
+  if (isMounted()) {
379 379
     flag.sdprinting = true;
380 380
     #if SD_RESORT
381 381
       flush_presort();
@@ -425,7 +425,7 @@ void CardReader::getAbsFilename(char *t) {
425 425
 
426 426
 void CardReader::openFile(char * const path, const bool read, const bool subcall/*=false*/) {
427 427
 
428
-  if (!isDetected()) return;
428
+  if (!isMounted()) return;
429 429
 
430 430
   uint8_t doing = 0;
431 431
   if (isFileOpen()) {                     // Replacing current file or doing a subroutine
@@ -499,7 +499,7 @@ void CardReader::openFile(char * const path, const bool read, const bool subcall
499 499
 }
500 500
 
501 501
 void CardReader::removeFile(const char * const name) {
502
-  if (!isDetected()) return;
502
+  if (!isMounted()) return;
503 503
 
504 504
   //stopSDPrint();
505 505
 
@@ -558,12 +558,12 @@ void CardReader::checkautostart() {
558 558
 
559 559
   if (autostart_index < 0 || flag.sdprinting) return;
560 560
 
561
-  if (!isDetected()) initsd();
561
+  if (!isMounted()) mount();
562 562
   #if ENABLED(EEPROM_SETTINGS) && NONE(FLASH_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)
563 563
     else settings.first_load();
564 564
   #endif
565 565
 
566
-  if (isDetected()
566
+  if (isMounted()
567 567
     #if ENABLED(POWER_LOSS_RECOVERY)
568 568
       && !recovery.valid() // Don't run auto#.g when a resume file exists
569 569
     #endif
@@ -1049,7 +1049,7 @@ void CardReader::printingHasFinished() {
1049 1049
   }
1050 1050
 
1051 1051
   void CardReader::openJobRecoveryFile(const bool read) {
1052
-    if (!isDetected()) return;
1052
+    if (!isMounted()) return;
1053 1053
     if (recovery.file.isOpen()) return;
1054 1054
     if (!recovery.file.open(&root, recovery.filename, read ? O_READ : O_CREAT | O_WRITE | O_TRUNC | O_SYNC))
1055 1055
       SERIAL_ECHOLNPAIR(MSG_SD_OPEN_FILE_FAIL, recovery.filename, ".");

+ 4
- 4
Marlin/src/sd/cardreader.h Bestand weergeven

@@ -39,7 +39,7 @@ typedef struct {
39 39
   bool saving:1,
40 40
        logging:1,
41 41
        sdprinting:1,
42
-       detected:1,
42
+       mounted:1,
43 43
        filenameIsDir:1,
44 44
        abort_sd_printing:1
45 45
        #if ENABLED(BINARY_FILE_TRANSFER)
@@ -52,7 +52,7 @@ class CardReader {
52 52
 public:
53 53
   CardReader();
54 54
 
55
-  static void initsd();
55
+  static void mount();
56 56
   static void write_command(char *buf);
57 57
 
58 58
   static void beginautostart();
@@ -111,8 +111,8 @@ public:
111 111
   #endif
112 112
 
113 113
   static inline void pauseSDPrint() { flag.sdprinting = false; }
114
-  static inline bool isDetected() { return flag.detected; }
115
-  static inline bool isFileOpen() { return isDetected() && file.isOpen(); }
114
+  static inline bool isMounted() { return flag.mounted; }
115
+  static inline bool isFileOpen() { return isMounted() && file.isOpen(); }
116 116
   static inline bool isPaused() { return isFileOpen() && !flag.sdprinting; }
117 117
   static inline bool isPrinting() { return flag.sdprinting; }
118 118
   static inline bool eof() { return sdpos >= filesize; }

Laden…
Annuleren
Opslaan