Skip to content

SPI.begin does not set pinMode of SS as output #1889

Closed
@marcelkottmann

Description

@marcelkottmann

Reading the original arduino documention of SPI.begin (https://www.arduino.cc/en/Reference/SPIBegin) they say that the spi bus is configured setting the pinMode of SS to OUTPUT.
The SPI-implementation of arduino-esp32 doesn't do this.

I understand that this is totally unnecessary in Master-mode, but it introduces a major incompatibility to libs that are relying on that and where the SS pin is not explicitly set as output by the lib.

void SPIClass::begin(int8_t sck, int8_t miso, int8_t mosi, int8_t ss)
{
if(_spi) {
return;
}
if(!_div) {
_div = spiFrequencyToClockDiv(_freq);
}
_spi = spiStartBus(_spi_num, _div, SPI_MODE0, SPI_MSBFIRST);
if(!_spi) {
return;
}
if(sck == -1 && miso == -1 && mosi == -1 && ss == -1) {
_sck = (_spi_num == VSPI) ? SCK : 14;
_miso = (_spi_num == VSPI) ? MISO : 12;
_mosi = (_spi_num == VSPI) ? MOSI : 13;
_ss = (_spi_num == VSPI) ? SS : 15;
} else {
_sck = sck;
_miso = miso;
_mosi = mosi;
_ss = ss;
}
spiAttachSCK(_spi, _sck);
spiAttachMISO(_spi, _miso);
spiAttachMOSI(_spi, _mosi);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: StaleIssue is stale stage (outdated/stuck)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions