diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2025-04-06 10:11:09 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2025-04-06 10:11:09 +0800 |
| commit | f2801a35b43f4117d97dd4d8eba9db480454c9e3 (patch) | |
| tree | 74379f443af948faac953262d162f7cab51808aa | |
| parent | 5ea8572fcbc6a3dbcbb47393dcab128585df2ce6 (diff) | |
| download | avr-nrf24l01-driver-f2801a35b43f4117d97dd4d8eba9db480454c9e3.tar.gz | |
Fix programming errors in setting the address registers.
| -rw-r--r-- | Send.Makefile | 2 | ||||
| -rw-r--r-- | nrfm.c | 2 | ||||
| -rw-r--r-- | nrfm.h | 2 | ||||
| -rw-r--r-- | recv.c | 1 | ||||
| -rw-r--r-- | send.c | 12 |
5 files changed, 12 insertions, 7 deletions
diff --git a/Send.Makefile b/Send.Makefile index 7c20759..941fa0f 100644 --- a/Send.Makefile +++ b/Send.Makefile @@ -1,6 +1,6 @@ CC = avr-gcc MCU = atmega328p -TARGET = app +TARGET = sender SRC = send.c uart.c nrfm.c OBJ = $(SRC:.c=.o) @@ -81,7 +81,7 @@ static inline void read_reg_bulk(uint8_t reg, uint8_t *data, uint8_t n) static inline void setaddr(uint8_t reg, const uint8_t addr[ADDRLEN]) { - uint8_t i; + int i; SPI_PORT &= ~(1 << SPI_SS); SPDR = (reg & 0x1F) | W_REGISTER; @@ -3,7 +3,7 @@ #include <stdint.h> -#define ADDRLEN 5 +#define ADDRLEN 3 #define MAXPDLEN 32 void radio_init(const uint8_t rxaddr[ADDRLEN]); @@ -39,7 +39,6 @@ int main(void) n = radio_recv(buf, MAXPDLEN); buf[n] = '\0'; rxdr = 0; - uart_write("INFO: "); uart_write_line(buf); @@ -1,5 +1,6 @@ #include <stdint.h> #include <string.h> +#include <util/delay.h> #include "nrfm.h" #include "uart.h" @@ -7,15 +8,20 @@ int main(void) { const char *s = "hello world!"; + uint8_t slen = strlen(s); - uint8_t rxaddr[] = { 194, 178, 82 }; - uint8_t txaddr[] = { 194, 178, 83 }; + uint8_t rxaddr[ADDRLEN] = { 194, 178, 82 }; + uint8_t txaddr[ADDRLEN] = { 194, 178, 83 }; uart_init(); radio_init(rxaddr); radio_print_config(); - radio_sendto(txaddr, s, strlen(s)); + for (;;) { + radio_sendto(txaddr, s, slen); + _delay_ms(1000); + } + return 0; } |
