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()
29
29
noInterrupts (); // Protect from a scheduler and prevent transactionBegin
30
30
if (!initialized) {
31
31
// 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
+ }
33
41
34
42
// When the SS pin is set as OUTPUT, it can be used as
35
43
// a general purpose output port (it doesn't influence
You can’t perform that action at this time.
0 commit comments