Skip to content

Commit

Permalink
Fix broken POWER_LOSS_RECOVERY prompt (#18557)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <[email protected]>
  • Loading branch information
sjasonsmith and thinkyhead authored Jul 6, 2020
1 parent 764fc81 commit af8be58
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Marlin/src/HAL/LPC1768/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void HAL_init() {
delay(1000); // Give OS time to notice
USB_Connect(TRUE);

#if !BOTH(SHARED_SD_CARD, INIT_SDCARD_ON_BOOT) && DISABLED(NO_SD_HOST_DRIVE)
#if DISABLED(NO_SD_HOST_DRIVE)
MSC_SD_Init(0); // Enable USB SD card access
#endif

Expand All @@ -140,7 +140,7 @@ void HAL_init() {

// HAL idle task
void HAL_idletask() {
#if ENABLED(SHARED_SD_CARD)
#if HAS_SHARED_MEDIA
// If Marlin is using the SD card we need to lock it to prevent access from
// a PC via USB.
// Other HALs use IS_SD_PRINTING() and IS_SD_FILE_OPEN() to check for access but
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/HAL/STM32F1/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,15 @@ void HAL_init() {
// HAL idle task
void HAL_idletask() {
#ifdef USE_USB_COMPOSITE
#if ENABLED(SHARED_SD_CARD)
#if HAS_SHARED_MEDIA
// If Marlin is using the SD card we need to lock it to prevent access from
// a PC via USB.
// Other HALs use IS_SD_PRINTING() and IS_SD_FILE_OPEN() to check for access but
// this will not reliably detect delete operations. To be safe we will lock
// the disk if Marlin has it mounted. Unfortunately there is currently no way
// to unmount the disk from the LCD menu.
// if (IS_SD_PRINTING() || IS_SD_FILE_OPEN())
/* copy from lpc1768 framework, should be fixed later for process SHARED_SD_CARD*/
/* copy from lpc1768 framework, should be fixed later for process HAS_SHARED_MEDIA*/
#endif
// process USB mass storage device class loop
MarlinMSC.loop();
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32F1/onboard_sd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "SPI.h"
#include "fastio.h"

#if ENABLED(SHARED_SD_CARD)
#if HAS_SHARED_MEDIA
#ifndef ON_BOARD_SPI_DEVICE
#define ON_BOARD_SPI_DEVICE SPI_DEVICE
#endif
Expand Down
6 changes: 1 addition & 5 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,7 @@
// mount/unmount the card and refresh it. So we disable card detect.
//
#undef SD_DETECT_PIN
#define SHARED_SD_CARD
#endif

#if DISABLED(SHARED_SD_CARD)
#define INIT_SDCARD_ON_BOOT
#define HAS_SHARED_MEDIA 1
#endif

#if PIN_EXISTS(SD_DETECT)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/sd/cardreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ void CardReader::mount() {
#endif

void CardReader::manage_media() {
static uint8_t prev_stat = TERN(INIT_SDCARD_ON_BOOT, 2, 0);
static uint8_t prev_stat = 2; // First call, no prior state
uint8_t stat = uint8_t(IS_SD_INSERTED());
if (stat == prev_stat) return;

Expand Down

0 comments on commit af8be58

Please sign in to comment.