diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2025-04-11 13:25:11 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2025-04-11 13:25:11 +0800 |
| commit | 52112f19821f6f667c51f3ac2c68da41365e0b43 (patch) | |
| tree | 7747b55922d76d435ea2b528f87201950a14b5e2 /dong.c | |
| parent | 7b9d39da831a6454eb0eb57bbfa86ff2d615d287 (diff) | |
| download | avr-nrf24l01-driver-52112f19821f6f667c51f3ac2c68da41365e0b43.tar.gz | |
wip: some packets are being exchanged, after about 3 packets they fail (WDT)
Diffstat (limited to 'dong.c')
| -rw-r--r-- | dong.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -1,10 +1,13 @@ #include <stdint.h> #include <string.h> + #include <avr/interrupt.h> +#include <avr/wdt.h> #include <util/delay.h> #include "nrfm.h" #include "uart.h" +#include "util.h" #define RX_PIN PD7 #define RX_DDR DDRD @@ -22,12 +25,14 @@ int main(void) char buf[MAXPDLEN + 1]; uint8_t rxaddr[] = { 194, 178, 83 }; + uint8_t txaddr[] = { 194, 178, 82 }; RX_DDR &= ~(1 << RX_PIN); RX_PORT |= (1 << RX_PIN); PCICR |= (1 << RX_PCIE); RX_PCMSK |= (1 << RX_PCINT); + wdt_stop(); uart_init(); radio_init(rxaddr); radio_print_config(); @@ -37,18 +42,19 @@ int main(void) for (;;) { if (rxdr) { - uart_write_line("IRQ recv, reading data"); n = radio_recv(buf, MAXPDLEN); buf[n] = '\0'; rxdr = 0; - if (n > 0) { + if (strncmp(buf, "SYN", 3) == 0) { uart_write("INFO: "); uart_write_line(buf); + radio_sendto(txaddr, "ACK", 3); } } else { uart_write_line("No IRQ"); - _delay_ms(2000); } + + _delay_ms(1000); } return 0; |
