소스 검색

Fix ESP8266 SPI divisor calculation

main
Bill Greiman 8 년 전
부모
커밋
6ac05353a6
2개의 변경된 파일6개의 추가작업 그리고 6개의 파일을 삭제
  1. +2
    -3
      SdFat/src/SdSpiCard/SdSpi.h
  2. +4
    -3
      SdFat/src/SdSpiCard/SdSpiESP8266.cpp

+ 2
- 3
SdFat/src/SdSpiCard/SdSpi.h 파일 보기

*/ */
void beginTransaction(uint8_t divisor) { void beginTransaction(uint8_t divisor) {
#if ENABLE_SPI_TRANSACTIONS #if ENABLE_SPI_TRANSACTIONS
SPISettings settings(F_CPU/(divisor ? divisor : 1), MSBFIRST, SPI_MODE0);
SPI.beginTransaction(settings);
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
#else // ENABLE_SPI_TRANSACTIONS #else // ENABLE_SPI_TRANSACTIONS
SPI.setBitOrder(MSBFIRST); SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0); SPI.setDataMode(SPI_MODE0);
#endif // ENABLE_SPI_TRANSACTIONS
#ifndef SPI_CLOCK_DIV128 #ifndef SPI_CLOCK_DIV128
SPI.setClockDivider(divisor); SPI.setClockDivider(divisor);
#else // SPI_CLOCK_DIV128 #else // SPI_CLOCK_DIV128
} }
SPI.setClockDivider(v); SPI.setClockDivider(v);
#endif // SPI_CLOCK_DIV128 #endif // SPI_CLOCK_DIV128
#endif // ENABLE_SPI_TRANSACTIONS
} }
/** /**
* End SPI transaction. * End SPI transaction.

+ 4
- 3
SdFat/src/SdSpiCard/SdSpiESP8266.cpp 파일 보기

//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** 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

Loading…
취소
저장