Skip to content

Commit ab93cbd

Browse files
committed
feat(spi): Add return values to SPI begin
1 parent 7462b09 commit ab93cbd

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

‎cores/esp32/esp32-hal-spi.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ extern "C"{
3838
#defineHSPI 2 //SPI 2 bus normally mapped to pins 12 - 15, but can be matrixed to any pins
3939
#defineVSPI 3 //SPI 3 bus normally attached to pins 5, 18, 19 and 23, but can be matrixed to any pins
4040
#else
41-
#defineFSPI 0
42-
#defineHSPI 1
41+
#defineFSPI 0 // ESP32C2, C3, C6, H2, S3, P4 - SPI 2 bus
42+
#defineHSPI 1 // ESP32S3, P4 - SPI 3 bus
4343
#endif
4444

4545
// This defines are not representing the real Divider of the ESP32

‎libraries/SPI/src/SPI.cpp‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ SPIClass::~SPIClass(){
6363
#endif
6464
}
6565

66-
voidSPIClass::begin(int8_t sck, int8_t miso, int8_t mosi, int8_t ss){
66+
boolSPIClass::begin(int8_t sck, int8_t miso, int8_t mosi, int8_t ss){
6767
if (_spi){
68-
return;
68+
returntrue;
6969
}
7070

7171
if (!_div){
@@ -74,7 +74,7 @@ void SPIClass::begin(int8_t sck, int8_t miso, int8_t mosi, int8_t ss){
7474

7575
_spi = spiStartBus(_spi_num, _div, SPI_MODE0, SPI_MSBFIRST);
7676
if (!_spi){
77-
return;
77+
returnfalse;
7878
}
7979

8080
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){
110110
if (_mosi >= 0 && !spiAttachMOSI(_spi, _mosi)){
111111
goto err;
112112
}
113-
return;
113+
returntrue;
114114

115115
err:
116116
log_e("Attaching pins to SPI failed.");
117+
returnfalse;
117118
}
118119

119120
voidSPIClass::end(){

‎libraries/SPI/src/SPI.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class SPIClass{
6161
public:
6262
SPIClass(uint8_t spi_bus = HSPI);
6363
~SPIClass();
64-
voidbegin(int8_t sck = -1, int8_t miso = -1, int8_t mosi = -1, int8_t ss = -1);
64+
boolbegin(int8_t sck = -1, int8_t miso = -1, int8_t mosi = -1, int8_t ss = -1);
6565
voidend();
6666

6767
voidsetHwCs(bool use);

0 commit comments

Comments
(0)