mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 12:55:19 +03:00
Merge pull request #7417 from phobos-/flysky-refactor
Added flysky spi rx specific cli commands
This commit is contained in:
commit
2e2609fbb6
9 changed files with 47 additions and 41 deletions
|
@ -76,9 +76,9 @@ void A7105Init (uint32_t id)
|
||||||
void A7105Config(const uint8_t *regsTable, uint8_t size)
|
void A7105Config(const uint8_t *regsTable, uint8_t size)
|
||||||
{
|
{
|
||||||
if (regsTable) {
|
if (regsTable) {
|
||||||
uint32_t timeout = 1000;
|
unsigned timeout = 1000;
|
||||||
|
|
||||||
for (uint8_t i = 0; i < size; i++) {
|
for (unsigned i = 0; i < size; i++) {
|
||||||
if (regsTable[i] != 0xFF) {
|
if (regsTable[i] != 0xFF) {
|
||||||
A7105WriteReg ((A7105Reg_t)i, regsTable[i]);
|
A7105WriteReg ((A7105Reg_t)i, regsTable[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,7 @@
|
||||||
#include "rx/cc2500_sfhss.h"
|
#include "rx/cc2500_sfhss.h"
|
||||||
#include "rx/spektrum.h"
|
#include "rx/spektrum.h"
|
||||||
#include "rx/cyrf6936_spektrum.h"
|
#include "rx/cyrf6936_spektrum.h"
|
||||||
|
#include "rx/a7105_flysky.h"
|
||||||
|
|
||||||
#include "sensors/acceleration.h"
|
#include "sensors/acceleration.h"
|
||||||
#include "sensors/barometer.h"
|
#include "sensors/barometer.h"
|
||||||
|
@ -1257,7 +1258,7 @@ const clivalue_t valueTable[] = {
|
||||||
{ "frsky_spi_tx_id", VAR_UINT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = 2, PG_RX_FRSKY_SPI_CONFIG, offsetof(rxFrSkySpiConfig_t, bindTxId) },
|
{ "frsky_spi_tx_id", VAR_UINT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = 2, PG_RX_FRSKY_SPI_CONFIG, offsetof(rxFrSkySpiConfig_t, bindTxId) },
|
||||||
{ "frsky_spi_offset", VAR_INT8 | MASTER_VALUE, .config.minmax = { -127, 127 }, PG_RX_FRSKY_SPI_CONFIG, offsetof(rxFrSkySpiConfig_t, bindOffset) },
|
{ "frsky_spi_offset", VAR_INT8 | MASTER_VALUE, .config.minmax = { -127, 127 }, PG_RX_FRSKY_SPI_CONFIG, offsetof(rxFrSkySpiConfig_t, bindOffset) },
|
||||||
{ "frsky_spi_bind_hop_data", VAR_UINT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = 50, PG_RX_FRSKY_SPI_CONFIG, offsetof(rxFrSkySpiConfig_t, bindHopData) },
|
{ "frsky_spi_bind_hop_data", VAR_UINT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = 50, PG_RX_FRSKY_SPI_CONFIG, offsetof(rxFrSkySpiConfig_t, bindHopData) },
|
||||||
{ "frsky_x_rx_num", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 255 }, PG_RX_FRSKY_SPI_CONFIG, offsetof(rxFrSkySpiConfig_t, rxNum) },
|
{ "frsky_x_rx_num", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, UINT8_MAX }, PG_RX_FRSKY_SPI_CONFIG, offsetof(rxFrSkySpiConfig_t, rxNum) },
|
||||||
{ "frsky_spi_a1_source", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_RX_FRSKY_SPI_A1_SOURCE }, PG_RX_FRSKY_SPI_CONFIG, offsetof(rxFrSkySpiConfig_t, a1Source) },
|
{ "frsky_spi_a1_source", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_RX_FRSKY_SPI_A1_SOURCE }, PG_RX_FRSKY_SPI_CONFIG, offsetof(rxFrSkySpiConfig_t, a1Source) },
|
||||||
#endif
|
#endif
|
||||||
{ "led_inversion", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, ((1 << STATUS_LED_NUMBER) - 1) }, PG_STATUS_LED_CONFIG, offsetof(statusLedConfig_t, inversion) },
|
{ "led_inversion", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, ((1 << STATUS_LED_NUMBER) - 1) }, PG_STATUS_LED_CONFIG, offsetof(statusLedConfig_t, inversion) },
|
||||||
|
@ -1340,7 +1341,7 @@ const clivalue_t valueTable[] = {
|
||||||
{ "mco2_on_pc9", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_MCO_CONFIG, offsetof(mcoConfig_t, enabled[1]) },
|
{ "mco2_on_pc9", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_MCO_CONFIG, offsetof(mcoConfig_t, enabled[1]) },
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_RX_SPEKTRUM
|
#ifdef USE_RX_SPEKTRUM
|
||||||
{ "spektrum_spi_protocol", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 255 }, PG_RX_SPEKTRUM_SPI_CONFIG, offsetof(spektrumConfig_t, protocol) },
|
{ "spektrum_spi_protocol", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, UINT8_MAX }, PG_RX_SPEKTRUM_SPI_CONFIG, offsetof(spektrumConfig_t, protocol) },
|
||||||
{ "spektrum_spi_mfg_id", VAR_UINT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = 4, PG_RX_SPEKTRUM_SPI_CONFIG, offsetof(spektrumConfig_t, mfgId) },
|
{ "spektrum_spi_mfg_id", VAR_UINT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = 4, PG_RX_SPEKTRUM_SPI_CONFIG, offsetof(spektrumConfig_t, mfgId) },
|
||||||
{ "spektrum_spi_num_channels", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, DSM_MAX_CHANNEL_COUNT }, PG_RX_SPEKTRUM_SPI_CONFIG, offsetof(spektrumConfig_t, numChannels) },
|
{ "spektrum_spi_num_channels", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, DSM_MAX_CHANNEL_COUNT }, PG_RX_SPEKTRUM_SPI_CONFIG, offsetof(spektrumConfig_t, numChannels) },
|
||||||
#endif
|
#endif
|
||||||
|
@ -1358,6 +1359,12 @@ const clivalue_t valueTable[] = {
|
||||||
{ "dterm_rpm_notch_q", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 1, 1000 }, PG_RPM_FILTER_CONFIG, offsetof(rpmFilterConfig_t, dterm_rpm_notch_q) },
|
{ "dterm_rpm_notch_q", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 1, 1000 }, PG_RPM_FILTER_CONFIG, offsetof(rpmFilterConfig_t, dterm_rpm_notch_q) },
|
||||||
{ "dterm_rpm_notch_min", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 50, 200 }, PG_RPM_FILTER_CONFIG, offsetof(rpmFilterConfig_t, dterm_rpm_notch_min) },
|
{ "dterm_rpm_notch_min", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 50, 200 }, PG_RPM_FILTER_CONFIG, offsetof(rpmFilterConfig_t, dterm_rpm_notch_min) },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_RX_FLYSKY
|
||||||
|
{ "flysky_spi_tx_id", VAR_UINT32 | MASTER_VALUE, .config.u32_max = UINT32_MAX, PG_FLYSKY_CONFIG, offsetof(flySkyConfig_t, txId) },
|
||||||
|
{ "flysky_spi_rf_channels", VAR_UINT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = 16, PG_FLYSKY_CONFIG, offsetof(flySkyConfig_t, rfChannelMap) },
|
||||||
|
{ "flysky_spi_protocol", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, UINT8_MAX }, PG_FLYSKY_CONFIG, offsetof(flySkyConfig_t, protocol) },
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint16_t valueTableEntryCount = ARRAYLEN(valueTable);
|
const uint16_t valueTableEntryCount = ARRAYLEN(valueTable);
|
||||||
|
|
|
@ -40,14 +40,14 @@
|
||||||
#include "pg/pg_ids.h"
|
#include "pg/pg_ids.h"
|
||||||
#include "pg/rx_spi.h"
|
#include "pg/rx_spi.h"
|
||||||
|
|
||||||
#include "rx/flysky_defs.h"
|
#include "rx/a7105_flysky_defs.h"
|
||||||
#include "rx/rx.h"
|
#include "rx/rx.h"
|
||||||
#include "rx/rx_spi.h"
|
#include "rx/rx_spi.h"
|
||||||
#include "rx/rx_spi_common.h"
|
#include "rx/rx_spi_common.h"
|
||||||
|
|
||||||
#include "sensors/battery.h"
|
#include "sensors/battery.h"
|
||||||
|
|
||||||
#include "flysky.h"
|
#include "a7105_flysky.h"
|
||||||
|
|
||||||
#if FLYSKY_CHANNEL_COUNT > MAX_FLYSKY_CHANNEL_COUNT
|
#if FLYSKY_CHANNEL_COUNT > MAX_FLYSKY_CHANNEL_COUNT
|
||||||
#error "FlySky AFHDS protocol support 8 channel max"
|
#error "FlySky AFHDS protocol support 8 channel max"
|
||||||
|
@ -123,7 +123,6 @@ static uint16_t errorRate = 0;
|
||||||
static uint16_t rssi_dBm = 0;
|
static uint16_t rssi_dBm = 0;
|
||||||
static uint8_t rfChannelMap[FLYSKY_FREQUENCY_COUNT] = {0};
|
static uint8_t rfChannelMap[FLYSKY_FREQUENCY_COUNT] = {0};
|
||||||
|
|
||||||
|
|
||||||
static uint8_t getNextChannel(uint8_t step)
|
static uint8_t getNextChannel(uint8_t step)
|
||||||
{
|
{
|
||||||
static uint8_t channel = 0;
|
static uint8_t channel = 0;
|
||||||
|
@ -140,7 +139,7 @@ static void flySkyCalculateRfChannels (void)
|
||||||
channelOffset = 9; // from sloped soarer findings, bug in flysky protocol
|
channelOffset = 9; // from sloped soarer findings, bug in flysky protocol
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < FLYSKY_FREQUENCY_COUNT; i++) {
|
for (unsigned i = 0; i < FLYSKY_FREQUENCY_COUNT; i++) {
|
||||||
rfChannelMap[i] = flySkyRfChannels[channelRow][i] - channelOffset;
|
rfChannelMap[i] = flySkyRfChannels[channelRow][i] - channelOffset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -408,7 +407,7 @@ void flySkySetRcDataFromPayload (uint16_t *rcData, const uint8_t *payload)
|
||||||
uint32_t channelCount;
|
uint32_t channelCount;
|
||||||
channelCount = (protocol == RX_SPI_A7105_FLYSKY_2A) ? (FLYSKY_2A_CHANNEL_COUNT) : (FLYSKY_CHANNEL_COUNT);
|
channelCount = (protocol == RX_SPI_A7105_FLYSKY_2A) ? (FLYSKY_2A_CHANNEL_COUNT) : (FLYSKY_CHANNEL_COUNT);
|
||||||
|
|
||||||
for (uint8_t i = 0; i < channelCount; i++) {
|
for (unsigned i = 0; i < channelCount; i++) {
|
||||||
rcData[i] = payload[2 * i + 1] << 8 | payload [2 * i + 0];
|
rcData[i] = payload[2 * i + 1] << 8 | payload [2 * i + 0];
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -46,7 +46,7 @@
|
||||||
#include "rx/nrf24_h8_3d.h"
|
#include "rx/nrf24_h8_3d.h"
|
||||||
#include "rx/nrf24_inav.h"
|
#include "rx/nrf24_inav.h"
|
||||||
#include "rx/nrf24_kn.h"
|
#include "rx/nrf24_kn.h"
|
||||||
#include "rx/flysky.h"
|
#include "rx/a7105_flysky.h"
|
||||||
#include "rx/cc2500_sfhss.h"
|
#include "rx/cc2500_sfhss.h"
|
||||||
#include "rx/cyrf6936_spektrum.h"
|
#include "rx/cyrf6936_spektrum.h"
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ TARGET_SRC = \
|
||||||
ifeq ($(TARGET), CRAZYBEEF3FS)
|
ifeq ($(TARGET), CRAZYBEEF3FS)
|
||||||
TARGET_SRC += \
|
TARGET_SRC += \
|
||||||
drivers/rx/rx_a7105.c \
|
drivers/rx/rx_a7105.c \
|
||||||
rx/flysky.c
|
rx/a7105_flysky.c
|
||||||
else
|
else
|
||||||
ifeq ($(TARGET), CRAZYBEEF3FR)
|
ifeq ($(TARGET), CRAZYBEEF3FR)
|
||||||
TARGET_SRC += \
|
TARGET_SRC += \
|
||||||
|
|
|
@ -8,4 +8,4 @@ TARGET_SRC = \
|
||||||
drivers/barometer/barometer_bmp280.c \
|
drivers/barometer/barometer_bmp280.c \
|
||||||
drivers/barometer/barometer_ms5611.c \
|
drivers/barometer/barometer_ms5611.c \
|
||||||
drivers/rx/rx_a7105.c \
|
drivers/rx/rx_a7105.c \
|
||||||
rx/flysky.c
|
rx/a7105_flysky.c
|
||||||
|
|
|
@ -14,5 +14,5 @@ TARGET_SRC = \
|
||||||
ifeq ($(TARGET), CRAZYBEEF4FS)
|
ifeq ($(TARGET), CRAZYBEEF4FS)
|
||||||
TARGET_SRC += \
|
TARGET_SRC += \
|
||||||
drivers/rx/rx_a7105.c \
|
drivers/rx/rx_a7105.c \
|
||||||
rx/flysky.c
|
rx/a7105_flysky.c
|
||||||
endif
|
endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue