From fa29ace8da61b6737acd27bc26f9eaa844806353 Mon Sep 17 00:00:00 2001 From: mverdy Date: Wed, 4 Jul 2018 10:32:01 +0200 Subject: [PATCH 01/15] Remove the malloc behavior in SX1276 driver. Remove an unused preprocessor define --- radio/SX1276Lib/sx1276/sx1276.cpp | 2 -- radio/SX1276Lib/sx1276/sx1276.h | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/radio/SX1276Lib/sx1276/sx1276.cpp b/radio/SX1276Lib/sx1276/sx1276.cpp index fe431f3..dc9750d 100644 --- a/radio/SX1276Lib/sx1276/sx1276.cpp +++ b/radio/SX1276Lib/sx1276/sx1276.cpp @@ -32,7 +32,6 @@ Maintainer : Olivier Gimenez (SEMTECH) #define FSK_MAX_MODEM_PAYLOAD 64 #define FSK_THRESHOLD_REFILL_LIMIT 32 #define LORAWAN_MIN_PACKET_SIZE 9 -#define MAX_PAYLOAD_SIZE 255 #define FSK_FAKE_IRQ_THRESHOLD 2 @@ -45,7 +44,6 @@ isFakeIrq(false), fakeIrqFlag(RADIO_IRQ_NONE), pinCS( nss ), pinReset( reset ), mcu.SetValueDigitalOutPin ( pinCS, 1); mcu.Init_Irq ( TxRxIt ) ; mcu.Init_Irq ( RxTimeOutIt ) ; - rxBuffer = (uint8_t*) malloc(MAX_PAYLOAD_SIZE); rxPayloadSize = 0; } diff --git a/radio/SX1276Lib/sx1276/sx1276.h b/radio/SX1276Lib/sx1276/sx1276.h index 58106bf..20b0d24 100644 --- a/radio/SX1276Lib/sx1276/sx1276.h +++ b/radio/SX1276Lib/sx1276/sx1276.h @@ -56,7 +56,7 @@ class SX1276 { uint32_t Channel; private: - uint8_t* rxBuffer; + uint8_t rxBuffer[RX_BUFFER_SIZE]; uint8_t rxPayloadSize; bool isFakeIrq; IrqFlags_t fakeIrqFlag; From c6d10fbed614d1081c001059ee8609c8e78212db Mon Sep 17 00:00:00 2001 From: mverdy Date: Wed, 4 Jul 2018 10:33:11 +0200 Subject: [PATCH 02/15] Modify the while true of fsk rx to first wait and then check the status registers --- radio/SX1276Lib/sx1276/sx1276.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/radio/SX1276Lib/sx1276/sx1276.cpp b/radio/SX1276Lib/sx1276/sx1276.cpp index dc9750d..ec0ddb7 100644 --- a/radio/SX1276Lib/sx1276/sx1276.cpp +++ b/radio/SX1276Lib/sx1276/sx1276.cpp @@ -244,12 +244,16 @@ void SX1276::RxFsk(uint32_t channel, uint16_t timeOutMs) { SetFifoThreshold(LORAWAN_MIN_PACKET_SIZE - 1); SetOpMode( RF_OPMODE_RECEIVER ); - while(!IsFskFifoLevelReached()) { - wait_ms(2); + while(true) { + mcu.mwait_ms(5); if(this->HasTimeouted()) { this->SetAndGenerateFakeIRQ(RXTIMEOUT_IRQ_FLAG); return; } + if(this->IsFskFifoLevelReached()){ + break; + } + mcu.mwait_ms(5); } ReadFifo( &firstBytesRx[0], LORAWAN_MIN_PACKET_SIZE ); rxPayloadSize = firstBytesRx[0]; From c88d811e94d8888ef3d07c3910164bfd4ec816f0 Mon Sep 17 00:00:00 2001 From: mverdy Date: Wed, 4 Jul 2018 10:35:01 +0200 Subject: [PATCH 03/15] Add a debug print dedicated to tx with FSK and fix the coding style of the debug printf for lora --- MinimouseSrc/PhyLayer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MinimouseSrc/PhyLayer.cpp b/MinimouseSrc/PhyLayer.cpp index 9955df0..84573ed 100644 --- a/MinimouseSrc/PhyLayer.cpp +++ b/MinimouseSrc/PhyLayer.cpp @@ -73,11 +73,12 @@ template void RadioContainer ::Send(eModulationType TxModulation , Radio->Reset( ); if ( TxModulation == LORA ) { InsertTrace ( __COUNTER__, FileId ); - DEBUG_PRINTF ( " TxFrequency = %d, RxSf = %d , RxBw = %d PayloadSize = %d\n", TxFrequency, TxSf,TxBw, TxPayloadSize) ; + DEBUG_PRINTF ( " TxFrequency = %d, RxSf = %d , RxBw = %d PayloadSize = %d\n", TxFrequency, TxSf,TxBw, TxPayloadSize); Radio->SendLora( TxPhyPayload, TxPayloadSize, TxSf, TxBw, TxFrequency, TxPower ); } else { InsertTrace ( __COUNTER__, FileId ); DEBUG_MSG("FSK TRANSMISSION \n"); + DEBUG_PRINTF ( " TxFrequency = %d, PayloadSize = %d\n", TxFrequency, TxPayloadSize); Radio->SendFsk( TxPhyPayload, TxPayloadSize, TxFrequency, TxPower ); } mcu.mwait_ms(1); From d9a4173998b0a55682dafb08b3b1abde304d74eb Mon Sep 17 00:00:00 2001 From: mverdy Date: Wed, 4 Jul 2018 10:35:53 +0200 Subject: [PATCH 04/15] Fix some conding styles in Define header --- MinimouseSrc/Define.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MinimouseSrc/Define.h b/MinimouseSrc/Define.h index 6675a39..50cd2fa 100644 --- a/MinimouseSrc/Define.h +++ b/MinimouseSrc/Define.h @@ -154,7 +154,7 @@ enum { typedef enum{ RADIO_IRQ_NONE = 0x00, - SENT_PACKET_IRQ_FLAG = 0x20, + SENT_PACKET_IRQ_FLAG = 0x20, RECEIVE_PACKET_IRQ_FLAG = 0x40, BAD_PACKET_IRQ_FLAG = 0x60, RXTIMEOUT_IRQ_FLAG = 0x80, @@ -215,16 +215,19 @@ typedef enum { ERROR_CHANNEL_MASK = -1, OKCHANNEL = 0, }eStatusChannel; + typedef enum { NO_MORE_VALID_RX_PACKET, USERRX_FOPTSPACKET, NWKRXPACKET, JOIN_ACCEPT_PACKET, } eRxPacketType; + typedef enum { RX1, RX2 }eRxWinType; + /*************************/ /* SHARE WITH USER */ /*************************/ @@ -271,4 +274,3 @@ typedef struct sLoRaWanKeys { eDeviceTypeOTA_APB OtaDevice; }sLoRaWanKeys; #endif - From 0f07e14ce8bafebc7c4c04aec434c6c190aaeaff Mon Sep 17 00:00:00 2001 From: mverdy Date: Wed, 4 Jul 2018 10:37:30 +0200 Subject: [PATCH 05/15] Modify the datarates distribution structure definition to handle FSK --- MinimouseSrc/Regions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MinimouseSrc/Regions.cpp b/MinimouseSrc/Regions.cpp index d1fe859..4ad834d 100644 --- a/MinimouseSrc/Regions.cpp +++ b/MinimouseSrc/Regions.cpp @@ -282,8 +282,8 @@ template < class R >void LoraRegionsEU::RegionSetDataRateDistribution( uint8_ this->MacNbTrans = 1; break; case USER_DR_DISTRIBUTION: //in this example 1/3 dr5 1/3 dr4 and 1/3 dr0 - DistriDataRateInit[7] = 0; - DistriDataRateInit[6] = ( ( USER_DR_DISTRIBUTION_PARAMETERS )& ( 0x000000F0 ) ) >> 4; //fsk + DistriDataRateInit[7] = USER_DR_DISTRIBUTION_PARAMETERS & 0x0000000F; //fsk + DistriDataRateInit[6] = ( ( USER_DR_DISTRIBUTION_PARAMETERS )& ( 0x000000F0 ) ) >> 4; DistriDataRateInit[5] = ( ( USER_DR_DISTRIBUTION_PARAMETERS )& ( 0x00000F00 ) ) >> 8; DistriDataRateInit[4] = ( ( USER_DR_DISTRIBUTION_PARAMETERS )& ( 0x0000F000 ) ) >> 12; DistriDataRateInit[3] = ( ( USER_DR_DISTRIBUTION_PARAMETERS )& ( 0x000F0000 ) ) >> 16; From be3d18117c8606c7e92b53b6b7100033a9f11c1b Mon Sep 17 00:00:00 2001 From: mverdy Date: Fri, 6 Jul 2018 18:07:42 +0200 Subject: [PATCH 06/15] Add method in MacLayer to compute the rx window parameters for FSK. Modify the configuration to use the FSK or LORA rx parameters depending on the last tx modulation. Fix some coding style --- MinimouseSrc/MacLayer.cpp | 19 ++++++++++++++++--- MinimouseSrc/MacLayer.h | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/MinimouseSrc/MacLayer.cpp b/MinimouseSrc/MacLayer.cpp index ab7e0e1..1ea0cf5 100644 --- a/MinimouseSrc/MacLayer.cpp +++ b/MinimouseSrc/MacLayer.cpp @@ -135,13 +135,18 @@ template void LoraWanContainer::Configure template void LoraWanContainer::ConfigureTimerForRx ( eRxWinType type ) { InsertTrace ( __COUNTER__, FileId ); - uint32_t tCurrentMillisec; + uint32_t tCurrentMillisec; uint32_t tAlarmMillisec; tCurrentMillisec = mcu.RtcGetTimeMs( ); if (type == RX1) { RegionSetRxConfig ( RX1 ); - ComputeRxWindowParameters ( MacRx1SfCurrent, MacRx1BwCurrent, CRYSTAL_ERROR, MacRx1Delay * 1000 , BOARD_DELAY_RX_SETTING_MS ); + if( MacTxModulationCurrent == LORA ){ + ComputeRxWindowParameters(MacRx1SfCurrent, MacRx1BwCurrent, CRYSTAL_ERROR, MacRx1Delay * 1000 , BOARD_DELAY_RX_SETTING_MS); + } + else{ + ComputeRxWindowParametersFSK(CRYSTAL_ERROR, MacRx1Delay * 1000 , BOARD_DELAY_RX_SETTING_MS); + } tAlarmMillisec = ( ( MacRx1Delay * 1000 )+ Phy.TimestampRtcIsr ) - tCurrentMillisec ; if ( (int)(tAlarmMillisec - RxOffsetMs) < 0 ) {// too late to launch a timer Phy.StateRadioProcess = RADIOSTATE_RX1FINISHED ; @@ -904,10 +909,11 @@ template int LoraWanContainer::FindEnabl } return (-1) ; // for error case }; + template void LoraWanContainer::ComputeRxWindowParameters( uint8_t SF, eBandWidth BW, uint32_t ClockAccuracy, uint32_t RxDelayMs, uint8_t BoardDelayRxMs) { // ClockAccuracy is set in Define.h, it is board dependent. It must be equal to error in per thousand InsertTrace ( __COUNTER__, FileId ); - uint32_t RxErrorMs= ( ClockAccuracy * RxDelayMs ) / 1000; // for example with an clockaccuracy = 30 (3%) and a rx windows set to 5s => rxerror = 150 ms + uint32_t RxErrorMs= ( ClockAccuracy * RxDelayMs ) / 1000; // for example with an clockaccuracy = 30 (3%) and a rx windows set to 5s => rxerror = 150 ms int bwTemp = 125* ( BW + 1 ); double tSymbol = (double) (1< void LoraWanContainer::ComputeR RxOffsetMs = ( int32_t )((ceil( ( 4.0 * tSymbol ) - ( ( MacRxWindowSymb * tSymbol ) / 2.0 ) - BoardDelayRxMs ))*(-1)); MacRxWindowMs = MacRxWindowSymb * tSymbol ; }; + + +template void LoraWanContainer::ComputeRxWindowParametersFSK(uint32_t ClockAccuracy, uint32_t RxDelayMs, uint8_t BoardDelayRxMs) { + uint32_t RxErrorMs= ( ClockAccuracy * RxDelayMs ) / 1000; + MacRxWindowMs = 2 + 2*RxErrorMs; // Exact formula is 1.3 + 2*RxErrorMs + RxOffsetMs = MacRxWindowMs >> 1; +}; diff --git a/MinimouseSrc/MacLayer.h b/MinimouseSrc/MacLayer.h index fb17a22..4b6f2b9 100644 --- a/MinimouseSrc/MacLayer.h +++ b/MinimouseSrc/MacLayer.h @@ -221,6 +221,7 @@ void SetAlarm ( uint32_t alarmInMs ,eRxWinType type ); void DicChannelParser ( void ); void UpdateDataRateForAdr ( void ); void ComputeRxWindowParameters ( uint8_t SF, eBandWidth BW, uint32_t ClockAccuracy, uint32_t RxDelayMs ,uint8_t BoardDelayRxMs ); + void ComputeRxWindowParametersFSK(uint32_t ClockAccuracy, uint32_t RxDelayMs, uint8_t BoardDelayRxMs); sBackUpFlash BackUpFlash; uint8_t NwkPayloadIndex ; uint8_t RxEmptyPayload ; From 520dc2f989729c06345f22961754c283a3565019 Mon Sep 17 00:00:00 2001 From: mverdy Date: Tue, 10 Jul 2018 09:37:20 +0200 Subject: [PATCH 07/15] Use a software timeout instead of the one from the radio for FSK Rx operation --- radio/SX1276Lib/sx1276/sx1276.cpp | 29 ++++++++++++++++++++++++----- radio/SX1276Lib/sx1276/sx1276.h | 2 ++ 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/radio/SX1276Lib/sx1276/sx1276.cpp b/radio/SX1276Lib/sx1276/sx1276.cpp index ec0ddb7..a825447 100644 --- a/radio/SX1276Lib/sx1276/sx1276.cpp +++ b/radio/SX1276Lib/sx1276/sx1276.cpp @@ -236,6 +236,8 @@ void SX1276::RxFsk(uint32_t channel, uint16_t timeOutMs) { uint8_t remainingBytes = 0; uint8_t firstBytesRx[LORAWAN_MIN_PACKET_SIZE] = {0x00}; uint8_t payloadChunkSize = FSK_THRESHOLD_REFILL_LIMIT; + uint32_t timeoutExpectedMS = 0x00000000; + bool preamble_detected = false; SetOpModeFsk( RF_OPMODE_MODULATIONTYPE_FSK, RFLR_OPMODE_FREQMODE_ACCESS_LF, RF_OPMODE_SLEEP ); SetRfFrequency( channel ); @@ -244,16 +246,27 @@ void SX1276::RxFsk(uint32_t channel, uint16_t timeOutMs) { SetFifoThreshold(LORAWAN_MIN_PACKET_SIZE - 1); SetOpMode( RF_OPMODE_RECEIVER ); + timeoutExpectedMS = mcu.RtcGetTimeMs() + timeOutMs; while(true) { - mcu.mwait_ms(5); - if(this->HasTimeouted()) { - this->SetAndGenerateFakeIRQ(RXTIMEOUT_IRQ_FLAG); - return; + if(mcu.RtcGetTimeMs() > timeoutExpectedMS) { + if(this->HasDetectedPreamble() && !preamble_detected){ + // A timeout has been detected so a payload might be in the process of being received. + // Allocate here the amount of time required to receive the 3 bytes of address and the + // LORAWAN_MIN_PACKET_SIZE that should trigger the FifoLevelReached. + timeoutExpectedMS += 2; + DEBUG_MSG(" ...Timeout but preamble detected...\n"); + preamble_detected = true; + } + else{ + this->Sleep(false); + this->SetAndGenerateFakeIRQ(RXTIMEOUT_IRQ_FLAG); + return; + } } + mcu.mwait_ms(5); if(this->IsFskFifoLevelReached()){ break; } - mcu.mwait_ms(5); } ReadFifo( &firstBytesRx[0], LORAWAN_MIN_PACKET_SIZE ); rxPayloadSize = firstBytesRx[0]; @@ -371,6 +384,12 @@ bool SX1276::HasTimeouted() { return (irqFlags & 0x04); } +bool SX1276::HasDetectedPreamble() { + uint8_t irqFlags = 0x00; + Read(REG_IRQFLAGS1, &irqFlags, 1); + return (irqFlags & 0x02); +} + void SX1276::GetPacketStatusLora( int16_t *pktRssi, int16_t *snr, int16_t *signalRssi ) { *snr = ((int16_t) Read( REG_LR_PKTSNRVALUE ))/4; int16_t rssi = (int16_t) Read( REG_LR_PKTRSSIVALUE ); diff --git a/radio/SX1276Lib/sx1276/sx1276.h b/radio/SX1276Lib/sx1276/sx1276.h index 20b0d24..29ba06d 100644 --- a/radio/SX1276Lib/sx1276/sx1276.h +++ b/radio/SX1276Lib/sx1276/sx1276.h @@ -109,6 +109,8 @@ class SX1276 { */ bool HasTimeouted( void ); + bool HasDetectedPreamble(void); + bool IsPayloadReady(void); int8_t GetCurrentRssi(void); From 3e86710075f66f8d0be15324d3511d3d16732bbe Mon Sep 17 00:00:00 2001 From: mverdy Date: Tue, 10 Jul 2018 09:38:34 +0200 Subject: [PATCH 08/15] Remove the radio timeout configuration for Rx FSK operation --- radio/SX1276Lib/sx1276/sx1276.cpp | 9 +++++---- radio/SX1276Lib/sx1276/sx1276.h | 3 +-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/radio/SX1276Lib/sx1276/sx1276.cpp b/radio/SX1276Lib/sx1276/sx1276.cpp index a825447..47e0bd7 100644 --- a/radio/SX1276Lib/sx1276/sx1276.cpp +++ b/radio/SX1276Lib/sx1276/sx1276.cpp @@ -241,8 +241,7 @@ void SX1276::RxFsk(uint32_t channel, uint16_t timeOutMs) { SetOpModeFsk( RF_OPMODE_MODULATIONTYPE_FSK, RFLR_OPMODE_FREQMODE_ACCESS_LF, RF_OPMODE_SLEEP ); SetRfFrequency( channel ); - uint8_t symbTimeout = timeOutMs / 0.32; // 0.32 = 16 * 1/50000 -> See datasheet for TimeoutRxPreamble - SetModulationParamsRxFsk( symbTimeout ); + SetModulationParamsRxFsk( ); SetFifoThreshold(LORAWAN_MIN_PACKET_SIZE - 1); SetOpMode( RF_OPMODE_RECEIVER ); @@ -495,7 +494,7 @@ void SX1276::SetModulationParamsTxFsk( ) { Write( REG_DIOMAPPING2, 0x00 ); } -void SX1276::SetModulationParamsRxFsk( uint8_t symbTimeout ) { +void SX1276::SetModulationParamsRxFsk( void ) { this->SetModulationParamsCommonFsk(); this->ConfigureRssi(); Write( REG_DIOMAPPING1, RF_DIOMAPPING1_DIO0_10 | RF_DIOMAPPING1_DIO1_11 | RF_DIOMAPPING1_DIO2_10 | RF_DIOMAPPING1_DIO3_01 ); @@ -508,7 +507,9 @@ void SX1276::SetModulationParamsRxFsk( uint8_t symbTimeout ) { Write( REG_AFCFEI, RF_AFCFEI_AFCAUTOCLEAR_ON ); Write( REG_LNA, RF_LNA_GAIN_G1 | RF_LNA_BOOST_ON ); Write( REG_PAYLOADLENGTH, 0xFF ); - Write( REG_RXTIMEOUT2, symbTimeout ); + Write( REG_RXTIMEOUT1, 0x00 ); + Write( REG_RXTIMEOUT2, 0x00 ); + Write( REG_RXTIMEOUT3, 0x00 ); } void SX1276::SetModulationParamsRxLora( uint8_t SF, eBandWidth BW, uint16_t symbTimeout ) { diff --git a/radio/SX1276Lib/sx1276/sx1276.h b/radio/SX1276Lib/sx1276/sx1276.h index 29ba06d..30d8640 100644 --- a/radio/SX1276Lib/sx1276/sx1276.h +++ b/radio/SX1276Lib/sx1276/sx1276.h @@ -188,9 +188,8 @@ class SX1276 { /*! * \brief Set the modulation parameters for Rx with FSK - * @param [IN] symbTimeout : number of symbols before raising the timeout interrupt */ - void SetModulationParamsRxFsk( uint8_t symbTimeout ); + void SetModulationParamsRxFsk( void ); /*! * \brief Set the RF frequency From f137d6286965df719398c38474c5d76f5d26048b Mon Sep 17 00:00:00 2001 From: mverdy Date: Tue, 10 Jul 2018 09:42:03 +0200 Subject: [PATCH 09/15] Modify the Rx FSK method to handle the case where payload length is inferior to maximal FSK FIFO length. Modify the receiving sequence so that there is no need for a firstByteReceived buffer --- radio/SX1276Lib/sx1276/sx1276.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/radio/SX1276Lib/sx1276/sx1276.cpp b/radio/SX1276Lib/sx1276/sx1276.cpp index 47e0bd7..512b6a8 100644 --- a/radio/SX1276Lib/sx1276/sx1276.cpp +++ b/radio/SX1276Lib/sx1276/sx1276.cpp @@ -234,7 +234,6 @@ void SX1276::RxFsk(uint32_t channel, uint16_t timeOutMs) { rxPayloadSize = 0; uint8_t bytesReceived = 0; uint8_t remainingBytes = 0; - uint8_t firstBytesRx[LORAWAN_MIN_PACKET_SIZE] = {0x00}; uint8_t payloadChunkSize = FSK_THRESHOLD_REFILL_LIMIT; uint32_t timeoutExpectedMS = 0x00000000; bool preamble_detected = false; @@ -267,27 +266,27 @@ void SX1276::RxFsk(uint32_t channel, uint16_t timeOutMs) { break; } } - ReadFifo( &firstBytesRx[0], LORAWAN_MIN_PACKET_SIZE ); - rxPayloadSize = firstBytesRx[0]; bytesReceived = LORAWAN_MIN_PACKET_SIZE - 1; // -1 because the first one is the payload size, which is not included into the payload - memcpy(rxBuffer, firstBytesRx + 1, bytesReceived); + ReadFifo( &rxPayloadSize, 1 ); + ReadFifo( rxBuffer, bytesReceived ); remainingBytes = rxPayloadSize - bytesReceived; - SetFifoThreshold(payloadChunkSize - 1); - while(remainingBytes > payloadChunkSize) { - while(!IsFskFifoLevelReached()) { - wait_ms(2); + if(rxPayloadSize > (FSK_MAX_MODEM_PAYLOAD - 1)){ + SetFifoThreshold(payloadChunkSize - 1); + while(remainingBytes > payloadChunkSize) { + while(!IsFskFifoLevelReached()) { + wait_ms(3); + } + ReadFifo( &rxBuffer[0] + bytesReceived, payloadChunkSize ); + bytesReceived += payloadChunkSize; + remainingBytes = rxPayloadSize - bytesReceived; } - ReadFifo( rxBuffer + bytesReceived, payloadChunkSize ); - bytesReceived += payloadChunkSize; - remainingBytes = rxPayloadSize - bytesReceived; } - SetFifoThreshold(remainingBytes - 1); while(!IsPayloadReady()) { wait_ms(2); } - ReadFifo( rxBuffer + bytesReceived, remainingBytes ); + ReadFifo( &rxBuffer[0] + bytesReceived, remainingBytes ); lastPacketRssi = this->GetCurrentRssi(); this->Sleep(false); this->SetAndGenerateFakeIRQ(RECEIVE_PACKET_IRQ_FLAG); From c63761131393fa88dba6b82d4522f15f179bdfb8 Mon Sep 17 00:00:00 2001 From: mverdy Date: Tue, 10 Jul 2018 09:42:45 +0200 Subject: [PATCH 10/15] Clean some coding rules in sx1276.h --- radio/SX1276Lib/sx1276/sx1276.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/radio/SX1276Lib/sx1276/sx1276.h b/radio/SX1276Lib/sx1276/sx1276.h index 30d8640..11a595e 100644 --- a/radio/SX1276Lib/sx1276/sx1276.h +++ b/radio/SX1276Lib/sx1276/sx1276.h @@ -173,10 +173,8 @@ class SX1276 { * \brief Set the modulation parameters for FSK Tx * @see SX1276::SetPowerParamsTx, SX1276::SetRfFrequency */ - void SetModulationParamsTxFsk( void ); - - //void SetModulationParamsRxFsk( uint8_t symbTimeout ); - void SetModulationParamsCommonFsk( void ); + void SetModulationParamsTxFsk( void ); + void SetModulationParamsCommonFsk( void ); /*! * \brief Set the modulation parameters for Rx with Lora @@ -217,7 +215,7 @@ class SX1276 { * \param [IN] lowFrequencyModeOn * \param [IN] opMode */ - void SetOpModeFsk( uint8_t modulationType, uint8_t lowFrequencyModeOn, uint8_t opMode ); + void SetOpModeFsk( uint8_t modulationType, uint8_t lowFrequencyModeOn, uint8_t opMode ); /*! * \brief Sets the radio opmode for FSK operations @@ -234,7 +232,7 @@ class SX1276 { * \brief Sets the radio opmode * @param [IN] opMode mode to put the radio into */ - void SetOpMode( uint8_t opMode ); + void SetOpMode( uint8_t opMode ); /*! * \brief Write Payload inside the sx1276 fifo From 129e0a887720987cdeeadef30e34b2a3ce008361 Mon Sep 17 00:00:00 2001 From: mverdy Date: Tue, 10 Jul 2018 09:43:28 +0200 Subject: [PATCH 11/15] Set the fifo level for sx1276 FSK to the default value --- radio/SX1276Lib/sx1276/sx1276.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/SX1276Lib/sx1276/sx1276.cpp b/radio/SX1276Lib/sx1276/sx1276.cpp index 512b6a8..7347c0d 100644 --- a/radio/SX1276Lib/sx1276/sx1276.cpp +++ b/radio/SX1276Lib/sx1276/sx1276.cpp @@ -30,7 +30,7 @@ Maintainer : Olivier Gimenez (SEMTECH) #define FSK_PREAMBLE_LSB_LORAWAN_REG_VALUE 0x05 #define FSK_SYNCWORD_LORAWAN_REG_VALUE 0xC194C1 #define FSK_MAX_MODEM_PAYLOAD 64 -#define FSK_THRESHOLD_REFILL_LIMIT 32 +#define FSK_THRESHOLD_REFILL_LIMIT 0x0F #define LORAWAN_MIN_PACKET_SIZE 9 #define FSK_FAKE_IRQ_THRESHOLD 2 From 5f73aabb96b8a0de3397c1ae5be935ddfc3a5ea1 Mon Sep 17 00:00:00 2001 From: mverdy Date: Tue, 10 Jul 2018 10:23:45 +0200 Subject: [PATCH 12/15] Add the Rx1 and Rx2 current modulation members to MacLayer class. Modify the RegionSetRxConfig and modify the call to PhyLayer SetRxConfig to compute and use these members --- MinimouseSrc/MacLayer.cpp | 12 +++++++++--- MinimouseSrc/MacLayer.h | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/MinimouseSrc/MacLayer.cpp b/MinimouseSrc/MacLayer.cpp index 1ea0cf5..091df01 100644 --- a/MinimouseSrc/MacLayer.cpp +++ b/MinimouseSrc/MacLayer.cpp @@ -119,7 +119,7 @@ template void LoraWanContainer::Configure template void LoraWanContainer::ConfigureRadioForRx1 ( void ) { InsertTrace ( __COUNTER__, FileId ); - Phy.SetRxConfig(MacTxModulationCurrent,MacRx1FrequencyCurrent, MacRx1SfCurrent, MacRx1BwCurrent, MacRxWindowMs); + Phy.SetRxConfig(MacRx1ModulationCurrent, MacRx1FrequencyCurrent, MacRx1SfCurrent, MacRx1BwCurrent, MacRxWindowMs); }; /************************************************************************************************************************************/ /* ConfigureRadioForRx2 + ConfigureTimerForRx */ @@ -129,7 +129,7 @@ template void LoraWanContainer::Configure template void LoraWanContainer::ConfigureRadioForRx2 ( void ) { InsertTrace ( __COUNTER__, FileId ); - Phy.SetRxConfig(MacTxModulationCurrent, MacRx2Frequency, MacRx2SfCurrent, MacRx2BwCurrent, MacRxWindowMs ); + Phy.SetRxConfig(MacRx2ModulationCurrent, MacRx2Frequency, MacRx2SfCurrent, MacRx2BwCurrent, MacRxWindowMs ); }; @@ -141,7 +141,7 @@ template void LoraWanContainer::Configure if (type == RX1) { RegionSetRxConfig ( RX1 ); - if( MacTxModulationCurrent == LORA ){ + if( MacRx1ModulationCurrent == LORA ){ ComputeRxWindowParameters(MacRx1SfCurrent, MacRx1BwCurrent, CRYSTAL_ERROR, MacRx1Delay * 1000 , BOARD_DELAY_RX_SETTING_MS); } else{ @@ -156,6 +156,12 @@ template void LoraWanContainer::Configure } } else { RegionSetRxConfig ( RX2 ); + if( MacRx2ModulationCurrent == LORA ){ + ComputeRxWindowParameters(MacRx2SfCurrent, MacRx2BwCurrent, CRYSTAL_ERROR, MacRx1Delay * 1000 , BOARD_DELAY_RX_SETTING_MS); + } + else{ + ComputeRxWindowParametersFSK(CRYSTAL_ERROR, MacRx1Delay * 1000 , BOARD_DELAY_RX_SETTING_MS); + } ComputeRxWindowParameters ( MacRx2SfCurrent, MacRx2BwCurrent, CRYSTAL_ERROR, MacRx1Delay * 1000 + 1000 , BOARD_DELAY_RX_SETTING_MS ); tAlarmMillisec = ( MacRx1Delay * 1000 ) + 1000 + Phy.TimestampRtcIsr - tCurrentMillisec ;// @note Rx2 Dalay is alway RX1DELAY + 1 second if ( (int)(tAlarmMillisec - RxOffsetMs) < 0 ) {// too late to launch a timer diff --git a/MinimouseSrc/MacLayer.h b/MinimouseSrc/MacLayer.h index 4b6f2b9..2346f94 100644 --- a/MinimouseSrc/MacLayer.h +++ b/MinimouseSrc/MacLayer.h @@ -193,8 +193,10 @@ protected : eBandWidth MacTxBwCurrent; uint32_t MacTxFrequencyCurrent; uint32_t MacRx1FrequencyCurrent; + eModulationType MacRx1ModulationCurrent; uint8_t MacRx1SfCurrent; eBandWidth MacRx1BwCurrent; + eModulationType MacRx2ModulationCurrent; uint8_t MacRx2SfCurrent; eBandWidth MacRx2BwCurrent; int FindEnabledChannel ( uint8_t Index); From f59281415625ce7f62e7f1253e3c01ad861a45ae Mon Sep 17 00:00:00 2001 From: mverdy Date: Tue, 10 Jul 2018 10:34:49 +0200 Subject: [PATCH 13/15] Update the EU region to handle the Rx config depending on Tx datarate and Rx1Offset for RX1 window. Update the TxDatarateToSfBw and Rx2DatarateToSfBw to handle the case of FSK... --- MinimouseSrc/Regions.cpp | 52 +++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/MinimouseSrc/Regions.cpp b/MinimouseSrc/Regions.cpp index 4ad834d..193d23f 100644 --- a/MinimouseSrc/Regions.cpp +++ b/MinimouseSrc/Regions.cpp @@ -170,8 +170,14 @@ template < class R >eStatusLoRaWan LoraRegionsEU::RegionMaxPayloadSize ( uint template < class R >void LoraRegionsEU::RegionSetRxConfig ( eRxWinType type ) { InsertTrace ( __COUNTER__, FileId ); if ( type == RX1 ) { - this->MacRx1SfCurrent = ( this->MacTxSfCurrent < 12 - this->MacRx1DataRateOffset) ? this->MacTxSfCurrent + this->MacRx1DataRateOffset : 12; - this->MacRx1BwCurrent = this->MacTxBwCurrent; + if( this->MacTxModulationCurrent == FSK && this->MacRx1DataRateOffset == 0){ + this->MacRx1ModulationCurrent = FSK; + } + else{ + this->MacRx1ModulationCurrent = LORA; + this->MacRx1SfCurrent = ( this->MacTxSfCurrent < 12 - this->MacRx1DataRateOffset) ? this->MacTxSfCurrent + this->MacRx1DataRateOffset : 12; + this->MacRx1BwCurrent = this->MacTxBwCurrent; + } } else if ( type == RX2 ) { Rx2DataRateToSfBw ( this->MacRx2DataRate ); } else { @@ -530,36 +536,38 @@ template < class R >void LoraRegionsEU::RegionSetBadCrcInFlash ( void ){ /***********************************************************************************************/ //@notereview function a commun template < class R >void LoraRegionsEU:: TxDataRateToSfBw ( uint8_t dataRate ) { - InsertTrace ( __COUNTER__, FileId ); - this->MacTxModulationCurrent = LORA ; + InsertTrace ( __COUNTER__, FileId ); + this->MacTxModulationCurrent = LORA; if ( dataRate < 6 ){ - this->MacTxSfCurrent = 12 - dataRate ; - this->MacTxBwCurrent = BW125 ; + this->MacTxSfCurrent = 12 - dataRate; + this->MacTxBwCurrent = BW125; } else if ( dataRate == 6 ){ this->MacTxSfCurrent = 7; - this->MacTxBwCurrent = BW250 ;} - else if ( dataRate == 7 ) { - this->MacTxModulationCurrent = FSK ; + this->MacTxBwCurrent = BW250; + } else if ( dataRate == 7 ) { + this->MacTxModulationCurrent = FSK; } else { - this->MacTxSfCurrent = 12 ; - this->MacTxBwCurrent = BW125 ; - DEBUG_MSG( " Invalid Datarate \n" ) ; + this->MacTxSfCurrent = 12; + this->MacTxBwCurrent = BW125; + DEBUG_MSG( " Invalid Datarate \n" ); } } template < class R >void LoraRegionsEU:: Rx2DataRateToSfBw ( uint8_t dataRate ) { InsertTrace ( __COUNTER__, FileId ); - if ( dataRate < 6 ){ - this->MacRx2SfCurrent = 12 - dataRate ; - this->MacRx2BwCurrent = BW125 ; - } else if ( dataRate== 6 ){ + if ( dataRate < 6 ){ + this->MacRx2ModulationCurrent = LORA; + this->MacRx2SfCurrent = 12 - dataRate; + this->MacRx2BwCurrent = BW125; + } else if ( dataRate== 6 ){ + this->MacRx2ModulationCurrent = LORA; this->MacRx2SfCurrent = 7; - this->MacRx2BwCurrent = BW250 ;} - else if ( dataRate == 7 ) { - //@note tbd manage fsk case } + this->MacRx2BwCurrent = BW250; + } else if ( dataRate == 7 ) { + this->MacRx2ModulationCurrent = FSK; } else { - this->MacRx2SfCurrent = 12 ; - this->MacRx2BwCurrent = BW125 ; - DEBUG_MSG( " Invalid Datarate \n" ) ; + this->MacRx2SfCurrent = 12; + this->MacRx2BwCurrent = BW125; + DEBUG_MSG( " Invalid Datarate \n" ); } } From ffcc3962168eecee386b7130dbc859c0e7ca54c3 Mon Sep 17 00:00:00 2001 From: mverdy Date: Thu, 12 Jul 2018 09:43:22 +0200 Subject: [PATCH 14/15] Integrate LoRaWan FSK to sx126x: fix the parameters value, add the correct whitening seed. Fix an issue with preivous modification of LoRa modulation parameters --- radio/SX126X/SX126x.cpp | 128 ++++++++++++++++++++++------------------ radio/SX126X/SX126x.h | 8 +-- 2 files changed, 75 insertions(+), 61 deletions(-) diff --git a/radio/SX126X/SX126x.cpp b/radio/SX126X/SX126x.cpp index 9356cf4..80ebf57 100644 --- a/radio/SX126X/SX126x.cpp +++ b/radio/SX126X/SX126x.cpp @@ -23,9 +23,9 @@ Maintainer : Olivier Gimenez (SEMTECH) #define FSK_DATARATE_MOD_PARAMETER 0x005000 // = 32 * Fxtal / 50kbps #define FSK_PULSE_SHAPE_MOD_PARAMETER 0x09 // : Gaussian BT 0.5 #define FSK_RX_BW_MOD_PARAMETER 0x13 // : 93.8kHz DSB ==> ~ 50kHz SSB -#define FSK_FDEV_MOD_PARAMETER 0x006666 // = 25kHz * 2^25 / Fxtal +#define FSK_FDEV_MOD_PARAMETER 0x005D22 // = 25kHz * Fxtal / 2^25 -#define FSK_PREAMBLE_LENGTH_PACKET_PARAMETER 0x0005 +#define FSK_PREAMBLE_LENGTH_PACKET_PARAMETER 40 #define FSK_PREAMBLE_DETECTOR_LENGTH_PACKET_PARAMETER 0x05 // : Preamble detector over 2 Bytes #define FSK_SYNC_WORD_LENGTH_PACKET_PARAMETER 0x18 // : 3 Bytes #define FSK_ADDRESS_COMP_PACKET_PARAMETER 0x00 // : Address filtering disabled @@ -40,6 +40,7 @@ Maintainer : Olivier Gimenez (SEMTECH) #define REG_CRCSEEDBASEADDR 0x06bc #define REG_CRCPOLYBASEADDR 0x06be #define REG_SYNCWORDBASEADDRESS 0x06c0 +#define REG_WHITSEEDBASEADDR_MSB 0x06B8 /************************************************************************************************ * Public Methods * @@ -157,7 +158,7 @@ void SX126x::SendLora( //CalibrateImage( channel ); SetRfFrequency( channel ); SetModulationParamsLora( SF, BW ); - SetPacketParamsLora( payloadSize ); + SetPacketParamsLora( payloadSize, IQ_STANDARD ); SetTxParams( power ); WriteRegisters( REG_LORA_SYNC_WORD_MSB, ( uint8_t * ) this->LoraSyncword, 2 ); // Send the payload to the radio @@ -167,52 +168,53 @@ void SX126x::SendLora( ClearIrqStatus( IRQ_RADIO_ALL ); // Configure IRQ SetDioIrqParams( - 0xFFFF, - 0xFFFF, - IRQ_RADIO_NONE, - IRQ_RADIO_NONE - ); + 0xFFFF, + 0xFFFF, + IRQ_RADIO_NONE, + IRQ_RADIO_NONE + ); ClearIrqStatus( IRQ_RADIO_ALL ); - + // Send ! No timeout here as it is already handled by the MAC SetTx( 0 ); } void SX126x::SendFsk( - uint8_t *payload, - uint8_t payloadSize, - uint32_t channel, - int8_t power - ) { + uint8_t *payload, + uint8_t payloadSize, + uint32_t channel, + int8_t power + ) { //! \warning: FSK is under still test and not officialy supported on this driver // Init radio - Reset( ); SetRegulatorMode( USE_DCDC ); SetDio2AsRfSwitchCtrl( true ); - SetStandby( STDBY_XOSC ); + SetStandby( STDBY_RC ); // Configure the radio SetPacketType( FSK ); - //CalibrateImage( channel ); + // CalibrateImage( channel ); SetRfFrequency( channel ); - SetModulationParamsFsk( ); - SetPacketParamsFsk( payloadSize ); - ConfigureCrcCCITT(); SetTxParams( power ); - SetSyncWordFskLorawan(); - // Send the payload to the radio SetBufferBaseAddress( 0, 0 ); + // Send the payload to the radio WriteBuffer( 0, payload, payloadSize ); + SetModulationParamsFsk( ); + SetPacketParamsFsk( payloadSize ); + ConfigureCrcCCITT(); + SetSyncWordFskLorawan(); + + SetWhiteningSeedFSK( 0x01FF ); ClearIrqStatus( IRQ_RADIO_ALL ); // Configure IRQ SetDioIrqParams( - 0xFFFF, - 0xFFFF, - IRQ_RADIO_NONE, - IRQ_RADIO_NONE - ); + 0xFFFF, + 0xFFFF, + IRQ_RADIO_NONE, + IRQ_RADIO_NONE + ); ClearIrqStatus( IRQ_RADIO_ALL ); // Send ! No timeout here as it is already handled by the MAC @@ -221,49 +223,50 @@ void SX126x::SendFsk( // @TODO: SetRxBoosted ? void SX126x::RxLora( - eBandWidth BW, - uint8_t SF, - uint32_t channel, - uint32_t rxTimeoutMs - ) { - + eBandWidth BW, + uint8_t SF, + uint32_t channel, + uint32_t rxTimeoutMs + ) { + uint8_t val = 0; // Configure the radio SetPacketType( LORA ); SetRfFrequency( channel ); SetModulationParamsLora( SF, BW ); - SetPacketParamsLora( 0 ); + SetPacketParamsLora( 0, IQ_INVERTED ); StopTimerOnPreamble( true ); WriteRegisters( REG_LORA_SYNC_WORD_MSB, ( uint8_t * ) this->LoraSyncword, 2 ); // Configure IRQ SetDioIrqParams( - IRQ_RX_DONE | IRQ_CRC_ERROR | IRQ_RX_TX_TIMEOUT, - IRQ_RX_DONE | IRQ_CRC_ERROR | IRQ_RX_TX_TIMEOUT, - IRQ_RADIO_NONE, - IRQ_RADIO_NONE - ); + IRQ_RX_DONE | IRQ_CRC_ERROR | IRQ_RX_TX_TIMEOUT, + IRQ_RX_DONE | IRQ_CRC_ERROR | IRQ_RX_TX_TIMEOUT, + IRQ_RADIO_NONE, + IRQ_RADIO_NONE + ); ClearIrqStatus( IRQ_RADIO_ALL ); + SetRx( rxTimeoutMs << 6 ); } void SX126x::RxFsk( - uint32_t channel, - uint32_t rxTimeoutMs - ) { + uint32_t channel, + uint32_t rxTimeoutMs + ) { //! \warning: FSK is under still test and not officialy supported on this driver // Configure the radio SetPacketType( FSK ); SetRfFrequency( channel ); SetModulationParamsFsk(); - SetPacketParamsFsk( 0 ); + SetPacketParamsFsk( 0xFF ); StopTimerOnPreamble( true ); - SetSyncWordFskLorawan(); + SetSyncWordFskLorawan(); // Configure IRQ SetDioIrqParams( - IRQ_RX_DONE | IRQ_CRC_ERROR | IRQ_RX_TX_TIMEOUT, - IRQ_RX_DONE | IRQ_CRC_ERROR | IRQ_RX_TX_TIMEOUT, - IRQ_RADIO_NONE, - IRQ_RADIO_NONE - ); + IRQ_RX_DONE | IRQ_CRC_ERROR | IRQ_RX_TX_TIMEOUT, + IRQ_RX_DONE | IRQ_CRC_ERROR | IRQ_RX_TX_TIMEOUT, + IRQ_RADIO_NONE, + IRQ_RADIO_NONE + ); ClearIrqStatus( IRQ_RADIO_ALL ); SetRx( rxTimeoutMs << 6 ); } @@ -469,14 +472,14 @@ void SX126x::SetModulationParamsFsk( ) { WriteCommand( SET_MODULATION_PARAMS, buf, 8 ); } -void SX126x::SetPacketParamsLora( uint8_t payloadSize ) { +void SX126x::SetPacketParamsLora( uint8_t payloadSize, InvertIQ_t iq_type ) { uint8_t buf[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; buf[0] = 0x00; // Preamble of 0x08 symbols buf[1] = 0x08; buf[2] = 0x00; // Explicit header (Variable packet length) buf[3] = payloadSize; buf[4] = 0x01; // Uplink: CRC ON - buf[5] = IQ_STANDARD; // Uplink: Standard IQ + buf[5] = iq_type; // Uplink: Standard IQ WriteCommand( SET_PACKET_PARAMS, buf, 6 ); } @@ -488,7 +491,7 @@ void SX126x::SetPacketParamsFsk( uint8_t payloadSize ) { buf[3] = FSK_SYNC_WORD_LENGTH_PACKET_PARAMETER; buf[4] = FSK_ADDRESS_COMP_PACKET_PARAMETER; buf[5] = FSK_PACKET_TYPE_PACKET_PARAMETER; - buf[6] = FSK_PAYLOAD_LENGTH_PACKET_PARAMETER; + buf[6] = payloadSize; buf[7] = FSK_CRC_TYPE_PACKET_PARAMETER; buf[8] = FSK_WHITENING_PACKET_PARAMETER; WriteCommand( SET_PACKET_PARAMS, buf, 9 ); @@ -496,7 +499,7 @@ void SX126x::SetPacketParamsFsk( uint8_t payloadSize ) { void SX126x::ConfigureCrcCCITT(void) { this->SetCrcSeedFskCCITT( ); - this->SetCrcPolynomialFskCCITT( ); + this->SetCrcPolynomialFskCCITT( ); } void SX126x::SetCrcSeedFskCCITT(void) { @@ -517,15 +520,18 @@ void SX126x::SetCrcPolynomialFskCCITT(void) { void SX126x::SetSyncWordFskLorawan(void) { WriteRegister( REG_SYNCWORDBASEADDRESS, ( FSK_SYNCWORD_LORAWAN_REG_VALUE >> 16 ) & 0x0000FF ); - WriteRegister( REG_SYNCWORDBASEADDRESS, ( FSK_SYNCWORD_LORAWAN_REG_VALUE >> 8 ) & 0x0000FF ); - WriteRegister( REG_SYNCWORDBASEADDRESS, FSK_SYNCWORD_LORAWAN_REG_VALUE & 0x0000FF ); + WriteRegister( REG_SYNCWORDBASEADDRESS + 1, ( FSK_SYNCWORD_LORAWAN_REG_VALUE >> 8 ) & 0x0000FF ); + WriteRegister( REG_SYNCWORDBASEADDRESS + 2, FSK_SYNCWORD_LORAWAN_REG_VALUE & 0x0000FF ); } void SX126x::SetPacketType( eModulationType modulation ) { + uint8_t mod = 0; if ( modulation == LORA ) { - uint8_t mod = 1; - WriteCommand( SET_PACKET_TYPE, ( uint8_t* )&mod, 1 ); + mod = 1; + } else if (modulation == FSK ) { + mod = 0; } + WriteCommand( SET_PACKET_TYPE, ( uint8_t* )&mod, 1 ); } void SX126x::SetPaConfig( @@ -678,3 +684,11 @@ void SX126x::WriteRegister( uint16_t address, uint8_t value ){ this->WriteRegisters( address, &value, 1 ); } +void SX126x::SetWhiteningSeedFSK( uint16_t seed ) +{ + uint8_t regValue = 0; + regValue = ReadRegister( REG_WHITSEEDBASEADDR_MSB ) & 0xFE; + regValue = ( ( seed >> 8 ) & 0x01 ) | regValue; + WriteRegister( REG_WHITSEEDBASEADDR_MSB, regValue ); // only 1 bit. + WriteRegister( REG_WHITSEEDBASEADDR_MSB + 1, ( uint8_t )seed ); +} diff --git a/radio/SX126X/SX126x.h b/radio/SX126X/SX126x.h index aca2047..3b1b916 100644 --- a/radio/SX126X/SX126x.h +++ b/radio/SX126X/SX126x.h @@ -283,15 +283,14 @@ class SX126x { * \brief Sets the packet parameters for LORA */ void SetPacketParamsLora( - uint8_t payloadSize + uint8_t payloadSize, + InvertIQ_t iq_type ); /*! * \brief Sets the packet parameters for FSK */ - void SetPacketParamsFsk( - uint8_t payloadSize - ); + void SetPacketParamsFsk( uint8_t payloadSize ); /*! * \brief Sets the transmission parameters @@ -411,6 +410,7 @@ class SX126x { void SetCrcSeedFskCCITT(void); void SetCrcPolynomialFskCCITT(void); void SetSyncWordFskLorawan(void); + void SetWhiteningSeedFSK( uint16_t seed ); }; #endif From acaa568ccef3539399f6d7fafb5786e88547a177 Mon Sep 17 00:00:00 2001 From: mverdy Date: Thu, 12 Jul 2018 18:48:32 +0200 Subject: [PATCH 15/15] Modify SX1276 driver to fix a buffer size and make use of mcu.mwait_ms instead of direct wait_ms call --- radio/SX1276Lib/sx1276/sx1276.cpp | 2 +- radio/SX1276Lib/sx1276/sx1276.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/radio/SX1276Lib/sx1276/sx1276.cpp b/radio/SX1276Lib/sx1276/sx1276.cpp index 650063f..8a0db7f 100644 --- a/radio/SX1276Lib/sx1276/sx1276.cpp +++ b/radio/SX1276Lib/sx1276/sx1276.cpp @@ -275,7 +275,7 @@ void SX1276::RxFsk(uint32_t channel, uint16_t timeOutMs) { SetFifoThreshold(payloadChunkSize - 1); while(remainingBytes > payloadChunkSize) { while(!IsFskFifoLevelReached()) { - wait_ms(3); + mcu.mwait_ms(3); } ReadFifo( &rxBuffer[0] + bytesReceived, payloadChunkSize ); bytesReceived += payloadChunkSize; diff --git a/radio/SX1276Lib/sx1276/sx1276.h b/radio/SX1276Lib/sx1276/sx1276.h index 11a595e..04dae01 100644 --- a/radio/SX1276Lib/sx1276/sx1276.h +++ b/radio/SX1276Lib/sx1276/sx1276.h @@ -26,7 +26,7 @@ Maintainer : Olivier Gimenez (SEMTECH) #define XTAL_FREQ 32000000 #define FREQ_STEP 61.03515625 #define FREQ_STEP_8 15625 /* FREQ_STEP<<8 */ -#define RX_BUFFER_SIZE 256 +#define RX_BUFFER_SIZE 255 /*! * Constant values need to compute the RSSI value