X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Favr%2Fao_spi_usart.c;h=5ea11da6a093527a6ae96cb4caa0f8cd5ccdcaed;hp=6ed708ff38faf9d09e3eb44ff13ee33aea3bc5ee;hb=refs%2Ftags%2F1.0.9.3;hpb=f6f54d70b768dca1715ddddea64a4df00d82b09e diff --git a/src/avr/ao_spi_usart.c b/src/avr/ao_spi_usart.c index 6ed708ff..5ea11da6 100644 --- a/src/avr/ao_spi_usart.c +++ b/src/avr/ao_spi_usart.c @@ -33,35 +33,33 @@ ao_spi_send(void __xdata *block, uint16_t len) __reentrant { uint8_t *d = block; - ao_mutex_get(&ao_spi_mutex); while (len--) { while (!(UCSR1A & (1 << UDRE1))); UDR1 = *d++; while (!(UCSR1A & (1 << RXC1))); (void) UDR1; } - ao_mutex_put(&ao_spi_mutex); } /* 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 { uint8_t *d = block; - ao_mutex_get(&ao_spi_mutex); + /* Clear any pending data */ + while (UCSR1A & (1 << RXC1)) + (void) UDR1; + while (len--) { while (!(UCSR1A & (1 << UDRE1))); UDR1 = 0; while (!(UCSR1A & (1 << RXC1))); *d++ = UDR1; } - ao_mutex_put(&ao_spi_mutex); } /*