From: Keith Packard Date: Sun, 27 May 2012 05:12:07 +0000 (-0600) Subject: altos: Wait for companion to see CS before attempting communcation X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=f9607fb76c22187396cceb46b745fa1485d4f155;p=fw%2Faltos altos: Wait for companion to see CS before attempting communcation The AVR just can't go fast enough to see the CS in time, so pause for a while Signed-off-by: Keith Packard --- diff --git a/configure.ac b/configure.ac index ab73b11d..14237d99 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/src/ao_companion.c b/src/ao_companion.c index 4c8f4269..e1478249 100644 --- a/src/ao_companion.c +++ b/src/ao_companion.c @@ -27,8 +27,20 @@ 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;