From 2d68c30934c496f9ff414f12725c507ed03cc40d Mon Sep 17 00:00:00 2001 From: Mariano Alvira Date: Sat, 6 Mar 2010 18:48:13 -0500 Subject: [PATCH] this receive works --- lib/maca.c | 18 ++++++++++++------ tests/per.c | 11 ++++++----- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/maca.c b/lib/maca.c index f4b180872..a54830751 100644 --- a/lib/maca.c +++ b/lib/maca.c @@ -110,6 +110,7 @@ volatile packet_t* get_free_packet(void) { } void post_receive(void) { + volatile uint32_t i; disable_irq(MACA); last_post = RX_POST; /* this sets the rxlen field */ @@ -119,7 +120,7 @@ void post_receive(void) { if(dma_rx == 0) { dma_rx = get_free_packet(); if (dma_rx == 0) { - printf("trying to fill MACA_DMARX but out of packet buffers\n"); + printf("trying to fill MACA_DMARX but out of packet buffers\n\r"); return; } } @@ -129,15 +130,16 @@ void post_receive(void) { *MACA_TMREN = (1 << maca_tmren_sft); /* start the receive sequence */ enable_irq(MACA); -/* *MACA_CONTROL = ( (1 << maca_ctrl_asap) | + *MACA_CONTROL = ( (1 << maca_ctrl_asap) | (1 << maca_ctrl_auto) | (1 << maca_ctrl_prm) | (maca_ctrl_seq_rx)); -*/ - *MACA_CONTROL = ( + +/* *MACA_CONTROL = ( (1 << maca_ctrl_asap) | ( 4 << PRECOUNT) | (1 << maca_ctrl_prm) | - (maca_ctrl_seq_rx)); + (maca_ctrl_seq_rx));*/ + for(i=0; i<1000; i++) { continue; } } @@ -182,7 +184,11 @@ void post_tx(void) { *MACA_TMREN = (1 << maca_tmren_cpl); /* do the transmit */ enable_irq(MACA); - *MACA_CONTROL = ( (1 << maca_ctrl_prm) | ( 4 << PRECOUNT) | +/* *MACA_CONTROL = ( (1 << maca_ctrl_prm) | ( 4 << PRECOUNT) | + (maca_ctrl_mode_no_cca << maca_ctrl_mode) | + (1 << maca_ctrl_asap) | + (maca_ctrl_seq_tx)); */ + *MACA_CONTROL = ( (1 << maca_ctrl_prm) | (maca_ctrl_mode_no_cca << maca_ctrl_mode) | (1 << maca_ctrl_asap) | (maca_ctrl_seq_tx)); diff --git a/tests/per.c b/tests/per.c index a7e7d0239..c2fcd4989 100644 --- a/tests/per.c +++ b/tests/per.c @@ -16,7 +16,7 @@ #define DEBUG_MACA 1 /* how long to wait between session requests */ -#define SESSION_REQ_TIMEOUT 10 /* phony seconds */ +#define SESSION_REQ_TIMEOUT 10000 /* phony seconds */ enum STATES { SCANNING, @@ -47,7 +47,7 @@ uint32_t get_time(void) { #define random_short_addr() (*MACA_RANDOM & ones(sizeof(short_addr_t)*8)) void build_session_req(volatile packet_t *p) { - p->length = 4; + p->length = 16; p->data[0] = 0xff; p->data[1] = 0x01; p->data[2] = 0x23; @@ -72,9 +72,10 @@ void session_req(short_addr_t addr) { void print_packet(packet_t *p) { volatile uint8_t i,j; if(p) { - for(j=0; j < (p->length)%16; j++) { + printf("len 0x%02x:",p->length); + for(j=0; j < ((p->length)%16)-1; j++) { for(i=0; ilength; i++) { - printf("%x02 ",p->data[i]); + printf("%02x ",p->data[j*16+i]); } printf("\n\r"); } @@ -145,7 +146,7 @@ void main(void) { sesid = open_session(p->addr); } } else { - session_req(my_addr); + // session_req(my_addr); } break; default: