rftest-tx and refine post_tx for fast transmission

This commit is contained in:
Mariano Alvira 2010-03-07 16:49:57 -05:00
parent 4b17c144d0
commit 667b238148
2 changed files with 40 additions and 134 deletions

View file

@ -177,24 +177,24 @@ void post_tx(void) {
/* disable soft timeout clock */
/* disable start clock */
*MACA_TMRDIS = (1 << maca_tmren_sft) | ( 1 << maca_tmren_strt ) ;
/* this doesn't work right */
/* lock up seems to happen when switching from receive to transmitt */
/* set complete clock to long value */
/* acts like a watchdog incase the MACA locks up */
*MACA_CPLCLK = *MACA_CLK + (CLK_PER_BYTE * dma_tx->length+6) + (CLK_PER_BYTE * 0);
// *MACA_CPLCLK = *MACA_CLK + (CLK_PER_BYTE * dma_tx->length+6) + (CLK_PER_BYTE * 0);
/* enable complete clock */
*MACA_TMREN = (1 << maca_tmren_cpl);
/* do the transmit */
for(i=0; i<1000; i++) { continue; }
// *MACA_TMREN = (1 << maca_tmren_cpl);
enable_irq(MACA);
/* *MACA_CONTROL = ( (1 << maca_ctrl_prm) | ( 4 << PRECOUNT) |
(maca_ctrl_mode_no_cca << maca_ctrl_mode) |
(1 << maca_ctrl_asap) |
(maca_ctrl_seq_tx)); */
// for(i=0; i<1000; i++) { continue; }
*MACA_CONTROL = ( (1 << maca_ctrl_prm) |
(maca_ctrl_mode_no_cca << maca_ctrl_mode) |
(1 << maca_ctrl_asap) |
(maca_ctrl_seq_tx));
for(i=0; i<1000; i++) { continue; }
}
void tx_packet(volatile packet_t *p) {

View file

@ -5,57 +5,40 @@
#include "tests.h"
#include "config.h"
#define DELAY 100000
#define DATA 0x00401000
#define DEBUG_MACA 1
#define LED LED_RED
uint32_t ackBox[10];
#define PAYLOAD_LEN 16
#define DELAY 400000
#define command_xcvr_rx() \
do { \
maca_txlen = (uint32_t)1<<16; \
maca_dmatx = (uint32_t)&ackBox; \
maca_dmarx = DATA; \
maca_tmren = (maca_cpl_clk | maca_soft_clk); \
maca_control = (control_prm | control_asap | control_seq_rx); \
}while(0)
#define PAYLOAD_LEN 16 /* not including the extra 4 bytes for len+fcs+somethingelse */
/* maca dmatx needs extra 4 bytes for checksum */
/* needs + 4 bytes for len(1 byte) + fcs(2 bytes) + somethingelse */
#define command_xcvr_tx() \
do { \
maca_txlen = (uint32_t)(PAYLOAD_LEN+4); \
maca_dmatx = (uint32_t)DATA; \
maca_dmarx = (uint32_t)&ackBox; \
maca_control = (control_prm | control_mode_no_cca | \
control_asap | control_seq_tx); \
}while(0)
volatile uint8_t *data;
uint8_t count=0;
void fill_data(void) {
uint8_t i;
void fill_packet(volatile packet_t *p) {
static volatile uint8_t count=0;
volatile uint8_t i;
p->length = PAYLOAD_LEN;
for(i=0; i<PAYLOAD_LEN; i++) {
data[i] = count++;
p->data[i] = count++;
}
}
void main(void) {
volatile uint32_t i;
uint16_t status;
volatile packet_t *p;
*GPIO_PAD_DIR0 = LED;
led_on();
*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 );
uart_init(INC,MOD);
print_welcome("rftest-tx");
reset_maca();
radio_init();
vreg_init();
flyback_init();
init_phy();
free_all_packets();
/* trim the reference osc. to 24MHz */
pack_XTAL_CNTL(CTUNE_4PF, CTUNE, FTUNE, IBIAS);
@ -63,102 +46,25 @@ void main(void) {
set_power(0x0f); /* 0dbm */
set_channel(0); /* channel 11 */
/* initial radio command */
/* nop, promiscuous, no cca */
*MACA_CONTROL = (1 << PRM) | (NO_CCA << MODE);
for(i=0; i<DELAY; i++) { continue; }
data = (void *)DATA;
*MACA_DMARX = DATA; /* put data somewhere */
*MACA_PREAMBLE = 0;
/* sets up tx_on, should be a board specific item */
*GPIO_FUNC_SEL2 = (0x01 << ((44-16*2)*2));
*GPIO_PAD_DIR0 = *GPIO_PAD_DIR0 | (1<<(44-32));
fill_data();
command_xcvr_tx();
while(1) {
if(_is_action_complete_interrupt(maca_irq)) {
maca_clrirq = maca_irq;
p = get_free_packet();
if(p) {
fill_packet(p);
status = *MACA_STATUS & 0x0000ffff;
switch(status)
{
case(cc_aborted):
{
printf("aborted\n\r");
ResumeMACASync();
break;
toggle_gpio0(LED);
printf("rftest-tx --- ");
print_packet(p);
}
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-tx --- payload len+crc: 0x%02x timestamp: 0x%08x\n\r", PAYLOAD_LEN+4, maca_timestamp);
printf(" data: ");
for(i=0; i<PAYLOAD_LEN; i++) {
printf("%02x ",data[i]);
}
printf("\n\r");
toggle_led();
fill_data();
command_xcvr_tx();
break;
}
default:
{
printf("status: 0x%04x",status);
ResumeMACASync();
}
}
} else if (_is_filter_failed_interrupt(maca_irq)) {
printf("filter failed\n\r");
ResumeMACASync();
}
tx_packet(p);
for(i=0; i<DELAY; i++) { continue; }
}
}
};
}