From cf4474a9a93f454bc7af0db64c8cf0303741a4d1 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Thu, 20 Jun 2013 21:06:23 +0200 Subject: [PATCH] better fix for receiving multiple packets, read them all from the fifo! --- culfw/culfw-asksin-fix.diff | 124 ++++++++++++++++++++++++++++-------- 1 file changed, 98 insertions(+), 26 deletions(-) diff --git a/culfw/culfw-asksin-fix.diff b/culfw/culfw-asksin-fix.diff index b17fd05..5c8db33 100644 --- a/culfw/culfw-asksin-fix.diff +++ b/culfw/culfw-asksin-fix.diff @@ -16,7 +16,7 @@ Index: clib/rf_asksin.c 0x12, 0x03, 0x15, 0x34, - 0x17, 0x30, // always go into IDLE -+ 0x17, 0x33, // always go into RX after TX, CCA, ELV uses 0x03 ++ 0x17, 0x3F, // always go into RX after TX, CCA, ELV uses 0x03 0x18, 0x18, 0x19, 0x16, 0x1B, 0x43, @@ -55,37 +55,109 @@ Index: clib/rf_asksin.c } void -@@ -97,13 +96,13 @@ - } - - rssi = cc1100_sendbyte( 0 ); +@@ -77,80 +76,74 @@ + uint8_t dec[MAX_ASKSIN_MSG]; + uint8_t rssi; + uint8_t l; ++ uint8_t rxfifo_cnt; + + if(!asksin_on) + return; + + // see if a CRC OK pkt has been arrived + if (bit_is_set( CC1100_IN_PORT, CC1100_IN_PIN )) { ++ while((rxfifo_cnt = cc1100_readReg(CC1100_RXBYTES)) != 0x00) { ++ if (rxfifo_cnt & 0x80) // Overflow ++ break; + +- enc[0] = cc1100_readReg( CC1100_RXFIFO ) & 0x7f; // read len ++ enc[0] = cc1100_readReg( CC1100_RXFIFO ) & 0x7f; // read len + +- if (enc[0]>=MAX_ASKSIN_MSG) +- enc[0] = MAX_ASKSIN_MSG-1; - -+ - CC1100_DEASSERT; +- CC1100_ASSERT; +- cc1100_sendbyte( CC1100_READ_BURST | CC1100_RXFIFO ); +- +- for (uint8_t i=0; i=MAX_ASKSIN_MSG) ++ enc[0] = MAX_ASKSIN_MSG-1; ++ ++ CC1100_ASSERT; ++ cc1100_sendbyte( CC1100_READ_BURST | CC1100_RXFIFO ); ++ ++ for (uint8_t i=0; i