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>
This commit is contained in:
parent
d651851567
commit
7aec52dfb3
|
@ -371,7 +371,9 @@ static const uint8_t MOSI = GPIO('B', 2), MISO = GPIO('B', 3);
|
||||||
static void
|
static void
|
||||||
spi_init(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(SCK, 0);
|
||||||
gpio_out_setup(MOSI, 0);
|
gpio_out_setup(MOSI, 0);
|
||||||
gpio_in_setup(MISO, 0);
|
gpio_in_setup(MISO, 0);
|
||||||
|
|
Loading…
Reference in New Issue