Fix SX1280 init

This commit is contained in:
Thomas Göttgens 2022-11-10 23:00:01 +01:00
parent 5c59c8d701
commit 74f31d7d68
4 changed files with 17 additions and 13 deletions

View File

@ -87,8 +87,6 @@ uint8_t kb_model;
// The I2C address of the RTC Module (if found) // The I2C address of the RTC Module (if found)
uint8_t rtc_found; uint8_t rtc_found;
bool rIf_wide_lora = false;
// Keystore Chips // Keystore Chips
uint8_t keystore_found; uint8_t keystore_found;
#ifndef ARCH_PORTDUINO #ifndef ARCH_PORTDUINO
@ -385,7 +383,6 @@ void setup()
rIf = NULL; rIf = NULL;
} else { } else {
DEBUG_MSG("SX1280 Radio init succeeded, using SX1280 radio\n"); DEBUG_MSG("SX1280 Radio init succeeded, using SX1280 radio\n");
rIf_wide_lora = true;
} }
} }
#endif #endif

View File

@ -17,7 +17,6 @@ extern uint8_t kb_model;
extern uint8_t rtc_found; extern uint8_t rtc_found;
extern uint8_t keystore_found; extern uint8_t keystore_found;
extern bool rIf_wide_lora;
extern bool eink_found; extern bool eink_found;
extern bool pmu_found; extern bool pmu_found;
extern bool isCharging; extern bool isCharging;

View File

@ -365,37 +365,37 @@ void RadioInterface::applyModemConfig()
switch (loraConfig.modem_preset) { switch (loraConfig.modem_preset) {
case Config_LoRaConfig_ModemPreset_SHORT_FAST: case Config_LoRaConfig_ModemPreset_SHORT_FAST:
bw = (myRegion->wideLora && rIf_wide_lora) ? 800 : 250; bw = (myRegion->wideLora) ? 812.5 : 250;
cr = 8; cr = 8;
sf = 7; sf = 7;
break; break;
case Config_LoRaConfig_ModemPreset_SHORT_SLOW: case Config_LoRaConfig_ModemPreset_SHORT_SLOW:
bw = (myRegion->wideLora && rIf_wide_lora) ? 800 : 250; bw = (myRegion->wideLora) ? 812.5 : 250;
cr = 8; cr = 8;
sf = 8; sf = 8;
break; break;
case Config_LoRaConfig_ModemPreset_MEDIUM_FAST: case Config_LoRaConfig_ModemPreset_MEDIUM_FAST:
bw = (myRegion->wideLora && rIf_wide_lora) ? 800 : 250; bw = (myRegion->wideLora) ? 812.5 : 250;
cr = 8; cr = 8;
sf = 9; sf = 9;
break; break;
case Config_LoRaConfig_ModemPreset_MEDIUM_SLOW: case Config_LoRaConfig_ModemPreset_MEDIUM_SLOW:
bw = (myRegion->wideLora && rIf_wide_lora) ? 800 : 250; bw = (myRegion->wideLora) ? 812.5 : 250;
cr = 8; cr = 8;
sf = 10; sf = 10;
break; break;
case Config_LoRaConfig_ModemPreset_LONG_FAST: case Config_LoRaConfig_ModemPreset_LONG_FAST:
bw = (myRegion->wideLora && rIf_wide_lora) ? 800 : 250; bw = (myRegion->wideLora) ? 812.5 : 250;
cr = 8; cr = 8;
sf = 11; sf = 11;
break; break;
case Config_LoRaConfig_ModemPreset_LONG_SLOW: case Config_LoRaConfig_ModemPreset_LONG_SLOW:
bw = (myRegion->wideLora && rIf_wide_lora) ? 400 : 125; bw = (myRegion->wideLora) ? 406.25 : 125;
cr = 8; cr = 8;
sf = 12; sf = 12;
break; break;
case Config_LoRaConfig_ModemPreset_VERY_LONG_SLOW: case Config_LoRaConfig_ModemPreset_VERY_LONG_SLOW:
bw = (myRegion->wideLora && rIf_wide_lora) ? 200 : 31.25; bw = (myRegion->wideLora) ? 203.125 : 31.25;
cr = 8; cr = 8;
sf = 12; sf = 12;
break; break;
@ -411,6 +411,14 @@ void RadioInterface::applyModemConfig()
bw = 31.25; bw = 31.25;
if (bw == 62) // Fix for 62.5Khz bandwidth if (bw == 62) // Fix for 62.5Khz bandwidth
bw = 62.5; bw = 62.5;
if (bw == 200)
bw = 203.125;
if (bw == 400)
bw = 406.25;
if (bw == 800)
bw = 812.5;
if (bw == 1600)
bw = 1625.0;
} }
power = loraConfig.tx_power; power = loraConfig.tx_power;
@ -443,7 +451,7 @@ void RadioInterface::applyModemConfig()
DEBUG_MSG("Set radio: region=%s, name=%s, config=%u, ch=%d, power=%d\n", myRegion->name, channelName, loraConfig.modem_preset, channel_num, power); DEBUG_MSG("Set radio: region=%s, name=%s, config=%u, ch=%d, power=%d\n", myRegion->name, channelName, loraConfig.modem_preset, channel_num, power);
DEBUG_MSG("Radio myRegion->freqStart / myRegion->freqEnd: %f -> %f (%f mhz)\n", myRegion->freqStart, myRegion->freqEnd, myRegion->freqEnd - myRegion->freqStart); DEBUG_MSG("Radio myRegion->freqStart / myRegion->freqEnd: %f -> %f (%f mhz)\n", myRegion->freqStart, myRegion->freqEnd, myRegion->freqEnd - myRegion->freqStart);
DEBUG_MSG("Radio myRegion->numChannels: %d\n", numChannels); DEBUG_MSG("Radio myRegion->numChannels: %d x %.3fkHz\n", numChannels, bw);
DEBUG_MSG("Radio channel_num: %d\n", channel_num); DEBUG_MSG("Radio channel_num: %d\n", channel_num);
DEBUG_MSG("Radio frequency: %f\n", getFreq()); DEBUG_MSG("Radio frequency: %f\n", getFreq());
DEBUG_MSG("Slot time: %u msec\n", slotTimeMsec); DEBUG_MSG("Slot time: %u msec\n", slotTimeMsec);

View File

@ -61,7 +61,7 @@ bool SX128xInterface<T>::init()
#endif #endif
if (res == RADIOLIB_ERR_NONE) if (res == RADIOLIB_ERR_NONE)
res = lora.setCRC(RADIOLIB_SX128X_LORA_CRC_ON); res = lora.setCRC(2);
if (res == RADIOLIB_ERR_NONE) if (res == RADIOLIB_ERR_NONE)
startReceive(); // start receiving startReceive(); // start receiving