Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» Generalize SDSUPPORT as HAS_MEDIA
Browse files Browse the repository at this point in the history
In preparation for single- and multi-volume refactoring.
  • Loading branch information
thinkyhead committed Apr 23, 2023
1 parent ce85b98 commit 5664c02
Show file tree
Hide file tree
Showing 164 changed files with 399 additions and 397 deletions.
14 changes: 7 additions & 7 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1601,13 +1601,13 @@
#define SET_REMAINING_TIME // Add 'R' parameter to set remaining time
//#define SET_INTERACTION_TIME // Add 'C' parameter to set time until next filament change or other user interaction
//#define M73_REPORT // Report M73 values to host
#if BOTH(M73_REPORT, SDSUPPORT)
#if BOTH(M73_REPORT, HAS_MEDIA)
#define M73_REPORT_SD_ONLY // Report only when printing from SD
#endif
#endif

// LCD Print Progress options. Multiple times may be displayed in turn.
#if HAS_DISPLAY && EITHER(SDSUPPORT, SET_PROGRESS_MANUALLY)
#if HAS_DISPLAY && EITHER(HAS_MEDIA, SET_PROGRESS_MANUALLY)
#define SHOW_PROGRESS_PERCENT // Show print progress percentage (doesn't affect progress bar)
#define SHOW_ELAPSED_TIME // Display elapsed printing time (prefix 'E')
//#define SHOW_REMAINING_TIME // Display estimated time to completion (prefix 'R')
Expand All @@ -1628,7 +1628,7 @@
#endif
#endif

#if ENABLED(SDSUPPORT)
#if HAS_MEDIA
/**
* SD Card SPI Speed
* May be required to resolve "volume init" errors.
Expand Down Expand Up @@ -1868,7 +1868,7 @@
#define DEFAULT_SHARED_VOLUME SV_USB_FLASH_DRIVE
#endif

#endif // SDSUPPORT
#endif // HAS_MEDIA

/**
* By default an onboard SD card reader may be shared as a USB mass-
Expand Down Expand Up @@ -2492,9 +2492,9 @@

// The number of linear moves that can be in the planner at once.
// The value of BLOCK_BUFFER_SIZE must be a power of 2 (e.g., 8, 16, 32)
#if BOTH(SDSUPPORT, DIRECT_STEPPING)
#if BOTH(HAS_MEDIA, DIRECT_STEPPING)
#define BLOCK_BUFFER_SIZE 8
#elif ENABLED(SDSUPPORT)
#elif HAS_MEDIA
#define BLOCK_BUFFER_SIZE 16
#else
#define BLOCK_BUFFER_SIZE 16
Expand Down Expand Up @@ -2527,7 +2527,7 @@
//#define SERIAL_XON_XOFF
#endif

#if ENABLED(SDSUPPORT)
#if HAS_MEDIA
// Enable this option to collect and display the maximum
// RX queue usage after transferring a file to SD.
//#define SERIAL_STATS_MAX_RX_QUEUED
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/HAL/AVR/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ void MarlinHAL::reboot() {
// Free Memory Accessor
// ------------------------

#if ENABLED(SDSUPPORT)
#if HAS_MEDIA

#include "../../sd/SdFatUtil.h"
int freeMemory() { return SdFatUtil::FreeRam(); }

#else // !SDSUPPORT
#else // !HAS_MEDIA

extern "C" {
extern char __bss_end;
Expand All @@ -167,6 +167,6 @@ void MarlinHAL::reboot() {
}
}

#endif // !SDSUPPORT
#endif // !HAS_MEDIA

#endif // __AVR__
2 changes: 1 addition & 1 deletion Marlin/src/HAL/DUE/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ uint16_t MarlinHAL::adc_result;
#endif

void MarlinHAL::init() {
#if ENABLED(SDSUPPORT)
#if HAS_MEDIA
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
#endif
usb_task_init(); // Initialize the USB stack
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/DUE/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
*/
#define _IS_HW_SPI(P) (defined(TMC_SPI_##P) && (TMC_SPI_##P == SD_MOSI_PIN || TMC_SPI_##P == SD_MISO_PIN || TMC_SPI_##P == SD_SCK_PIN))

