From 965631aa47705dc74568faa03a00c67d57fbe17f Mon Sep 17 00:00:00 2001 From: Andrea Guglielmini Date: Sun, 16 Feb 2020 21:53:52 +0100 Subject: [PATCH 01/23] [CC1101] Transmit up to 255 bytes --- src/modules/CC1101/CC1101.cpp | 41 ++++++++++++++++++++++++++++++++--- src/modules/CC1101/CC1101.h | 7 ++++-- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 380658bd..3f02dbeb 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -218,24 +218,54 @@ int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) { int16_t state = SPIsetRegValue(CC1101_REG_IOCFG0, CC1101_GDOX_SYNC_WORD_SENT_OR_RECEIVED); RADIOLIB_ASSERT(state); + // data put on FIFO. + uint8_t dataSent = 0; + // optionally write packet length if (_packetLengthConfig == CC1101_LENGTH_CONFIG_VARIABLE) { + + // enforce variable len limit. + if (len > 254) { + return (ERR_PACKET_TOO_LONG); + } + SPIwriteRegister(CC1101_REG_FIFO, len); + dataSent += 1; } // check address filtering uint8_t filter = SPIgetRegValue(CC1101_REG_PKTCTRL1, 1, 0); if(filter != CC1101_ADR_CHK_NONE) { SPIwriteRegister(CC1101_REG_FIFO, addr); + dataSent += 1; } - // write packet to FIFO - SPIwriteRegisterBurst(CC1101_REG_FIFO, data, len); + // fill the FIFO. + uint8_t initialWrite = min(len, (CC1101_FIFO_SIZE - dataSent)); + SPIwriteRegisterBurst(CC1101_REG_FIFO, data, initialWrite); + dataSent += initialWrite; // set mode to transmit SPIsendCommand(CC1101_CMD_TX); - return(state); + // keep feeding the FIFO until the packet is over. + uint8_t bytesInFIFO; + while (dataSent < len) { + // get number of bytes in FIFO. + bytesInFIFO = SPIgetRegValue(CC1101_REG_TXBYTES, 6, 0); + + // if there's room then put other data. + if (bytesInFIFO < CC1101_FIFO_SIZE) { + uint8_t bytesToWrite = min(CC1101_FIFO_SIZE - bytesInFIFO, len - dataSent); + SPIwriteRegisterBurst(CC1101_REG_FIFO, &data[dataSent], bytesToWrite); + dataSent += bytesToWrite; + } else { + // wait for radio to send some data. + delay(1); + } + } + + return (state); } int16_t CC1101::startReceive() { @@ -851,3 +881,8 @@ void CC1101::SPIsendCommand(uint8_t cmd) { SPI.endTransaction(); Module::digitalWrite(_mod->getCs(), HIGH); } + +uint8_t CC1101::min(uint8_t a, uint8_t b) { + if (a < b) return a; + return b; +} \ No newline at end of file diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index 2486647f..5d27c420 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -8,9 +8,10 @@ // CC1101 physical layer properties #define CC1101_FREQUENCY_STEP_SIZE 396.7285156 -#define CC1101_MAX_PACKET_LENGTH 63 +#define CC1101_MAX_PACKET_LENGTH 255 #define CC1101_CRYSTAL_FREQ 26.0 #define CC1101_DIV_EXPONENT 16 +#define CC1101_FIFO_SIZE 64 // CC1101 SPI commands #define CC1101_CMD_READ 0b10000000 @@ -168,7 +169,7 @@ #define CC1101_RX_ATTEN_6_DB 0b00010000 // 5 4 6 dB #define CC1101_RX_ATTEN_12_DB 0b00100000 // 5 4 12 dB #define CC1101_RX_ATTEN_18_DB 0b00110000 // 5 4 18 dB -#define CC1101_FIFO_THR 0b00000111 // 5 4 Rx FIFO threshold [bytes] = CC1101_FIFO_THR * 4; Tx FIFO threshold [bytes] = 65 - (CC1101_FIFO_THR * 4) +#define CC1101_FIFO_THR_TX_61_RX_4 0b00000000 // 3 0 TX fifo threshold: 61, RX fifo threshold: 4 // CC1101_REG_SYNC1 #define CC1101_SYNC_WORD_MSB 0xD3 // 7 0 sync word MSB @@ -884,6 +885,8 @@ class CC1101: public PhysicalLayer { uint8_t _syncWordLength; int8_t _power; + uint8_t min(uint8_t a, uint8_t b); + int16_t config(); int16_t directMode(); void getExpMant(float target, uint16_t mantOffset, uint8_t divExp, uint8_t expMax, uint8_t& exp, uint8_t& mant); From 54405ac0429ff09b9c868167695f055b8916b3f6 Mon Sep 17 00:00:00 2001 From: Andrea Guglielmini Date: Sun, 16 Feb 2020 21:57:07 +0100 Subject: [PATCH 02/23] [CC1101] Receive up to 255 bytes --- src/modules/CC1101/CC1101.cpp | 81 ++++++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 25 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 3f02dbeb..192708cf 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -124,13 +124,8 @@ int16_t CC1101::receive(uint8_t* data, size_t len) { int16_t state = startReceive(); RADIOLIB_ASSERT(state); - // wait for sync word - while(!digitalRead(_mod->getIrq())) { - yield(); - } - - // wait for packet end - while(digitalRead(_mod->getIrq())) { + // wait for rx queue to exceed threshold. + while (!digitalRead(_mod->getIrq())) { yield(); } @@ -275,8 +270,9 @@ int16_t CC1101::startReceive() { // flush Rx FIFO SPIsendCommand(CC1101_CMD_FLUSH_RX); - // set GDO0 mapping - int state = SPIsetRegValue(CC1101_REG_IOCFG0, CC1101_GDOX_SYNC_WORD_SENT_OR_RECEIVED); + // set GDO0 mapping: Asserted when RX FIFO > 4 bytes. + int state = SPIsetRegValue(CC1101_REG_IOCFG0, CC1101_GDOX_RX_FIFO_FULL_OR_PKT_END); + state |= SPIsetRegValue(CC1101_REG_FIFOTHR, CC1101_FIFO_THR_TX_61_RX_4, 3, 0); RADIOLIB_ASSERT(state); // set mode to receive @@ -288,8 +284,8 @@ int16_t CC1101::startReceive() { int16_t CC1101::readData(uint8_t* data, size_t len) { // get packet length size_t length = len; - if(len == CC1101_MAX_PACKET_LENGTH) { - length = getPacketLength(); + if (len == CC1101_MAX_PACKET_LENGTH) { + length = getPacketLength(true); } // check address filtering @@ -298,31 +294,66 @@ int16_t CC1101::readData(uint8_t* data, size_t len) { SPIreadRegister(CC1101_REG_FIFO); } - // read packet data - SPIreadRegisterBurst(CC1101_REG_FIFO, length, data); + uint8_t bytesInFIFO = SPIgetRegValue(CC1101_REG_RXBYTES, 6, 0); + uint16_t readBytes = 0; + unsigned long lastPop = millis(); - // read RSSI byte - _rawRSSI = SPIgetRegValue(CC1101_REG_FIFO); + // keep reading from FIFO until we get all the packet. + while (readBytes < length) { + if (bytesInFIFO == 0) { + if (millis() - lastPop > 5) { + // readData was required to read a packet longer than the one received. + RADIOLIB_DEBUG_PRINT(F("No data for more than 5mS. Stop here.")); + break; + } else { + delay(1); + bytesInFIFO = SPIgetRegValue(CC1101_REG_RXBYTES, 6, 0); + continue; + } + } + + // read the minimum between "remaining length" and bytesInFifo + uint8_t bytesToRead = min(length - readBytes, bytesInFIFO); + SPIreadRegisterBurst(CC1101_REG_FIFO, bytesToRead, &(data[readBytes])); + readBytes += bytesToRead; + lastPop = millis(); + + // Get how many bytes are left in FIFO. + bytesInFIFO = SPIgetRegValue(CC1101_REG_RXBYTES, 6, 0); + } + + // add terminating null + data[readBytes] = 0; + + // check if status bytes are enabled (default: CC1101_APPEND_STATUS_ON) + bool isAppendStatus = SPIgetRegValue(CC1101_REG_PKTCTRL1, 2, 2) == CC1101_APPEND_STATUS_ON; + + // If status byte is enabled at least 2 bytes (2 status bytes + any following packet) will remain in FIFO. + if (bytesInFIFO >= 2 && isAppendStatus) { + // read RSSI byte + _rawRSSI = SPIgetRegValue(CC1101_REG_FIFO); // read LQI and CRC byte uint8_t val = SPIgetRegValue(CC1101_REG_FIFO); _rawLQI = val & 0x7F; - // add terminating null - data[length] = 0; - - // flush Rx FIFO - SPIsendCommand(CC1101_CMD_FLUSH_RX); + // check CRC + if (_crcOn && (val & 0b10000000) == 0b00000000) { + return (ERR_CRC_MISMATCH); + } + } // clear internal flag so getPacketLength can return the new packet length _packetLengthQueried = false; - // set mode to standby - standby(); + // Flush then standby according to RXOFF_MODE (default: CC1101_RXOFF_IDLE) + if (SPIgetRegValue(CC1101_REG_MCSM1, 3, 2) == CC1101_RXOFF_IDLE) { - // check CRC - if (_crcOn && (val & 0b10000000) == 0b00000000) { - return (ERR_CRC_MISMATCH); + // flush Rx FIFO + SPIsendCommand(CC1101_CMD_FLUSH_RX); + + // set mode to standby + standby(); } return(ERR_NONE); From 4f78d95738e9a425e1bf9fd44576d91933fcf7af Mon Sep 17 00:00:00 2001 From: Andrea Guglielmini Date: Mon, 17 Feb 2020 12:45:19 +0100 Subject: [PATCH 03/23] [CC1101] Fixed interrupt direction. Tested: CC1101_Receive, CC1101_Receive_Interrupt, CC1101_Transmit, CC1101_Transmit_Interrupt --- src/modules/CC1101/CC1101.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index 5d27c420..ecc1b4ef 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -599,9 +599,9 @@ class CC1101: public PhysicalLayer { \param func ISR to call. - \param dir Signal change direction. Defaults to FALLING. + \param dir Signal change direction. Defaults to RISING. */ - void setGdo0Action(void (*func)(void), uint8_t dir = FALLING); + void setGdo0Action(void (*func)(void), uint8_t dir = RISING); /*! \brief Clears interrupt service routine to call when GDO0 activates. From c23b9302b0c69e9ce8e63bb07fbb040f83614c4a Mon Sep 17 00:00:00 2001 From: Andrea Guglielmini Date: Mon, 17 Feb 2020 13:15:43 +0100 Subject: [PATCH 04/23] [CC1101] Requested changes PR #114 --- src/modules/CC1101/CC1101.cpp | 20 +++++++------------- src/modules/CC1101/CC1101.h | 2 -- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 192708cf..8a04b36b 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -236,7 +236,7 @@ int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) { } // fill the FIFO. - uint8_t initialWrite = min(len, (CC1101_FIFO_SIZE - dataSent)); + uint8_t initialWrite = min((uint8_t)len, (uint8_t)(CC1101_FIFO_SIZE - dataSent)); SPIwriteRegisterBurst(CC1101_REG_FIFO, data, initialWrite); dataSent += initialWrite; @@ -244,14 +244,13 @@ int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) { SPIsendCommand(CC1101_CMD_TX); // keep feeding the FIFO until the packet is over. - uint8_t bytesInFIFO; while (dataSent < len) { // get number of bytes in FIFO. - bytesInFIFO = SPIgetRegValue(CC1101_REG_TXBYTES, 6, 0); + uint8_t bytesInFIFO = SPIgetRegValue(CC1101_REG_TXBYTES, 6, 0); // if there's room then put other data. if (bytesInFIFO < CC1101_FIFO_SIZE) { - uint8_t bytesToWrite = min(CC1101_FIFO_SIZE - bytesInFIFO, len - dataSent); + uint8_t bytesToWrite = min((uint8_t)(CC1101_FIFO_SIZE - bytesInFIFO), (uint8_t)(len - dataSent)); SPIwriteRegisterBurst(CC1101_REG_FIFO, &data[dataSent], bytesToWrite); dataSent += bytesToWrite; } else { @@ -271,7 +270,7 @@ int16_t CC1101::startReceive() { SPIsendCommand(CC1101_CMD_FLUSH_RX); // set GDO0 mapping: Asserted when RX FIFO > 4 bytes. - int state = SPIsetRegValue(CC1101_REG_IOCFG0, CC1101_GDOX_RX_FIFO_FULL_OR_PKT_END); + int16_t state = SPIsetRegValue(CC1101_REG_IOCFG0, CC1101_GDOX_RX_FIFO_FULL_OR_PKT_END); state |= SPIsetRegValue(CC1101_REG_FIFOTHR, CC1101_FIFO_THR_TX_61_RX_4, 3, 0); RADIOLIB_ASSERT(state); @@ -296,14 +295,14 @@ int16_t CC1101::readData(uint8_t* data, size_t len) { uint8_t bytesInFIFO = SPIgetRegValue(CC1101_REG_RXBYTES, 6, 0); uint16_t readBytes = 0; - unsigned long lastPop = millis(); + uint32_t lastPop = millis(); // keep reading from FIFO until we get all the packet. while (readBytes < length) { if (bytesInFIFO == 0) { if (millis() - lastPop > 5) { // readData was required to read a packet longer than the one received. - RADIOLIB_DEBUG_PRINT(F("No data for more than 5mS. Stop here.")); + RADIOLIB_DEBUG_PRINTLN(F("No data for more than 5mS. Stop here.")); break; } else { delay(1); @@ -313,7 +312,7 @@ int16_t CC1101::readData(uint8_t* data, size_t len) { } // read the minimum between "remaining length" and bytesInFifo - uint8_t bytesToRead = min(length - readBytes, bytesInFIFO); + uint8_t bytesToRead = min((uint8_t)(length - readBytes), bytesInFIFO); SPIreadRegisterBurst(CC1101_REG_FIFO, bytesToRead, &(data[readBytes])); readBytes += bytesToRead; lastPop = millis(); @@ -912,8 +911,3 @@ void CC1101::SPIsendCommand(uint8_t cmd) { SPI.endTransaction(); Module::digitalWrite(_mod->getCs(), HIGH); } - -uint8_t CC1101::min(uint8_t a, uint8_t b) { - if (a < b) return a; - return b; -} \ No newline at end of file diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index ecc1b4ef..714b2da4 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -885,8 +885,6 @@ class CC1101: public PhysicalLayer { uint8_t _syncWordLength; int8_t _power; - uint8_t min(uint8_t a, uint8_t b); - int16_t config(); int16_t directMode(); void getExpMant(float target, uint16_t mantOffset, uint8_t divExp, uint8_t expMax, uint8_t& exp, uint8_t& mant); From 93981f1fcbae458ced7cc2e0f5859e6db00caf9d Mon Sep 17 00:00:00 2001 From: Andrea Guglielmini Date: Wed, 26 Feb 2020 15:54:41 +0100 Subject: [PATCH 05/23] [nRF24] Added "isCarrierDetected()" --- src/modules/nRF24/nRF24.cpp | 4 ++++ src/modules/nRF24/nRF24.h | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/modules/nRF24/nRF24.cpp b/src/modules/nRF24/nRF24.cpp index 14f9a943..3bd01719 100644 --- a/src/modules/nRF24/nRF24.cpp +++ b/src/modules/nRF24/nRF24.cpp @@ -426,6 +426,10 @@ int16_t nRF24::getStatus(uint8_t mask) { return(_mod->SPIgetRegValue(NRF24_REG_STATUS) & mask); } +bool nRF24::isCarrierDetected() { + return(_mod->SPIgetRegValue(NRF24_REG_RPD, 0,0)) == 1; +} + int16_t nRF24::setFrequencyDeviation(float freqDev) { // nRF24 is unable to set frequency deviation // this method is implemented only for PhysicalLayer compatibility diff --git a/src/modules/nRF24/nRF24.h b/src/modules/nRF24/nRF24.h index 6eafc342..4528c949 100644 --- a/src/modules/nRF24/nRF24.h +++ b/src/modules/nRF24/nRF24.h @@ -392,6 +392,13 @@ class nRF24: public PhysicalLayer { */ int16_t getStatus(uint8_t mask = 0xFF); + /*! + \brief Checks if carrier was detected during last RX + + \returns Whatever the carrier was above threshold. + */ + bool isCarrierDetected(); + /*! \brief Dummy configuration method, to ensure PhysicalLayer compatibility. From 959f8751b0dbf03fbbc8f31d046d99d747838aed Mon Sep 17 00:00:00 2001 From: Andrea Guglielmini Date: Wed, 26 Feb 2020 15:55:44 +0100 Subject: [PATCH 06/23] [nRF24] Minor fixes --- src/modules/nRF24/nRF24.cpp | 15 +++++++++------ src/modules/nRF24/nRF24.h | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/modules/nRF24/nRF24.cpp b/src/modules/nRF24/nRF24.cpp index 3bd01719..67985a72 100644 --- a/src/modules/nRF24/nRF24.cpp +++ b/src/modules/nRF24/nRF24.cpp @@ -233,14 +233,9 @@ int16_t nRF24::setFrequency(int16_t freq) { return(ERR_INVALID_FREQUENCY); } - // set mode to standby - int16_t state = standby(); - RADIOLIB_ASSERT(state); - // set frequency uint8_t freqRaw = freq - 2400; - state = _mod->SPIsetRegValue(NRF24_REG_RF_CH, freqRaw, 6, 0); - return(state); + return _mod->SPIsetRegValue(NRF24_REG_RF_CH, freqRaw, 6, 0); } int16_t nRF24::setDataRate(int16_t dataRate) { @@ -335,6 +330,7 @@ int16_t nRF24::setTransmitPipe(uint8_t* addr) { // set Rx pipe 0 address (for ACK) _mod->SPIwriteRegisterBurst(NRF24_REG_RX_ADDR_P0, addr, _addrWidth); + state |= _mod->SPIsetRegValue(NRF24_REG_EN_RXADDR, NRF24_P0_ON, 0, 0); return(state); } @@ -445,6 +441,13 @@ size_t nRF24::getPacketLength(bool update) { } int16_t nRF24::setCrcFiltering(bool crcOn) { + // Auto Ack needs to be disabled in order to disable CRC. + if (!crcOn) { + int16_t status = setAutoAck(false); + RADIOLIB_ASSERT(status) + } + + // Disable CRC return _mod->SPIsetRegValue(NRF24_REG_CONFIG, crcOn ? NRF24_CRC_ON : NRF24_CRC_OFF, 3, 3); } diff --git a/src/modules/nRF24/nRF24.h b/src/modules/nRF24/nRF24.h index 4528c949..3ca3ac75 100644 --- a/src/modules/nRF24/nRF24.h +++ b/src/modules/nRF24/nRF24.h @@ -127,7 +127,7 @@ // NRF24_REG_STATUS #define NRF24_RX_DR 0b01000000 // 6 6 Rx data ready #define NRF24_TX_DS 0b00100000 // 5 5 Tx data sent -#define NRF24_MAX_RT 0b00010000 // 4 4 maximum number of rentransmits reached (must be cleared to continue) +#define NRF24_MAX_RT 0b00010000 // 4 4 maximum number of retransmits reached (must be cleared to continue) #define NRF24_RX_FIFO_EMPTY 0b00001110 // 3 1 Rx FIFO is empty #define NRF24_RX_P_NO 0b00000000 // 3 1 number of data pipe that received data #define NRF24_TX_FIFO_FULL 0b00000001 // 0 0 Tx FIFO is full From c1e4be41b0875a8eed48632aa11c9746fd7526e1 Mon Sep 17 00:00:00 2001 From: Andrea Guglielmini Date: Thu, 27 Feb 2020 20:11:47 +0100 Subject: [PATCH 07/23] [nRF24] Removed ambiguity, PR #119 --- src/modules/nRF24/nRF24.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/nRF24/nRF24.h b/src/modules/nRF24/nRF24.h index 3ca3ac75..70362dfe 100644 --- a/src/modules/nRF24/nRF24.h +++ b/src/modules/nRF24/nRF24.h @@ -445,7 +445,7 @@ class nRF24: public PhysicalLayer { \returns \ref status_codes */ - int16_t setAutoAck(uint8_t pipeNum, bool autoAckOn = true); + int16_t setAutoAck(uint8_t pipeNum, bool autoAckOn); /*! \brief Dummy data shaping configuration method, to ensure PhysicalLayer compatibility. From 1da981a7cd3f6cbb3e20ea3f88bd7cf1b9e625e4 Mon Sep 17 00:00:00 2001 From: Andrea Guglielmini Date: Fri, 10 Apr 2020 12:26:16 +0200 Subject: [PATCH 08/23] [CC1101] Added bitrate caching. --- src/modules/CC1101/CC1101.cpp | 7 ++++++- src/modules/CC1101/CC1101.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 8a04b36b..6b01a9d8 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -401,7 +401,12 @@ int16_t CC1101::setBitRate(float br) { // set bit rate value int16_t state = SPIsetRegValue(CC1101_REG_MDMCFG4, e, 3, 0); state |= SPIsetRegValue(CC1101_REG_MDMCFG3, m); - return(state); + + if (state == ERR_NONE) { + _br = br; + } + + return (state); } int16_t CC1101::setRxBandwidth(float rxBw) { diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index 714b2da4..56062f73 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -871,6 +871,7 @@ class CC1101: public PhysicalLayer { Module* _mod; float _freq; + float _br; uint8_t _rawRSSI; uint8_t _rawLQI; uint8_t _modulation; From 535bce9ac7472dbb5b2214707a5b74012ca52a23 Mon Sep 17 00:00:00 2001 From: Federico Maggi Date: Tue, 14 Jul 2020 10:27:47 +0200 Subject: [PATCH 09/23] Added space --- src/modules/nRF24/nRF24.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/nRF24/nRF24.h b/src/modules/nRF24/nRF24.h index 1e1b3823..2e380984 100644 --- a/src/modules/nRF24/nRF24.h +++ b/src/modules/nRF24/nRF24.h @@ -411,7 +411,6 @@ class nRF24: public PhysicalLayer { */ size_t getPacketLength(bool update = true); - /*! \brief Enable CRC filtering and generation. From 7535faad3279e1d9f58f1d9846b602d4d6b9ed39 Mon Sep 17 00:00:00 2001 From: Federico Maggi Date: Tue, 14 Jul 2020 15:50:55 +0200 Subject: [PATCH 10/23] Fixed conflicts --- src/modules/CC1101/CC1101.h | 8 -------- src/modules/RF69/RF69.cpp | 19 +++++++++++++++++++ src/modules/RF69/RF69.h | 9 +++++++++ src/modules/nRF24/nRF24.cpp | 11 ----------- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index 3ae59291..5f9e3e2d 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -880,18 +880,10 @@ class CC1101: public PhysicalLayer { #endif Module* _mod; -<<<<<<< HEAD - float _freq; - float _br; - uint8_t _rawRSSI; - uint8_t _rawLQI; - uint8_t _modulation; -======= float _freq = 0; uint8_t _rawRSSI = 0; uint8_t _rawLQI = 0; uint8_t _modulation = CC1101_MOD_FORMAT_2_FSK; ->>>>>>> upstream/master size_t _packetLength = 0; bool _packetLengthQueried = false; diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index ddffc532..24002914 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -369,6 +369,25 @@ int16_t RF69::readData(uint8_t* data, size_t len) { return(ERR_NONE); } +int16_t CC1101::setOOK(bool enableOOK) { + // Change modulation + if(enableOOK) { + int16_t state = SPIsetRegValue(RF69_REG_DATA_MODUL, RF69_OOK, 4, 3); + RADIOLIB_ASSERT(state); + + // update current modulation + _modulation = CC1101_MOD_FORMAT_ASK_OOK; + } else { + int16_t state = SPIsetRegValue(RF69_REG_DATA_MODUL, RF69_FSK, 4, 3); + RADIOLIB_ASSERT(state); + + // update current modulation + _modulation = CC1101_MOD_FORMAT_2_FSK; + } + + return(setOutputPower(_power)); +} + int16_t RF69::setFrequency(float freq) { // check allowed frequency range if(!(((freq > 290.0) && (freq < 340.0)) || diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index 63b63513..0f6fe507 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -614,6 +614,15 @@ class RF69: public PhysicalLayer { // configuration methods + /*! + \brief Enables/disables OOK modulation instead of FSK. + + \param enableOOK Enable (true) or disable (false) OOK. + + \returns \ref status_codes + */ + int16_t setOOK(bool enableOOK); + /*! \brief Sets carrier frequency. Allowed values are in bands 290.0 to 340.0 MHz, 431.0 to 510.0 MHz and 862.0 to 1020.0 MHz. diff --git a/src/modules/nRF24/nRF24.cpp b/src/modules/nRF24/nRF24.cpp index 9a8db289..135e75af 100644 --- a/src/modules/nRF24/nRF24.cpp +++ b/src/modules/nRF24/nRF24.cpp @@ -240,22 +240,11 @@ int16_t nRF24::readData(uint8_t* data, size_t len) { } int16_t nRF24::setFrequency(int16_t freq) { -<<<<<<< HEAD - // check allowed range - if(!((freq >= 2400) && (freq <= 2525))) { - return(ERR_INVALID_FREQUENCY); - } - - // set frequency - uint8_t freqRaw = freq - 2400; - return _mod->SPIsetRegValue(NRF24_REG_RF_CH, freqRaw, 6, 0); -======= RADIOLIB_CHECK_RANGE(freq, 2400, 2525, ERR_INVALID_FREQUENCY); // set frequency uint8_t freqRaw = freq - 2400; return(_mod->SPIsetRegValue(NRF24_REG_RF_CH, freqRaw, 6, 0)); ->>>>>>> upstream/master } int16_t nRF24::setDataRate(int16_t dataRate) { From 932921440514875973bdbe9b1577272f1a35c4db Mon Sep 17 00:00:00 2001 From: Alessandro Fiorillo Date: Sat, 28 Nov 2020 00:56:24 +0100 Subject: [PATCH 11/23] Fixed compiling issues --- src/modules/CC1101/CC1101.cpp | 1 - src/modules/CC1101/CC1101.h | 1 + src/modules/RF69/RF69.cpp | 2 ++ src/modules/RF69/RF69.h | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 46e10452..6362937d 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -660,7 +660,6 @@ int16_t CC1101::setOOK(bool enableOOK) { return(setOutputPower(_power)); } - float CC1101::getRSSI() const { float rssi; if(_rawRSSI >= 128) { diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index 5f9e3e2d..af5899bc 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -881,6 +881,7 @@ class CC1101: public PhysicalLayer { Module* _mod; float _freq = 0; + float _br = 0; uint8_t _rawRSSI = 0; uint8_t _rawLQI = 0; uint8_t _modulation = CC1101_MOD_FORMAT_2_FSK; diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index 24002914..ca7920ed 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -369,6 +369,7 @@ int16_t RF69::readData(uint8_t* data, size_t len) { return(ERR_NONE); } +/* int16_t CC1101::setOOK(bool enableOOK) { // Change modulation if(enableOOK) { @@ -387,6 +388,7 @@ int16_t CC1101::setOOK(bool enableOOK) { return(setOutputPower(_power)); } +*/ int16_t RF69::setFrequency(float freq) { // check allowed frequency range diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index 0f6fe507..4752967b 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -621,7 +621,7 @@ class RF69: public PhysicalLayer { \returns \ref status_codes */ - int16_t setOOK(bool enableOOK); + //int16_t setOOK(bool enableOOK); /*! \brief Sets carrier frequency. Allowed values are in bands 290.0 to 340.0 MHz, 431.0 to 510.0 MHz and 862.0 to 1020.0 MHz. From 3d1c45654b6a6127cf5546f9dac03142be0412ea Mon Sep 17 00:00:00 2001 From: Alessandro Fiorillo Date: Wed, 2 Dec 2020 16:43:02 +0100 Subject: [PATCH 12/23] [CC1101] Fix in promiscuous mode --- src/modules/CC1101/CC1101.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 6362937d..24a2ffa8 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -749,6 +749,8 @@ int16_t CC1101::setPromiscuousMode(bool promiscuous) { state = setCrcFiltering(true); } + _promiscuous = promiscuous; + return(state); } From 1787505ea7ac24843683e9a5735672564f447cf9 Mon Sep 17 00:00:00 2001 From: Alessandro Fiorillo Date: Fri, 4 Dec 2020 15:36:58 +0100 Subject: [PATCH 13/23] [RF69] Fixed setOOK() --- src/modules/CC1101/CC1101.cpp | 1 - src/modules/RF69/RF69.cpp | 10 +--------- src/modules/RF69/RF69.h | 2 +- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 24a2ffa8..ba93bdc5 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -641,7 +641,6 @@ int16_t CC1101::setOOK(bool enableOOK) { state = SPIsetRegValue(CC1101_REG_FREND0, 1, 2, 0); RADIOLIB_ASSERT(state); - // update current modulation _modulation = CC1101_MOD_FORMAT_ASK_OOK; } else { diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index ca7920ed..2e7f755e 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -369,26 +369,18 @@ int16_t RF69::readData(uint8_t* data, size_t len) { return(ERR_NONE); } -/* -int16_t CC1101::setOOK(bool enableOOK) { +int16_t RF69::setOOK(bool enableOOK) { // Change modulation if(enableOOK) { int16_t state = SPIsetRegValue(RF69_REG_DATA_MODUL, RF69_OOK, 4, 3); RADIOLIB_ASSERT(state); - - // update current modulation - _modulation = CC1101_MOD_FORMAT_ASK_OOK; } else { int16_t state = SPIsetRegValue(RF69_REG_DATA_MODUL, RF69_FSK, 4, 3); RADIOLIB_ASSERT(state); - - // update current modulation - _modulation = CC1101_MOD_FORMAT_2_FSK; } return(setOutputPower(_power)); } -*/ int16_t RF69::setFrequency(float freq) { // check allowed frequency range diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index 4752967b..0f6fe507 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -621,7 +621,7 @@ class RF69: public PhysicalLayer { \returns \ref status_codes */ - //int16_t setOOK(bool enableOOK); + int16_t setOOK(bool enableOOK); /*! \brief Sets carrier frequency. Allowed values are in bands 290.0 to 340.0 MHz, 431.0 to 510.0 MHz and 862.0 to 1020.0 MHz. From 5b5bc6efb9c0be2cb281d7cf9d44eb0a26b5a214 Mon Sep 17 00:00:00 2001 From: Federico Maggi Date: Tue, 13 Apr 2021 10:07:44 +0200 Subject: [PATCH 14/23] Remove duplicate setOOK() method --- src/modules/RF69/RF69.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index 46ed0ec9..bb0e8009 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -622,15 +622,6 @@ class RF69: public PhysicalLayer { // configuration methods - /*! - \brief Enables/disables OOK modulation instead of FSK. - - \param enableOOK Enable (true) or disable (false) OOK. - - \returns \ref status_codes - */ - int16_t setOOK(bool enableOOK); - /*! \brief Sets carrier frequency. Allowed values are in bands 290.0 to 340.0 MHz, 431.0 to 510.0 MHz and 862.0 to 1020.0 MHz. From f9cc7cefcddf54f4025b59fff33b242ffb533a2a Mon Sep 17 00:00:00 2001 From: Federico Maggi Date: Tue, 13 Apr 2021 10:43:50 +0200 Subject: [PATCH 15/23] Declaring SPI get/set RegValue in line with CC1101 --- src/modules/RF69/RF69.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index bb0e8009..41a149d8 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -874,6 +874,14 @@ class RF69: public PhysicalLayer { #endif Module* _mod; + // SPI read overrides to set bit for burst write and status registers access + int16_t SPIgetRegValue(uint8_t reg, uint8_t msb = 7, uint8_t lsb = 0); + int16_t SPIsetRegValue(uint8_t reg, uint8_t value, uint8_t msb = 7, uint8_t lsb = 0, uint8_t checkInterval = 2); + void SPIreadRegisterBurst(uint8_t reg, uint8_t numBytes, uint8_t* inBytes); + uint8_t SPIreadRegister(uint8_t reg); + void SPIwriteRegisterBurst(uint8_t reg, uint8_t* data, size_t len); + void SPIwriteRegister(uint8_t reg, uint8_t data); + #if !defined(RADIOLIB_GODMODE) protected: #endif From aebe2d2f9868a178c64f246f6d618a0f87079ecc Mon Sep 17 00:00:00 2001 From: Federico Maggi Date: Tue, 13 Apr 2021 12:22:49 +0200 Subject: [PATCH 16/23] Caching carrier frequency --- src/modules/RF69/RF69.cpp | 3 +++ src/modules/RF69/RF69.h | 1 + 2 files changed, 4 insertions(+) diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index e6777e2b..aa5ec80a 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -407,6 +407,9 @@ int16_t RF69::setFrequency(float freq) { _mod->SPIwriteRegister(RF69_REG_FRF_MSB, (FRF & 0xFF0000) >> 16); _mod->SPIwriteRegister(RF69_REG_FRF_MID, (FRF & 0x00FF00) >> 8); _mod->SPIwriteRegister(RF69_REG_FRF_LSB, FRF & 0x0000FF); + + _freq = freq; + return(ERR_NONE); } diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index 41a149d8..ee2564ab 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -886,6 +886,7 @@ class RF69: public PhysicalLayer { protected: #endif + float _freq = 0; float _br = 0; float _rxBw = 0; bool _ook = false; From 012c39e7f59bc1f249022c2775a8c3cb0635d335 Mon Sep 17 00:00:00 2001 From: Federico Maggi Date: Tue, 13 Apr 2021 15:25:28 +0200 Subject: [PATCH 17/23] Addressing PR#279 comments --- .gitignore | 2 +- src/modules/CC1101/CC1101.cpp | 22 +++++++++++++++++++--- src/modules/CC1101/CC1101.h | 9 ++++++++- src/modules/RF69/RF69.cpp | 4 ++++ src/modules/RF69/RF69.h | 11 +++++------ 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 444a1ef0..58d33796 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,4 @@ extras/decoder/log.txt extras/decoder/out.txt # PlatformIO -.pio* \ No newline at end of file +.pio* diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index e096f4dd..5650852a 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -269,7 +269,7 @@ int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) { if (_packetLengthConfig == CC1101_LENGTH_CONFIG_VARIABLE) { // enforce variable len limit. - if (len > 254) { + if (len > CC1101_MAX_PACKET_LENGTH - 1) { return (ERR_PACKET_TOO_LONG); } @@ -307,6 +307,12 @@ int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) { dataSent += bytesToWrite; } else { // wait for radio to send some data. + /* + * Does this work for all rates? If 1 ms is longer than the 1ms delay + * then the entire FIFO will be transmitted during that delay. + * + * TODO: drop this delay(1) or come up with a better solution: + */ delay(1); } } @@ -349,7 +355,7 @@ int16_t CC1101::readData(uint8_t* data, size_t len) { } uint8_t bytesInFIFO = SPIgetRegValue(CC1101_REG_RXBYTES, 6, 0); - uint16_t readBytes = 0; + size_t readBytes = 0; uint32_t lastPop = millis(); // keep reading from FIFO until we get all the packet. @@ -360,6 +366,12 @@ int16_t CC1101::readData(uint8_t* data, size_t len) { RADIOLIB_DEBUG_PRINTLN(F("No data for more than 5mS. Stop here.")); break; } else { + /* + * Does this work for all rates? If 1 ms is longer than the 1ms delay + * then the entire FIFO will be transmitted during that delay. + * + * TODO: drop this delay(1) or come up with a better solution: + */ delay(1); bytesInFIFO = SPIgetRegValue(CC1101_REG_RXBYTES, 6, 0); continue; @@ -392,7 +404,7 @@ int16_t CC1101::readData(uint8_t* data, size_t len) { _rawLQI = val & 0x7F; // check CRC - if (_crcOn && (val & 0b10000000) == 0b00000000) { + if (_crcOn && (val & CC1101_CRC_OK) == CC1101_CRC_ERROR) { return (ERR_CRC_MISMATCH); } } @@ -786,6 +798,10 @@ int16_t CC1101::setPromiscuousMode(bool promiscuous) { return(state); } +bool CC1101::getPromiscuousMode() { + return (_promiscuous); +} + int16_t CC1101::setDataShaping(uint8_t sh) { // set mode to standby int16_t state = standby(); diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index a956c344..55ffaa71 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -602,7 +602,7 @@ class CC1101: public PhysicalLayer { \param dir Signal change direction. Defaults to RISING. */ - void setGdo0Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir = FALLING); + void setGdo0Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir = RISING); /*! \brief Clears interrupt service routine to call when GDO0 activates. @@ -847,6 +847,13 @@ class CC1101: public PhysicalLayer { */ int16_t setPromiscuousMode(bool promiscuous = true); + /*! + \brief Get whether the modem is in promiscuous mode: no packet filtering (e.g., no preamble, sync word, address, CRC). + + \returns Whether the modem is in promiscuous mode + */ + bool getPromiscuousMode(); + /*! \brief Sets Gaussian filter bandwidth-time product that will be used for data shaping. Allowed value is RADIOLIB_SHAPING_0_5. Set to RADIOLIB_SHAPING_NONE to disable data shaping. diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index aa5ec80a..f3b11151 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -910,4 +910,8 @@ void RF69::clearIRQFlags() { _mod->SPIwriteRegister(RF69_REG_IRQ_FLAGS_2, 0b11111111); } +int16_t SPIsetRegValue(uint8_t reg, uint8_t value, uint8_t msb = 7, uint8_t lsb = 0, uint8_t checkInterval = 2) { + return (_mod->SPIsetRegValue(reg, value, msb, lsb, checkInterval)); +} + #endif diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index ee2564ab..789f19e4 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -874,13 +874,12 @@ class RF69: public PhysicalLayer { #endif Module* _mod; - // SPI read overrides to set bit for burst write and status registers access - int16_t SPIgetRegValue(uint8_t reg, uint8_t msb = 7, uint8_t lsb = 0); + /*! + \brief Proxy to _mod->SPIsetRegValue (to avoid exposing _mod) + + \returns \ref status code + */ int16_t SPIsetRegValue(uint8_t reg, uint8_t value, uint8_t msb = 7, uint8_t lsb = 0, uint8_t checkInterval = 2); - void SPIreadRegisterBurst(uint8_t reg, uint8_t numBytes, uint8_t* inBytes); - uint8_t SPIreadRegister(uint8_t reg); - void SPIwriteRegisterBurst(uint8_t reg, uint8_t* data, size_t len); - void SPIwriteRegister(uint8_t reg, uint8_t data); #if !defined(RADIOLIB_GODMODE) protected: From f18d75a853882a69e78ccaa5c9824d64cebf851c Mon Sep 17 00:00:00 2001 From: Federico Maggi Date: Tue, 13 Apr 2021 15:27:25 +0200 Subject: [PATCH 18/23] Missing RF69:: --- src/modules/RF69/RF69.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index f3b11151..a05a6d31 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -910,7 +910,7 @@ void RF69::clearIRQFlags() { _mod->SPIwriteRegister(RF69_REG_IRQ_FLAGS_2, 0b11111111); } -int16_t SPIsetRegValue(uint8_t reg, uint8_t value, uint8_t msb = 7, uint8_t lsb = 0, uint8_t checkInterval = 2) { +int16_t RF69::SPIsetRegValue(uint8_t reg, uint8_t value, uint8_t msb = 7, uint8_t lsb = 0, uint8_t checkInterval = 2) { return (_mod->SPIsetRegValue(reg, value, msb, lsb, checkInterval)); } From 6f783d5fc02fcc8f5e6f11b7d529f3e56a416402 Mon Sep 17 00:00:00 2001 From: Federico Maggi Date: Tue, 13 Apr 2021 16:15:33 +0200 Subject: [PATCH 19/23] RFQuack's fork of RadioLib has LOW_LEVEL mode on by default --- src/BuildOpt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index eba3cca5..547640d6 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -405,7 +405,7 @@ * This will make some hardware methods like SPI get/set accessible from the user sketch - think of it as "god mode lite" * Warning: RadioLib won't stop you from writing invalid stuff into your device, so it's quite easy to brick your module with this. */ -//#define RADIOLIB_LOW_LEVEL +#define RADIOLIB_LOW_LEVEL /* * Uncomment to enable pre-defined modules when using RadioShield. From f5f722e30f41cf300b4b130ddb5b7694293883f2 Mon Sep 17 00:00:00 2001 From: Federico Maggi Date: Tue, 13 Apr 2021 16:15:39 +0200 Subject: [PATCH 20/23] No need to use _mod --- src/modules/RF69/RF69.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index a05a6d31..aa5ec80a 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -910,8 +910,4 @@ void RF69::clearIRQFlags() { _mod->SPIwriteRegister(RF69_REG_IRQ_FLAGS_2, 0b11111111); } -int16_t RF69::SPIsetRegValue(uint8_t reg, uint8_t value, uint8_t msb = 7, uint8_t lsb = 0, uint8_t checkInterval = 2) { - return (_mod->SPIsetRegValue(reg, value, msb, lsb, checkInterval)); -} - #endif From 24216c00edf553ff952c517aa005903f08ceddc6 Mon Sep 17 00:00:00 2001 From: Federico Maggi Date: Wed, 21 Apr 2021 23:38:49 +0200 Subject: [PATCH 21/23] Commenting RADIOLIB_LOW_LEVEL --- src/BuildOpt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 547640d6..eba3cca5 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -405,7 +405,7 @@ * This will make some hardware methods like SPI get/set accessible from the user sketch - think of it as "god mode lite" * Warning: RadioLib won't stop you from writing invalid stuff into your device, so it's quite easy to brick your module with this. */ -#define RADIOLIB_LOW_LEVEL +//#define RADIOLIB_LOW_LEVEL /* * Uncomment to enable pre-defined modules when using RadioShield. From 12975b23e543fc11396bc2a75e182f2aac1b90bb Mon Sep 17 00:00:00 2001 From: Federico Maggi Date: Wed, 21 Apr 2021 23:39:11 +0200 Subject: [PATCH 22/23] delay(1) -> delayMicroseconds(250) --- src/modules/CC1101/CC1101.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 5650852a..4fe96dbf 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -311,9 +311,9 @@ int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) { * Does this work for all rates? If 1 ms is longer than the 1ms delay * then the entire FIFO will be transmitted during that delay. * - * TODO: drop this delay(1) or come up with a better solution: + * TODO: test this on real hardware */ - delay(1); + delayMicroseconds(250); } } @@ -388,9 +388,6 @@ int16_t CC1101::readData(uint8_t* data, size_t len) { bytesInFIFO = SPIgetRegValue(CC1101_REG_RXBYTES, 6, 0); } - // add terminating null - data[readBytes] = 0; - // check if status bytes are enabled (default: CC1101_APPEND_STATUS_ON) bool isAppendStatus = SPIgetRegValue(CC1101_REG_PKTCTRL1, 2, 2) == CC1101_APPEND_STATUS_ON; From 871a0fe34f8c9fcfe0606257248c460dba8e04eb Mon Sep 17 00:00:00 2001 From: Federico Maggi Date: Wed, 21 Apr 2021 23:39:25 +0200 Subject: [PATCH 23/23] Removed SPIsetRegValue --- src/modules/RF69/RF69.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index 789f19e4..fab56900 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -874,13 +874,6 @@ class RF69: public PhysicalLayer { #endif Module* _mod; - /*! - \brief Proxy to _mod->SPIsetRegValue (to avoid exposing _mod) - - \returns \ref status code - */ - int16_t SPIsetRegValue(uint8_t reg, uint8_t value, uint8_t msb = 7, uint8_t lsb = 0, uint8_t checkInterval = 2); - #if !defined(RADIOLIB_GODMODE) protected: #endif