Skip to content

Commit

Permalink
Add dji sbus fast (#483)
Browse files Browse the repository at this point in the history
* Added idle interupt to callback to UART driver, Added uart interrupt callback to the serial driver which is required for Spektrum SRXL2 protocol
* Added rx configuration for DJI_HDL receiver, 
* Added DJI_HDL to the RX protocol list for CLI
* Bugfix
* Simplified configuration of fast SBus
* remove DJI_HDL from CLI
  • Loading branch information
madchiller authored and nerdCopter committed Mar 19, 2021
1 parent 0e89169 commit 11d9f38
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/main/interface/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,9 @@ const clivalue_t valueTable[] = {
#ifdef USE_SPEKTRUM_BIND
{ "spektrum_sat_bind", VAR_UINT8 | MASTER_VALUE, .config.minmax = { SPEKTRUM_SAT_BIND_DISABLED, SPEKTRUM_SAT_BIND_MAX}, PG_RX_CONFIG, offsetof(rxConfig_t, spektrum_sat_bind) },
{ "spektrum_sat_bind_autoreset", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_RX_CONFIG, offsetof(rxConfig_t, spektrum_sat_bind_autoreset) },
#endif
#if defined(USE_SERIALRX_SBUS)
{ "sbus_baud_fast", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_RX_CONFIG, offsetof(rxConfig_t, sbus_baud_fast) },
#endif
{ "airmode_start_throttle_percent", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 100 }, PG_RX_CONFIG, offsetof(rxConfig_t, airModeActivateThreshold) },
{ "rx_min_usec", VAR_UINT16 | MASTER_VALUE, .config.minmax = { PWM_PULSE_MIN, PWM_PULSE_MAX }, PG_RX_CONFIG, offsetof(rxConfig_t, rx_min_usec) },
Expand Down
1 change: 1 addition & 0 deletions src/main/pg/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ void pgResetFn_rxConfig(rxConfig_t *rxConfig) {
.rc_smoothing_input_type = RC_SMOOTHING_INPUT_BIQUAD,
.rc_smoothing_derivative_type = RC_SMOOTHING_DERIVATIVE_BIQUAD,
.showAlteredRc = 0,
.sbus_baud_fast = false,
);
#ifdef RX_CHANNELS_TAER
parseRcChannels("TAER1234", rxConfig);
Expand Down
1 change: 1 addition & 0 deletions src/main/pg/rx.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ typedef struct rxConfig_s {
uint8_t rc_smoothing_derivative_type; // Derivative filter type (0 = OFF, 1 = PT1, 2 = BIQUAD)

uint8_t showAlteredRc; // allow you to see rate dynamics in the configurator
uint8_t sbus_baud_fast; // Select SBus fast baud rate
} rxConfig_t;

PG_DECLARE(rxConfig_t, rxConfig);
1 change: 1 addition & 0 deletions src/main/rx/rx.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ typedef enum {
SERIALRX_TARGET_CUSTOM = 11,
SERIALRX_FPORT = 12,
SERIALRX_GHST = 13,
SERIALRX_SRXL2 = 14,
} SerialRXType;

#define MAX_SUPPORTED_RC_PPM_CHANNEL_COUNT 12
Expand Down
34 changes: 26 additions & 8 deletions src/main/rx/sbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
*/

#define SBUS_TIME_NEEDED_PER_FRAME 3000
#define SBUS_BAUDRATE 100000
#define SBUS_RX_REFRESH_RATE 11000
#define SBUS_TIME_NEEDED_PER_FRAME 3000

#define SBUS_FAST_BAUDRATE 200000
#define SBUS_FAST_RX_REFRESH_RATE 6000

#define SBUS_STATE_FAILSAFE (1 << 0)
#define SBUS_STATE_SIGNALLOSS (1 << 1)
Expand All @@ -80,6 +86,7 @@ enum {
DEBUG_SBUS_FRAME_TIME,
};

static uint32_t sbusTimeNeededPreFrame = SBUS_TIME_NEEDED_PER_FRAME;

struct sbusFrame_s {
uint8_t syncByte;
Expand Down Expand Up @@ -155,11 +162,21 @@ static uint8_t sbusFrameStatus(rxRuntimeConfig_t *rxRuntimeConfig) {
bool sbusInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig) {
static uint16_t sbusChannelData[SBUS_MAX_CHANNEL];
static sbusFrameData_t sbusFrameData;
static uint32_t sbusBaudRate;
rxRuntimeConfig->channelData = sbusChannelData;
rxRuntimeConfig->frameData = &sbusFrameData;
sbusChannelsInit(rxConfig, rxRuntimeConfig);
rxRuntimeConfig->channelCount = SBUS_MAX_CHANNEL;
rxRuntimeConfig->rxRefreshRate = 11000;

if (rxConfig->sbus_baud_fast) {
rxRuntimeConfig->rxRefreshRate = SBUS_FAST_RX_REFRESH_RATE;
sbusBaudRate = SBUS_FAST_BAUDRATE;
} else {
rxRuntimeConfig->rxRefreshRate = SBUS_RX_REFRESH_RATE;
sbusBaudRate = SBUS_BAUDRATE;
sbusTimeNeededPreFrame = SBUS_TIME_NEEDED_PER_FRAME;
}

rxRuntimeConfig->rcFrameStatusFn = sbusFrameStatus;
const serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_RX_SERIAL);
if (!portConfig) {
Expand All @@ -171,13 +188,14 @@ bool sbusInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig) {
bool portShared = false;
#endif
serialPort_t *sBusPort = openSerialPort(portConfig->identifier,
FUNCTION_RX_SERIAL,
sbusDataReceive,
&sbusFrameData,
SBUS_BAUDRATE,
portShared ? MODE_RXTX : MODE_RX,
SBUS_PORT_OPTIONS | (rxConfig->serialrx_inverted ? 0 : SERIAL_INVERTED) | (rxConfig->halfDuplex ? SERIAL_BIDIR : 0)
);
FUNCTION_RX_SERIAL,
sbusDataReceive,
&sbusFrameData,
sbusBaudRate,
portShared ? MODE_RXTX : MODE_RX,
SBUS_PORT_OPTIONS | (rxConfig->serialrx_inverted ? 0 : SERIAL_INVERTED) | (rxConfig->halfDuplex ? SERIAL_BIDIR : 0)
);

if (rxConfig->rssi_src_frame_errors) {
rssiSource = RSSI_SOURCE_FRAME_ERRORS;
}
Expand Down

0 comments on commit 11d9f38

Please sign in to comment.