Skip to content

Commit

Permalink
♻️ SDSUPPORT => HAS_MEDIA
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Feb 8, 2024
1 parent 2e4b037 commit d403352
Show file tree
Hide file tree
Showing 161 changed files with 385 additions and 380 deletions.
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_SW_##P) && (TMC_SW_##P == SD_MOSI_PIN || TMC_SW_##P == SD_MISO_PIN || TMC_SW_##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 ALL(HAS_MARLINUI_U8GLIB, SDSUPPORT) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_ENABLE == SD_MOSI_PIN || DOGLCD_SCK == SD_SCK_PIN || DOGLCD_MOSI == SD_MOSI_PIN)
#if ALL(HAS_MARLINUI_U8GLIB, HAS_MEDIA) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_ENABLE == 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 ALL(SDSUPPORT, HAS_MARLINUI_U8GLIB) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_ENABLE == SD_MOSI_PIN || DOGLCD_SCK == SD_SCK_PIN || DOGLCD_MOSI == SD_MOSI_PIN)
#if ALL(HAS_MEDIA, HAS_MARLINUI_U8GLIB) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_ENABLE == 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 ALL(HAS_MARLINUI_U8GLIB, SDSUPPORT) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_ENABLE == SD_MOSI_PIN || DOGLCD_SCK == SD_SCK_PIN || DOGLCD_MOSI == SD_MOSI_PIN)
#if ALL(HAS_MARLINUI_U8GLIB, HAS_MEDIA) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_ENABLE == 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 ALL(SDSUPPORT, USBD_USE_CDC_MSC) && DISABLED(NO_SD_HOST_DRIVE)
#if ALL(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
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32F1/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
#endif

// Allow SDSUPPORT to be disabled
#if DISABLED(SDSUPPORT)
#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
14 changes: 7 additions & 7 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
#include "feature/spindle_laser.h"
#endif

#if ENABLED(SDSUPPORT)
#if HAS_MEDIA
CardReader card;
#endif

Expand Down Expand Up @@ -358,7 +358,7 @@ void startOrResumeJob() {
print_job_timer.start();
}

#if ENABLED(SDSUPPORT)
#if HAS_MEDIA

inline void abortSDPrinting() {
IF_DISABLED(NO_SD_AUTOSTART, card.autofile_cancel());
Expand Down Expand Up @@ -392,7 +392,7 @@ void startOrResumeJob() {
}
}

#endif // SDSUPPORT
#endif // HAS_MEDIA

/**
* Minimal management of Marlin's core activities:
Expand Down Expand Up @@ -829,7 +829,7 @@ void idle(const bool no_stepper_sleep/*=false*/) {
#endif

// Handle SD Card insert / remove
TERN_(SDSUPPORT, card.manage_media());
TERN_(HAS_MEDIA, card.manage_media());

// Handle USB Flash Drive insert / remove
TERN_(USB_FLASH_DRIVE_SUPPORT, card.diskIODriver()->idle());
Expand Down Expand Up @@ -1331,7 +1331,7 @@ void setup() {
#endif
#endif

#if ALL(SDSUPPORT, SDCARD_EEPROM_EMULATION)
#if ALL(HAS_MEDIA, SDCARD_EEPROM_EMULATION)
SETUP_RUN(card.mount()); // Mount media with settings before first_load
#endif

Expand Down Expand Up @@ -1615,7 +1615,7 @@ void setup() {
#endif

#if HAS_TFT_LVGL_UI
#if ENABLED(SDSUPPORT)
#if HAS_MEDIA
if (!card.isMounted()) SETUP_RUN(card.mount()); // Mount SD to load graphics and fonts
#endif
SETUP_RUN(tft_lvgl_init());
Expand Down Expand Up @@ -1673,7 +1673,7 @@ void loop() {
do {
idle();

#if ENABLED(SDSUPPORT)
#if HAS_MEDIA
if (card.flag.abort_sd_printing) abortSDPrinting();
if (marlin_state == MF_SD_COMPLETE) finishSDPrinting();
#endif
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/binary_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ class BinaryStream {
uint8_t data = 0;
millis_t transfer_window = millis() + RX_TIMESLICE;

#if ENABLED(SDSUPPORT)
#if HAS_MEDIA
PORT_REDIRECT(SERIAL_PORTMASK(card.transfer_port_index));
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/e_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// Static data members
bool EmergencyParser::killed_by_M112, // = false
EmergencyParser::quickstop_by_M410,
#if ENABLED(SDSUPPORT)
#if HAS_MEDIA
EmergencyParser::sd_abort_by_M524,
#endif
EmergencyParser::enabled;
Expand Down
Loading

0 comments on commit d403352

Please sign in to comment.