Browse Source

Use "mount" as card verb

Scott Lahteine 4 years ago
parent
commit
d5f5203880

+ 5
- 5
Marlin/src/HAL/HAL_DUE/usb/sd_mmc_spi_mem.cpp View File

19
 }
19
 }
20
 
20
 
21
 Ctrl_status sd_mmc_spi_test_unit_ready(void) {
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
     return CTRL_NO_PRESENT;
23
     return CTRL_NO_PRESENT;
24
   return CTRL_GOOD;
24
   return CTRL_GOOD;
25
 }
25
 }
27
 // NOTE: This function is defined as returning the address of the last block
27
 // NOTE: This function is defined as returning the address of the last block
28
 // in the card, which is cardSize() - 1
28
 // in the card, which is cardSize() - 1
29
 Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector) {
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
     return CTRL_NO_PRESENT;
31
     return CTRL_NO_PRESENT;
32
   *nb_sector = card.getSd2Card().cardSize() - 1;
32
   *nb_sector = card.getSd2Card().cardSize() - 1;
33
   return CTRL_GOOD;
33
   return CTRL_GOOD;
43
 }
43
 }
44
 
44
 
45
 bool sd_mmc_spi_removal(void) {
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
     return true;
47
     return true;
48
   return false;
48
   return false;
49
 }
49
 }
62
 // #define DEBUG_MMC
62
 // #define DEBUG_MMC
63
 
63
 
64
 Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) {
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
     return CTRL_NO_PRESENT;
66
     return CTRL_NO_PRESENT;
67
 
67
 
68
   #ifdef DEBUG_MMC
68
   #ifdef DEBUG_MMC
99
 }
99
 }
100
 
100
 
101
 Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector) {
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
     return CTRL_NO_PRESENT;
103
     return CTRL_NO_PRESENT;
104
 
104
 
105
   #ifdef DEBUG_MMC
105
   #ifdef DEBUG_MMC

+ 1
- 1
Marlin/src/HAL/HAL_LPC1768/main.cpp View File

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

+ 2
- 2
Marlin/src/HAL/HAL_STM32/persistent_store_sdcard.cpp View File

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

+ 2
- 2
Marlin/src/HAL/HAL_STM32F1/persistent_store_sdcard.cpp View File

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

+ 1
- 2
Marlin/src/Marlin.cpp View File

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

+ 1
- 1
Marlin/src/feature/binary_protocol.h View File

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

+ 2
- 2
Marlin/src/feature/power_loss_recovery.cpp View File

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

+ 1
- 1
Marlin/src/gcode/sdcard/M21_M22.cpp View File

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

+ 1
- 1
Marlin/src/gcode/sdcard/M26.cpp View File

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

+ 1
- 1
Marlin/src/gcode/sdcard/M30.cpp View File

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

+ 1
- 1
Marlin/src/gcode/sdcard/M32.cpp View File

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

+ 4
- 4
Marlin/src/lcd/extensible_ui/ui_api.cpp View File

911
   }
911
   }
912
 
912
 
913
   bool isMediaInserted() {
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
   void pausePrint() {
917
   void pausePrint() {
1008
     if (sd_status != last_sd_status) {
1008
     if (sd_status != last_sd_status) {
1009
       last_sd_status = sd_status;
1009
       last_sd_status = sd_status;
1010
       if (sd_status) {
1010
       if (sd_status) {
1011
-        card.initsd();
1012
-        if (card.isDetected())
1011
+        card.mount();
1012
+        if (card.isMounted())
1013
           ExtUI::onMediaInserted();
1013
           ExtUI::onMediaInserted();
1014
         else
1014
         else
1015
           ExtUI::onMediaError();
1015
           ExtUI::onMediaError();
1016
       }
1016
       }
1017
       else {
1017
       else {
1018
-        const bool ok = card.isDetected();
1018
+        const bool ok = card.isMounted();
1019
         card.release();
1019
         card.release();
1020
         if (ok) ExtUI::onMediaRemoved();
1020
         if (ok) ExtUI::onMediaRemoved();
1021
       }
1021
       }

+ 1
- 1
Marlin/src/lcd/extui_malyan_lcd.cpp View File

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

+ 1
- 1
Marlin/src/lcd/menu/menu_main.cpp View File

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

+ 2
- 2
Marlin/src/lcd/menu/menu_media.cpp View File

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

+ 1
- 1
Marlin/src/lcd/ultralcd.cpp View File

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

+ 11
- 11
Marlin/src/sd/cardreader.cpp View File

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

+ 4
- 4
Marlin/src/sd/cardreader.h View File

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

Loading…
Cancel
Save