summaryrefslogtreecommitdiffstats
path: root/nrfm.c
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2025-04-09 19:31:30 +0800
committerSadeep Madurange <sadeep@asciimx.com>2025-04-09 19:31:30 +0800
commitde096ea780245c8beb748839120e5669fe37d457 (patch)
tree1f8ee90f3a452cfbeb67d18f52fbfbd3cb6d7e21 /nrfm.c
parente34917da814c2cdb3710553d479df0aed3979e28 (diff)
downloadavr-nrf24l01-driver-de096ea780245c8beb748839120e5669fe37d457.tar.gz
Rename and fix pdlen read.
Diffstat (limited to 'nrfm.c')
-rw-r--r--nrfm.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/nrfm.c b/nrfm.c
index afbb1d9..1c3444a 100644
--- a/nrfm.c
+++ b/nrfm.c
@@ -165,6 +165,9 @@ static inline uint8_t rx_pdlen(void)
SPDR = 0b01100000;
while (!(SPSR & (1 << SPIF)))
;
+ SPDR = NOP;
+ while (!(SPSR & (1 << SPIF)))
+ ;
SPI_PORT |= (1 << SPI_SS);
return SPDR;
}
@@ -287,8 +290,8 @@ void radio_listen(void)
uint8_t radio_recv(char *buf, uint8_t n)
{
- char s[5];
- uint8_t rxdr, readlen, pdlen, maxlen;
+ char s[3];
+ uint8_t readlen, pdlen, maxlen;
pdlen = 0;
disable_chip();
@@ -300,8 +303,14 @@ uint8_t radio_recv(char *buf, uint8_t n)
uart_write_line("ERROR: PDLEN = 0, abort read");
return 0;
}
+
+ s[2] = '\0';
+ pdlen = 0;
+ pdlen = rx_pdlen();
+ itoa(pdlen, s, 10);
+ uart_write("DEBUG: PDLEN=");
+ uart_write_line(s);
- // for some reason, PDLEN reads as 64 causing the below check to fail
//if (pdlen > MAXPDLEN) {
// flush_rx();
// reset_irqs();