doc: Add 1.9 release notes
[fw/altos] / src / avr / ao_spi_usart.c
index 6ed708ff38faf9d09e3eb44ff13ee33aea3bc5ee..6c30b025f5935c5b69ac633aceb4f888f5c76998 100644 (file)
@@ -3,7 +3,8 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -21,7 +22,7 @@
  * Atmega32u4 USART in MSPIM (master SPI mode)
  */
 
-__xdata uint8_t        ao_spi_mutex;
+uint8_t        ao_spi_mutex;
 
 /* Send bytes over SPI.
  *
@@ -29,39 +30,37 @@ __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 *block, uint16_t len) 
 {
        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
+ao_spi_recv_bus(void *block, uint16_t len) 
 {
        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);
 }
 
 /*