Allow disabling of I2C for targets that do not use it.

This commit is contained in:
Dominic Clifton 2014-09-26 01:14:39 +01:00
parent 15cbeff86e
commit 35280abfed
14 changed files with 46 additions and 11 deletions

View File

@ -312,7 +312,6 @@ CC3D_SRC = startup_stm32f10x_md_gcc.S \
drivers/accgyro_spi_mpu6000.c \
drivers/adc.c \
drivers/adc_stm32f10x.c \
drivers/bus_i2c_stm32f10x.c \
drivers/bus_spi.c \
drivers/gpio_stm32f10x.c \
drivers/inverter.c \

View File

@ -162,6 +162,7 @@ void i2cInitPort(I2C_TypeDef *I2Cx)
void i2cInit(I2CDevice index)
{
UNUSED(index);
i2cInitPort(I2C1); // FIXME hard coded to use I2C1 for now
}

View File

@ -131,7 +131,7 @@ void systemInit(bool overclock)
spiInit(SPI2);
#endif
#ifndef CC3D
#ifdef USE_I2C
// Configure the rest of the stuff
i2cInit(I2C_DEVICE);
#endif

View File

@ -1161,7 +1161,13 @@ static void cliStatus(char *cmdline)
}
cliPrint("\r\n");
printf("Cycle Time: %d, I2C Errors: %d, config size: %d\r\n", cycleTime, i2cGetErrorCounter(), sizeof(master_t));
#ifdef USE_I2C
uint16_t i2cErrorCounter = i2cGetErrorCounter();
#else
uint16_t i2cErrorCounter = 0;
#endif
printf("Cycle Time: %d, I2C Errors: %d, config size: %d\r\n", cycleTime, i2cErrorCounter, sizeof(master_t));
}
static void cliVersion(char *cmdline)

View File

@ -484,7 +484,11 @@ static bool processOutCommand(uint8_t cmdMSP)
case MSP_STATUS:
headSerialReply(11);
serialize16(cycleTime);
#ifdef USE_I2C
serialize16(i2cGetErrorCounter());
#else
serialize16(0);
#endif
serialize16(sensors(SENSOR_ACC) | sensors(SENSOR_BARO) << 1 | sensors(SENSOR_MAG) << 2 | sensors(SENSOR_GPS) << 3 | sensors(SENSOR_SONAR) << 4);
// OK, so you waste all the fucking time to have BOXNAMES and BOXINDEXES etc, and then you go ahead and serialize enabled shit simply by stuffing all
// the bits in order, instead of setting the enabled bits based on BOXINDEX. WHERE IS THE FUCKING LOGIC IN THIS, FUCKWADS.

View File

@ -60,20 +60,45 @@
// Use these to help with porting to new boards
//#define USE_FAKE_GYRO
#ifdef USE_I2C
#define USE_GYRO_L3G4200D
#define USE_GYRO_L3GD20
#define USE_GYRO_MPU6050
#define USE_GYRO_SPI_MPU6000
#define USE_GYRO_MPU3050
#endif
#define USE_GYRO_SPI_MPU6000
//#define USE_FAKE_ACC
#ifdef USE_I2C
#define USE_ACC_ADXL345
#define USE_ACC_BMA280
#define USE_ACC_MMA8452
#define USE_ACC_LSM303DLHC
#define USE_ACC_MPU6050
#endif
#define USE_ACC_SPI_MPU6000
#ifdef USE_I2C
#define USE_BARO_MS5611
#define USE_BARO_BMP085
#endif
#ifdef MASSIVEF3
#define USE_FAKE_GYRO
#define USE_FAKE_ACC
#undef USE_GYRO_MPU6050
#undef USE_ACC_MPU6050
#undef USE_ACC_ADXL345
#undef USE_ACC_BMA280
#undef USE_ACC_MMA8452
#undef USE_ACC_LSM303DLHC
#undef USE_ACC_SPI_MPU6000
#undef USE_GYRO_L3G4200D
#undef USE_GYRO_MPU3050
#undef USE_GYRO_SPI_MPU6000
#undef USE_GYRO_L3GD20
#undef USE_BARO_BMP085
#endif
#ifdef NAZE
#undef USE_ACC_LSM303DLHC

View File

@ -34,12 +34,6 @@
#define INVERTER
#define BEEPER
// #define SOFT_I2C // enable to test software i2c
// #define SOFT_I2C_PB1011 // If SOFT_I2C is enabled above, need to define pinout as well (I2C1 = PB67, I2C2 = PB1011)
// #define SOFT_I2C_PB67
#define USE_USART1
#define USE_USART3

View File

@ -45,6 +45,7 @@
#define USE_USART2
#define SERIAL_PORT_COUNT 3
#define USE_I2C
#define I2C_DEVICE (I2CDEV_1)
#define SENSORS_SET (SENSOR_ACC)

View File

@ -44,6 +44,7 @@
#define SERIAL_PORT_COUNT 2
#define USE_I2C
#define I2C_DEVICE (I2CDEV_1)
// #define SOFT_I2C // enable to test software i2c

View File

@ -29,6 +29,7 @@
#define USE_SOFT_SERIAL
#define SERIAL_PORT_COUNT 4
#define USE_I2C
#define I2C_DEVICE (I2CDEV_2)
// #define SOFT_I2C // enable to test software i2c

View File

@ -53,7 +53,7 @@
#define USE_SOFT_SERIAL
#define SERIAL_PORT_COUNT 4
#define USE_I2C
#define I2C_DEVICE (I2CDEV_2)
// #define SOFT_I2C // enable to test software i2c

View File

@ -35,6 +35,7 @@
#define USE_USART2
#define SERIAL_PORT_COUNT 3
#define USE_I2C
#define I2C_DEVICE (I2CDEV_1)
#define SENSORS_SET (SENSOR_ACC)

View File

@ -46,6 +46,7 @@
#define USE_SOFT_SERIAL
#define SERIAL_PORT_COUNT 4
#define USE_I2C
#define I2C_DEVICE (I2CDEV_2)
// #define SOFT_I2C // enable to test software i2c

View File

@ -47,6 +47,7 @@
#define USE_USART2
#define SERIAL_PORT_COUNT 3
#define USE_I2C
#define I2C_DEVICE (I2CDEV_1)
#define SENSORS_SET (SENSOR_ACC)