X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Favr%2Fao_spi_usart.c;h=7c41042a4424026e99b0ea821c618a7b750298fe;hb=bc3610d8cecbfed40c62d4dcb93fc9a4d2a7c9e3;hp=1996fcd9e98a9cee798aaaf3ace662c2b623924a;hpb=06b044629951b06c7ec9b0105b89f51b2880ebd0;p=fw%2Faltos diff --git a/src/avr/ao_spi_usart.c b/src/avr/ao_spi_usart.c index 1996fcd9..7c41042a 100644 --- a/src/avr/ao_spi_usart.c +++ b/src/avr/ao_spi_usart.c @@ -29,7 +29,7 @@ __xdata uint8_t ao_spi_mutex; * so using interrupts would take way too long */ void -ao_spi_send(void __xdata *block, uint16_t len) __reentrant +ao_spi_send_bus(void __xdata *block, uint16_t len) __reentrant { uint8_t *d = block; @@ -43,15 +43,17 @@ ao_spi_send(void __xdata *block, uint16_t len) __reentrant /* Receive bytes over SPI. * - * This sets up tow DMA engines, one reading the data and another - * writing constant values to the SPI transmitter as that is what - * clocks the data coming in. + * Poll, sending zeros and reading data back */ void -ao_spi_recv(void __xdata *block, uint16_t len) __reentrant +ao_spi_recv_bus(void __xdata *block, uint16_t len) __reentrant { uint8_t *d = block; + /* Clear any pending data */ + while (UCSR1A & (1 << RXC1)) + (void) UDR1; + while (len--) { while (!(UCSR1A & (1 << UDRE1))); UDR1 = 0;