1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-24 00:35:39 +03:00

Configurable acc/gyro

This commit is contained in:
jflyper 2018-05-10 22:25:37 +09:00
parent 5ef68ef6a3
commit fc6c24c38e
133 changed files with 1095 additions and 1116 deletions

View file

@ -126,6 +126,7 @@ extern uint8_t __config_end;
#include "pg/board.h"
#include "pg/bus_i2c.h"
#include "pg/bus_spi.h"
#include "pg/gyrodev.h"
#include "pg/max7456.h"
#include "pg/pinio.h"
#include "pg/pg.h"
@ -2701,7 +2702,7 @@ static void cliPrintGyroRegisters(uint8_t whichSensor)
static void cliDumpGyroRegisters(char *cmdline)
{
#ifdef USE_DUAL_GYRO
#ifdef USE_MULTI_GYRO
if ((gyroConfig()->gyro_to_use == GYRO_CONFIG_USE_GYRO_1) || (gyroConfig()->gyro_to_use == GYRO_CONFIG_USE_GYRO_BOTH)) {
cliPrintLinef("\r\n# Gyro 1");
cliPrintGyroRegisters(GYRO_CONFIG_USE_GYRO_1);
@ -2712,7 +2713,7 @@ static void cliDumpGyroRegisters(char *cmdline)
}
#else
cliPrintGyroRegisters(GYRO_CONFIG_USE_GYRO_1);
#endif // USE_DUAL_GYRO
#endif
UNUSED(cmdline);
}
#endif
@ -3823,6 +3824,8 @@ const cliResourceValue_t resourceTable[] = {
#ifdef USE_RX_SPI
DEFS( OWNER_RX_SPI_CS, PG_RX_SPI_CONFIG, rxSpiConfig_t, csnTag ),
#endif
#define PG_ARRAY_OFFSET(type, index, member) (index * sizeof(type) + offsetof(type, member))
DEFW( OWNER_GYRO_CS, PG_GYRO_DEVICE_CONFIG, gyroDeviceConfig_t, csnTag, 2 ),
};
#undef DEFS

View file

