blob: 1c6ac0fe260501e6877b7fe598bf70e09736d94d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#include <avr/io.h>
#include <avr/interrupt.h>
#include "radio.h"
#include "serial.h"
#define RX_PIN PD7
#define RX_DDR DDRD
#define RX_PORT PORTD
#define RX_PCIE PCIE2
#define RX_PCINT PCINT23
#define RX_PCMSK PCMSK2
#define RX_PCINTVEC PCINT2_vect
#define MAX_PAYLOAD_LEN 60
static char *s = "hello, world!";
static uint8_t slen = 13;
int main(void)
{
struct radio_cfg cfg;
cfg.netid = 0x01;
cfg.nodeid = 0x01;
cfg.payload_len = slen;
RX_DDR &= ~(1 << RX_PIN);
RX_PORT &= ~(1 << RX_PIN);
PCICR |= (1 << RX_PCIE);
RX_PCMSK |= (1 << RX_PCINT);
serial_init();
radio_init(&cfg);
radio_listen();
sei();
for (;;)
;
return 0;
}
ISR(RX_PCINTVEC)
{
uint8_t i, n;
char buf[MAX_PAYLOAD_LEN];
cli();
serial_write_line("Detected pin change IRQ");
n = radio_recv(buf, MAX_PAYLOAD_LEN - 1);
buf[n] = '\0';
for (i = 0; i < n; i++)
serial_write(buf[i]);
serial_write('\r');
serial_write('\n');
sei();
}
|