diff --git a/esphome/components/spi/spi.h b/esphome/components/spi/spi.h index 6c3fd17e56..7f0b0f481a 100644 --- a/esphome/components/spi/spi.h +++ b/esphome/components/spi/spi.h @@ -156,15 +156,17 @@ class SPIComponent : public Component { template uint8_t transfer_byte(uint8_t data) { -#ifdef USE_SPI_ARDUINO_BACKEND if (this->miso_ != nullptr) { +#ifdef USE_SPI_ARDUINO_BACKEND if (this->hw_spi_ != nullptr) { return this->hw_spi_->transfer(data); } else { - return this->transfer_(data); - } - } #endif // USE_SPI_ARDUINO_BACKEND + return this->transfer_(data); +#ifdef USE_SPI_ARDUINO_BACKEND + } +#endif // USE_SPI_ARDUINO_BACKEND + } this->write_byte(data); return 0; }