Fix 8266 SPI Clock Polarity Setting (#2836)

This commit is contained in:
Keith Burzinski 2021-11-30 00:30:45 -06:00 committed by GitHub
parent 939fb313df
commit 556d071e7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -195,7 +195,14 @@ class SPIComponent : public Component {
void enable(GPIOPin *cs) {
#ifdef USE_SPI_ARDUINO_BACKEND
if (this->hw_spi_ != nullptr) {
uint8_t data_mode = (uint8_t(CLOCK_POLARITY) << 1) | uint8_t(CLOCK_PHASE);
uint8_t data_mode = SPI_MODE0;
if (!CLOCK_POLARITY && CLOCK_PHASE) {
data_mode = SPI_MODE1;
} else if (CLOCK_POLARITY && !CLOCK_PHASE) {
data_mode = SPI_MODE2;
} else if (CLOCK_POLARITY && CLOCK_PHASE) {
data_mode = SPI_MODE3;
}
SPISettings settings(DATA_RATE, BIT_ORDER, data_mode);
this->hw_spi_->beginTransaction(settings);
} else {