Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: DISCO-L072CZ-LRWAN1_LoRa_PingPong DISCO-L072CZ-LRWAN1_LoRa_PingPong DISCO-L072CZ-LRWAN1_LoRa_PingPong DISCO-L072CZ-LRWAN1_LoRa_USB_Rx ... more
Fork of SX1276Lib by
Revision 83:019da451b283, committed 2017-08-06
- Comitter:
- Helmut Tschemernjak
- Date:
- Sun Aug 06 14:23:43 2017 +0200
- Parent:
- 82:b93c4169ce41
- Child:
- 84:3428e25c7157
- Commit message:
- Added GetFrequencyError API support
Changed in this revision
--- a/LoRa_TODO.txt Sun Aug 06 11:28:33 2017 +0200 +++ b/LoRa_TODO.txt Sun Aug 06 14:23:43 2017 +0200 @@ -44,3 +44,7 @@ level protocols - Added initial Arduino support, needs more testing/completion. - Support for Arduino completed, initial version works. +- Added GetFrequency support + The Murata’s Frequency shift using an TCXO us about 58 Hz + The RFM95 against Murata is about 3300 Hz + RFM95 against RFM95 testing will follow.
--- a/radio/radio.h Sun Aug 06 11:28:33 2017 +0200
+++ b/radio/radio.h Sun Aug 06 14:23:43 2017 +0200
@@ -431,6 +431,13 @@
virtual int16_t GetRssi ( RadioModems_t modem ) = 0;
/*!
+ * @brief Reads the current frequency error
+ *
+ * @retval frequency error value in [Hz]
+ */
+ virtual int32_t GetFrequencyError( RadioModems_t modem ) = 0;
+
+ /*!
* @brief Writes the radio register at the specified address
*
* @param [IN]: addr Register address
--- a/sx1276/sx1276.cpp Sun Aug 06 11:28:33 2017 +0200
+++ b/sx1276/sx1276.cpp Sun Aug 06 14:23:43 2017 +0200
@@ -632,10 +632,10 @@
case LORA_BANKWIDTH_20kHz: // 20.8 kHz
bw = 208e2;
break;
- case LORA_BANKWIDTH_31kHz: // 31.2 kHz
+ case LORA_BANKWIDTH_31kHz: // 31.25 kHz
bw = 312e2;
break;
- case LORA_BANKWIDTH_41kHz: // 41.4 kHz
+ case LORA_BANKWIDTH_41kHz: // 41.7 kHz
bw = 414e2;
break;
case LORA_BANKWIDTH_62kHz: // 62.5 kHz
@@ -851,7 +851,7 @@
Write( REG_LR_TEST2F, 0x44 );
SetChannel(this->settings.Channel + 20.83e3 );
break;
- case LORA_BANKWIDTH_31kHz: // 31.2 kHz
+ case LORA_BANKWIDTH_31kHz: // 31.25 kHz
Write( REG_LR_TEST2F, 0x44 );
SetChannel(this->settings.Channel + 31.25e3 );
break;
@@ -1113,6 +1113,36 @@
return rssi;
}
+int32_t SX1276::GetFrequencyError(RadioModems_t modem )
+{
+ int32_t val = 0;
+
+ if (modem != MODEM_LORA)
+ return 0;
+
+ val = (Read(REG_LR_FEIMSB) & 0b1111) << 16; // high word, 4 valid bits only
+ val |= (Read(REG_LR_FEIMID) << 8) | Read(REG_LR_FEILSB); // high byte, low byte
+ if (val & 0x8000) //sconvert ign bit
+ val |= 0xfff00000;
+
+ int32_t bandwidth = 0;
+ for (int i = 0; i < (int)(sizeof(LoRaBandwidths) / sizeof(BandwidthMap)) -1; i++ ) {
+ if (LoRaBandwidths[i].RegValue == this->settings.LoRa.Bandwidth) {
+ bandwidth = LoRaBandwidths[i].bandwidth;
+ break;
+ }
+ }
+ if (!bandwidth)
+ return 0;
+
+ float bandWidthkHz = (float)bandwidth/1000;
+
+ int32_t hz = (((float)val * (float)(1<<24)) / ((float)XTAL_FREQ)) * (bandWidthkHz / 500.0);
+
+ return hz;
+}
+
+
void SX1276::SetOpMode( uint8_t opMode )
{
if( opMode == RF_OPMODE_SLEEP )
--- a/sx1276/sx1276.h Sun Aug 06 11:28:33 2017 +0200
+++ b/sx1276/sx1276.h Sun Aug 06 14:23:43 2017 +0200
@@ -384,7 +384,14 @@
* @retval rssiValue Current RSSI value in [dBm]
*/
virtual int16_t GetRssi ( RadioModems_t modem );
-
+
+ /*!
+ * @brief Reads the current frequency error
+ *
+ * @retval frequency error value in [Hz]
+ */
+ virtual int32_t GetFrequencyError( RadioModems_t modem );
+
/*!
* @brief Writes the radio register at the specified address
*

