mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 01:05:27 +03:00
add support for flysky and turnigy ibus receiver ia6
This commit is contained in:
parent
fc480fab5b
commit
82626de33a
4 changed files with 45 additions and 15 deletions
|
@ -523,6 +523,7 @@ void createDefaultConfig(master_t *config)
|
||||||
#else
|
#else
|
||||||
config->rxConfig.serialrx_provider = 0;
|
config->rxConfig.serialrx_provider = 0;
|
||||||
#endif
|
#endif
|
||||||
|
config->rxConfig.ibus_model = 0;
|
||||||
config->rxConfig.sbus_inversion = 1;
|
config->rxConfig.sbus_inversion = 1;
|
||||||
config->rxConfig.spektrum_sat_bind = 0;
|
config->rxConfig.spektrum_sat_bind = 0;
|
||||||
config->rxConfig.spektrum_sat_bind_autoreset = 1;
|
config->rxConfig.spektrum_sat_bind_autoreset = 1;
|
||||||
|
|
|
@ -429,6 +429,10 @@ static const char * const lookupTableSerialRX[] = {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static const char * const lookupTableIbusModel[] = {
|
||||||
|
"IA6B", "IA6"
|
||||||
|
};
|
||||||
|
|
||||||
static const char * const lookupTableGyroLpf[] = {
|
static const char * const lookupTableGyroLpf[] = {
|
||||||
"OFF",
|
"OFF",
|
||||||
"188HZ",
|
"188HZ",
|
||||||
|
@ -546,6 +550,7 @@ typedef enum {
|
||||||
#ifdef SERIAL_RX
|
#ifdef SERIAL_RX
|
||||||
TABLE_SERIAL_RX,
|
TABLE_SERIAL_RX,
|
||||||
#endif
|
#endif
|
||||||
|
TABLE_IBUS_MODEL,
|
||||||
TABLE_GYRO_LPF,
|
TABLE_GYRO_LPF,
|
||||||
TABLE_ACC_HARDWARE,
|
TABLE_ACC_HARDWARE,
|
||||||
#ifdef BARO
|
#ifdef BARO
|
||||||
|
@ -585,6 +590,7 @@ static const lookupTableEntry_t lookupTables[] = {
|
||||||
#ifdef SERIAL_RX
|
#ifdef SERIAL_RX
|
||||||
{ lookupTableSerialRX, sizeof(lookupTableSerialRX) / sizeof(char *) },
|
{ lookupTableSerialRX, sizeof(lookupTableSerialRX) / sizeof(char *) },
|
||||||
#endif
|
#endif
|
||||||
|
{ lookupTableIbusModel, sizeof(lookupTableIbusModel) / sizeof(char *) },
|
||||||
{ lookupTableGyroLpf, sizeof(lookupTableGyroLpf) / sizeof(char *) },
|
{ lookupTableGyroLpf, sizeof(lookupTableGyroLpf) / sizeof(char *) },
|
||||||
{ lookupTableAccHardware, sizeof(lookupTableAccHardware) / sizeof(char *) },
|
{ lookupTableAccHardware, sizeof(lookupTableAccHardware) / sizeof(char *) },
|
||||||
#ifdef BARO
|
#ifdef BARO
|
||||||
|
@ -730,6 +736,7 @@ const clivalue_t valueTable[] = {
|
||||||
#ifdef SERIAL_RX
|
#ifdef SERIAL_RX
|
||||||
{ "serialrx_provider", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.rxConfig.serialrx_provider, .config.lookup = { TABLE_SERIAL_RX } },
|
{ "serialrx_provider", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.rxConfig.serialrx_provider, .config.lookup = { TABLE_SERIAL_RX } },
|
||||||
#endif
|
#endif
|
||||||
|
{ "ibus_model", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.rxConfig.ibus_model, .config.lookup = { TABLE_IBUS_MODEL } },
|
||||||
{ "sbus_inversion", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.rxConfig.sbus_inversion, .config.lookup = { TABLE_OFF_ON } },
|
{ "sbus_inversion", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.rxConfig.sbus_inversion, .config.lookup = { TABLE_OFF_ON } },
|
||||||
#ifdef SPEKTRUM_BIND
|
#ifdef SPEKTRUM_BIND
|
||||||
{ "spektrum_sat_bind", VAR_UINT8 | MASTER_VALUE, &masterConfig.rxConfig.spektrum_sat_bind, .config.minmax = { SPEKTRUM_SAT_BIND_DISABLED, SPEKTRUM_SAT_BIND_MAX} },
|
{ "spektrum_sat_bind", VAR_UINT8 | MASTER_VALUE, &masterConfig.rxConfig.spektrum_sat_bind, .config.minmax = { SPEKTRUM_SAT_BIND_DISABLED, SPEKTRUM_SAT_BIND_MAX} },
|
||||||
|
|
|
@ -42,12 +42,20 @@
|
||||||
#include "rx/rx.h"
|
#include "rx/rx.h"
|
||||||
#include "rx/ibus.h"
|
#include "rx/ibus.h"
|
||||||
|
|
||||||
#define IBUS_MAX_CHANNEL 10
|
#define IBUS_MAX_CHANNEL 14
|
||||||
#define IBUS_BUFFSIZE 32
|
#define IBUS_BUFFSIZE 32
|
||||||
#define IBUS_SYNCBYTE 0x20
|
#define IBUS_MODEL_IA6B 0
|
||||||
|
#define IBUS_MODEL_IA6 1
|
||||||
|
|
||||||
#define IBUS_BAUDRATE 115200
|
#define IBUS_BAUDRATE 115200
|
||||||
|
|
||||||
|
static uint8_t ibusModel = 0;
|
||||||
|
static uint8_t ibusSyncByte = 0x20;
|
||||||
|
static uint8_t ibusFrameSize = 32;
|
||||||
|
static uint8_t ibusChannelOffset = 2;
|
||||||
|
static uint32_t ibusInterframeGap = 3000;
|
||||||
|
static uint16_t ibusChecksum = 0xFFFF;
|
||||||
|
|
||||||
static bool ibusFrameDone = false;
|
static bool ibusFrameDone = false;
|
||||||
static uint32_t ibusChannelData[IBUS_MAX_CHANNEL];
|
static uint32_t ibusChannelData[IBUS_MAX_CHANNEL];
|
||||||
|
|
||||||
|
@ -56,7 +64,15 @@ static uint16_t ibusReadRawRC(rxRuntimeConfig_t *rxRuntimeConfig, uint8_t chan);
|
||||||
|
|
||||||
bool ibusInit(rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig, rcReadRawDataPtr *callback)
|
bool ibusInit(rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig, rcReadRawDataPtr *callback)
|
||||||
{
|
{
|
||||||
UNUSED(rxConfig);
|
|
||||||
|
if (rxConfig->ibus_model == IBUS_MODEL_IA6) {
|
||||||
|
ibusModel = 1;
|
||||||
|
ibusSyncByte = 0x55;
|
||||||
|
ibusFrameSize = 31;
|
||||||
|
ibusInterframeGap = 500;
|
||||||
|
ibusChecksum = 0x0000;
|
||||||
|
ibusChannelOffset = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (callback)
|
if (callback)
|
||||||
*callback = ibusReadRawRC;
|
*callback = ibusReadRawRC;
|
||||||
|
@ -96,17 +112,17 @@ static void ibusDataReceive(uint16_t c)
|
||||||
|
|
||||||
ibusTime = micros();
|
ibusTime = micros();
|
||||||
|
|
||||||
if ((ibusTime - ibusTimeLast) > 3000)
|
if ((ibusTime - ibusTimeLast) > ibusInterframeGap)
|
||||||
ibusFramePosition = 0;
|
ibusFramePosition = 0;
|
||||||
|
|
||||||
ibusTimeLast = ibusTime;
|
ibusTimeLast = ibusTime;
|
||||||
|
|
||||||
if (ibusFramePosition == 0 && c != IBUS_SYNCBYTE)
|
if (ibusFramePosition == 0 && c != ibusSyncByte)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ibus[ibusFramePosition] = (uint8_t)c;
|
ibus[ibusFramePosition] = (uint8_t)c;
|
||||||
|
|
||||||
if (ibusFramePosition == IBUS_BUFFSIZE - 1) {
|
if (ibusFramePosition == ibusFrameSize - 1) {
|
||||||
ibusFrameDone = true;
|
ibusFrameDone = true;
|
||||||
} else {
|
} else {
|
||||||
ibusFramePosition++;
|
ibusFramePosition++;
|
||||||
|
@ -125,17 +141,22 @@ uint8_t ibusFrameStatus(void)
|
||||||
|
|
||||||
ibusFrameDone = false;
|
ibusFrameDone = false;
|
||||||
|
|
||||||
chksum = 0xFFFF;
|
chksum = ibusChecksum;
|
||||||
for (i = 0; i < 30; i++)
|
rxsum = ibus[ibusFrameSize - 2] + (ibus[ibusFrameSize - 1] << 8);
|
||||||
chksum -= ibus[i];
|
|
||||||
|
if (ibusModel == IBUS_MODEL_IA6) {
|
||||||
rxsum = ibus[30] + (ibus[31] << 8);
|
for (i = 0, offset = ibusChannelOffset; i < IBUS_MAX_CHANNEL; i++, offset += 2)
|
||||||
|
chksum += ibus[offset] + (ibus[offset + 1] << 8);
|
||||||
|
} else {
|
||||||
|
for (i = 0; i < 30; i++)
|
||||||
|
chksum -= ibus[i];
|
||||||
|
}
|
||||||
|
|
||||||
if (chksum == rxsum) {
|
if (chksum == rxsum) {
|
||||||
for (i = 0, offset = 2; i < IBUS_MAX_CHANNEL; i++, offset += 2) {
|
for (i = 0, offset = ibusChannelOffset; i < IBUS_MAX_CHANNEL; i++, offset += 2) {
|
||||||
ibusChannelData[i] = ibus[offset] + (ibus[offset + 1] << 8);
|
ibusChannelData[i] = ibus[offset] + (ibus[offset + 1] << 8);
|
||||||
}
|
}
|
||||||
frameStatus = SERIAL_RX_FRAME_COMPLETE;
|
frameStatus = SERIAL_RX_FRAME_COMPLETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return frameStatus;
|
return frameStatus;
|
||||||
|
|
|
@ -112,6 +112,7 @@ typedef struct rxChannelRangeConfiguration_s {
|
||||||
typedef struct rxConfig_s {
|
typedef struct rxConfig_s {
|
||||||
uint8_t rcmap[MAX_MAPPABLE_RX_INPUTS]; // mapping of radio channels to internal RPYTA+ order
|
uint8_t rcmap[MAX_MAPPABLE_RX_INPUTS]; // mapping of radio channels to internal RPYTA+ order
|
||||||
uint8_t serialrx_provider; // type of UART-based receiver (0 = spek 10, 1 = spek 11, 2 = sbus). Must be enabled by FEATURE_RX_SERIAL first.
|
uint8_t serialrx_provider; // type of UART-based receiver (0 = spek 10, 1 = spek 11, 2 = sbus). Must be enabled by FEATURE_RX_SERIAL first.
|
||||||
|
uint8_t ibus_model;
|
||||||
uint8_t sbus_inversion; // default sbus (Futaba, FrSKY) is inverted. Support for uninverted OpenLRS (and modified FrSKY) receivers.
|
uint8_t sbus_inversion; // default sbus (Futaba, FrSKY) is inverted. Support for uninverted OpenLRS (and modified FrSKY) receivers.
|
||||||
uint8_t spektrum_sat_bind; // number of bind pulses for Spektrum satellite receivers
|
uint8_t spektrum_sat_bind; // number of bind pulses for Spektrum satellite receivers
|
||||||
uint8_t spektrum_sat_bind_autoreset; // whenever we will reset (exit) binding mode after hard reboot
|
uint8_t spektrum_sat_bind_autoreset; // whenever we will reset (exit) binding mode after hard reboot
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue