Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SD pins for SKR Pro and GTR #19047

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Marlin/src/lcd/extui/ui_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1057,10 +1057,6 @@ namespace ExtUI {
// At the moment, we piggy-back off the ultralcd calls, but this could be cleaned up in the future

void MarlinUI::init() {
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
SET_INPUT_PULLUP(SD_DETECT_PIN);
#endif

ExtUI::onStartup();
}

Expand Down
4 changes: 0 additions & 4 deletions Marlin/src/lcd/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,6 @@ void MarlinUI::init() {

#endif // HAS_SHIFT_ENCODER

#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
SET_INPUT_PULLUP(SD_DETECT_PIN);
#endif

#if HAS_ENCODER_ACTION && HAS_SLOW_BUTTONS
slow_buttons = 0;
#endif
Expand Down
52 changes: 30 additions & 22 deletions Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,24 +280,29 @@
//#define FAN6_PIN PC9 // Fan6
//#define FAN7_PIN PE14 // Fan7

#ifndef SDCARD_CONNECTION
#define SDCARD_CONNECTION ONBOARD
#endif

//
// By default the onboard SD (SPI1) is enabled
// By default the LCD SD (SPI2) is enabled
// Onboard SD is on a completely separate SPI bus, and requires
// overriding pins to access.
//
#define CUSTOM_SPI_PINS
#if DISABLED(CUSTOM_SPI_PINS)
#if SD_CONNECTION_IS(LCD)
#define SD_DETECT_PIN PB10
#define SDSS PB12
#endif

// HAL SPI1 pins group
#if ENABLED(CUSTOM_SPI_PINS)
#elif SD_CONNECTION_IS(ONBOARD)
// Instruct the STM32 HAL to override the default SPI pins from the variant.h file
#define CUSTOM_SPI_PINS
#define SDSS PA4
#define SD_DETECT_PIN PC4
#define LCD_SDSS PA4

#define SS_PIN SDSS
#define SCK_PIN PA5
#define MISO_PIN PA6
#define MOSI_PIN PA7
#define SS_PIN PA4 // Chip select for SD card used by Marlin
#define SD_DETECT_PIN PC4
#elif SD_CONNECTION_IS(CUSTOM_CABLE)
#define "CUSTOM_CABLE is not a supported SDCARD_CONNECTION for this board"
#endif

/**
Expand All @@ -319,7 +324,6 @@
#define BTN_ENC PA15

#if ENABLED(CR10_STOCKDISPLAY)

#define LCD_PINS_RS PG6

#define BTN_EN1 PC10
Expand All @@ -333,24 +337,33 @@
#undef BOARD_ST7920_DELAY_2
#undef BOARD_ST7920_DELAY_3

#elif ENABLED(MKS_MINI_12864)
#define DOGLCD_A0 PG6
#define DOGLCD_CS PG7
#define BTN_EN1 PD10
#define BTN_EN2 PH10

#if SD_CONNECTION_IS(ONBOARD)
#define SOFTWARE_SPI
#endif
#else

#define LCD_PINS_RS PA8

#define BTN_EN1 PD10
#define BTN_EN2 PH10

#if DISABLED(CUSTOM_SPI_PINS)
#define SD_DETECT_PIN PB10
#define LCD_SDSS PB12
#endif

#define LCD_PINS_ENABLE PC10
#define LCD_PINS_D4 PG8

#if ENABLED(FYSETC_MINI_12864)
#define DOGLCD_CS PC10
#define DOGLCD_A0 PA8

#if SD_CONNECTION_IS(ONBOARD)
#define SOFTWARE_SPI
#endif

//#define LCD_BACKLIGHT_PIN -1
#define LCD_RESET_PIN PG8 // Must be high or open for LCD to operate normally.
#if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0)
Expand Down Expand Up @@ -389,11 +402,6 @@
#endif
#endif

//#define DOGLCD_CS PB12
//#define DOGLCD_A0 PA8
//#define LCD_PINS_DC PB14
//#define DOGLCD_MOSI PB15

#endif // HAS_SPI_LCD

#undef TP
23 changes: 14 additions & 9 deletions Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,22 @@
// Onboard SD card
// Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2
//
#if SD_CONNECTION_IS(ONBOARD)
#define SOFTWARE_SPI // Use soft SPI for onboard SD
#if SD_CONNECTION_IS(LCD)
#define SD_DETECT_PIN PF12
#define SDSS PB12
#elif SD_CONNECTION_IS(ONBOARD)
// The SKR Pro's ONBOARD SD interface is on SPI1.
// Due to a pull resistor on the clock line, it needs to use SPI Data Mode 3 to
// function with Hardware SPI. This is not currently configurable in the HAL,
// so force Software SPI to work around this issue.
#define SOFTWARE_SPI
#define SDSS PA4
#define SCK_PIN PA5
#define MISO_PIN PA6
#define MOSI_PIN PB5
#define SD_DETECT_PIN PB11
#elif SD_CONNECTION_IS(CUSTOM_CABLE)
#define "CUSTOM_CABLE is not a supported SDCARD_CONNECTION for this board"
#endif

/**
Expand All @@ -275,9 +285,6 @@
#if HAS_SPI_LCD
#define BEEPER_PIN PG4
#define BTN_ENC PA8
#if SD_CONNECTION_IS(LCD)
#define SDSS PB12 // Uses default hardware SPI for LCD's SD
#endif

#if ENABLED(CR10_STOCKDISPLAY)
#define LCD_PINS_RS PG6
Expand All @@ -296,16 +303,14 @@
#elif ENABLED(MKS_MINI_12864)
#define DOGLCD_A0 PG6
#define DOGLCD_CS PG3

#define BTN_EN1 PG10
#define BTN_EN2 PF11
#else

#define LCD_PINS_RS PD10

#define BTN_EN1 PG10
#define BTN_EN2 PF11
#define SD_DETECT_PIN PF12

#define LCD_SDSS PB12

#define LCD_PINS_ENABLE PD11
#define LCD_PINS_D4 PG2
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/sd/cardreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ CardReader::CardReader() {
// Disable autostart until card is initialized
autostart_index = -1;

#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
SET_INPUT_PULLUP(SD_DETECT_PIN);
#endif

#if PIN_EXISTS(SDPOWER)
OUT_WRITE(SDPOWER_PIN, HIGH); // Power the SD reader
#endif
Expand Down