Skip to content

Commit f2cf315

Browse files
authored
Merge pull request #3599 from iNavFlight/de_sbus_sync_config
Make sbus sync delay configurable
2 parents c54f113 + 8277edd commit f2cf315

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

src/main/fc/settings.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,10 @@ groups:
349349
- name: rssi_invert
350350
field: rssiInvert
351351
type: bool
352+
- name: sbus_sync_interval
353+
field: sbusSyncInterval
354+
min: 10000
355+
max: 500
352356
- name: rc_smoothing
353357
field: rcSmoothing
354358
type: bool

src/main/rx/rx.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ uint32_t rcInvalidPulsPeriod[MAX_SUPPORTED_RC_CHANNEL_COUNT];
100100
rxRuntimeConfig_t rxRuntimeConfig;
101101
static uint8_t rcSampleIndex = 0;
102102

103-
PG_REGISTER_WITH_RESET_TEMPLATE(rxConfig_t, rxConfig, PG_RX_CONFIG, 4);
103+
PG_REGISTER_WITH_RESET_TEMPLATE(rxConfig_t, rxConfig, PG_RX_CONFIG, 5);
104104

105105
#ifndef RX_SPI_DEFAULT_PROTOCOL
106106
#define RX_SPI_DEFAULT_PROTOCOL 0
@@ -129,6 +129,7 @@ PG_RESET_TEMPLATE(rxConfig_t, rxConfig,
129129
.rssi_channel = 0,
130130
.rssi_scale = RSSI_SCALE_DEFAULT,
131131
.rssiInvert = 0,
132+
.sbusSyncInterval = SBUS_DEFAULT_INTERFRAME_DELAY_US,
132133
.rcSmoothing = 1,
133134
);
134135

src/main/rx/rx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ typedef struct rxConfig_s {
121121
uint8_t rssi_channel;
122122
uint8_t rssi_scale;
123123
uint8_t rssiInvert;
124-
uint16_t __reserved; // was micrd
124+
uint16_t sbusSyncInterval;
125125
uint16_t mincheck; // minimum rc end
126126
uint16_t maxcheck; // maximum rc end
127127
uint16_t rx_min_usec;

src/main/rx/sbus.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252
* time to send frame: 3ms.
5353
*/
5454

55-
#define SBUS_MIN_INTERFRAME_DELAY_US 3000 // According to FrSky interframe is 6.67ms, we go smaller just in case
56-
5755
#define SBUS_FRAME_SIZE (SBUS_CHANNEL_DATA_LENGTH + 2)
5856

5957
#define SBUS_FRAME_BEGIN_BYTE 0x0F
@@ -114,7 +112,7 @@ static void sbusDataReceive(uint16_t c, void *data)
114112
sbusFrameData->lastActivityTimeUs = currentTimeUs;
115113

116114
// Handle inter-frame gap. We dwell in STATE_SBUS_WAIT_SYNC state ignoring all incoming bytes until we get long enough quite period on the wire
117-
if (sbusFrameData->state == STATE_SBUS_WAIT_SYNC && timeSinceLastByteUs >= SBUS_MIN_INTERFRAME_DELAY_US) {
115+
if (sbusFrameData->state == STATE_SBUS_WAIT_SYNC && timeSinceLastByteUs >= rxConfig()->sbusSyncInterval) {
118116
DEBUG_SET(DEBUG_SBUS, DEBUG_SBUS_INTERFRAME_TIME, timeSinceLastByteUs);
119117
sbusFrameData->state = STATE_SBUS_SYNC;
120118
}

src/main/rx/sbus.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@
1717

1818
#pragma once
1919

20+
#define SBUS_DEFAULT_INTERFRAME_DELAY_US 3000 // According to FrSky interframe is 6.67ms, we go smaller just in case
21+
2022
bool sbusInit(const rxConfig_t *initialRxConfig, rxRuntimeConfig_t *rxRuntimeConfig);

0 commit comments

Comments
 (0)