|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//------------------------------------------------------------------------------
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
#ifdef SPI_HAS_TRANSACTION
|
|
|
|
|
|
static uint8_t chip_select_asserted = 0;
|
|
|
|
|
|
#endif
|
|
|
void Sd2Card::chipSelectHigh(void) {
|
|
|
void Sd2Card::chipSelectHigh(void) {
|
|
|
digitalWrite(chipSelectPin_, HIGH);
|
|
|
digitalWrite(chipSelectPin_, HIGH);
|
|
|
#ifdef SPI_HAS_TRANSACTION
|
|
|
#ifdef SPI_HAS_TRANSACTION
|
|
|
SPI.endTransaction();
|
|
|
|
|
|
|
|
|
if (chip_select_asserted) {
|
|
|
|
|
|
chip_select_asserted = 0;
|
|
|
|
|
|
SPI.endTransaction();
|
|
|
|
|
|
}
|
|
|
#endif
|
|
|
#endif
|
|
|
}
|
|
|
}
|
|
|
//------------------------------------------------------------------------------
|
|
|
//------------------------------------------------------------------------------
|
|
|
void Sd2Card::chipSelectLow(void) {
|
|
|
void Sd2Card::chipSelectLow(void) {
|
|
|
#ifdef SPI_HAS_TRANSACTION
|
|
|
#ifdef SPI_HAS_TRANSACTION
|
|
|
SPI.beginTransaction(settings);
|
|
|
|
|
|
|
|
|
if (!chip_select_asserted) {
|
|
|
|
|
|
chip_select_asserted = 1;
|
|
|
|
|
|
SPI.beginTransaction(settings);
|
|
|
|
|
|
}
|
|
|
#endif
|
|
|
#endif
|
|
|
digitalWrite(chipSelectPin_, LOW);
|
|
|
digitalWrite(chipSelectPin_, LOW);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
uint16_t t0 = (uint16_t)millis();
|
|
|
uint16_t t0 = (uint16_t)millis();
|
|
|
uint32_t arg;
|
|
|
uint32_t arg;
|
|
|
|
|
|
|
|
|
|
|
|
digitalWrite(chipSelectPin_, HIGH);
|
|
|
pinMode(chipSelectPin_, OUTPUT);
|
|
|
pinMode(chipSelectPin_, OUTPUT);
|
|
|
digitalWrite(chipSelectPin_, HIGH);
|
|
|
digitalWrite(chipSelectPin_, HIGH);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spiInit(6);
|
|
|
spiInit(6);
|
|
|
#else
|
|
|
#else
|
|
|
// set pin modes
|
|
|
// set pin modes
|
|
|
pinMode(chipSelectPin_, OUTPUT);
|
|
|
|
|
|
chipSelectHigh();
|
|
|
|
|
|
pinMode(SPI_MISO_PIN, INPUT);
|
|
|
pinMode(SPI_MISO_PIN, INPUT);
|
|
|
pinMode(SPI_MOSI_PIN, OUTPUT);
|
|
|
pinMode(SPI_MOSI_PIN, OUTPUT);
|
|
|
pinMode(SPI_SCK_PIN, OUTPUT);
|
|
|
pinMode(SPI_SCK_PIN, OUTPUT);
|