this receive works

This commit is contained in:
Mariano Alvira 2010-03-06 18:48:13 -05:00
parent 0f400b4341
commit 2d68c30934
2 changed files with 18 additions and 11 deletions

View file

@ -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));

View file

@ -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; i<p->length; 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: