Skip to content

Commit

Permalink
SX12xx and CC13x2 radios: align legacy protocol carrier frequency set…
Browse files Browse the repository at this point in the history
…ting with Nordic nRF905 100 kHz (LF) or 200 kHz (HF) resolution (step)
  • Loading branch information
lyusupov committed Feb 5, 2024
1 parent 967f977 commit 83c25ee
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion software/firmware/source/SoftRF/src/driver/RF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,15 @@ static void sx12xx_channel(int8_t channel)
uint32_t frequency = RF_FreqPlan.getChanFrequency((uint8_t) channel);
int8_t fc = settings->freq_corr;

if (LMIC.protocol->type == RF_PROTOCOL_LEGACY) {
nRF905_band_t nrf_band;
uint32_t nrf_freq_resolution;

nrf_band = (frequency >= 844800000UL ? NRF905_BAND_868 : NRF905_BAND_433);
nrf_freq_resolution = (nrf_band == NRF905_BAND_433 ? 100000UL : 200000UL);
frequency -= (frequency % nrf_freq_resolution);
}

//Serial.print("frequency: "); Serial.println(frequency);

if (sx12xx_receive_active) {
Expand All @@ -892,7 +901,7 @@ static void sx12xx_channel(int8_t channel)
}

#if defined(ENABLE_PROL)
if (settings->rf_protocol == RF_PROTOCOL_APRS) {
if (LMIC.protocol->type == RF_PROTOCOL_APRS) {
frequency = 433775000UL;
}
#endif /* ENABLE_PROL */
Expand Down Expand Up @@ -1847,6 +1856,15 @@ static void cc13xx_channel(int8_t channel)
channel != cc13xx_channel_prev) {
uint32_t frequency = RF_FreqPlan.getChanFrequency((uint8_t) channel);

if (settings->rf_protocol == RF_PROTOCOL_LEGACY) {
nRF905_band_t nrf_band;
uint32_t nrf_freq_resolution;

nrf_band = (frequency >= 844800000UL ? NRF905_BAND_868 : NRF905_BAND_433);
nrf_freq_resolution = (nrf_band == NRF905_BAND_433 ? 100000UL : 200000UL);
frequency -= (frequency % nrf_freq_resolution);
}

if (cc13xx_receive_active) {
/* restart Rx upon a channel switch */
EasyLink_abort();
Expand Down

0 comments on commit 83c25ee

Please sign in to comment.