diff --git a/cores/esp32/esp32-hal-spi.h b/cores/esp32/esp32-hal-spi.h index 7d56f0820d3..565ca43f60d 100644 --- a/cores/esp32/esp32-hal-spi.h +++ b/cores/esp32/esp32-hal-spi.h @@ -38,8 +38,8 @@ extern "C" { #define HSPI 2 //SPI 2 bus normally mapped to pins 12 - 15, but can be matrixed to any pins #define VSPI 3 //SPI 3 bus normally attached to pins 5, 18, 19 and 23, but can be matrixed to any pins #else -#define FSPI 0 -#define HSPI 1 +#define FSPI 0 // ESP32C2, C3, C6, H2, S3, P4 - SPI 2 bus +#define HSPI 1 // ESP32S3, P4 - SPI 3 bus #endif // This defines are not representing the real Divider of the ESP32 diff --git a/libraries/SPI/src/SPI.cpp b/libraries/SPI/src/SPI.cpp index ae207a7ff3c..c0d7665df03 100644 --- a/libraries/SPI/src/SPI.cpp +++ b/libraries/SPI/src/SPI.cpp @@ -63,9 +63,9 @@ SPIClass::~SPIClass() { #endif } -void SPIClass::begin(int8_t sck, int8_t miso, int8_t mosi, int8_t ss) { +bool SPIClass::begin(int8_t sck, int8_t miso, int8_t mosi, int8_t ss) { if (_spi) { - return; + return true; } if (!_div) { @@ -74,7 +74,7 @@ void SPIClass::begin(int8_t sck, int8_t miso, int8_t mosi, int8_t ss) { _spi = spiStartBus(_spi_num, _div, SPI_MODE0, SPI_MSBFIRST); if (!_spi) { - return; + return false; } if (sck == -1 && miso == -1 && mosi == -1 && ss == -1) { @@ -110,10 +110,11 @@ void SPIClass::begin(int8_t sck, int8_t miso, int8_t mosi, int8_t ss) { if (_mosi >= 0 && !spiAttachMOSI(_spi, _mosi)) { goto err; } - return; + return true; err: log_e("Attaching pins to SPI failed."); + return false; } void SPIClass::end() { diff --git a/libraries/SPI/src/SPI.h b/libraries/SPI/src/SPI.h index 628c2190f50..6c300e53df2 100644 --- a/libraries/SPI/src/SPI.h +++ b/libraries/SPI/src/SPI.h @@ -61,7 +61,7 @@ class SPIClass { public: SPIClass(uint8_t spi_bus = HSPI); ~SPIClass(); - void begin(int8_t sck = -1, int8_t miso = -1, int8_t mosi = -1, int8_t ss = -1); + bool begin(int8_t sck = -1, int8_t miso = -1, int8_t mosi = -1, int8_t ss = -1); void end(); void setHwCs(bool use);