From: Michael Gernoth Date: Thu, 20 Jun 2013 20:24:29 +0000 (+0200) Subject: try even harder to not drop any packets X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/fhem-stuff/commitdiff_plain/532a7bf0b5af89a860126c534048a9923cf516d1?ds=sidebyside try even harder to not drop any packets --- diff --git a/culfw/culfw-asksin-fix.diff b/culfw/culfw-asksin-fix.diff index 5c8db33..07a587f 100644 --- a/culfw/culfw-asksin-fix.diff +++ b/culfw/culfw-asksin-fix.diff @@ -2,16 +2,24 @@ Index: clib/rf_asksin.c =================================================================== --- clib/rf_asksin.c (revision 373) +++ clib/rf_asksin.c (working copy) -@@ -11,7 +11,7 @@ +@@ -11,13 +11,13 @@ uint8_t asksin_on = 0; -const uint8_t PROGMEM ASKSIN_CFG[50] = { +- 0x00, 0x07, +const uint8_t PROGMEM ASKSIN_CFG[] = { - 0x00, 0x07, ++ 0x00, 0x01, 0x02, 0x2e, 0x03, 0x0d, -@@ -26,16 +26,17 @@ + 0x04, 0xE9, + 0x05, 0xCA, +- 0x07, 0x0C, ++ 0x07, 0x04, + 0x0B, 0x06, + 0x0D, 0x21, + 0x0E, 0x65, +@@ -26,18 +26,21 @@ 0x11, 0x93, 0x12, 0x03, 0x15, 0x34, @@ -31,8 +39,12 @@ Index: clib/rf_asksin.c + 0x3e, 0xc3 }; ++static inline uint8_t read_cc1100_rxbytes(); ++ void -@@ -56,18 +57,16 @@ + rf_asksin_init(void) + { +@@ -56,20 +59,30 @@ my_delay_us(100); // load configuration @@ -54,8 +66,22 @@ Index: clib/rf_asksin.c + ccRX(); } ++// Workaround for CC1101 Errata 3 ++static inline uint8_t read_cc1100_rxbytes() ++{ ++ uint8_t rxbytes, rxbytes2; ++ ++ rxbytes = cc1100_readReg(CC1100_RXBYTES); ++ while((rxbytes2 = cc1100_readReg(CC1100_RXBYTES)) != rxbytes) ++ rxbytes = rxbytes2; ++ ++ return rxbytes; ++} ++ void -@@ -77,80 +76,74 @@ + rf_asksin_task(void) + { +@@ -77,15 +90,27 @@ uint8_t dec[MAX_ASKSIN_MSG]; uint8_t rssi; uint8_t l; @@ -64,101 +90,69 @@ Index: clib/rf_asksin.c 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; +- // see if a CRC OK pkt has been arrived +- if (bit_is_set( CC1100_IN_PORT, CC1100_IN_PIN )) { ++ // see if there is data to be read ++ while (bit_is_set( CC1100_IN_PORT, CC1100_IN_PIN )) { ++ rxfifo_cnt = read_cc1100_rxbytes(); -- enc[0] = cc1100_readReg( CC1100_RXFIFO ) & 0x7f; // read len -+ enc[0] = cc1100_readReg( CC1100_RXFIFO ) & 0x7f; // read len ++ if (rxfifo_cnt & 0x80) // Overflow ++ break; ++ ++ rxfifo_cnt &= 0x7f; ++ + enc[0] = cc1100_readReg( CC1100_RXFIFO ) & 0x7f; // read len -- if (enc[0]>=MAX_ASKSIN_MSG) -- enc[0] = MAX_ASKSIN_MSG-1; -- -- CC1100_ASSERT; -- cc1100_sendbyte( CC1100_READ_BURST | CC1100_RXFIFO ); -- -- for (uint8_t i=0; i=MAX_ASKSIN_MSG) + enc[0] = MAX_ASKSIN_MSG-1; + +@@ -97,13 +122,12 @@ + } + + rssi = cc1100_sendbyte( 0 ); - -- CC1100_DEASSERT; -+ if (enc[0]>=MAX_ASKSIN_MSG) -+ enc[0] = MAX_ASKSIN_MSG-1; -+ -+ CC1100_ASSERT; -+ cc1100_sendbyte( CC1100_READ_BURST | CC1100_RXFIFO ); -+ -+ for (uint8_t i=0; i