#if ENABLED(SDSUPPORT) && HAS_DRIVER(TMC2130)
#if HAS_MEDIA && HAS_DRIVER(TMC2130)
#if ENABLED(TMC_USE_SW_SPI)
#if DISABLED(DUE_SOFTWARE_SPI) && (_IS_HW_SPI(MOSI) || _IS_HW_SPI(MISO) || _IS_HW_SPI(SCK))
#error "DUE hardware SPI is required but is incompatible with TMC2130 software SPI. Either disable TMC_USE_SW_SPI or use separate pins for the two SPIs."
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/HAL/DUE/usb/conf_usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
#define USB_DEVICE_SPECIFIC_REQUEST() usb_task_other_requests()
//@}

#if ENABLED(SDSUPPORT)
#if HAS_MEDIA
/**
* USB Device low level configuration
* When only one interface is used, these configurations are defined by the class module.
Expand Down Expand Up @@ -185,7 +185,7 @@
//! Enable id string of interface to add an extra USB string
#define UDI_CDC_IAD_STRING_ID 4

#if ENABLED(SDSUPPORT)
#if HAS_MEDIA
/**
* USB CDC low level configuration
* In standalone these configurations are defined by the CDC module.
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "../../../inc/MarlinConfig.h"

#if ENABLED(SDSUPPORT)
#if HAS_MEDIA

#include "../../../sd/cardreader.h"
extern "C" {
Expand Down Expand Up @@ -138,5 +138,5 @@ Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector) {

#endif // ACCESS_USB == true

#endif // SDSUPPORT
#endif // HAS_MEDIA
#endif // ARDUINO_ARCH_SAM
4 changes: 2 additions & 2 deletions Marlin/src/HAL/DUE/usb/udi_cdc_desc.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#include "udc_desc.h"
#include "udi_cdc.h"

#if DISABLED(SDSUPPORT)
#if !HAS_MEDIA

/**
* \defgroup udi_cdc_group_single_desc USB device descriptors for a single interface
Expand Down Expand Up @@ -256,6 +256,6 @@ UDC_DESC_STORAGE udc_config_t udc_config = {
//@}
//@}

#endif // SDSUPPORT
#endif // HAS_MEDIA

#endif // ARDUINO_ARCH_SAM
4 changes: 2 additions & 2 deletions Marlin/src/HAL/DUE/usb/udi_composite_desc.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#include "udd.h"
#include "udc_desc.h"

#if ENABLED(SDSUPPORT)
#if HAS_MEDIA

/**
* \defgroup udi_group_desc Descriptors for a USB Device
Expand Down Expand Up @@ -189,4 +189,4 @@ UDC_DESC_STORAGE udc_config_t udc_config = {

#endif // ARDUINO_ARCH_SAM

#endif // SDSUPPORT
#endif // HAS_MEDIA
4 changes: 2 additions & 2 deletions Marlin/src/HAL/DUE/usb/udi_msc.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#include "ctrl_access.h"
#include <string.h>

#if ENABLED(SDSUPPORT)
#if HAS_MEDIA

#ifndef UDI_MSC_NOTIFY_TRANS_EXT
# define UDI_MSC_NOTIFY_TRANS_EXT()
Expand Down Expand Up @@ -1127,6 +1127,6 @@ bool udi_msc_trans_block(bool b_read, uint8_t * block, iram_size_t block_size,

//@}

#endif // SDSUPPORT
#endif // HAS_MEDIA

#endif // ARDUINO_ARCH_SAM
12 changes: 6 additions & 6 deletions Marlin/src/HAL/DUE/usb/usb_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@
#include "conf_usb.h"
#include "udc.h"

#if ENABLED(SDSUPPORT)
#if HAS_MEDIA
static volatile bool main_b_msc_enable = false;
#endif
static volatile bool main_b_cdc_enable = false;
static volatile bool main_b_dtr_active = false;

void usb_task_idle(void) {
#if ENABLED(SDSUPPORT)
#if HAS_MEDIA
// Attend SD card access from the USB MSD -- Prioritize access to improve speed
int delay = 2;
while (main_b_msc_enable && --delay > 0) {
Expand All @@ -70,7 +70,7 @@ void usb_task_idle(void) {
#endif
}

#if ENABLED(SDSUPPORT)
#if HAS_MEDIA
bool usb_task_msc_enable(void) { return ((main_b_msc_enable = true)); }
void usb_task_msc_disable(void) { main_b_msc_enable = false; }
bool usb_task_msc_isenabled(void) { return main_b_msc_enable; }
Expand Down Expand Up @@ -206,13 +206,13 @@ static USB_MicrosoftExtendedPropertiesDescriptor microsoft_extended_properties_d
bool usb_task_extra_string(void) {
static uint8_t udi_msft_magic[] = "MSFT100\xEE";
static uint8_t udi_cdc_name[] = "CDC interface";
#if ENABLED(SDSUPPORT)
#if HAS_MEDIA
static uint8_t udi_msc_name[] = "MSC interface";
#endif

struct extra_strings_desc_t {
usb_str_desc_t header;
#if ENABLED(SDSUPPORT)
#if HAS_MEDIA
le16_t string[Max(Max(sizeof(udi_cdc_name) - 1, sizeof(udi_msc_name) - 1), sizeof(udi_msft_magic) - 1)];
#else
le16_t string[Max(sizeof(udi_cdc_name) - 1, sizeof(udi_msft_magic) - 1)];
Expand All @@ -231,7 +231,7 @@ bool usb_task_extra_string(void) {
str_lgt = sizeof(udi_cdc_name) - 1;
str = udi_cdc_name;
break;
#if ENABLED(SDSUPPORT)
#if HAS_MEDIA
case UDI_MSC_STRING_ID:
str_lgt = sizeof(udi_msc_name) - 1;
str = udi_msc_name;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/ESP32/HAL_SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static SPISettings spiConfig;
// ------------------------

void spiBegin() {
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_SS)
#if HAS_MEDIA && PIN_EXISTS(SD_SS)
OUT_WRITE(SD_SS_PIN, HIGH);
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "HAL.h"
#include "SPI.h"

#if ENABLED(SDSUPPORT)
#if HAS_MEDIA
#include "../../sd/cardreader.h"
#if ENABLED(ESP3D_WIFISUPPORT)
#include "sd_ESP32.h"
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/LINUX/spi_pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "../../core/macros.h"
#include "../../inc/MarlinConfigPre.h"

#if BOTH(HAS_MARLINUI_U8GLIB, SDSUPPORT) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_EN == SD_MOSI_PIN || DOGLCD_SCK == SD_SCK_PIN || DOGLCD_MOSI == SD_MOSI_PIN)
#if BOTH(HAS_MARLINUI_U8GLIB, HAS_MEDIA) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_EN == SD_MOSI_PIN || DOGLCD_SCK == SD_SCK_PIN || DOGLCD_MOSI == SD_MOSI_PIN)
#define SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently
// needed due to the speed and mode required for communicating with each device being different.
// This requirement can be removed if the SPI access to these devices is updated to use
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/LPC1768/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
#if USEDI2CDEV_M == 0 // P0_27 [D57] (AUX-1) .......... P0_28 [D58] (AUX-1)
#define PIN_IS_SDA0(P) (P##_PIN == P0_27)
#define IS_SCL0(P) (P == P0_28)
#if ENABLED(SDSUPPORT) && PIN_IS_SDA0(SD_DETECT)
#if HAS_MEDIA && PIN_IS_SDA0(SD_DETECT)
#error "SDA0 overlaps with SD_DETECT_PIN!"
#elif PIN_IS_SDA0(E0_AUTO_FAN)
#error "SDA0 overlaps with E0_AUTO_FAN_PIN!"
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/LPC1768/spi_pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "../../core/macros.h"

#if BOTH(SDSUPPORT, HAS_MARLINUI_U8GLIB) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_EN == SD_MOSI_PIN || DOGLCD_SCK == SD_SCK_PIN || DOGLCD_MOSI == SD_MOSI_PIN)
#if BOTH(HAS_MEDIA, HAS_MARLINUI_U8GLIB) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_EN == SD_MOSI_PIN || DOGLCD_SCK == SD_SCK_PIN || DOGLCD_MOSI == SD_MOSI_PIN)
#define SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently
// needed due to the speed and mode required for communicating with each device being different.
// This requirement can be removed if the SPI access to these devices is updated to use
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/NATIVE_SIM/spi_pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "../../core/macros.h"
#include "../../inc/MarlinConfigPre.h"

#if BOTH(HAS_MARLINUI_U8GLIB, SDSUPPORT) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_EN == SD_MOSI_PIN || DOGLCD_SCK == SD_SCK_PIN || DOGLCD_MOSI == SD_MOSI_PIN)
#if BOTH(HAS_MARLINUI_U8GLIB, HAS_MEDIA) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_EN == SD_MOSI_PIN || DOGLCD_SCK == SD_SCK_PIN || DOGLCD_MOSI == SD_MOSI_PIN)
#define SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently
// needed due to the speed and mode required for communicating with each device being different.
// This requirement can be removed if the SPI access to these devices is updated to use
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/SAMD21/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void MarlinHAL::dma_init() {}
// HAL initialization task
void MarlinHAL::init() {
TERN_(DMA_IS_REQUIRED, dma_init());
#if ENABLED(SDSUPPORT)
#if HAS_MEDIA
#if HAS_SD_DETECT && SD_CONNECTION_IS(ONBOARD)
SET_INPUT_PULLUP(SD_DETECT_PIN);
#endif
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/SAMD51/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ void MarlinHAL::dma_init() {
// HAL initialization task
void MarlinHAL::init() {
TERN_(DMA_IS_REQUIRED, dma_init());
#if ENABLED(SDSUPPORT)
#if HAS_MEDIA
#if HAS_SD_DETECT && SD_CONNECTION_IS(ONBOARD)
SET_INPUT_PULLUP(SD_DETECT_PIN);
#endif
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void MarlinHAL::init() {
constexpr int cpuFreq = F_CPU;
UNUSED(cpuFreq);

#if ENABLED(SDSUPPORT) && DISABLED(SDIO_SUPPORT) && (defined(SDSS) && SDSS != -1)
#if HAS_MEDIA && DISABLED(SDIO_SUPPORT) && (defined(SDSS) && SDSS != -1)
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
#pragma once

#if BOTH(SDSUPPORT, USBD_USE_CDC_MSC) && DISABLED(NO_SD_HOST_DRIVE)
#if BOTH(HAS_MEDIA, USBD_USE_CDC_MSC) && DISABLED(NO_SD_HOST_DRIVE)
#define HAS_SD_HOST_DRIVE 1
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
//#endif


#if ENABLED(SDCARD_EEPROM_EMULATION) && DISABLED(SDSUPPORT)
#if ENABLED(SDCARD_EEPROM_EMULATION) && !HAS_MEDIA
#undef SDCARD_EEPROM_EMULATION // Avoid additional error noise
#if USE_FALLBACK_EEPROM
#warning "EEPROM type not specified. Fallback is SDCARD_EEPROM_EMULATION."
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/HAL/STM32F1/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#define USE_SHARED_EEPROM 1
#endif

// Allow SDSUPPORT to be disabled
#if DISABLED(SDSUPPORT)
// Allow for no media drives
#if !HAS_MEDIA
#undef SDIO_SUPPORT
#endif
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32F1/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* Test STM32F1-specific configuration values for errors at compile-time.
*/

#if ENABLED(SDCARD_EEPROM_EMULATION) && DISABLED(SDSUPPORT)
#if ENABLED(SDCARD_EEPROM_EMULATION) && !HAS_MEDIA
#undef SDCARD_EEPROM_EMULATION // Avoid additional error noise
#if USE_FALLBACK_EEPROM
#warning "EEPROM type not specified. Fallback is SDCARD_EEPROM_EMULATION."
Expand Down
Loading

0 comments on commit 5664c02

Please sign in to comment.