update rftest-rx to use new maca.

This commit is contained in:
Mariano Alvira 2010-03-06 21:47:22 -05:00
parent 0dac24e1eb
commit c218d1bffa
4 changed files with 33 additions and 147 deletions

View file

@ -69,22 +69,6 @@ void session_req(short_addr_t addr) {
return; return;
} }
void print_packet(packet_t *p) {
volatile uint8_t i,j,k;
#define PER_ROW 16
if(p) {
printf("len 0x%02x\n\r",p->length);
for(j=0, k=0; j < ((p->length)%PER_ROW)-1; j++) {
for(i=0; i < PER_ROW; i++, k++) {
if(k>=p->length) { break; }
printf("%02x ",p->data[j*PER_ROW+i]);
}
printf("\n\r");
}
printf("\n\r");
}
return;
}
session_id_t open_session(short_addr_t addr) { return 0; } session_id_t open_session(short_addr_t addr) { return 0; }
void main(void) { void main(void) {

View file

@ -5,53 +5,21 @@
#include "tests.h" #include "tests.h"
#include "config.h" #include "config.h"
#define DELAY 400000 #define DEBUG_MACA 1
#define DATA 0x00401000;
uint32_t ackBox[10];
#define MAX_PAYLOAD 128
volatile uint8_t data[MAX_PAYLOAD];
/* maca_rxlen is very important */
#define command_xcvr_rx() \
do { \
maca_txlen = ((0xff)<<16); \
maca_dmatx = (uint32_t)&ackBox; \
maca_dmarx = (uint32_t)data; \
maca_tmren = (maca_cpl_clk | maca_soft_clk); \
maca_control = (control_prm | control_asap | control_seq_rx); \
}while(0)
#define LED LED_GREEN
#define led_on() do { led = 1; *GPIO_DATA0 = LED; } while(0);
#define led_off() do { led = 0; *GPIO_DATA0 = 0x00000000; } while(0);
volatile uint8_t led;
void toggle_led(void) {
if(0 == led) {
led_on();
led = 1;
} else {
led_off();
}
}
void main(void) { void main(void) {
volatile uint32_t i; volatile packet_t *p;
uint16_t status;
*GPIO_PAD_DIR0 = LED;
led_on();
uart_init(INC,MOD); uart_init(INC,MOD);
print_welcome("rftest-rx");
reset_maca(); reset_maca();
radio_init(); radio_init();
flyback_init(); flyback_init();
vreg_init(); vreg_init();
init_phy(); init_phy();
free_all_packets();
/* trim the reference osc. to 24MHz */ /* trim the reference osc. to 24MHz */
pack_XTAL_CNTL(CTUNE_4PF, CTUNE, FTUNE, IBIAS); pack_XTAL_CNTL(CTUNE_4PF, CTUNE, FTUNE, IBIAS);
@ -59,102 +27,18 @@ void main(void) {
set_power(0x0f); /* 0dbm */ set_power(0x0f); /* 0dbm */
set_channel(0); /* channel 11 */ set_channel(0); /* channel 11 */
enable_irq(MACA);
/* initial radio command */
/* nop, promiscuous, no cca */
*MACA_CONTROL = (1 << PRM) | (NO_CCA << MODE); *MACA_CONTROL = (1 << PRM) | (NO_CCA << MODE);
for(i=0; i<DELAY; i++) { continue; }
*MACA_DMARX = (uint32_t)data; /* put data somewhere */
*MACA_PREAMBLE = 0;
command_xcvr_rx();
while(1) { while(1) {
if((p = rx_packet())) {
if(_is_action_complete_interrupt(maca_irq)) { /* print and free the packet */
maca_clrirq = maca_irq; printf("rftest-rx --- ");
print_packet(p);
status = *MACA_STATUS & 0x0000ffff; free_packet(p);
switch(status)
{
case(cc_aborted):
{
printf("aborted\n\r");
ResumeMACASync();
break;
}
case(cc_not_completed):
{
printf("not completed\n\r");
ResumeMACASync();
break;
}
case(cc_timeout):
{
printf("timeout\n\r");
ResumeMACASync();
break;
}
case(cc_no_ack):
{
printf("no ack\n\r");
ResumeMACASync();
break;
}
case(cc_ext_timeout):
{
printf("ext timeout\n\r");
ResumeMACASync();
break;
}
case(cc_ext_pnd_timeout):
{
printf("ext pnd timeout\n\r");
ResumeMACASync();
break;
}
case(cc_success):
{
// printf("success\n\r");
printf("rftest-rx --- maca_getrxlvl: 0x%02x timestamp: 0x%08x\n\r", maca_getrxlvl, maca_timestamp);
printf(" data: 0x%08x ", (uint32_t)data);
for(i=0; i<=(*MACA_GETRXLVL-4); i++) { /* fcs+somethingelse is not transferred by DMA */
printf("%02x ", data[i]);
}
printf("\n\r");
toggle_led();
ResumeMACASync();
command_xcvr_rx();
break;
}
default:
{
printf("status: %04x\n\r",status);
ResumeMACASync();
command_xcvr_rx();
} }
} }
} else if (_is_filter_failed_interrupt(maca_irq)) {
printf("filter failed\n\r");
ResumeMACASync();
command_xcvr_rx();
} else if (_is_checksum_failed_interrupt(maca_irq)) {
printf("crc failed\n\r");
ResumeMACASync();
command_xcvr_rx();
}
};
} }

View file

@ -27,6 +27,23 @@ void print_welcome(char* testname) {
printf("board: %s\n\r", STR2(BOARD)); printf("board: %s\n\r", STR2(BOARD));
} }
void print_packet(packet_t *p) {
volatile uint8_t i,j,k;
#define PER_ROW 16
if(p) {
printf("len 0x%02x\n\r",p->length);
for(j=0, k=0; j < ((p->length)%PER_ROW)-1; j++) {
for(i=0; i < PER_ROW; i++, k++) {
if(k>=p->length) { break; }
printf("%02x ",p->data[j*PER_ROW+i]);
}
printf("\n\r");
}
printf("\n\r");
}
return;
}
void dump_regs(uint32_t base, uint32_t len) { void dump_regs(uint32_t base, uint32_t len) {
volatile uint32_t i; volatile uint32_t i;

View file

@ -9,5 +9,6 @@
void uart1_init(uint16_t inc, uint16_t mod); void uart1_init(uint16_t inc, uint16_t mod);
void print_welcome(char* testname); void print_welcome(char* testname);
void dump_regs(uint32_t base, uint32_t len); void dump_regs(uint32_t base, uint32_t len);
void print_packet(packet_t *p);
#endif #endif