Use HW SPI for rp2040 (#4955)

This commit is contained in:
Jesse Hills 2023-06-19 07:24:44 +12:00 committed by GitHub
parent e1b0d86098
commit d4099d68a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -87,6 +87,30 @@ void SPIComponent::setup() {
return; return;
} }
#endif // USE_ESP32 #endif // USE_ESP32
#ifdef USE_RP2040
static uint8_t spi_bus_num = 0;
if (spi_bus_num >= 2) {
use_hw_spi = false;
}
if (use_hw_spi) {
SPIClassRP2040 *spi;
if (spi_bus_num == 0) {
spi = &SPI;
} else {
spi = &SPI1;
}
spi_bus_num++;
if (miso_pin != -1)
spi->setRX(miso_pin);
if (mosi_pin != -1)
spi->setTX(mosi_pin);
spi->setSCK(clk_pin);
this->hw_spi_ = spi;
this->hw_spi_->begin();
return;
}
#endif // USE_RP2040
#endif // USE_SPI_ARDUINO_BACKEND #endif // USE_SPI_ARDUINO_BACKEND
if (this->miso_ != nullptr) { if (this->miso_ != nullptr) {