From f1e8cc2cf091fe6a3c857d802a3d5d391c1d4886 Mon Sep 17 00:00:00 2001 From: Ignacio Hernandez-Ros Date: Wed, 14 Sep 2022 06:53:51 +0200 Subject: [PATCH] fix spi timing issues (#3763) --- esphome/components/spi/spi.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/esphome/components/spi/spi.h b/esphome/components/spi/spi.h index 7f0b0f481a..6c92321ac8 100644 --- a/esphome/components/spi/spi.h +++ b/esphome/components/spi/spi.h @@ -195,6 +195,11 @@ class SPIComponent : public Component { template void enable(GPIOPin *cs) { + if (cs != nullptr) { + this->active_cs_ = cs; + this->active_cs_->digital_write(false); + } + #ifdef USE_SPI_ARDUINO_BACKEND if (this->hw_spi_ != nullptr) { uint8_t data_mode = SPI_MODE0; @@ -215,11 +220,6 @@ class SPIComponent : public Component { #ifdef USE_SPI_ARDUINO_BACKEND } #endif // USE_SPI_ARDUINO_BACKEND - - if (cs != nullptr) { - this->active_cs_ = cs; - this->active_cs_->digital_write(false); - } } void disable();