diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2018-06-27 11:36:27 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2018-06-27 12:10:25 -0400 |
commit | 7aec52dfb3743850935d1080e045339c4a766231 (patch) | |
tree | dc20a2be7befe827db94402f1d4a043080627ade /src/avr | |
parent | d6518515679b939d1fd5c4af490c4ff9e75f88a9 (diff) | |
download | kutter-7aec52dfb3743850935d1080e045339c4a766231.tar.gz kutter-7aec52dfb3743850935d1080e045339c4a766231.tar.xz kutter-7aec52dfb3743850935d1080e045339c4a766231.zip |
avr: Don't set SS high on spi_init()
The AVR requires that the SS pin be an output pin for correct SPI
operation. Some boards use the SS pin to control devices separate
from SPI, however. Don't change the output level if the pin is
already an output, and prefer setting it low if it is not already an
output pin.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/avr')
-rw-r--r-- | src/avr/gpio.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/avr/gpio.c b/src/avr/gpio.c index ce89b1be..a6b7aa41 100644 --- a/src/avr/gpio.c +++ b/src/avr/gpio.c @@ -371,7 +371,9 @@ static const uint8_t MOSI = GPIO('B', 2), MISO = GPIO('B', 3); static void spi_init(void) { - gpio_out_setup(SS, 1); + if (!(GPIO2REGS(SS)->mode & GPIO2BIT(SS))) + // The SS pin must be an output pin (but is otherwise unused) + gpio_out_setup(SS, 0); gpio_out_setup(SCK, 0); gpio_out_setup(MOSI, 0); gpio_in_setup(MISO, 0); |