Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FLRC F-modes to ELRS SPI implementation #12936

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/main/cli/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,6 @@ static const char* const lookupTableFreqDomain[] = {
"NONE",
#endif
};

static const char* const lookupTableSwitchMode[] = {
"WIDE", "HYBRID",
};
#endif

#define LOOKUP_TABLE_ENTRY(name) { name, ARRAYLEN(name) }
Expand Down Expand Up @@ -652,7 +648,6 @@ const lookupTableEntry_t lookupTables[] = {
#endif
#ifdef USE_RX_EXPRESSLRS
LOOKUP_TABLE_ENTRY(lookupTableFreqDomain),
LOOKUP_TABLE_ENTRY(lookupTableSwitchMode),
#endif
};

Expand Down Expand Up @@ -1717,8 +1712,6 @@ const clivalue_t valueTable[] = {
#ifdef USE_RX_EXPRESSLRS
{ "expresslrs_uid", VAR_UINT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = 6, PG_RX_EXPRESSLRS_SPI_CONFIG, offsetof(rxExpressLrsSpiConfig_t, UID) },
{ "expresslrs_domain", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_FREQ_DOMAIN }, PG_RX_EXPRESSLRS_SPI_CONFIG, offsetof(rxExpressLrsSpiConfig_t, domain) },
{ "expresslrs_rate_index", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 3 }, PG_RX_EXPRESSLRS_SPI_CONFIG, offsetof(rxExpressLrsSpiConfig_t, rateIndex) },
{ "expresslrs_switch_mode", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_SWITCH_MODE }, PG_RX_EXPRESSLRS_SPI_CONFIG, offsetof(rxExpressLrsSpiConfig_t, switchMode) },
{ "expresslrs_model_id", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, UINT8_MAX }, PG_RX_EXPRESSLRS_SPI_CONFIG, offsetof(rxExpressLrsSpiConfig_t, modelId) },
#endif

Expand Down
1 change: 0 additions & 1 deletion src/main/cli/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ typedef enum {
#endif
#ifdef USE_RX_EXPRESSLRS
TABLE_FREQ_DOMAIN,
TABLE_SWITCH_MODE,
#endif
LOOKUP_TABLE_COUNT
} lookupTableIndex_e;
Expand Down
29 changes: 16 additions & 13 deletions src/main/drivers/rx/rx_sx127x.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,17 @@ void sx127xStartReceiving(void)
sx127xSetMode(SX127x_OPMODE_RXCONTINUOUS);
}

void sx127xConfig(const sx127xBandwidth_e bw, const sx127xSpreadingFactor_e sf, const sx127xCodingRate_e cr,
const uint32_t freq, const uint8_t preambleLen, const bool iqInverted)
void sx127xConfig(const uint8_t bw, const uint8_t sfbt, const uint8_t cr,
const uint32_t freq, const uint8_t preambleLength, const bool iqInverted,
const uint32_t flrcSyncWord, const uint16_t flrcCrcSeed, const bool isFlrc)
{
UNUSED(flrcSyncWord); UNUSED(flrcCrcSeed); UNUSED(isFlrc);

sx127xConfigLoraDefaults(iqInverted);
sx127xSetPreambleLength(preambleLen);
sx127xSetPreambleLength(preambleLength);
sx127xSetOutputPower(SX127x_MAX_POWER);
sx127xSetSpreadingFactor(sf);
sx127xSetBandwidthCodingRate(bw, cr, sf, false, false);
sx127xSetSpreadingFactor(sfbt);
sx127xSetBandwidthCodingRate(bw, cr, sfbt, false, false);
sx127xSetFrequencyReg(freq);
}

Expand Down Expand Up @@ -384,22 +387,22 @@ int32_t sx127xGetFrequencyError(const sx127xBandwidth_e bw)
return fErrorHZ;
}

void sx127xAdjustFrequency(int32_t offset, const uint32_t freq)
void sx127xAdjustFrequency(int32_t *offset, const uint32_t freq)
{
if (sx127xGetFrequencyErrorbool()) { //logic is flipped compared to original code
if (offset > SX127x_FREQ_CORRECTION_MIN) {
offset -= 1;
if (*offset > SX127x_FREQ_CORRECTION_MIN) {
*offset -= 1;
} else {
offset = 0; //reset because something went wrong
*offset = 0; //reset because something went wrong
}
} else {
if (offset < SX127x_FREQ_CORRECTION_MAX) {
offset += 1;
if (*offset < SX127x_FREQ_CORRECTION_MAX) {
*offset += 1;
} else {
offset = 0; //reset because something went wrong
*offset = 0; //reset because something went wrong
}
}
sx127xSetPPMoffsetReg(offset, freq); //as above but corrects a different PPM offset based on freq error
sx127xSetPPMoffsetReg(*offset, freq); //as above but corrects a different PPM offset based on freq error
}

uint8_t sx127xUnsignedGetLastPacketRSSI(void)
Expand Down
7 changes: 4 additions & 3 deletions src/main/drivers/rx/rx_sx127x.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,14 @@ void sx127xSetFrequencyReg(const uint32_t freq);
void sx127xTransmitData(const uint8_t *data, const uint8_t length);
void sx127xReceiveData(uint8_t *data, const uint8_t length);
void sx127xStartReceiving(void);
void sx127xConfig(const sx127xBandwidth_e bw, const sx127xSpreadingFactor_e sf, const sx127xCodingRate_e cr, const uint32_t freq, const uint8_t preambleLen, const bool iqInverted);

void sx127xConfig(const uint8_t bw, const uint8_t sfbt, const uint8_t cr,
const uint32_t freq, const uint8_t preambleLength, const bool iqInverted,
const uint32_t flrcSyncWord, const uint16_t flrcCrcSeed, const bool isFlrc);
uint32_t sx127xGetCurrBandwidth(const sx127xBandwidth_e bw);
uint32_t sx127xGetCurrBandwidthNormalisedShifted(const sx127xBandwidth_e bw);
void sx127xSetPPMoffsetReg(const int32_t offset, const uint32_t freq);
int32_t sx127xGetFrequencyError(const sx127xBandwidth_e bw);
void sx127xAdjustFrequency(int32_t offset, const uint32_t freq);
void sx127xAdjustFrequency(int32_t *offset, const uint32_t freq);
uint8_t sx127xUnsignedGetLastPacketRSSI(void);
int8_t sx127xGetLastPacketRSSI(void);
int8_t sx127xGetCurrRSSI(void);
Expand Down