summaryrefslogtreecommitdiffstats
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
parente34917da814c2cdb3710553d479df0aed3979e28 (diff)
downloadavr-nrf24l01-driver-de096ea780245c8beb748839120e5669fe37d457.tar.gz
Rename and fix pdlen read.
-rw-r--r--Ding.Makefile (renamed from Recv.Makefile)4
-rw-r--r--Dong.Makefile (renamed from Send.Makefile)4
-rw-r--r--ding.c (renamed from send.c)0
-rw-r--r--dong.c (renamed from recv.c)0
-rw-r--r--nrfm.c15
5 files changed, 16 insertions, 7 deletions
diff --git a/Recv.Makefile b/Ding.Makefile
index f77be2f..2f31bc2 100644
--- a/Recv.Makefile
+++ b/Ding.Makefile
@@ -1,8 +1,8 @@
CC = avr-gcc
MCU = atmega328p
-TARGET = app
+TARGET = ding
-SRC = recv.c uart.c nrfm.c
+SRC = ding.c uart.c nrfm.c
OBJ = $(SRC:.c=.o)
CFLAGS = -std=gnu99
diff --git a/Send.Makefile b/Dong.Makefile
index 941fa0f..4dcb942 100644
--- a/Send.Makefile
+++ b/Dong.Makefile
@@ -1,8 +1,8 @@
CC = avr-gcc
MCU = atmega328p
-TARGET = sender
+TARGET = dong
-SRC = send.c uart.c nrfm.c
+SRC = dong.c uart.c nrfm.c
OBJ = $(SRC:.c=.o)
CFLAGS = -std=gnu99
diff --git a/send.c b/ding.c
index 5950ddc..5950ddc 100644
--- a/send.c
+++ b/ding.c
diff --git a/recv.c b/dong.c
index 70006dc..70006dc 100644
--- a/recv.c
+++ b/dong.c
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();