File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
hardware/arduino/avr/libraries/SPI Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,15 @@ void SPIClass::begin()
2929 noInterrupts (); // Protect from a scheduler and prevent transactionBegin
3030 if (!initialized) {
3131 // Set SS to high so a connected chip will be "deselected" by default
32- digitalWrite (SS, HIGH);
32+ uint8_t port = digitalPinToPort (SS);
33+ uint8_t bit = digitalPinToBitMask (SS);
34+ volatile uint8_t *reg = portModeRegister (port);
35+
36+ // if the SS pin is not already configured as an output
37+ // then set it high (to enable the internal pull-up resistor)
38+ if (!(*reg & bit)){
39+ digitalWrite (SS, HIGH);
40+ }
3341
3442 // When the SS pin is set as OUTPUT, it can be used as
3543 // a general purpose output port (it doesn't influence
You can’t perform that action at this time.
0 commit comments