X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fao_companion.c;h=b424dd896078c468e09759311546181647771ac8;hb=aa642cf55c43188e9a21198d828d7ea90ff54280;hp=8db3273eaea126cce802ee0f11bdef5b61216e83;hpb=30abbdc7ffcfc809b4a3fc31486fe968161ea225;p=fw%2Faltos diff --git a/src/ao_companion.c b/src/ao_companion.c index 8db3273e..b424dd89 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; @@ -69,11 +79,21 @@ ao_companion(void) ao_delay(ao_companion_setup.update_period); ao_companion_get_data(); } + ao_exit(); } void ao_companion_status(void) __reentrant { + uint8_t i; + printf("Companion running: %d\n", ao_companion_running); + printf("device: %d\n", ao_companion_setup.board_id); + printf("update period: %d\n", ao_companion_setup.update_period); + printf("channels: %d\n", ao_companion_setup.channels); + printf("data:"); + for(i = 0; i < ao_companion_setup.channels; i++) + printf(" %5u", ao_companion_data[i]); + printf("\n"); } __code struct ao_cmds ao_companion_cmds[] = { @@ -91,6 +111,5 @@ ao_companion_init(void) COMPANION_CS_SEL &= ~COMPANION_CS_MASK; /* set CS pins as GPIO */ ao_cmd_register(&ao_companion_cmds[0]); - ao_add_task(&ao_companion_task, ao_companion, "companion"); }