Try to init SD with no detect pin

This commit is contained in:
Scott Lahteine 2019-06-15 15:32:09 -05:00
parent 9a56a88200
commit eb1c9113c2
2 changed files with 19 additions and 13 deletions

View file

@ -937,7 +937,7 @@ void setup() {
ui.show_bootscreen(); ui.show_bootscreen();
#endif #endif
#if ENABLED(SDIO_SUPPORT) && SD_DETECT_PIN == -1 #if ENABLED(SDIO_SUPPORT) && !PIN_EXISTS(SD_DETECT)
// Auto-mount the SD for EEPROM.dat emulation // Auto-mount the SD for EEPROM.dat emulation
if (!card.isDetected()) card.initsd(); if (!card.isDetected()) card.initsd();
#endif #endif

View file

@ -104,7 +104,7 @@
#endif #endif
#endif #endif
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) #if ENABLED(SDSUPPORT)
uint8_t lcd_sd_status; uint8_t lcd_sd_status;
#endif #endif
@ -315,8 +315,10 @@ void MarlinUI::init() {
#endif // HAS_SHIFT_ENCODER #endif // HAS_SHIFT_ENCODER
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) #if ENABLED(SDSUPPORT)
SET_INPUT_PULLUP(SD_DETECT_PIN); #if PIN_EXISTS(SD_DETECT)
SET_INPUT_PULLUP(SD_DETECT_PIN);
#endif
lcd_sd_status = 2; // UNKNOWN lcd_sd_status = 2; // UNKNOWN
#endif #endif
@ -766,7 +768,7 @@ void MarlinUI::update() {
#endif // HAS_LCD_MENU #endif // HAS_LCD_MENU
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) #if ENABLED(SDSUPPORT)
const uint8_t sd_status = (uint8_t)IS_SD_INSERTED(); const uint8_t sd_status = (uint8_t)IS_SD_INSERTED();
if (sd_status != lcd_sd_status && detected()) { if (sd_status != lcd_sd_status && detected()) {
@ -782,16 +784,20 @@ void MarlinUI::update() {
else else
set_status_P(PSTR(MSG_SD_INSERTED)); set_status_P(PSTR(MSG_SD_INSERTED));
} }
else { #if PIN_EXISTS(SD_DETECT)
card.release(); else {
if (old_sd_status != 2) { card.release();
set_status_P(PSTR(MSG_SD_REMOVED)); if (old_sd_status != 2) {
if (!on_status_screen()) return_to_status(); set_status_P(PSTR(MSG_SD_REMOVED));
if (!on_status_screen()) return_to_status();
}
} }
}
init_lcd(); // May revive the LCD if static electricity killed it
#endif
refresh(); refresh();
init_lcd(); // May revive the LCD if static electricity killed it
ms = millis(); ms = millis();
next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL; // delay LCD update until after SD activity completes next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL; // delay LCD update until after SD activity completes
@ -801,7 +807,7 @@ void MarlinUI::update() {
#endif #endif
} }
#endif // SDSUPPORT && SD_DETECT_PIN #endif // SDSUPPORT
if (ELAPSED(ms, next_lcd_update_ms) if (ELAPSED(ms, next_lcd_update_ms)
#if HAS_GRAPHICAL_LCD #if HAS_GRAPHICAL_LCD