Skip to content

Commit

Permalink
adding half of radiocounttoleds
Browse files Browse the repository at this point in the history
Simple test allows a user to test the rpi/cc2520 against the common
radiocounttoleds app.
  • Loading branch information
Brad Campbell committed Feb 7, 2013
1 parent e416267 commit 7e49b98
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/radio_count_to_leds.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include "ioctl.h"
#include <unistd.h>

int main(char ** argv, int argc)
{

int result = 0;
printf("Testing cc2520 driver...\n");
int file_desc;
file_desc = open("/dev/radio", O_RDWR);

printf("Setting channel\n");
struct cc2520_set_channel_data chan_data;
chan_data.channel = 24;
ioctl(file_desc, CC2520_IO_RADIO_SET_CHANNEL, &chan_data);

printf("Setting address\n");
struct cc2520_set_address_data addr_data;
addr_data.short_addr = 0x0001;
addr_data.extended_addr = 0x0000000000000001;
addr_data.pan_id = 0x22;
ioctl(file_desc, CC2520_IO_RADIO_SET_ADDRESS, &addr_data);

printf("Setting tx power\n");
struct cc2520_set_txpower_data txpower_data;
txpower_data.txpower = CC2520_TXPOWER_0DBM;
ioctl(file_desc, CC2520_IO_RADIO_SET_TXPOWER, &txpower_data);

printf("Turning on the radio...\n");
ioctl(file_desc, CC2520_IO_RADIO_INIT, NULL);
ioctl(file_desc, CC2520_IO_RADIO_ON, NULL);

uint16_t i = 0;

while (1) {
printf("Sending RCTL packet.\n");
// 8 Byte Header, 6 Byte Payload.
char test_msg[] = {0x0D, 0x41, 0x88, (char) i, 0x22, 0xFF, 0xFF, 0x00, 0x01, 0x06, (char) (i >> 8), (char) (i & 0xFF)};
result = write(file_desc, test_msg, 12);
usleep(250 * 1000);
}

printf("Turning off the radio...\n");
ioctl(file_desc, CC2520_IO_RADIO_OFF, NULL);

close(file_desc);
}

0 comments on commit 7e49b98

Please sign in to comment.