Skip to content

Commit

Permalink
⛙ Merge w/Marlin
Browse files Browse the repository at this point in the history
  • Loading branch information
classicrocker883 committed Jan 28, 2025
2 parents 944e057 + 09a519b commit 049314e
Show file tree
Hide file tree
Showing 198 changed files with 1,748 additions and 949 deletions.
4 changes: 2 additions & 2 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1877,7 +1877,7 @@
*
* SCLK, MOSI, MISO --> SCLK, MOSI, MISO
* INT --> SD_DETECT_PIN [1]
* SS --> SDSS
* SS --> SD_SS_PIN
*
* [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
*/
Expand All @@ -1904,7 +1904,7 @@
//#define USE_OTG_USB_HOST

#if DISABLED(USE_OTG_USB_HOST)
#define USB_CS_PIN SDSS
#define USB_CS_PIN SD_SS_PIN
#define USB_INTR_PIN SD_DETECT_PIN
#endif
#endif
Expand Down
33 changes: 3 additions & 30 deletions Marlin/src/HAL/NATIVE_SIM/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,37 +71,10 @@ extern MSerialT serial_stream_2;
extern MSerialT serial_stream_3;

#define _MSERIAL(X) serial_stream_##X
#define MSERIAL(X) _MSERIAL(X)

#if WITHIN(SERIAL_PORT, 0, 3)
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
#else
#error "SERIAL_PORT must be from 0 to 3. Please update your configuration."
#endif

#ifdef SERIAL_PORT_2
#if WITHIN(SERIAL_PORT_2, 0, 3)
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
#else
#error "SERIAL_PORT_2 must be from 0 to 3. Please update your configuration."
#endif
#endif

#ifdef MMU_SERIAL_PORT
#if WITHIN(MMU_SERIAL_PORT, 0, 3)
#define MMU_SERIAL MSERIAL(MMU_SERIAL_PORT)
#else
#error "MMU_SERIAL_PORT must be from 0 to 3. Please update your configuration."
#endif
#endif

#ifdef LCD_SERIAL_PORT
#if WITHIN(LCD_SERIAL_PORT, 0, 3)
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
#else
#error "LCD_SERIAL_PORT must be from 0 to 3. Please update your configuration."
#endif
#endif
#define SERIAL_INDEX_MIN 0
#define SERIAL_INDEX_MAX 3
#include "../shared/serial_ports.h"

// ------------------------
// Interrupts
Expand Down
7 changes: 0 additions & 7 deletions Marlin/src/HAL/NATIVE_SIM/spi_pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
//#define SD_SCK_PIN P0_07
//#define SD_MISO_PIN P0_08
//#define SD_MOSI_PIN P0_09
//#define SD_SS_PIN P0_06

// External SD
#ifndef SD_SCK_PIN
Expand All @@ -44,9 +43,3 @@
#ifndef SD_MOSI_PIN
#define SD_MOSI_PIN 52
#endif
#ifndef SD_SS_PIN
#define SD_SS_PIN 53
#endif
#ifndef SDSS
#define SDSS SD_SS_PIN
#endif
7 changes: 2 additions & 5 deletions Marlin/src/HAL/RP2040/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,8 @@ void MarlinHAL::init() {
constexpr int cpuFreq = F_CPU;
UNUSED(cpuFreq);

#undef SDSS
#define SDSS 2
#define PIN_EXISTS_(P1,P2) (defined(P1##P2) && P1##P2 >= 0)
#if HAS_MEDIA && DISABLED(SDIO_SUPPORT) && PIN_EXISTS_(SDSS,)
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
#if HAS_MEDIA && DISABLED(SDIO_SUPPORT) && PIN_EXISTS(SD_SS)
OUT_WRITE(SD_SS_PIN, HIGH); // Try to set SD_SS_PIN inactive before any other SPI users start up
#endif

#if PIN_EXISTS(LED)
Expand Down
65 changes: 4 additions & 61 deletions Marlin/src/HAL/RP2040/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,73 +35,16 @@
#include "fastio.h"
//#include "Servo.h"
#include "watchdog.h"
#include "MarlinSerial.h"

#include "../../inc/MarlinConfigPre.h"

#include <stdint.h>

// ------------------------
// Serial ports
// ------------------------

#include "../../core/serial_hook.h"
typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1;
extern DefaultSerial1 MSerial0;

#define _MSERIAL(X) MSerial##X
#define MSERIAL(X) _MSERIAL(X)

#if SERIAL_PORT == -1
#define MYSERIAL1 MSerial0
#elif WITHIN(SERIAL_PORT, 0, 6)
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
#else
#error "SERIAL_PORT must be from 0 to 6. You can also use -1 if the board supports Native USB."
#endif

#ifdef SERIAL_PORT_2
#if SERIAL_PORT_2 == -1
#define MYSERIAL2 MSerial0
#elif WITHIN(SERIAL_PORT_2, 0, 6)
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
#else
#error "SERIAL_PORT_2 must be from 0 to 6. You can also use -1 if the board supports Native USB."
#endif
#endif

#ifdef SERIAL_PORT_3
#if SERIAL_PORT_3 == -1
#define MYSERIAL3 MSerial0
#elif WITHIN(SERIAL_PORT_3, 0, 6)
#define MYSERIAL3 MSERIAL(SERIAL_PORT_3)
#else
#error "SERIAL_PORT_3 must be from 0 to 6. You can also use -1 if the board supports Native USB."
#endif
#endif

#ifdef MMU2_SERIAL_PORT
#if MMU2_SERIAL_PORT == -1
#define MMU2_SERIAL MSerial0
#elif WITHIN(MMU2_SERIAL_PORT, 0, 6)
#define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
#else
#error "MMU2_SERIAL_PORT must be from 0 to 6. You can also use -1 if the board supports Native USB."
#endif
#endif
//
// Serial Ports
//

#ifdef LCD_SERIAL_PORT
#if LCD_SERIAL_PORT == -1
#define LCD_SERIAL MSerial0
#elif WITHIN(LCD_SERIAL_PORT, 0, 6)
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
#else
#error "LCD_SERIAL_PORT must be from 0 to 6. You can also use -1 if the board supports Native USB."
#endif
#if HAS_DGUS_LCD
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
#endif
#endif
#include "MarlinSerial.h"

// ------------------------
// Defines
Expand Down
24 changes: 11 additions & 13 deletions Marlin/src/HAL/RP2040/MarlinSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,22 @@

#include "../../core/serial_hook.h"

typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1;
extern DefaultSerial1 MSerial0;
typedef ForwardSerial1Class<decltype(SerialUSB)> USBSerialType;
extern USBSerialType USBSerial;

#define Serial0 Serial
#define _DECLARE_SERIAL(X) \
typedef ForwardSerial1Class<decltype(Serial##X)> DefaultSerial##X; \
extern DefaultSerial##X MSerial##X
#define DECLARE_SERIAL(X) _DECLARE_SERIAL(X)

typedef ForwardSerial1Class<decltype(SerialUSB)> USBSerialType;
extern USBSerialType USBSerial;

#define _MSERIAL(X) MSerial##X
#define MSERIAL(X) _MSERIAL(X)
#define SERIAL_INDEX_MIN 0
#define SERIAL_INDEX_MAX 6
#define USB_SERIAL_PORT(...) MSerial0
#include "../shared/serial_ports.h"

#if SERIAL_PORT == -1
// #define MYSERIAL1 USBSerial this is already done in the HAL
#elif WITHIN(SERIAL_PORT, 0, 3)
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
DECLARE_SERIAL(SERIAL_PORT);
#else
#error "SERIAL_PORT must be from 0 to 3, or -1 for Native USB."
#if defined(LCD_SERIAL_PORT) && ANY(HAS_DGUS_LCD, EXTENSIBLE_UI)
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
#endif

2 changes: 1 addition & 1 deletion Marlin/src/HAL/RP2040/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
// #error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector"
//#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/RP2040/msc_sd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
class Sd2CardUSBMscHandler : public USBMscHandler {
public:
DiskIODriver* diskIODriver() {
#if ENABLED(MULTI_VOLUME)
#if HAS_MULTI_VOLUME
#if SHARED_VOLUME_IS(SD_ONBOARD)
return &card.media_driver_sdcard;
#elif SHARED_VOLUME_IS(USB_FLASH_DRIVE)
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 @@ -107,7 +107,7 @@ void MarlinHAL::init() {
#if HAS_SD_DETECT && SD_CONNECTION_IS(ONBOARD)
SET_INPUT_PULLUP(SD_DETECT_PIN);
#endif
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
OUT_WRITE(SD_SS_PIN, HIGH); // Try to set SDSS inactive before any other SPI users start up
#endif
}

Expand Down
43 changes: 5 additions & 38 deletions Marlin/src/HAL/SAMD21/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
// ------------------------
// Serial ports
// ------------------------

#include "../../core/serial_hook.h"
typedef ForwardSerial1Class< decltype(SerialUSB) > DefaultSerial1;
extern DefaultSerial1 MSerialUSB;

// Serial ports
typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2;
typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3;

Expand All @@ -51,43 +51,10 @@ extern DefaultSerial3 MSerial1;
#define _MSERIAL(X) __MSERIAL(X)
#define MSERIAL(X) _MSERIAL(INCREMENT(X))

#if WITHIN(SERIAL_PORT, 0, 1)
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
#elif SERIAL_PORT == -1
#define MYSERIAL1 MSerialUSB
#else
#error "SERIAL_PORT must be -1 (Native USB only)."
#endif

#ifdef SERIAL_PORT_2
#if WITHIN(SERIAL_PORT_2, 0, 1)
#define MYSERIAL2 MSERIAL(SERIAL_PORT)
#elif SERIAL_PORT_2 == -1
#define MYSERIAL2 MSerialUSB
#else
#error "SERIAL_PORT_2 must be -1 (Native USB only)."
#endif
#endif

#ifdef MMU_SERIAL_PORT
#if WITHIN(MMU_SERIAL_PORT, 0, 1)
#define MMU_SERIAL MSERIAL(SERIAL_PORT)
#elif MMU_SERIAL_PORT == -1
#define MMU_SERIAL MSerialUSB
#else
#error "MMU_SERIAL_PORT must be -1 (Native USB only)."
#endif
#endif

#ifdef LCD_SERIAL_PORT
#if WITHIN(LCD_SERIAL_PORT, 0, 1)
#define LCD_SERIAL MSERIAL(SERIAL_PORT)
#elif LCD_SERIAL_PORT == -1
#define LCD_SERIAL MSerialUSB
#else
#error "LCD_SERIAL_PORT must be -1 (Native USB only)."
#endif
#endif
#define SERIAL_INDEX_MIN 0
#define SERIAL_INDEX_MAX 1
#define USB_SERIAL_PORT(...) MSerialUSB
#include "../shared/serial_ports.h"

typedef int8_t pin_t;

Expand Down
7 changes: 0 additions & 7 deletions Marlin/src/HAL/SAMD21/spi_pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,3 @@
#ifndef SD_MOSI_PIN
#define SD_MOSI_PIN 37
#endif
#ifndef SDSS
#define SDSS 18
#endif

#ifndef SD_SS_PIN
#define SD_SS_PIN SDSS
#endif
4 changes: 2 additions & 2 deletions Marlin/src/HAL/STM32/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ void MarlinHAL::init() {
constexpr int cpuFreq = F_CPU;
UNUSED(cpuFreq);

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

#if PIN_EXISTS(LED)
Expand Down
Loading

0 comments on commit 049314e

Please sign in to comment.