mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 01:07:45 +01:00
Fix 8266 SPI Clock Polarity Setting (#2836)
This commit is contained in:
parent
939fb313df
commit
556d071e7f
1 changed files with 8 additions and 1 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue