Skip to content

Commit

Permalink
Update Gyro driver for generic target
Browse files Browse the repository at this point in the history
  • Loading branch information
MJ666 committed Oct 2, 2018
1 parent 5b91ec4 commit 9e36354
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/main/interface/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -3838,6 +3838,9 @@ const cliResourceValue_t resourceTable[] = {
#endif
#ifdef USE_RX_SPI
DEFS( OWNER_RX_SPI_CS, PG_RX_SPI_CONFIG, rxSpiConfig_t, csnTag ),
#endif
#ifdef USE_GYRO_EXTI
DEFW( OWNER_GYRO_EXTI, PG_GYRO_DEVICE_CONFIG, gyroDeviceConfig_t, extiTag, 2 ),
#endif
DEFW( OWNER_GYRO_CS, PG_GYRO_DEVICE_CONFIG, gyroDeviceConfig_t, csnTag, 2 ),
#ifdef USE_USB_DETECT
Expand Down
2 changes: 2 additions & 0 deletions src/main/interface/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -1177,11 +1177,13 @@ const clivalue_t valueTable[] = {
{ "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) },
{ "gyro_1_sensor_align", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_ALIGNMENT }, PG_GYRO_DEVICE_CONFIG, PG_ARRAY_ELEMENT_OFFSET(gyroDeviceConfig_t, 0, align) },
#ifdef USE_MULTI_GYRO
{ "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) },
{ "gyro_2_sensor_align", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_ALIGNMENT }, PG_GYRO_DEVICE_CONFIG, PG_ARRAY_ELEMENT_OFFSET(gyroDeviceConfig_t, 1, align) },
#endif
};

Expand Down
2 changes: 2 additions & 0 deletions src/main/target/STM32F7X2/config/NERO.config
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ resource SPI_PREINIT_IPU 2 A15 // SDCARD

# Acc/gyro
resource gyro_cs 1 C4
resource GYRO_EXTI 1 B15
set gyro_1_bustype = SPI
set gyro_1_spibus = 1
set gyro_1_sensor_align = CW0
#set gyro_1_hardware = MPU6500 # Not working (yet ... will it ever?)

# Timers
Expand Down
12 changes: 0 additions & 12 deletions src/main/target/STM32F7X2/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,6 @@
#define USE_GYRO_SPI_MPU6500
// Other USE_ACCs and USE_GYROs should follow

#define GYRO_1_SPI_INSTANCE NULL
#define GYRO_1_CS_PIN NONE
#define GYRO_1_ALIGN ALIGN_DEFAULT
#define ACC_1_ALIGN ALIGN_DEFAULT
#define GYRO_1_EXTI_PIN PB15 // XXX Should be gone

#define GYRO_2_SPI_INSTANCE NULL
#define GYRO_2_CS_PIN NONE
#define GYRO_2_ALIGN ALIGN_DEFAULT
#define ACC_2_ALIGN ALIGN_DEFAULT
#define GYRO_2_EXTI_PIN NONE

#define GYRO_CONFIG_USE_GYRO_DEFAULT GYRO_CONFIG_USE_GYRO_1

#define USE_MAG
Expand Down
8 changes: 8 additions & 0 deletions src/main/target/common_defaults_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@
#define ACC_2_ALIGN ALIGN_DEFAULT
#endif

#if !defined(GYRO_1_SPI_INSTANCE)
#define GYRO_1_SPI_INSTANCE NULL
#endif

#if !defined(GYRO_1_CS_PIN)
#define GYRO_1_CS_PIN NONE
#endif

#if !defined(GYRO_1_EXTI_PIN)
#define GYRO_1_EXTI_PIN NONE
#endif
Expand Down

0 comments on commit 9e36354

Please sign in to comment.