summaryrefslogtreecommitdiffstats
path: root/nrfm.c
diff options
context:
space:
mode:
Diffstat (limited to 'nrfm.c')
-rw-r--r--nrfm.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/nrfm.c b/nrfm.c
index 5b2dfe9..5f0202c 100644
--- a/nrfm.c
+++ b/nrfm.c
@@ -316,13 +316,13 @@ uint8_t radio_recv(char *buf, uint8_t n)
return 0;
}
- readmax = (n - 1) < pdlen ? (n - 1) : pdlen;
+ readmax = n < pdlen ? n : pdlen;
SPI_PORT &= ~(1 << SPI_SS);
SPDR = 0b01100001;
while (!(SPSR & (1 << SPIF)))
;
- for (readlen = 0; readlen <= readmax; readlen++) {
+ for (readlen = 0; readlen < readmax; readlen++) {
SPDR = NOP;
while (!(SPSR & (1 << SPIF)))
;
@@ -334,5 +334,5 @@ uint8_t radio_recv(char *buf, uint8_t n)
reset_irqs();
enable_chip();
- return readlen - 1;
+ return readlen;
}