altos: Wait for companion to see CS before attempting communcation companion-delay
authorKeith Packard <keithp@keithp.com>
Mon, 15 Oct 2012 01:50:45 +0000 (18:50 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 15 Oct 2012 01:50:45 +0000 (18:50 -0700)
The AVR just can't go fast enough to see the CS in time, so pause for
a while.

(rewritten from f9607fb76c22187396cceb46b745fa1485d4f155)

Signed-off-by: Keith Packard <keithp@keithp.com>
src/drivers/ao_companion.c

index c749adea9de2f2da295bf2aa64f28c9642ed1103..2ed407f1d9b216ea4fa6ed34e9eaa82ead4d3cbe 100644 (file)
 #endif
 
 #define COMPANION_SELECT()     do {                    \
+               uint8_t pause;                          \
                ao_spi_get_bit(AO_COMPANION_CS_PORT,    \
                               AO_COMPANION_CS_PIN,     \
                               AO_COMPANION_CS,         \
                               AO_COMPANION_SPI_BUS,    \
                               AO_SPI_SPEED_200kHz);    \
+               for (pause = 0; pause < 100; pause++)   \
+                       ao_arch_nop();                  \
        } while (0)
 
 #define COMPANION_DESELECT()   do {                    \