diff --git a/Makefile b/Makefile index 62a026806f..17f472b94c 100644 --- a/Makefile +++ b/Makefile @@ -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 \ diff --git a/src/main/drivers/bus_i2c_stm32f30x.c b/src/main/drivers/bus_i2c_stm32f30x.c index 592cf5a3c8..098aff744b 100644 --- a/src/main/drivers/bus_i2c_stm32f30x.c +++ b/src/main/drivers/bus_i2c_stm32f30x.c @@ -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 } diff --git a/src/main/drivers/system.c b/src/main/drivers/system.c index a6cd081ded..3d4b102843 100755 --- a/src/main/drivers/system.c +++ b/src/main/drivers/system.c @@ -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 diff --git a/src/main/io/serial_cli.c b/src/main/io/serial_cli.c index a56f263f6a..b5dc104753 100644 --- a/src/main/io/serial_cli.c +++ b/src/main/io/serial_cli.c @@ -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) diff --git a/src/main/io/serial_msp.c b/src/main/io/serial_msp.c index ef2f11ee73..5907b647bf 100755 --- a/src/main/io/serial_msp.c +++ b/src/main/io/serial_msp.c @@ -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. diff --git a/src/main/sensors/initialisation.c b/src/main/sensors/initialisation.c index c49057b0ba..3d85b346a9 100755 --- a/src/main/sensors/initialisation.c +++ b/src/main/sensors/initialisation.c @@ -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 diff --git a/src/main/target/CC3D/target.h b/src/main/target/CC3D/target.h index a53c4e4f3f..663b57670d 100644 --- a/src/main/target/CC3D/target.h +++ b/src/main/target/CC3D/target.h @@ -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 diff --git a/src/main/target/CHEBUZZF3/target.h b/src/main/target/CHEBUZZF3/target.h index 44ab59f435..47a41511f1 100644 --- a/src/main/target/CHEBUZZF3/target.h +++ b/src/main/target/CHEBUZZF3/target.h @@ -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) diff --git a/src/main/target/CJMCU/target.h b/src/main/target/CJMCU/target.h index e11fdba345..b075e12fbf 100644 --- a/src/main/target/CJMCU/target.h +++ b/src/main/target/CJMCU/target.h @@ -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 diff --git a/src/main/target/EUSTM32F103RC/target.h b/src/main/target/EUSTM32F103RC/target.h index 4753d37a29..365e66cd13 100644 --- a/src/main/target/EUSTM32F103RC/target.h +++ b/src/main/target/EUSTM32F103RC/target.h @@ -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 diff --git a/src/main/target/NAZE/target.h b/src/main/target/NAZE/target.h index 97817a0e8e..e49a99f7de 100644 --- a/src/main/target/NAZE/target.h +++ b/src/main/target/NAZE/target.h @@ -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 diff --git a/src/main/target/NAZE32PRO/target.h b/src/main/target/NAZE32PRO/target.h index c6fedca4b6..0f0bbfcced 100644 --- a/src/main/target/NAZE32PRO/target.h +++ b/src/main/target/NAZE32PRO/target.h @@ -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) diff --git a/src/main/target/OLIMEXINO/target.h b/src/main/target/OLIMEXINO/target.h index 3cc89df390..25826a8310 100644 --- a/src/main/target/OLIMEXINO/target.h +++ b/src/main/target/OLIMEXINO/target.h @@ -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 diff --git a/src/main/target/STM32F3DISCOVERY/target.h b/src/main/target/STM32F3DISCOVERY/target.h index e22e8c6182..759ba09519 100644 --- a/src/main/target/STM32F3DISCOVERY/target.h +++ b/src/main/target/STM32F3DISCOVERY/target.h @@ -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)