set rxlen to zero before enabling interrupts.

This commit is contained in:
nvt-se 2007-12-17 16:37:15 +00:00
parent 2288cdecbb
commit 004143b6b8

View file

@ -291,17 +291,16 @@ cc1020_read(void *buf, unsigned short size)
memcpy(buf, (char *)cc1020_rxbuf + HDRSIZE, len); memcpy(buf, (char *)cc1020_rxbuf + HDRSIZE, len);
RIMESTATS_ADD(llrx); RIMESTATS_ADD(llrx);
// reset receiver
cc1020_rxlen = 0;
CC1020_SET_OPSTATE(CC1020_RX | CC1020_RX_SEARCHING); CC1020_SET_OPSTATE(CC1020_RX | CC1020_RX_SEARCHING);
//cc1020_rxstate = CC1020_RX_SEARCHING;
if ((cc1020_state & CC1020_TURN_OFF) && (cc1020_txlen == 0)) { if ((cc1020_state & CC1020_TURN_OFF) && (cc1020_txlen == 0)) {
cc1020_off(); cc1020_off();
} else { } else {
ENABLE_RX_IRQ(); ENABLE_RX_IRQ();
} }
// reset receiver
cc1020_rxlen = 0;
return len; return len;
} }
@ -451,14 +450,12 @@ interrupt(UART0RX_VECTOR) cc1020_rxhandler(void)
if (pktlen == 0 || pktlen > sizeof (cc1020_rxbuf)) { if (pktlen == 0 || pktlen > sizeof (cc1020_rxbuf)) {
cc1020_rxlen = 0; cc1020_rxlen = 0;
CC1020_SET_OPSTATE(CC1020_RX | CC1020_RX_SEARCHING); CC1020_SET_OPSTATE(CC1020_RX | CC1020_RX_SEARCHING);
//cc1020_rxstate = CC1020_RX_SEARCHING;
} }
} else if (cc1020_rxlen > HDRSIZE) { } else if (cc1020_rxlen > HDRSIZE) {
if (cc1020_rxlen == pktlen) { if (cc1020_rxlen == pktlen) {
// disable receiver // disable receiver
DISABLE_RX_IRQ(); DISABLE_RX_IRQ();
CC1020_SET_OPSTATE(CC1020_RX | CC1020_RX_PROCESSING); CC1020_SET_OPSTATE(CC1020_RX | CC1020_RX_PROCESSING);
//cc1020_rxstate = CC1020_RX_PROCESSING;
// call receiver to copy from buffer // call receiver to copy from buffer
process_poll(&cc1020_receiver_process); process_poll(&cc1020_receiver_process);