diff options
-rw-r--r-- | src/ao_companion.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/ao_companion.c b/src/ao_companion.c index 8db3273e..556ce044 100644 --- a/src/ao_companion.c +++ b/src/ao_companion.c @@ -17,8 +17,18 @@ #include "ao.h" -#define COMPANION_SELECT() ao_spi_get_bit(COMPANION_CS) -#define COMPANION_DESELECT() ao_spi_put_bit(COMPANION_CS) +#define ao_spi_slow() (U0GCR = (UxGCR_CPOL_NEGATIVE | \ + UxGCR_CPHA_FIRST_EDGE | \ + UxGCR_ORDER_MSB | \ + (13 << UxGCR_BAUD_E_SHIFT))) + +#define ao_spi_fast() (U0GCR = (UxGCR_CPOL_NEGATIVE | \ + UxGCR_CPHA_FIRST_EDGE | \ + 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) static __xdata struct ao_companion_command ao_companion_command; __xdata struct ao_companion_setup ao_companion_setup; |