Switch to TMC2130 compatible hardware SPI & misc (#10299)

This commit is contained in:
Bob-the-Kuhn
2018-04-04 20:13:27 -05:00
committed by Scott Lahteine
parent 1c36606886
commit 902c885782
5 changed files with 67 additions and 58 deletions

View File

@ -249,15 +249,16 @@ bool Sd2Card::init(uint8_t sckRateID, pin_t chipSelectPin) {
watchdog_reset();
#endif
// set pin modes
pinMode(chipSelectPin_, OUTPUT); // Solution for #8746 by @benlye
// Set pin modes
digitalWrite(chipSelectPin_, HIGH); // For some CPUs pinMode can write the wrong data so init desired data value first
pinMode(chipSelectPin_, OUTPUT); // Solution for #8746 by @benlye
spiBegin();
// set SCK rate for initialization commands
// Set SCK rate for initialization commands
spiRate_ = SPI_SD_INIT_RATE;
spiInit(spiRate_);
// must supply min of 74 clock cycles with CS high.
// Must supply min of 74 clock cycles with CS high.
for (uint8_t i = 0; i < 10; i++) spiSend(0xFF);
// Initialization can cause the watchdog to timeout, so reinit it here
@ -265,7 +266,7 @@ bool Sd2Card::init(uint8_t sckRateID, pin_t chipSelectPin) {
watchdog_reset();
#endif
// command to go idle in SPI mode
// Command to go idle in SPI mode
while ((status_ = cardCommand(CMD0, 0)) != R1_IDLE_STATE) {
if (((uint16_t)millis() - t0) > SD_INIT_TIMEOUT) {
error(SD_CARD_ERROR_CMD0);