]> git.gag.com Git - fw/altos/commitdiff
altos: Wait for companion to see CS before attempting communcation
authorKeith Packard <keithp@keithp.com>
Sun, 27 May 2012 05:12:07 +0000 (23:12 -0600)
committerKeith Packard <keithp@keithp.com>
Wed, 11 Jul 2012 07:38:47 +0000 (00:38 -0700)
The AVR just can't go fast enough to see the CS in time, so pause for
a while

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

index ab73b11d1b0b003fdfc6540284440dfd7a5bafbd..14237d99056bee5e65cebc846f2d497ba522181c 100644 (file)
@@ -18,7 +18,7 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.57)
-AC_INIT([altos], 1.0.3)
+AC_INIT([altos], 1.0.4)
 AC_CONFIG_SRCDIR([src/ao.h])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE
index 4c8f4269588769054a541535b5e939934f82aac7..e14782490ef1ed172475e30da84341bba93144bb 100644 (file)
                                UxGCR_ORDER_MSB |               \
                                (17 << UxGCR_BAUD_E_SHIFT)))
 
-#define COMPANION_SELECT()     do { ao_spi_get_bit(COMPANION_CS); ao_spi_slow(); } while (0)
-#define COMPANION_DESELECT()   do { ao_spi_fast(); ao_spi_put_bit(COMPANION_CS); } while (0)
+#define nop() _asm nop _endasm
+
+#define COMPANION_SELECT()     do {                    \
+               uint8_t pause;                          \
+               ao_spi_get_bit(COMPANION_CS);           \
+               ao_spi_slow();                          \
+               for (pause = 0; pause < 8; pause++)     \
+                       nop();                          \
+       } while (0)
+
+#define COMPANION_DESELECT()   do {            \
+               ao_spi_fast();                  \
+               ao_spi_put_bit(COMPANION_CS);   \
+       } while (0)
 
 static __xdata struct ao_companion_command     ao_companion_command;
 __xdata struct ao_companion_setup              ao_companion_setup;