|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------ |
|
|
//------------------------------------------------------------------------------ |
|
|
/** Set SPI options for access to SD/SDHC cards. |
|
|
/** Set SPI options for access to SD/SDHC cards. |
|
|
* |
|
|
* |
|
|
* \param[in] divisor SCK clock divider relative to the system clock. |
|
|
|
|
|
|
|
|
* \param[in] divisor SCK clock divider relative to the max SPI clock. |
|
|
*/ |
|
|
*/ |
|
|
void SdSpi::beginTransaction(uint8_t divisor) { |
|
|
void SdSpi::beginTransaction(uint8_t divisor) { |
|
|
|
|
|
const uint32_t F_SPI_MAX = 80000000; |
|
|
#if ENABLE_SPI_TRANSACTIONS |
|
|
#if ENABLE_SPI_TRANSACTIONS |
|
|
// Note: ESP8266 beginTransaction does not protect for interrupts. |
|
|
// Note: ESP8266 beginTransaction does not protect for interrupts. |
|
|
SPISettings settings(F_CPU/(divisor ? divisor : 1), MSBFIRST, SPI_MODE0); |
|
|
|
|
|
|
|
|
SPISettings settings(F_SPI_MAX/(divisor ? divisor : 1), MSBFIRST, SPI_MODE0); |
|
|
SPI.beginTransaction(settings); |
|
|
SPI.beginTransaction(settings); |
|
|
#else // ENABLE_SPI_TRANSACTIONS |
|
|
#else // ENABLE_SPI_TRANSACTIONS |
|
|
// Note: ESP8266 beginTransaction is the same as following code. |
|
|
// Note: ESP8266 beginTransaction is the same as following code. |
|
|
SPI.setFrequency(F_CPU/(divisor ? divisor : 1)); |
|
|
|
|
|
|
|
|
SPI.setFrequency(F_SPI_MAX/(divisor ? divisor : 1)); |
|
|
SPI.setBitOrder(MSBFIRST); |
|
|
SPI.setBitOrder(MSBFIRST); |
|
|
SPI.setDataMode(SPI_MODE0); |
|
|
SPI.setDataMode(SPI_MODE0); |
|
|
#endif // ENABLE_SPI_TRANSACTIONS |
|
|
#endif // ENABLE_SPI_TRANSACTIONS |