Use "mount" as card verb

This commit is contained in:
Scott Lahteine 2019-09-15 03:10:59 -05:00
parent 2386c147ad
commit d5f5203880
18 changed files with 42 additions and 43 deletions

View file

@ -19,7 +19,7 @@ void sd_mmc_spi_mem_init(void) {
}
Ctrl_status sd_mmc_spi_test_unit_ready(void) {
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
return CTRL_NO_PRESENT;
return CTRL_GOOD;
}
@ -27,7 +27,7 @@ Ctrl_status sd_mmc_spi_test_unit_ready(void) {
// NOTE: This function is defined as returning the address of the last block
// in the card, which is cardSize() - 1
Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector) {
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
return CTRL_NO_PRESENT;
*nb_sector = card.getSd2Card().cardSize() - 1;
return CTRL_GOOD;
@ -43,7 +43,7 @@ bool sd_mmc_spi_wr_protect(void) {
}
bool sd_mmc_spi_removal(void) {
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
return true;
return false;
}
@ -62,7 +62,7 @@ uint8_t sector_buf[SD_MMC_BLOCK_SIZE];
// #define DEBUG_MMC
Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) {
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
return CTRL_NO_PRESENT;
#ifdef DEBUG_MMC
@ -99,7 +99,7 @@ Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) {
}
Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector) {
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
return CTRL_NO_PRESENT;
#ifdef DEBUG_MMC

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -911,7 +911,7 @@ namespace ExtUI {
}
bool isMediaInserted() {
return IFSD(IS_SD_INSERTED() && card.isDetected(), false);
return IFSD(IS_SD_INSERTED() && card.isMounted(), false);
}
void pausePrint() {
@ -1008,14 +1008,14 @@ void MarlinUI::update() {
if (sd_status != last_sd_status) {
last_sd_status = sd_status;
if (sd_status) {
card.initsd();
if (card.isDetected())
card.mount();
if (card.isMounted())
ExtUI::onMediaInserted();
else
ExtUI::onMediaError();
}
else {
const bool ok = card.isDetected();
const bool ok = card.isMounted();
card.release();
if (ok) ExtUI::onMediaRemoved();
}

View file

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

View file

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

View file

@ -34,7 +34,7 @@
#if !PIN_EXISTS(SD_DETECT)
void lcd_sd_refresh() {
encoderTopLine = 0;
card.initsd();
card.mount();
}
#endif
@ -146,7 +146,7 @@ void menu_media() {
MENU_ITEM(function, LCD_STR_REFRESH MSG_REFRESH, lcd_sd_refresh);
#endif
}
else if (card.isDetected())
else if (card.isMounted())
MENU_ITEM(function, LCD_STR_FOLDER "..", lcd_sd_updir);
if (ui.should_draw()) for (uint16_t i = 0; i < fileCnt; i++) {

View file

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

View file

@ -123,7 +123,7 @@ CardReader::CardReader() {
//sort_reverse = false;
#endif
#endif
flag.sdprinting = flag.detected = flag.saving = flag.logging = false;
flag.sdprinting = flag.mounted = flag.saving = flag.logging = false;
filesize = sdpos = 0;
file_subcall_ctr = 0;
@ -329,8 +329,8 @@ void CardReader::printFilename() {
SERIAL_EOL();
}
void CardReader::initsd() {
flag.detected = false;
void CardReader::mount() {
flag.mounted = false;
if (root.isOpen()) root.close();
#ifndef SPI_SPEED
@ -350,7 +350,7 @@ void CardReader::initsd() {
else if (!root.openRoot(&volume))
SERIAL_ERROR_MSG(MSG_SD_OPENROOT_FAIL);
else {
flag.detected = true;
flag.mounted = true;
SERIAL_ECHO_MSG(MSG_SD_CARD_OK);
#if ENABLED(EEPROM_SETTINGS) && NONE(FLASH_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)
settings.first_load();
@ -363,7 +363,7 @@ void CardReader::initsd() {
void CardReader::release() {
stopSDPrint();
flag.detected = false;
flag.mounted = false;
}
void CardReader::openAndPrintFile(const char *name) {
@ -375,7 +375,7 @@ void CardReader::openAndPrintFile(const char *name) {
}
void CardReader::startFileprint() {
if (isDetected()) {
if (isMounted()) {
flag.sdprinting = true;
#if SD_RESORT
flush_presort();
@ -425,7 +425,7 @@ void CardReader::getAbsFilename(char *t) {
void CardReader::openFile(char * const path, const bool read, const bool subcall/*=false*/) {
if (!isDetected()) return;
if (!isMounted()) return;
uint8_t doing = 0;
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
}
void CardReader::removeFile(const char * const name) {
if (!isDetected()) return;
if (!isMounted()) return;
//stopSDPrint();
@ -558,12 +558,12 @@ void CardReader::checkautostart() {
if (autostart_index < 0 || flag.sdprinting) return;
if (!isDetected()) initsd();
if (!isMounted()) mount();
#if ENABLED(EEPROM_SETTINGS) && NONE(FLASH_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)
else settings.first_load();
#endif
if (isDetected()
if (isMounted()
#if ENABLED(POWER_LOSS_RECOVERY)
&& !recovery.valid() // Don't run auto#.g when a resume file exists
#endif
@ -1049,7 +1049,7 @@ void CardReader::printingHasFinished() {
}
void CardReader::openJobRecoveryFile(const bool read) {
if (!isDetected()) return;
if (!isMounted()) return;
if (recovery.file.isOpen()) return;
if (!recovery.file.open(&root, recovery.filename, read ? O_READ : O_CREAT | O_WRITE | O_TRUNC | O_SYNC))
SERIAL_ECHOLNPAIR(MSG_SD_OPEN_FILE_FAIL, recovery.filename, ".");

View file

@ -39,7 +39,7 @@ typedef struct {
bool saving:1,
logging:1,
sdprinting:1,
detected:1,
mounted:1,
filenameIsDir:1,
abort_sd_printing:1
#if ENABLED(BINARY_FILE_TRANSFER)
@ -52,7 +52,7 @@ class CardReader {
public:
CardReader();
static void initsd();
static void mount();
static void write_command(char *buf);
static void beginautostart();
@ -111,8 +111,8 @@ public:
#endif
static inline void pauseSDPrint() { flag.sdprinting = false; }
static inline bool isDetected() { return flag.detected; }
static inline bool isFileOpen() { return isDetected() && file.isOpen(); }
static inline bool isMounted() { return flag.mounted; }
static inline bool isFileOpen() { return isMounted() && file.isOpen(); }
static inline bool isPaused() { return isFileOpen() && !flag.sdprinting; }
static inline bool isPrinting() { return flag.sdprinting; }
static inline bool eof() { return sdpos >= filesize; }