summaryrefslogtreecommitdiffstats
path: root/rf_test/send.c
blob: c3831bab1971751cb9f0e890f00510e42d86eb02 (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
#include <stdlib.h>
#include <string.h>

#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>

#include "radio.h"
#include "serial.h"

#define LED_PIN  PB1
#define LED_DDR  DDRB
#define LED_PORT PORTB

#define NODE_ID  2

int main(void)
{
	uint8_t n;
	struct radio_cfg cfg;
	const char *s = "hello, world!";

	n = strlen(s);
	cfg.node_id = NODE_ID;
	cfg.payload_len = n;

	LED_DDR |= (1 << LED_PIN);

	serial_init();
	radio_init(&cfg);

	sei();

	for (;;) {
		radio_sendto(1, s, n);
		serial_write_line("sent data");

		LED_PORT |= (1 << LED_PIN);
		_delay_ms(100);
		LED_PORT &= ~(1 << LED_PIN);
		_delay_ms(1900);
	}

	return 0;
}