arduino / arduino/ArduinoCore-avr
Pins left as output mode after SPI.end()
- Dominant language
- C
- Stars
- 1.5k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
SCK, MOSI, and SS are left as output after calling SPI.end().
If SS is in input mode before calling SPI.begin(), it is left as output high.
The comments in SPI.cpp seem to imply the intention was to enable the pullup if the pin wasn't already set to output mode, but then goes on to set it to output (from line 36):
``` C
// if the SS pin is not already configured as an output
// then set it high (to enable the internal pull-up resistor)
if(!(*reg & bit)){
digitalWrite(SS, HIGH);
}
// When the SS pin is set as OUTPUT, it can be used as
// a general purpose output port (it doesn't influence
// SPI operations).
pinMode(SS, OUTPUT);
```
The docs imply that the user code should set the SS pin to output,
https://www.arduino.cc/en/Reference/SPI
If saving and restoring the port state is too complicated, then SPI.end should set the pins to reset state (input low). I also think controlling SS should be left to the user code, so just delete code in SPI.begin() that manipulates SS.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.