feat(spi): Add return values to SPI begin (#11477)
This commit is contained in:
parent
4bc5ffc88d
commit
6d4886cd1f
3 changed files with 8 additions and 7 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ private:
|
|||
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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue