mirror of
https://github.com/esphome/esphome.git
synced 2025-09-27 23:52:28 +01:00
Initial Support for RP2040 platform (#3284)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
@@ -46,9 +46,7 @@ async def to_code(config):
|
||||
mosi = await cg.gpio_pin_expression(config[CONF_MOSI_PIN])
|
||||
cg.add(var.set_mosi(mosi))
|
||||
|
||||
if CORE.is_esp32 and CORE.using_arduino:
|
||||
cg.add_library("SPI", None)
|
||||
if CORE.is_esp8266:
|
||||
if CORE.using_arduino:
|
||||
cg.add_library("SPI", None)
|
||||
|
||||
|
||||
|
@@ -105,7 +105,11 @@ class SPIComponent : public Component {
|
||||
void write_byte(uint8_t data) {
|
||||
#ifdef USE_SPI_ARDUINO_BACKEND
|
||||
if (this->hw_spi_ != nullptr) {
|
||||
#ifdef USE_RP2040
|
||||
this->hw_spi_->transfer(data);
|
||||
#else
|
||||
this->hw_spi_->write(data);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#endif // USE_SPI_ARDUINO_BACKEND
|
||||
@@ -116,7 +120,11 @@ class SPIComponent : public Component {
|
||||
void write_byte16(const uint16_t data) {
|
||||
#ifdef USE_SPI_ARDUINO_BACKEND
|
||||
if (this->hw_spi_ != nullptr) {
|
||||
#ifdef USE_RP2040
|
||||
this->hw_spi_->transfer16(data);
|
||||
#else
|
||||
this->hw_spi_->write16(data);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#endif // USE_SPI_ARDUINO_BACKEND
|
||||
@@ -130,7 +138,11 @@ class SPIComponent : public Component {
|
||||
#ifdef USE_SPI_ARDUINO_BACKEND
|
||||
if (this->hw_spi_ != nullptr) {
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
#ifdef USE_RP2040
|
||||
this->hw_spi_->transfer16(data[i]);
|
||||
#else
|
||||
this->hw_spi_->write16(data[i]);
|
||||
#endif
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -145,7 +157,11 @@ class SPIComponent : public Component {
|
||||
#ifdef USE_SPI_ARDUINO_BACKEND
|
||||
if (this->hw_spi_ != nullptr) {
|
||||
auto *data_c = const_cast<uint8_t *>(data);
|
||||
#ifdef USE_RP2040
|
||||
this->hw_spi_->transfer(data_c, length);
|
||||
#else
|
||||
this->hw_spi_->writeBytes(data_c, length);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#endif // USE_SPI_ARDUINO_BACKEND
|
||||
@@ -178,7 +194,11 @@ class SPIComponent : public Component {
|
||||
if (this->miso_ != nullptr) {
|
||||
this->hw_spi_->transfer(data, length);
|
||||
} else {
|
||||
#ifdef USE_RP2040
|
||||
this->hw_spi_->transfer(data, length);
|
||||
#else
|
||||
this->hw_spi_->writeBytes(data, length);
|
||||
#endif
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user