Skip to content

Commit

Permalink
🎨 Pins and SDIO cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Dec 26, 2021
1 parent 7762df7 commit 56ac681
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 161 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

#if ENABLED(SDIO_SUPPORT)

#include "sdio.h"

#include <stdint.h>
#include <stdbool.h>

Expand All @@ -49,14 +51,6 @@
#error "SDIO only supported with STM32F103xE, STM32F103xG, STM32F4xx, or STM32F7xx."
#endif

// Fixed
#define SDIO_D0_PIN PC8
#define SDIO_D1_PIN PC9
#define SDIO_D2_PIN PC10
#define SDIO_D3_PIN PC11
#define SDIO_CK_PIN PC12
#define SDIO_CMD_PIN PD2

SD_HandleTypeDef hsd; // create SDIO structure
// F4 supports one DMA for RX and another for TX, but Marlin will never
// do read and write at same time, so we use the same DMA for both.
Expand Down
29 changes: 29 additions & 0 deletions Marlin/src/HAL/STM32/sdio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once

#define SDIO_D0_PIN PC8
#define SDIO_D1_PIN PC9
#define SDIO_D2_PIN PC10
#define SDIO_D3_PIN PC11
#define SDIO_CK_PIN PC12
#define SDIO_CMD_PIN PD2
15 changes: 4 additions & 11 deletions Marlin/src/pins/stm32f4/pins_ANET_ET4.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,12 @@

#if ENABLED(SDSUPPORT)

#define SDIO_D0_PIN PC8
#define SDIO_D1_PIN PC9
#define SDIO_D2_PIN PC10
#define SDIO_D3_PIN PC11
#define SDIO_CK_PIN PC12
#define SDIO_CMD_PIN PD2

#if DISABLED(SDIO_SUPPORT)
#define SOFTWARE_SPI
#define SDSS SDIO_D3_PIN
#define SD_SCK_PIN SDIO_CK_PIN
#define SD_MISO_PIN SDIO_D0_PIN
#define SD_MOSI_PIN SDIO_CMD_PIN
#define SDSS PC11
#define SD_SCK_PIN PC12
#define SD_MISO_PIN PC8
#define SD_MOSI_PIN PD2
#endif

#ifndef SD_DETECT_PIN
Expand Down
18 changes: 5 additions & 13 deletions Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,25 +140,17 @@
//
// Onboard SD support
//
#define SDIO_D0_PIN PC8
#define SDIO_D1_PIN PC9
#define SDIO_D2_PIN PC10
#define SDIO_D3_PIN PC11
#define SDIO_CK_PIN PC12
#define SDIO_CMD_PIN PD2

#ifndef SDCARD_CONNECTION
#define SDCARD_CONNECTION ONBOARD
#endif

#if SD_CONNECTION_IS(ONBOARD)
#define SDIO_SUPPORT // Use SDIO for onboard SD

#ifndef SDIO_SUPPORT
#if DISABLED(SDIO_SUPPORT)
#define SOFTWARE_SPI // Use soft SPI for onboard SD
#define SDSS SDIO_D3_PIN
#define SD_SCK_PIN SDIO_CK_PIN
#define SD_MISO_PIN SDIO_D0_PIN
#define SD_MOSI_PIN SDIO_CMD_PIN
#define SDSS PC11
#define SD_SCK_PIN PC12
#define SD_MISO_PIN PC8
#define SD_MOSI_PIN PD2
#endif
#endif
7 changes: 0 additions & 7 deletions Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,6 @@

#if SD_CONNECTION_IS(ONBOARD)
#define SDIO_SUPPORT // Use SDIO for onboard SD
#define SDIO_D0_PIN PC8
#define SDIO_D1_PIN PC9
#define SDIO_D2_PIN PC10
#define SDIO_D3_PIN PC11
#define SDIO_CK_PIN PC12
#define SDIO_CMD_PIN PD2

//#define SDIO_CLOCK 48000000
#define SD_DETECT_PIN PC4
#elif SD_CONNECTION_IS(CUSTOM_CABLE)
Expand Down
10 changes: 0 additions & 10 deletions Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,24 +365,14 @@
// Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2
//
#if SD_CONNECTION_IS(LCD)

#define SDSS EXP2_07_PIN
#define SD_SS_PIN SDSS
#define SD_SCK_PIN EXP2_09_PIN
#define SD_MISO_PIN EXP2_10_PIN
#define SD_MOSI_PIN EXP2_05_PIN
#define SD_DETECT_PIN EXP2_04_PIN

#elif SD_CONNECTION_IS(ONBOARD)

#define SDIO_SUPPORT // Use SDIO for onboard SD
#define SDIO_D0_PIN PC8
#define SDIO_D1_PIN PC9
#define SDIO_D2_PIN PC10
#define SDIO_D3_PIN PC11
#define SDIO_CK_PIN PC12
#define SDIO_CMD_PIN PD2

#elif SD_CONNECTION_IS(CUSTOM_CABLE)
#error "No custom SD drive cable defined for this board."
#endif
Expand Down
Loading

0 comments on commit 56ac681

Please sign in to comment.