2010-02-26 23:27:58 +00:00
|
|
|
#include <mc1322x.h>
|
|
|
|
#include <board.h>
|
2010-03-02 22:52:31 +00:00
|
|
|
#include <stdio.h>
|
2009-04-02 18:54:02 +00:00
|
|
|
|
2010-02-26 23:27:58 +00:00
|
|
|
#include "tests.h"
|
|
|
|
#include "config.h"
|
2009-04-02 18:54:02 +00:00
|
|
|
|
2010-03-07 21:49:57 +00:00
|
|
|
#define LED LED_RED
|
2009-04-02 18:54:02 +00:00
|
|
|
|
2010-03-07 23:48:36 +00:00
|
|
|
/* 802.15.4 PSDU is 127 MAX */
|
|
|
|
/* 2 bytes are the FCS */
|
|
|
|
/* therefore 125 is the max payload length */
|
|
|
|
#define PAYLOAD_LEN 16
|
2010-03-08 22:36:42 +00:00
|
|
|
#define DELAY 1000000
|
2009-04-13 22:19:13 +00:00
|
|
|
|
2010-03-07 21:49:57 +00:00
|
|
|
void fill_packet(volatile packet_t *p) {
|
|
|
|
static volatile uint8_t count=0;
|
|
|
|
volatile uint8_t i;
|
|
|
|
p->length = PAYLOAD_LEN;
|
2010-03-07 22:04:30 +00:00
|
|
|
p->offset = 0;
|
2010-03-08 20:22:37 +00:00
|
|
|
for(i=0; i<PAYLOAD_LEN; i++) {
|
2010-03-07 21:49:57 +00:00
|
|
|
p->data[i] = count++;
|
2010-03-08 20:22:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* acks get treated differently, even in promiscuous mode */
|
|
|
|
/* setting the second bit makes sure that we never send an ack */
|
|
|
|
/* or any valid 802.15.4-2006 packet */
|
|
|
|
p->data[0] |= (1 << 2);
|
2009-04-13 22:19:13 +00:00
|
|
|
}
|
|
|
|
|
2009-04-02 18:54:02 +00:00
|
|
|
void main(void) {
|
|
|
|
volatile uint32_t i;
|
2010-03-07 21:49:57 +00:00
|
|
|
volatile packet_t *p;
|
|
|
|
|
2010-03-08 19:49:31 +00:00
|
|
|
/* trim the reference osc. to 24MHz */
|
|
|
|
pack_XTAL_CNTL(CTUNE_4PF, CTUNE, FTUNE, IBIAS);
|
2009-04-02 18:54:02 +00:00
|
|
|
|
2010-02-26 23:27:58 +00:00
|
|
|
uart_init(INC,MOD);
|
2009-04-16 21:59:00 +00:00
|
|
|
|
2009-04-13 22:19:13 +00:00
|
|
|
vreg_init();
|
2009-04-02 22:05:13 +00:00
|
|
|
|
2010-03-08 19:49:31 +00:00
|
|
|
maca_init();
|
2010-03-01 18:01:51 +00:00
|
|
|
|
2010-03-08 19:49:31 +00:00
|
|
|
set_channel(0); /* channel 11 */
|
2010-03-07 23:48:36 +00:00
|
|
|
// set_power(0x0f); /* 0xf = -1dbm, see 3-22 */
|
|
|
|
// set_power(0x11); /* 0x11 = 3dbm, see 3-22 */
|
2010-03-08 19:49:31 +00:00
|
|
|
set_power(0x12); /* 0x12 is the highest, not documented */
|
|
|
|
|
|
|
|
*GPIO_DATA0 = 0x00000000;
|
|
|
|
*GPIO_PAD_DIR0 = ( 1 << LED );
|
|
|
|
/* read from the data register instead of the pad */
|
|
|
|
/* this is needed because the led clamps the voltage low */
|
|
|
|
*GPIO_DATA_SEL0 = ( 1 << LED );
|
2009-04-13 22:19:13 +00:00
|
|
|
|
2010-03-08 19:49:31 +00:00
|
|
|
/* sets up tx_on, should be a board specific item */
|
|
|
|
*GPIO_FUNC_SEL2 = (0x01 << ((44-16*2)*2));
|
2010-03-08 22:36:42 +00:00
|
|
|
*GPIO_PAD_DIR_SET1 = (1 << (44-32));
|
2010-03-08 19:49:31 +00:00
|
|
|
|
|
|
|
print_welcome("rftest-tx");
|
2009-04-13 22:19:13 +00:00
|
|
|
|
2009-04-02 18:54:02 +00:00
|
|
|
while(1) {
|
2010-03-07 21:49:57 +00:00
|
|
|
|
|
|
|
p = get_free_packet();
|
|
|
|
if(p) {
|
|
|
|
fill_packet(p);
|
2009-04-13 22:19:13 +00:00
|
|
|
|
2010-03-07 21:49:57 +00:00
|
|
|
toggle_gpio0(LED);
|
|
|
|
printf("rftest-tx --- ");
|
|
|
|
print_packet(p);
|
|
|
|
|
|
|
|
tx_packet(p);
|
|
|
|
|
|
|
|
for(i=0; i<DELAY; i++) { continue; }
|
2009-04-13 22:19:13 +00:00
|
|
|
}
|
|
|
|
|
2010-03-07 21:49:57 +00:00
|
|
|
}
|
2009-04-13 22:19:13 +00:00
|
|
|
|
2009-04-02 18:54:02 +00:00
|
|
|
}
|