X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Favr%2Fao_spi_slave.c;h=3504739d683d35b9c2e4334917f22be875b61d34;hb=b1f1a4513391aa595eb64552f2aa4cfedd0cc0ff;hp=b742d29aa6de10b73bb6d1ce8e60f756c0d7fc3f;hpb=47c2c0b79dc516d2566ae149605b7d70ef2dca98;p=fw%2Faltos diff --git a/src/avr/ao_spi_slave.c b/src/avr/ao_spi_slave.c index b742d29a..3504739d 100644 --- a/src/avr/ao_spi_slave.c +++ b/src/avr/ao_spi_slave.c @@ -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 @@ -18,22 +19,24 @@ #include "ao.h" uint8_t -ao_spi_slave_recv(uint8_t *buf, uint8_t len) +ao_spi_slave_recv(void *buf, uint16_t len) { + uint8_t *b = buf; while (len--) { while (!(SPSR & (1 << SPIF))) if ((PINB & (1 << PINB0))) return 0; - *buf++ = SPDR; + *b++ = SPDR; } return 1; } void -ao_spi_slave_send(uint8_t *buf, uint8_t len) +ao_spi_slave_send(void *buf, uint16_t len) { + uint8_t *b = buf; while (len--) { - SPDR = *buf++; + SPDR = *b++; while (!(SPSR & (1 << SPIF))) if ((PINB & (1 << PINB0))) return; @@ -44,9 +47,8 @@ ao_spi_slave_send(uint8_t *buf, uint8_t len) static uint8_t ao_spi_slave_running; -ISR(PCINT0_vect) +ISR(PCINT0_vect, ISR_BLOCK) { - cli(); #if SPI_SLAVE_PIN_0_3 if ((PINB & (1 << PORTB0)) == 0) #endif @@ -61,7 +63,6 @@ ISR(PCINT0_vect) } else { ao_spi_slave_running = 0; } - sei(); } void