mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 12:51:11 +00:00
[spi] Enable host-platform builds for unit testing (#15188)
This commit is contained in:
@@ -68,7 +68,7 @@ void SPIComponent::dump_config() {
|
||||
LOG_PIN(" SDI Pin: ", this->sdi_pin_);
|
||||
LOG_PIN(" SDO Pin: ", this->sdo_pin_);
|
||||
for (size_t i = 0; i != this->data_pins_.size(); i++) {
|
||||
ESP_LOGCONFIG(TAG, " Data pin %u: GPIO%d", i, this->data_pins_[i]);
|
||||
ESP_LOGCONFIG(TAG, " Data pin %zu: GPIO%d", i, this->data_pins_[i]);
|
||||
}
|
||||
if (this->spi_bus_->is_hw()) {
|
||||
ESP_LOGCONFIG(TAG, " Using HW SPI: %s", this->interface_name_);
|
||||
@@ -118,4 +118,12 @@ uint16_t SPIDelegateBitBash::transfer_(uint16_t data, size_t num_bits) {
|
||||
return out_data;
|
||||
}
|
||||
|
||||
#if !defined(USE_ESP32) && !defined(USE_ARDUINO)
|
||||
// Stub for unsupported platforms (host, Zephyr, etc.) - hardware SPI is unavailable
|
||||
SPIBus *SPIComponent::get_bus(SPIInterface interface, GPIOPin *clk, GPIOPin *sdo, GPIOPin *sdi,
|
||||
const std::vector<uint8_t> &data_pins) {
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace esphome::spi
|
||||
|
||||
@@ -23,9 +23,9 @@ using SPIInterface = SPIClassRP2040 *;
|
||||
using SPIInterface = SPIClass *;
|
||||
#endif
|
||||
|
||||
#elif defined(CLANG_TIDY)
|
||||
#elif defined(USE_HOST) || defined(CLANG_TIDY)
|
||||
|
||||
using SPIInterface = void *; // Stub for platforms without SPI (e.g., Zephyr)
|
||||
using SPIInterface = void *; // Stub for platforms without SPI (e.g., host, Zephyr)
|
||||
|
||||
#endif // USE_ESP32 / USE_ARDUINO
|
||||
|
||||
|
||||
Reference in New Issue
Block a user