Various fixes based on mikeller's comment.
This commit is contained in:
parent
fc6c24c38e
commit
9ef9f98310
|
@ -3824,7 +3824,6 @@ 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 ),
|
||||
};
|
||||
|
||||
|
|
|
@ -531,7 +531,6 @@ 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
|
||||
#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
|
||||
|
@ -1157,21 +1156,19 @@ const clivalue_t valueTable[] = {
|
|||
// RCDEVICE
|
||||
#ifdef USE_RCDEVICE
|
||||
{ "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) }
|
||||
{ "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) },
|
||||
{ "gyro_1_bustype", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_BUS_TYPE }, PG_GYRO_DEVICE_CONFIG, PG_ARRAY_ELEMENT_OFFSET(gyroDeviceConfig_t, 0, bustype) },
|
||||
{ "gyro_1_spibus", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, SPIDEV_COUNT }, PG_GYRO_DEVICE_CONFIG, PG_ARRAY_ELEMENT_OFFSET(gyroDeviceConfig_t, 0, spiBus) },
|
||||
{ "gyro_1_i2cBus", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, I2CDEV_COUNT }, PG_GYRO_DEVICE_CONFIG, PG_ARRAY_ELEMENT_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_ELEMENT_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) },
|
||||
{ "gyro_2_bustype", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_BUS_TYPE }, PG_GYRO_DEVICE_CONFIG, PG_ARRAY_ELEMENT_OFFSET(gyroDeviceConfig_t, 1, bustype) },
|
||||
{ "gyro_2_spibus", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, SPIDEV_COUNT }, PG_GYRO_DEVICE_CONFIG, PG_ARRAY_ELEMENT_OFFSET(gyroDeviceConfig_t, 1, spiBus) },
|
||||
{ "gyro_2_i2cBus", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, I2CDEV_COUNT }, PG_GYRO_DEVICE_CONFIG, PG_ARRAY_ELEMENT_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_ELEMENT_OFFSET(gyroDeviceConfig_t, 1, i2cAddress) },
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -25,16 +25,18 @@
|
|||
|
||||
#include "pg/pg.h"
|
||||
#include "pg/pg_ids.h"
|
||||
#include "pg/gyrodev.h"
|
||||
|
||||
#include "drivers/io.h"
|
||||
#include "drivers/bus_spi.h"
|
||||
#include "drivers/sensor.h"
|
||||
#include "sensors/gyro.h"
|
||||
|
||||
#include "pg/gyrodev.h"
|
||||
|
||||
ioTag_t selectMPUIntExtiConfigByHardwareRevision(void); // XXX Should be gone
|
||||
|
||||
#if defined(USE_SPI_GYRO) || defined(USE_I2C_GYRO)
|
||||
static void gyroResetCommonDeviceConfig(gyroDeviceConfig_t *devconf, ioTag_t extiTag, sensor_align_e align)
|
||||
static void gyroResetCommonDeviceConfig(gyroDeviceConfig_t *devconf, ioTag_t extiTag, uint8_t align)
|
||||
{
|
||||
devconf->extiTag = extiTag;
|
||||
devconf->align = align;
|
||||
|
@ -42,7 +44,7 @@ static void gyroResetCommonDeviceConfig(gyroDeviceConfig_t *devconf, ioTag_t ext
|
|||
#endif
|
||||
|
||||
#ifdef USE_SPI_GYRO
|
||||
static void gyroResetSpiDeviceConfig(gyroDeviceConfig_t *devconf, SPI_TypeDef *instance, ioTag_t csnTag, ioTag_t extiTag, sensor_align_e align)
|
||||
static void gyroResetSpiDeviceConfig(gyroDeviceConfig_t *devconf, SPI_TypeDef *instance, ioTag_t csnTag, ioTag_t extiTag, uint8_t align)
|
||||
{
|
||||
devconf->bustype = BUSTYPE_SPI;
|
||||
devconf->spiBus = SPI_DEV_TO_CFG(spiDeviceByInstance(instance));
|
||||
|
@ -52,7 +54,7 @@ static void gyroResetSpiDeviceConfig(gyroDeviceConfig_t *devconf, SPI_TypeDef *i
|
|||
#endif
|
||||
|
||||
#ifdef USE_I2C_GYRO
|
||||
static void gyroResetI2cDeviceConfig(gyroDeviceConfig_t *devconf, I2CDevice i2cbus, ioTag_t extiTag, sensor_align_e align)
|
||||
static void gyroResetI2cDeviceConfig(gyroDeviceConfig_t *devconf, I2CDevice i2cbus, ioTag_t extiTag, uint8_t align)
|
||||
{
|
||||
devconf->bustype = BUSTYPE_I2C;
|
||||
devconf->i2cBus = I2C_DEV_TO_CFG(i2cbus);
|
||||
|
|
|
@ -22,12 +22,9 @@
|
|||
|
||||
|
||||
#include <stdint.h>
|
||||
//#include <stdbool.h>
|
||||
|
||||
#include "pg/pg.h"
|
||||
#include "drivers/io_types.h"
|
||||
#include "drivers/sensor.h"
|
||||
#include "sensors/gyro.h"
|
||||
|
||||
typedef struct gyroDeviceConfig_s {
|
||||
int8_t index;
|
||||
|
@ -37,13 +34,7 @@ typedef struct gyroDeviceConfig_s {
|
|||
uint8_t i2cBus;
|
||||
uint8_t i2cAddress;
|
||||
ioTag_t extiTag;
|
||||
sensor_align_e align;
|
||||
uint8_t align; // sensor_align_e
|
||||
} gyroDeviceConfig_t;
|
||||
|
||||
#ifdef USE_MULTI_GYRO
|
||||
#define MAX_GYRODEV_COUNT 2
|
||||
#else
|
||||
#define MAX_GYRODEV_COUNT 1
|
||||
#endif
|
||||
|
||||
PG_DECLARE_ARRAY(gyroDeviceConfig_t, MAX_GYRODEV_COUNT, gyroDeviceConfig);
|
||||
|
|
|
@ -174,6 +174,8 @@ extern const uint8_t __pg_resetdata_end[];
|
|||
/**/
|
||||
#endif
|
||||
|
||||
#define PG_ARRAY_ELEMENT_OFFSET(type, index, member) (index * sizeof(type) + offsetof(type, member))
|
||||
|
||||
// Emit reset defaults for config.
|
||||
// Config must be registered with PG_REGISTER_<xxx>_WITH_RESET_TEMPLATE macro
|
||||
#define PG_RESET_TEMPLATE(_type, _name, ...) \
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
#define USE_MPU_DATA_READY_SIGNAL
|
||||
#define USE_EXTI
|
||||
#define USE_GYRO_EXTI
|
||||
#define GYRO_1_EXTI_PINPC4
|
||||
#define GYRO_1_EXTI_PIN PC4
|
||||
#define USE_EXTI
|
||||
|
||||
#define USE_MAG
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
#define USE_MPU_DATA_READY_SIGNAL
|
||||
#define USE_EXTI
|
||||
#define USE_GYRO_EXTI
|
||||
#define GYRO_1_EXTI_PINPC4
|
||||
#define GYRO_1_EXTI_PIN PC4
|
||||
#define USE_EXTI
|
||||
|
||||
#define USE_MAG
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
|
||||
#define USE_EXTI
|
||||
#define USE_GYRO_EXTI
|
||||
#define GYRO_1_EXTI_PINPC13
|
||||
#define GYRO_1_EXTI_PIN PC13
|
||||
#define USE_MPU_DATA_READY_SIGNAL
|
||||
#define GYRO_1_SPI_INSTANCE SPI1
|
||||
#define GYRO_1_CS_PIN PA4
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
|
||||
#define USE_EXTI
|
||||
#define USE_GYRO_EXTI
|
||||
#define GYRO_1_EXTI_PINPC13
|
||||
#define GYRO_1_EXTI_PIN PC13
|
||||
#define USE_MPU_DATA_READY_SIGNAL
|
||||
#define EXTI15_10_CALLBACK_HANDLER_COUNT 1 // MPU_INT, SDCardDetect
|
||||
#define MPU_ADDRESS 0x69
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
#define USE_MPU_DATA_READY_SIGNAL
|
||||
#define USE_EXTI
|
||||
#define USE_GYRO_EXTI
|
||||
#define GYRO_1_EXTI_PINPB15
|
||||
#define GYRO_1_EXTI_PIN PB15
|
||||
#define USE_EXTI
|
||||
|
||||
#define USE_MAG
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
#define USE_EXTI
|
||||
#define USE_MPU_DATA_READY_SIGNAL
|
||||
#define USE_GYRO_EXTI
|
||||
#define GYRO_1_EXTI_PINPA15
|
||||
#define GYRO_1_EXTI_PIN PA15
|
||||
|
||||
#define USE_GYRO
|
||||
#define USE_GYRO_SPI_MPU6000
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
|
||||
#define USE_EXTI
|
||||
#define USE_GYRO_EXTI
|
||||
#define GYRO_1_EXTI_PINPC13
|
||||
#define GYRO_1_EXTI_PIN PC13
|
||||
#define USE_MPU_DATA_READY_SIGNAL
|
||||
#define ENSURE_MPU_DATA_READY_IS_LOW
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
|
||||
#define USE_EXTI
|
||||
#define USE_GYRO_EXTI
|
||||
#define GYRO_1_EXTI_PINPC13
|
||||
#define GYRO_1_EXTI_PIN PC13
|
||||
#define USE_MPU_DATA_READY_SIGNAL
|
||||
#define ENSURE_MPU_DATA_READY_IS_LOW
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#define USE_MPU_DATA_READY_SIGNAL
|
||||
//#define DEBUG_MPU_DATA_READY_INTERRUPT
|
||||
#define USE_GYRO_EXTI
|
||||
#define GYRO_1_EXTI_PINPB15 // XXX Should be gone
|
||||
#define GYRO_1_EXTI_PIN PB15 // XXX Should be gone
|
||||
|
||||
#define USE_ACC
|
||||
#define USE_GYRO
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
#define USE_EXTI
|
||||
#define USE_GYRO_EXTI
|
||||
#define GYRO_1_EXTI_PINPC13
|
||||
#define GYRO_1_EXTI_PIN PC13
|
||||
#define USE_MPU_DATA_READY_SIGNAL
|
||||
|
||||
#define GYRO_1_SPI_INSTANCE SPI1
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
// MPU6500 interrupts
|
||||
#define USE_EXTI
|
||||
#define USE_GYRO_EXTI
|
||||
#define GYRO_1_EXTI_PINPD10
|
||||
#define GYRO_1_EXTI_PIN PD10
|
||||
#define USE_MPU_DATA_READY_SIGNAL
|
||||
|
||||
/*
|
||||
|
|
|
@ -251,3 +251,9 @@
|
|||
#else
|
||||
#define GYRO_I2C_ADDRESS 0 // AUTO
|
||||
#endif
|
||||
|
||||
#ifdef USE_MULTI_GYRO
|
||||
#define MAX_GYRODEV_COUNT 2
|
||||
#else
|
||||
#define MAX_GYRODEV_COUNT 1
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue