mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 04:15:44 +03:00
Merge pull request #11472 from klutvott123/crsf-baud-negotiation
Make negotiated baud configurable for CRSF
This commit is contained in:
commit
61f43fea9e
6 changed files with 13 additions and 2 deletions
|
@ -783,6 +783,9 @@ const clivalue_t valueTable[] = {
|
|||
#endif
|
||||
#if defined(USE_SERIALRX_CRSF)
|
||||
{ "crsf_use_rx_snr", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_RX_CONFIG, offsetof(rxConfig_t, crsf_use_rx_snr) },
|
||||
#if defined(USE_CRSF_V3)
|
||||
{ "crsf_use_negotiated_baud", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_RX_CONFIG, offsetof(rxConfig_t, crsf_use_negotiated_baud) },
|
||||
#endif
|
||||
#endif
|
||||
{ "airmode_start_throttle_percent", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 100 }, PG_RX_CONFIG, offsetof(rxConfig_t, airModeActivateThreshold) },
|
||||
{ "rx_min_usec", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { PWM_PULSE_MIN, PWM_PULSE_MAX }, PG_RX_CONFIG, offsetof(rxConfig_t, rx_min_usec) },
|
||||
|
|
|
@ -71,6 +71,7 @@ void pgResetFn_rxConfig(rxConfig_t *rxConfig)
|
|||
.sbus_baud_fast = false,
|
||||
.crsf_use_rx_snr = false,
|
||||
.msp_override_channels_mask = 0,
|
||||
.crsf_use_negotiated_baud = false,
|
||||
);
|
||||
|
||||
#ifdef RX_CHANNELS_TAER
|
||||
|
|
|
@ -62,6 +62,7 @@ typedef struct rxConfig_s {
|
|||
uint8_t sbus_baud_fast; // Select SBus fast baud rate
|
||||
uint8_t crsf_use_rx_snr; // Use RX SNR (in dB) instead of RSSI dBm for CRSF
|
||||
uint32_t msp_override_channels_mask; // Channels to override when the MSP override mode is enabled
|
||||
uint8_t crsf_use_negotiated_baud; // Use negotiated baud rate for CRSF V3
|
||||
} rxConfig_t;
|
||||
|
||||
PG_DECLARE(rxConfig_t, rxConfig);
|
||||
|
|
|
@ -656,6 +656,11 @@ void crsfRxUpdateBaudrate(uint32_t baudrate)
|
|||
{
|
||||
serialSetBaudRate(serialPort, baudrate);
|
||||
}
|
||||
|
||||
bool crsfRxUseNegotiatedBaud(void)
|
||||
{
|
||||
return rxConfig()->crsf_use_negotiated_baud;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool crsfRxIsActive(void)
|
||||
|
|
|
@ -86,4 +86,5 @@ struct rxConfig_s;
|
|||
struct rxRuntimeState_s;
|
||||
bool crsfRxInit(const struct rxConfig_s *initialRxConfig, struct rxRuntimeState_s *rxRuntimeState);
|
||||
void crsfRxUpdateBaudrate(uint32_t baudrate);
|
||||
bool crsfRxUseNegotiatedBaud(void);
|
||||
bool crsfRxIsActive(void);
|
||||
|
|
|
@ -431,7 +431,7 @@ void speedNegotiationProcess(uint32_t currentTime)
|
|||
crsfRxSendTelemetryData();
|
||||
} else {
|
||||
if (crsfSpeed.hasPendingReply) {
|
||||
bool found = crsfSpeed.index < BAUD_COUNT ? true : false;
|
||||
bool found = ((crsfSpeed.index < BAUD_COUNT) && crsfRxUseNegotiatedBaud()) ? true : false;
|
||||
sbuf_t crsfSpeedNegotiationBuf;
|
||||
sbuf_t *dst = &crsfSpeedNegotiationBuf;
|
||||
crsfInitializeFrame(dst);
|
||||
|
@ -440,7 +440,7 @@ void speedNegotiationProcess(uint32_t currentTime)
|
|||
crsfFinalize(dst);
|
||||
crsfRxSendTelemetryData();
|
||||
crsfSpeed.hasPendingReply = false;
|
||||
crsfSpeed.isNewSpeedValid = true;
|
||||
crsfSpeed.isNewSpeedValid = found;
|
||||
crsfSpeed.confirmationTime = currentTime;
|
||||
return;
|
||||
} else if (crsfSpeed.isNewSpeedValid) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue