From 02474a321afdd691500d0f9da8a97990677e874d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 26 Feb 2018 14:40:40 -0600 Subject: [PATCH] Fix SDSUPPORT (and indentation) Based on https://github.com/MarlinFirmware/Marlin/issues/8746#issuecomment-368471901 by @benlye --- Marlin/src/sd/Sd2Card.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Marlin/src/sd/Sd2Card.cpp b/Marlin/src/sd/Sd2Card.cpp index ff82cdaac8..da831525ef 100644 --- a/Marlin/src/sd/Sd2Card.cpp +++ b/Marlin/src/sd/Sd2Card.cpp @@ -250,7 +250,7 @@ bool Sd2Card::init(uint8_t sckRateID, pin_t chipSelectPin) { #endif // set pin modes -//todo: should use chipSelectPin ? + pinMode(chipSelectPin_, OUTPUT); // Solution for #8746 by @benlye spiBegin(); // set SCK rate for initialization commands @@ -268,18 +268,18 @@ bool Sd2Card::init(uint8_t sckRateID, pin_t chipSelectPin) { } } -#if ENABLED(SD_CHECK_AND_RETRY) - crcSupported = (cardCommand(CMD59, 1) == R1_IDLE_STATE); -#endif + #if ENABLED(SD_CHECK_AND_RETRY) + crcSupported = (cardCommand(CMD59, 1) == R1_IDLE_STATE); + #endif // check SD version - while (1) { + for (;;) { if (cardCommand(CMD8, 0x1AA) == (R1_ILLEGAL_COMMAND | R1_IDLE_STATE)) { - type(SD_CARD_TYPE_SD1); + type(SD_CARD_TYPE_SD1); break; - } + } - // only need last byte of r7 response + // Get the last byte of r7 response for (uint8_t i = 0; i < 4; i++) status_ = spiRec(); if (status_ == 0xAA) { type(SD_CARD_TYPE_SD2);