[SX127x] Add emulated Rx single mode (#1496)

pull/1515/head
jgromes 2025-05-27 21:43:59 +02:00
rodzic f00395b5b7
commit 6495247bbf
1 zmienionych plików z 21 dodań i 7 usunięć

Wyświetl plik

@ -1175,12 +1175,21 @@ RadioLibTime_t SX127x::getTimeOnAir(size_t len) {
} }
RadioLibTime_t SX127x::calculateRxTimeout(RadioLibTime_t timeoutUs) { RadioLibTime_t SX127x::calculateRxTimeout(RadioLibTime_t timeoutUs) {
// the timeout is given as the number of symbols RadioLibTime_t timeout = 0;
// the calling function should provide some extra width, as this number of symbols is truncated to integer if(getActiveModem() == RADIOLIB_SX127X_LORA) {
// the order of operators is swapped here to decrease the effects of this truncation error // for LoRa, the timeout is given as the number of symbols
float symbolLength = (float) (uint32_t(1) << this->spreadingFactor) / (float) this->bandwidth; // the calling function should provide some extra width, as this number of symbols is truncated to integer
RadioLibTime_t numSymbols = (timeoutUs / symbolLength) / 1000; // the order of operators is swapped here to decrease the effects of this truncation error
return(numSymbols); float symbolLength = (float) (uint32_t(1) << this->spreadingFactor) / (float) this->bandwidth;
timeout = (timeoutUs / symbolLength) / 1000;
} else {
// for FSK, the timeout is in units of 16x bit time
timeout = ((float)timeoutUs / ((16.0f * 1000.0f) / this->bitRate));
}
return(timeout);
} }
uint32_t SX127x::getIrqFlags() { uint32_t SX127x::getIrqFlags() {
@ -1696,10 +1705,15 @@ int16_t SX127x::stageMode(RadioModeType_t mode, RadioModeConfig_t* cfg) {
RADIOLIB_ASSERT(state); RADIOLIB_ASSERT(state);
} else if(modem == RADIOLIB_SX127X_FSK_OOK) { } else if(modem == RADIOLIB_SX127X_FSK_OOK) {
// for non-zero timeout value, emulate timeout
state = this->mod->SPIsetRegValue(RADIOLIB_SX127X_REG_RX_TIMEOUT_3, cfg->receive.timeout & 0xFF);
RADIOLIB_ASSERT(state);
// clear interrupt flags // clear interrupt flags
clearIrqFlags(RADIOLIB_SX127X_FLAGS_ALL); clearIrqFlags(RADIOLIB_SX127X_FLAGS_ALL);
// FSK modem does not distinguish between Rx single and continuous // FSK modem does not actually distinguish between Rx single and continuous mode,
// Rx single is emulated using timeout
this->rxMode = RADIOLIB_SX127X_RX; this->rxMode = RADIOLIB_SX127X_RX;
} }
} break; } break;