diff options
Diffstat (limited to 'software/hhd70dongle/spi.c')
-rw-r--r-- | software/hhd70dongle/spi.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/software/hhd70dongle/spi.c b/software/hhd70dongle/spi.c index 618c581..ab5d5b2 100644 --- a/software/hhd70dongle/spi.c +++ b/software/hhd70dongle/spi.c @@ -69,25 +69,23 @@ void spi_write(char* data, unsigned int len) //enable SS of CC1101 PORTB |= (1<<CS); - for (unsigned int c=0; c++; c<len) - spi_write_byte(data[c]) + for (unsigned int c=0; c<len; c++) + spi_write_byte(data[c]); //disable SS of CC1101 PORTB &= ~(1<<CS); } -void spi_read(unsigned int maxlen, char* data) +void spi_read(unsigned int maxlen, char *data, unsigned int *len) { PORTB |= (1<<CS); while(SPI_PINB_REG & (1<<MISO)); /* wait for CC1101 to get ready... */ SPDR = 0x80; - unsigned int len = 0; - while(len < maxlen && !(SPSR & (1<<SPIF))) - { - data[len++]=SPSR - } + len = 0; + while(*len < maxlen && !(SPSR & (1<<SPIF))) + data[*len++]=SPSR; PORTB &= ~(1<<CS); } |