mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 14:25:20 +03:00
Change SFHSS bind parameter rxSfhssSpiConfig to rxFrSkySpiConfig
This commit is contained in:
parent
002d9aa504
commit
9a452f4a1e
6 changed files with 16 additions and 30 deletions
|
@ -2561,25 +2561,23 @@ static void cliBeeper(char *cmdline)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_RX_BIND
|
|
||||||
void cliRxBind(char *cmdline){
|
void cliRxBind(char *cmdline){
|
||||||
UNUSED(cmdline);
|
UNUSED(cmdline);
|
||||||
switch (rxSpiConfig()->rx_spi_protocol) {
|
switch (rxSpiConfig()->rx_spi_protocol) {
|
||||||
|
#ifdef USE_RX_CC2500_BIND
|
||||||
case RX_SPI_FRSKY_D:
|
case RX_SPI_FRSKY_D:
|
||||||
case RX_SPI_FRSKY_X:
|
case RX_SPI_FRSKY_X:
|
||||||
case RX_SPI_SFHSS:
|
case RX_SPI_SFHSS:
|
||||||
cc2500SpiBind();
|
cc2500SpiBind();
|
||||||
|
|
||||||
cliPrint("Binding...");
|
cliPrint("Binding...");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
cliPrint("Not supported.");
|
cliPrint("Not supported.");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static void printMap(uint8_t dumpMask, const rxConfig_t *rxConfig, const rxConfig_t *defaultRxConfig)
|
static void printMap(uint8_t dumpMask, const rxConfig_t *rxConfig, const rxConfig_t *defaultRxConfig)
|
||||||
{
|
{
|
||||||
|
@ -4466,9 +4464,8 @@ const clicmd_t cmdTable[] = {
|
||||||
CLI_COMMAND_DEF("flash_write", NULL, "<address> <message>", cliFlashWrite),
|
CLI_COMMAND_DEF("flash_write", NULL, "<address> <message>", cliFlashWrite),
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_RX_BIND
|
#ifdef USE_RX_CC2500_BIND
|
||||||
CLI_COMMAND_DEF("frsky_bind", "initiate binding for FrSky SPI RX", NULL, cliRxBind),
|
CLI_COMMAND_DEF("bind", "initiate binding for RX", NULL, cliRxBind),
|
||||||
CLI_COMMAND_DEF("sfhss_bind", "initiate binding for S-FHSS SPI RX", NULL, cliRxBind),
|
|
||||||
#endif
|
#endif
|
||||||
CLI_COMMAND_DEF("get", "get variable value", "[name]", cliGet),
|
CLI_COMMAND_DEF("get", "get variable value", "[name]", cliGet),
|
||||||
#ifdef USE_GPS
|
#ifdef USE_GPS
|
||||||
|
|
|
@ -1114,10 +1114,6 @@ const clivalue_t valueTable[] = {
|
||||||
{ "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, 255 }, PG_RX_FRSKY_SPI_CONFIG, offsetof(rxFrSkySpiConfig_t, rxNum) },
|
||||||
{ "frsky_spi_use_external_adc", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_RX_FRSKY_SPI_CONFIG, offsetof(rxFrSkySpiConfig_t, useExternalAdc) },
|
{ "frsky_spi_use_external_adc", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_RX_FRSKY_SPI_CONFIG, offsetof(rxFrSkySpiConfig_t, useExternalAdc) },
|
||||||
#endif
|
|
||||||
#ifdef USE_RX_SFHSS_SPI
|
|
||||||
{ "sfhss_tx_id", VAR_UINT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = 2, PG_RX_SFHSS_SPI_CONFIG, offsetof(rxSfhssSpiConfig_t, bindTxId) },
|
|
||||||
{ "sfhss_offset", VAR_INT8 | MASTER_VALUE, .config.minmax = { -127, 127 }, PG_RX_SFHSS_SPI_CONFIG, offsetof(rxSfhssSpiConfig_t, bindOffset) },
|
|
||||||
#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) },
|
||||||
#ifdef USE_DASHBOARD
|
#ifdef USE_DASHBOARD
|
||||||
|
|
|
@ -135,8 +135,7 @@
|
||||||
#define PG_BOARD_CONFIG 538
|
#define PG_BOARD_CONFIG 538
|
||||||
#define PG_RCDEVICE_CONFIG 539
|
#define PG_RCDEVICE_CONFIG 539
|
||||||
#define PG_GYRO_DEVICE_CONFIG 540
|
#define PG_GYRO_DEVICE_CONFIG 540
|
||||||
#define PG_RX_SFHSS_SPI_CONFIG 541
|
#define PG_BETAFLIGHT_END 540
|
||||||
#define PG_BETAFLIGHT_END 541
|
|
||||||
|
|
||||||
|
|
||||||
// OSD configuration (subject to change)
|
// OSD configuration (subject to change)
|
||||||
|
|
|
@ -150,7 +150,7 @@ void cc2500LedBlink(timeMs_t blinkms)
|
||||||
static bool ledIsOn=true;
|
static bool ledIsOn=true;
|
||||||
static timeMs_t ledBlinkMs = 0;
|
static timeMs_t ledBlinkMs = 0;
|
||||||
|
|
||||||
if ( (ledBlinkMs + blinkms) > millis() ){
|
if ( (ledBlinkMs + blinkms) > millis() ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ledBlinkMs = millis();
|
ledBlinkMs = millis();
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include "rx/rx_spi.h"
|
#include "rx/rx_spi.h"
|
||||||
|
|
||||||
#include "rx/cc2500_common.h"
|
#include "rx/cc2500_common.h"
|
||||||
|
#include "rx/cc2500_frsky_common.h"
|
||||||
#include "rx/cc2500_sfhss.h"
|
#include "rx/cc2500_sfhss.h"
|
||||||
|
|
||||||
//void cliPrintLinef(const char *format, ...);
|
//void cliPrintLinef(const char *format, ...);
|
||||||
|
@ -82,13 +83,6 @@ static timeMs_t timeTunedMs;
|
||||||
static int8_t bindOffset_max=0;
|
static int8_t bindOffset_max=0;
|
||||||
static int8_t bindOffset_min=0;
|
static int8_t bindOffset_min=0;
|
||||||
|
|
||||||
PG_REGISTER_WITH_RESET_TEMPLATE(rxSfhssSpiConfig_t, rxSfhssSpiConfig, PG_RX_SFHSS_SPI_CONFIG, 1);
|
|
||||||
|
|
||||||
PG_RESET_TEMPLATE(rxSfhssSpiConfig_t, rxSfhssSpiConfig,
|
|
||||||
.bindTxId = {0, 0},
|
|
||||||
.bindOffset = 0,
|
|
||||||
);
|
|
||||||
|
|
||||||
static void initialise() {
|
static void initialise() {
|
||||||
cc2500Reset();
|
cc2500Reset();
|
||||||
|
|
||||||
|
@ -101,7 +95,7 @@ static void initialise() {
|
||||||
cc2500WriteReg(CC2500_08_PKTCTRL0, 0x0C);
|
cc2500WriteReg(CC2500_08_PKTCTRL0, 0x0C);
|
||||||
cc2500WriteReg(CC2500_09_ADDR, 0x29);
|
cc2500WriteReg(CC2500_09_ADDR, 0x29);
|
||||||
cc2500WriteReg(CC2500_0B_FSCTRL1, 0x06);
|
cc2500WriteReg(CC2500_0B_FSCTRL1, 0x06);
|
||||||
cc2500WriteReg(CC2500_0C_FSCTRL0, (rxSfhssSpiConfigMutable()->bindOffset));
|
cc2500WriteReg(CC2500_0C_FSCTRL0, (rxFrSkySpiConfigMutable()->bindOffset));
|
||||||
cc2500WriteReg(CC2500_0D_FREQ2, 0x5C);
|
cc2500WriteReg(CC2500_0D_FREQ2, 0x5C);
|
||||||
cc2500WriteReg(CC2500_0E_FREQ1, 0x4E);
|
cc2500WriteReg(CC2500_0E_FREQ1, 0x4E);
|
||||||
cc2500WriteReg(CC2500_0F_FREQ0, 0xC4);
|
cc2500WriteReg(CC2500_0F_FREQ0, 0xC4);
|
||||||
|
@ -130,7 +124,7 @@ static void initialise() {
|
||||||
cc2500WriteReg(CC2500_2E_TEST0, 0x0B);
|
cc2500WriteReg(CC2500_2E_TEST0, 0x0B);
|
||||||
cc2500WriteReg(CC2500_3E_PATABLE, 0xFF);
|
cc2500WriteReg(CC2500_3E_PATABLE, 0xFF);
|
||||||
|
|
||||||
for(unsigned c = 0;c < 30; c++){
|
for(unsigned c = 0;c < 30; c++) {
|
||||||
//calibrate all channels
|
//calibrate all channels
|
||||||
cc2500Strobe(CC2500_SIDLE);
|
cc2500Strobe(CC2500_SIDLE);
|
||||||
cc2500WriteReg(CC2500_0A_CHANNR, SFHSSCH2CHANNR(c));
|
cc2500WriteReg(CC2500_0A_CHANNR, SFHSSCH2CHANNR(c));
|
||||||
|
@ -171,8 +165,8 @@ static bool sfhssPacketParse(uint8_t *packet, bool check_txid)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_txid){
|
if (check_txid){
|
||||||
if ((rxSfhssSpiConfigMutable()->bindTxId[0] != GET_TXID1(packet)) ||
|
if ((rxFrSkySpiConfigMutable()->bindTxId[0] != GET_TXID1(packet)) ||
|
||||||
(rxSfhssSpiConfigMutable()->bindTxId[1] != GET_TXID2(packet))){
|
(rxFrSkySpiConfigMutable()->bindTxId[1] != GET_TXID2(packet))){
|
||||||
return false; /* txid fail */
|
return false; /* txid fail */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,8 +214,8 @@ static bool tune1Rx(uint8_t *packet)
|
||||||
if (sfhssRecv(packet)){
|
if (sfhssRecv(packet)){
|
||||||
if (sfhssPacketParse(packet, false)){
|
if (sfhssPacketParse(packet, false)){
|
||||||
if ((packet[SFHSS_PACKET_LEN - 1] & 0x7F) > 40 ){ /* lqi */
|
if ((packet[SFHSS_PACKET_LEN - 1] & 0x7F) > 40 ){ /* lqi */
|
||||||
rxSfhssSpiConfigMutable()->bindTxId[0] = GET_TXID1(packet);
|
rxFrSkySpiConfigMutable()->bindTxId[0] = GET_TXID1(packet);
|
||||||
rxSfhssSpiConfigMutable()->bindTxId[1] = GET_TXID2(packet);
|
rxFrSkySpiConfigMutable()->bindTxId[1] = GET_TXID2(packet);
|
||||||
bindOffset_max = bindOffset_min;
|
bindOffset_max = bindOffset_min;
|
||||||
DEBUG_SET(DEBUG_RX_SFHSS_SPI, DEBUG_DATA_OFFSET_MAX, bindOffset_max);
|
DEBUG_SET(DEBUG_RX_SFHSS_SPI, DEBUG_DATA_OFFSET_MAX, bindOffset_max);
|
||||||
cc2500Strobe(CC2500_SRX);
|
cc2500Strobe(CC2500_SRX);
|
||||||
|
@ -347,7 +341,7 @@ rx_spi_received_e sfhssSpiDataReceived(uint8_t *packet)
|
||||||
initTuneRx();
|
initTuneRx();
|
||||||
SET_STATE(STATE_BIND_TUNING1); // retry
|
SET_STATE(STATE_BIND_TUNING1); // retry
|
||||||
} else {
|
} else {
|
||||||
rxSfhssSpiConfigMutable()->bindOffset = ((int16_t)bindOffset_max + (int16_t)bindOffset_min)/2 ;
|
rxFrSkySpiConfigMutable()->bindOffset = ((int16_t)bindOffset_max + (int16_t)bindOffset_min)/2 ;
|
||||||
SET_STATE(STATE_BIND_COMPLETE);
|
SET_STATE(STATE_BIND_COMPLETE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,13 +125,13 @@
|
||||||
|
|
||||||
#if defined(USE_RX_FRSKY_SPI_D) || defined(USE_RX_FRSKY_SPI_X)
|
#if defined(USE_RX_FRSKY_SPI_D) || defined(USE_RX_FRSKY_SPI_X)
|
||||||
#define USE_RX_CC2500
|
#define USE_RX_CC2500
|
||||||
|
#define USE_RX_CC2500_BIND
|
||||||
#define USE_RX_FRSKY_SPI
|
#define USE_RX_FRSKY_SPI
|
||||||
#define USE_RX_BIND
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(USE_RX_SFHSS_SPI)
|
#if defined(USE_RX_SFHSS_SPI)
|
||||||
#define USE_RX_CC2500
|
#define USE_RX_CC2500
|
||||||
#define USE_RX_BIND
|
#define USE_RX_CC2500_BIND
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Burst dshot to default off if not configured explicitly by target
|
// Burst dshot to default off if not configured explicitly by target
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue