Browse Source

Fix SD pins for SKR Pro and GTR (#19047)

Jason Smith 5 years ago
parent
commit
646d90f3da
No account linked to committer's email address

+ 0
- 4
Marlin/src/lcd/extui/ui_api.cpp View File

@@ -1057,10 +1057,6 @@ namespace ExtUI {
1057 1057
 // At the moment, we piggy-back off the ultralcd calls, but this could be cleaned up in the future
1058 1058
 
1059 1059
 void MarlinUI::init() {
1060
-  #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
1061
-    SET_INPUT_PULLUP(SD_DETECT_PIN);
1062
-  #endif
1063
-
1064 1060
   ExtUI::onStartup();
1065 1061
 }
1066 1062
 

+ 0
- 4
Marlin/src/lcd/ultralcd.cpp View File

@@ -372,10 +372,6 @@ void MarlinUI::init() {
372 372
 
373 373
   #endif // HAS_SHIFT_ENCODER
374 374
 
375
-  #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
376
-    SET_INPUT_PULLUP(SD_DETECT_PIN);
377
-  #endif
378
-
379 375
   #if HAS_ENCODER_ACTION && HAS_SLOW_BUTTONS
380 376
     slow_buttons = 0;
381 377
   #endif

+ 30
- 22
Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h View File

@@ -280,24 +280,29 @@
280 280
 //#define FAN6_PIN                          PC9   // Fan6
281 281
 //#define FAN7_PIN                          PE14  // Fan7
282 282
 
283
+#ifndef SDCARD_CONNECTION
284
+  #define SDCARD_CONNECTION ONBOARD
285
+#endif
286
+
283 287
 //
284
-// By default the onboard SD (SPI1) is enabled
288
+// By default the LCD SD (SPI2) is enabled
289
+// Onboard SD is on a completely separate SPI bus, and requires
290
+// overriding pins to access.
285 291
 //
286
-#define CUSTOM_SPI_PINS
287
-#if DISABLED(CUSTOM_SPI_PINS)
292
+#if SD_CONNECTION_IS(LCD)
293
+  #define SD_DETECT_PIN                     PB10
288 294
   #define SDSS                              PB12
289
-#endif
290
-
291
-// HAL SPI1 pins group
292
-#if ENABLED(CUSTOM_SPI_PINS)
295
+#elif SD_CONNECTION_IS(ONBOARD)
296
+  // Instruct the STM32 HAL to override the default SPI pins from the variant.h file
297
+  #define CUSTOM_SPI_PINS
293 298
   #define SDSS                              PA4
294
-  #define SD_DETECT_PIN                     PC4
295
-  #define LCD_SDSS                          PA4
296
-
299
+  #define SS_PIN                            SDSS
297 300
   #define SCK_PIN                           PA5
298 301
   #define MISO_PIN                          PA6
299 302
   #define MOSI_PIN                          PA7
300
-  #define SS_PIN                            PA4   // Chip select for SD card used by Marlin
303
+  #define SD_DETECT_PIN                     PC4
304
+#elif SD_CONNECTION_IS(CUSTOM_CABLE)
305
+  #define "CUSTOM_CABLE is not a supported SDCARD_CONNECTION for this board"
301 306
 #endif
302 307
 
303 308
 /**
@@ -319,7 +324,6 @@
319 324
   #define BTN_ENC                           PA15
320 325
 
321 326
   #if ENABLED(CR10_STOCKDISPLAY)
322
-
323 327
     #define LCD_PINS_RS                     PG6
324 328
 
325 329
     #define BTN_EN1                         PC10
@@ -333,6 +337,15 @@
333 337
     #undef BOARD_ST7920_DELAY_2
334 338
     #undef BOARD_ST7920_DELAY_3
335 339
 
340
+  #elif ENABLED(MKS_MINI_12864)
341
+    #define DOGLCD_A0                       PG6
342
+    #define DOGLCD_CS                       PG7
343
+    #define BTN_EN1                         PD10
344
+    #define BTN_EN2                         PH10
345
+
346
+    #if SD_CONNECTION_IS(ONBOARD)
347
+      #define SOFTWARE_SPI
348
+    #endif
336 349
   #else
337 350
 
338 351
     #define LCD_PINS_RS                     PA8
@@ -340,17 +353,17 @@
340 353
     #define BTN_EN1                         PD10
341 354
     #define BTN_EN2                         PH10
342 355
 
343
-    #if DISABLED(CUSTOM_SPI_PINS)
344
-      #define SD_DETECT_PIN                 PB10
345
-      #define LCD_SDSS                      PB12
346
-    #endif
347
-
348 356
     #define LCD_PINS_ENABLE                 PC10
349 357
     #define LCD_PINS_D4                     PG8
350 358
 
351 359
     #if ENABLED(FYSETC_MINI_12864)
352 360
       #define DOGLCD_CS                     PC10
353 361
       #define DOGLCD_A0                     PA8
362
+
363
+      #if SD_CONNECTION_IS(ONBOARD)
364
+        #define SOFTWARE_SPI
365
+      #endif
366
+
354 367
       //#define LCD_BACKLIGHT_PIN           -1
355 368
       #define LCD_RESET_PIN                 PG8   // Must be high or open for LCD to operate normally.
356 369
       #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0)
@@ -389,11 +402,6 @@
389 402
     #endif
390 403
   #endif
391 404
 
392
-  //#define DOGLCD_CS                       PB12
393
-  //#define DOGLCD_A0                       PA8
394
-  //#define LCD_PINS_DC                     PB14
395
-  //#define DOGLCD_MOSI                     PB15
396
-
397 405
 #endif // HAS_SPI_LCD
398 406
 
399 407
 #undef TP

+ 14
- 9
Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h View File

@@ -250,12 +250,22 @@
250 250
 // Onboard SD card
251 251
 // Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2
252 252
 //
253
-#if SD_CONNECTION_IS(ONBOARD)
254
-  #define SOFTWARE_SPI                            // Use soft SPI for onboard SD
253
+#if SD_CONNECTION_IS(LCD)
254
+  #define SD_DETECT_PIN                     PF12
255
+  #define SDSS                              PB12
256
+#elif SD_CONNECTION_IS(ONBOARD)
257
+  // The SKR Pro's ONBOARD SD interface is on SPI1.
258
+  // Due to a pull resistor on the clock line, it needs to use SPI Data Mode 3 to
259
+  // function with Hardware SPI. This is not currently configurable in the HAL,
260
+  // so force Software SPI to work around this issue.
261
+  #define SOFTWARE_SPI
255 262
   #define SDSS                              PA4
256 263
   #define SCK_PIN                           PA5
257 264
   #define MISO_PIN                          PA6
258 265
   #define MOSI_PIN                          PB5
266
+  #define SD_DETECT_PIN                     PB11
267
+#elif SD_CONNECTION_IS(CUSTOM_CABLE)
268
+  #define "CUSTOM_CABLE is not a supported SDCARD_CONNECTION for this board"
259 269
 #endif
260 270
 
261 271
 /**
@@ -275,9 +285,6 @@
275 285
 #if HAS_SPI_LCD
276 286
   #define BEEPER_PIN                        PG4
277 287
   #define BTN_ENC                           PA8
278
-  #if SD_CONNECTION_IS(LCD)
279
-    #define SDSS                            PB12  // Uses default hardware SPI for LCD's SD
280
-  #endif
281 288
 
282 289
   #if ENABLED(CR10_STOCKDISPLAY)
283 290
     #define LCD_PINS_RS                     PG6
@@ -296,16 +303,14 @@
296 303
   #elif ENABLED(MKS_MINI_12864)
297 304
     #define DOGLCD_A0                       PG6
298 305
     #define DOGLCD_CS                       PG3
299
-
306
+    #define BTN_EN1                         PG10
307
+    #define BTN_EN2                         PF11
300 308
   #else
301 309
 
302 310
     #define LCD_PINS_RS                     PD10
303 311
 
304 312
     #define BTN_EN1                         PG10
305 313
     #define BTN_EN2                         PF11
306
-    #define SD_DETECT_PIN                   PF12
307
-
308
-    #define LCD_SDSS                        PB12
309 314
 
310 315
     #define LCD_PINS_ENABLE                 PD11
311 316
     #define LCD_PINS_D4                     PG2

+ 4
- 0
Marlin/src/sd/cardreader.cpp View File

@@ -137,6 +137,10 @@ CardReader::CardReader() {
137 137
   // Disable autostart until card is initialized
138 138
   autostart_index = -1;
139 139
 
140
+  #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
141
+    SET_INPUT_PULLUP(SD_DETECT_PIN);
142
+  #endif
143
+  
140 144
   #if PIN_EXISTS(SDPOWER)
141 145
     OUT_WRITE(SDPOWER_PIN, HIGH); // Power the SD reader
142 146
   #endif

Loading…
Cancel
Save