blob: c50c32055e35b164756d570da52f69d86fdecf72 (
plain) (
blame)
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
65
66
67
68
|
/*
* Copyright © 2008 Keith Packard <keithp@keithp.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include "radio.h"
main ()
{
static uint8_t packet[PACKET_LEN + 2];
CLKCON = 0;
while (!(SLEEP & SLEEP_XOSC_STB))
;
/* Set P2_0 to output */
P1 = 0;
P1DIR = 0x02;
radio_init ();
delay(100);
for (;;) {
uint8_t i;
RFST = RFST_SIDLE;
RFIF = 0;
delay(100);
RFST = RFST_SRX;
// while (!(RFIF & RFIF_IM_CS));
// P1 = 2;
for (i = 0; i < PACKET_LEN + 2; i++) {
while (!RFTXRXIF)
;
P1=2;
RFTXRXIF = 0;
packet[i] = RFD;
}
P1 = 0;
/* check packet contents */
for (i = 0; i < PACKET_LEN; i++)
if (packet[i] != i)
break;
/* get excited if the packet came through correctly */
if (i == PACKET_LEN &&
packet[PACKET_LEN+1] & PKT_APPEND_STATUS_1_CRC_OK)
{
for (i = 0; i < 5; i++){
P1 = 2;
delay(100);
P1 = 0;
delay(100);
}
}
delay(100);
}
}
|