@ -70,6 +70,7 @@
#include "pg/beeper_dev.h"
#include "pg/dashboard.h"
#include "pg/flash.h"
#include "pg/gyrodev.h"
#include "pg/max7456.h"
#include "pg/pg.h"
#include "pg/pg_ids.h"
@ -158,7 +159,7 @@ static const char * const lookupTableAlignment[] = {
"CW270FLIP"
};
#ifdef USE_DUAL_GYRO
#ifdef USE_MULTI_GYRO
static const char * const lookupTableGyro[] = {
"FIRST", "SECOND", "BOTH"
};
@ -289,7 +290,10 @@ static const char * const lookupTableFailsafeSwitchMode[] = {
};
static const char * const lookupTableBusType[] = {
"NONE", "I2C", "SPI", "SLAVE"
"NONE", "I2C", "SPI", "SLAVE",
#if defined(USE_SPI_GYRO) && defined(USE_I2C_GYRO)
"GYROAUTO"
#endif
};
#ifdef USE_MAX7456
@ -458,7 +462,7 @@ const lookupTableEntry_t lookupTables[] = {
#ifdef USE_LED_STRIP
LOOKUP_TABLE_ENTRY(lookupLedStripFormatRGB),
#endif
#ifdef USE_DUAL_GYRO
#ifdef USE_MULTI_GYRO
LOOKUP_TABLE_ENTRY(lookupTableGyro),
#endif
LOOKUP_TABLE_ENTRY(lookupTableThrottleLimitType),
@ -485,6 +489,7 @@ const lookupTableEntry_t lookupTables[] = {
#ifdef USE_VTX_COMMON
LOOKUP_TABLE_ENTRY(lookupTableVtxLowPowerDisarm),
#endif
LOOKUP_TABLE_ENTRY(lookupTableGyroHardware),
};
#undef LOOKUP_TABLE_ENTRY
@ -526,7 +531,8 @@ const clivalue_t valueTable[] = {
#if defined(GYRO_USES_SPI) && defined(USE_32K_CAPABLE_GYRO)
{ "gyro_use_32khz", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_GYRO_CONFIG, offsetof(gyroConfig_t, gyro_use_32khz) },
#endif
#ifdef USE_DUAL_GYRO
#endif
#ifdef USE_MULTI_GYRO
{ "gyro_to_use", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_GYRO }, PG_GYRO_CONFIG, offsetof(gyroConfig_t, gyro_to_use) },
#endif
#if defined(USE_GYRO_DATA_ANALYSE)
@ -1153,6 +1159,20 @@ const clivalue_t valueTable[] = {
{ "rcdevice_init_dev_attempts", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 10 }, PG_RCDEVICE_CONFIG, offsetof(rcdeviceConfig_t, initDeviceAttempts) },
{ "rcdevice_init_dev_attempt_interval", VAR_UINT32 | MASTER_VALUE, .config.minmax = { 500, 5000 }, PG_RCDEVICE_CONFIG, offsetof(rcdeviceConfig_t, initDeviceAttemptInterval) }
#endif
#define PG_ARRAY_OFFSET(type, index, member) (index * sizeof(type) + offsetof(type, member))
// PG_GYRO_DEVICE_CONFIG
{ "gyro_1_bustype", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_BUS_TYPE }, PG_GYRO_DEVICE_CONFIG, PG_ARRAY_OFFSET(gyroDeviceConfig_t, 0, bustype) },
{ "gyro_1_spibus", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, SPIDEV_COUNT }, PG_GYRO_DEVICE_CONFIG, PG_ARRAY_OFFSET(gyroDeviceConfig_t, 0, spiBus) },
{ "gyro_1_i2cBus", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, I2CDEV_COUNT }, PG_GYRO_DEVICE_CONFIG, PG_ARRAY_OFFSET(gyroDeviceConfig_t, 0, i2cBus) },
{ "gyro_1_i2c_address", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, I2C_ADDR7_MAX }, PG_GYRO_DEVICE_CONFIG, PG_ARRAY_OFFSET(gyroDeviceConfig_t, 0, i2cAddress) },
#ifdef USE_MULTI_GYRO
{ "gyro_2_bustype", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_BUS_TYPE }, PG_GYRO_DEVICE_CONFIG, PG_ARRAY_OFFSET(gyroDeviceConfig_t, 1, bustype) },
{ "gyro_2_spibus", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, SPIDEV_COUNT }, PG_GYRO_DEVICE_CONFIG, PG_ARRAY_OFFSET(gyroDeviceConfig_t, 1, spiBus) },
{ "gyro_2_i2cBus", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, I2CDEV_COUNT }, PG_GYRO_DEVICE_CONFIG, PG_ARRAY_OFFSET(gyroDeviceConfig_t, 1, i2cBus) },
{ "gyro_2_i2c_address", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, I2C_ADDR7_MAX }, PG_GYRO_DEVICE_CONFIG, PG_ARRAY_OFFSET(gyroDeviceConfig_t, 1, i2cAddress) },
#endif
};
const uint16_t valueTableEntryCount = ARRAYLEN(valueTable);

View file

@ -92,7 +92,7 @@ typedef enum {
#ifdef USE_LED_STRIP
TABLE_RGB_GRB,
#endif
#ifdef USE_DUAL_GYRO
#ifdef USE_MULTI_GYRO
TABLE_GYRO,
#endif
TABLE_THROTTLE_LIMIT_TYPE,
@ -119,6 +119,7 @@ typedef enum {
#ifdef USE_VTX_COMMON
TABLE_VTX_LOW_POWER_DISARM,
#endif
TABLE_GYRO_HARDWARE,
LOOKUP_TABLE_COUNT
} lookupTableIndex_e;