From 8304becff77fbb3f2562d2fce6072c48dc90afe1 Mon Sep 17 00:00:00 2001 From: blckmn Date: Thu, 3 Nov 2016 15:35:37 +1100 Subject: [PATCH 1/4] Adding both AirbotF4 and Revolt targets --- src/main/drivers/accgyro_mpu6500.h | 5 ++-- src/main/drivers/accgyro_spi_mpu6500.c | 5 +++- src/main/drivers/dma.h | 1 + src/main/target/REVO/AIRBOTF4.mk | 0 src/main/target/REVO/REVOLT.mk | 0 src/main/target/REVO/target.h | 40 +++++++++++++++++++++----- src/main/target/REVO/target.mk | 2 ++ 7 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 src/main/target/REVO/AIRBOTF4.mk create mode 100644 src/main/target/REVO/REVOLT.mk diff --git a/src/main/drivers/accgyro_mpu6500.h b/src/main/drivers/accgyro_mpu6500.h index 32d0cefcc5..f761c835d3 100644 --- a/src/main/drivers/accgyro_mpu6500.h +++ b/src/main/drivers/accgyro_mpu6500.h @@ -15,9 +15,12 @@ * along with Cleanflight. If not, see . */ +#pragma once + #define MPU6500_WHO_AM_I_CONST (0x70) #define MPU9250_WHO_AM_I_CONST (0x71) #define ICM20608G_WHO_AM_I_CONST (0xAF) +#define ICM20602_WHO_AM_I_CONST (0x12) #define MPU6500_BIT_RESET (0x80) #define MPU6500_BIT_INT_ANYRD_2CLEAR (1 << 4) @@ -25,8 +28,6 @@ #define MPU6500_BIT_I2C_IF_DIS (1 << 4) #define MPU6500_BIT_RAW_RDY_EN (0x01) -#pragma once - bool mpu6500AccDetect(acc_t *acc); bool mpu6500GyroDetect(gyro_t *gyro); diff --git a/src/main/drivers/accgyro_spi_mpu6500.c b/src/main/drivers/accgyro_spi_mpu6500.c index 9c2b7a45df..bfbba6dce5 100755 --- a/src/main/drivers/accgyro_spi_mpu6500.c +++ b/src/main/drivers/accgyro_spi_mpu6500.c @@ -84,7 +84,10 @@ bool mpu6500SpiDetect(void) mpu6500ReadRegister(MPU_RA_WHO_AM_I, 1, &tmp); - if (tmp == MPU6500_WHO_AM_I_CONST || tmp == MPU9250_WHO_AM_I_CONST || tmp == ICM20608G_WHO_AM_I_CONST) { + if (tmp == MPU6500_WHO_AM_I_CONST || + tmp == MPU9250_WHO_AM_I_CONST || + tmp == ICM20608G_WHO_AM_I_CONST || + tmp == ICM20602_WHO_AM_I_CONST) { return true; } diff --git a/src/main/drivers/dma.h b/src/main/drivers/dma.h index ea2c3484f5..cd6ecc10be 100644 --- a/src/main/drivers/dma.h +++ b/src/main/drivers/dma.h @@ -15,6 +15,7 @@ * along with Cleanflight. If not, see . */ +#pragma once struct dmaChannelDescriptor_s; typedef void (*dmaCallbackHandlerFuncPtr)(struct dmaChannelDescriptor_s *channelDescriptor); diff --git a/src/main/target/REVO/AIRBOTF4.mk b/src/main/target/REVO/AIRBOTF4.mk new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/main/target/REVO/REVOLT.mk b/src/main/target/REVO/REVOLT.mk new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/main/target/REVO/target.h b/src/main/target/REVO/target.h index 4d73c99355..f3a065f73b 100644 --- a/src/main/target/REVO/target.h +++ b/src/main/target/REVO/target.h @@ -17,20 +17,33 @@ #pragma once -#define TARGET_BOARD_IDENTIFIER "REVO" - #define CONFIG_START_FLASH_ADDRESS (0x08080000) //0x08080000 to 0x080A0000 (FLASH_Sector_8) +#if defined(AIRBOTF4) +#define TARGET_BOARD_IDENTIFIER "AIR4" +#define USBD_PRODUCT_STRING "AirbotF4" + +#elif defined(REVOLT) +#define TARGET_BOARD_IDENTIFIER "RVLT" +#define USBD_PRODUCT_STRING "Revolt" + +#else +#define TARGET_BOARD_IDENTIFIER "REVO" #define USBD_PRODUCT_STRING "Revolution" + #ifdef OPBL #define USBD_SERIALNUMBER_STRING "0x8020000" #endif +#endif + #define USE_DSHOT #define LED0 PB5 // Disable LED1, conflicts with AirbotF4/Flip32F4 beeper -//#define LED1 PB4 +#if !defined(AIRBOTF4) +#define LED1 PB4 +#endif #define BEEPER PB4 #define BEEPER_INVERTED @@ -41,19 +54,31 @@ #define MPU6000_CS_PIN PA4 #define MPU6000_SPI_INSTANCE SPI1 +#define MPU6500_CS_PIN PA4 +#define MPU6500_SPI_INSTANCE SPI1 + #define ACC #define USE_ACC_SPI_MPU6000 #define GYRO_MPU6000_ALIGN CW270_DEG +#define USE_ACC_MPU6500 +#define USE_ACC_SPI_MPU6500 +#define ACC_MPU6500_ALIGN CW270_DEG + #define GYRO #define USE_GYRO_SPI_MPU6000 #define ACC_MPU6000_ALIGN CW270_DEG +#define USE_GYRO_MPU6500 +#define USE_GYRO_SPI_MPU6500 +#define GYRO_MPU9250_ALIGN CW270_DEG + // MPU6000 interrupts #define USE_EXTI #define MPU_INT_EXTI PC4 #define USE_MPU_DATA_READY_SIGNAL +#if !defined(AIRBOTF4) && !defined(REVOLT) #define MAG #define USE_MAG_HMC5883 #define MAG_HMC5883_ALIGN CW90_DEG @@ -67,6 +92,7 @@ //#define PITOT //#define USE_PITOT_MS4525 //#define MS4525_BUS I2C_DEVICE_EXT +#endif #define M25P16_CS_PIN PB3 #define M25P16_SPI_INSTANCE SPI3 @@ -78,8 +104,8 @@ #define VBUS_SENSING_PIN PC5 #define USE_UART1 -#define UART1_RX_PIN PA10 -#define UART1_TX_PIN PA9 +#define UART1_RX_PIN PA10 +#define UART1_TX_PIN PA9 #define UART1_AHB1_PERIPHERALS RCC_AHB1Periph_DMA2 #define USE_UART3 @@ -106,7 +132,7 @@ #define SPI3_MOSI_PIN PC12 #define USE_I2C -#define I2C_DEVICE (I2CDEV_1) +#define I2C_DEVICE (I2CDEV_1) #define USE_ADC #define CURRENT_METER_ADC_PIN PC1 @@ -126,7 +152,7 @@ #define WS2811_DMA_FLAG DMA_FLAG_TCIF4 #define WS2811_DMA_IT DMA_IT_TCIF4 -#define SENSORS_SET (SENSOR_ACC) +#define SENSORS_SET (SENSOR_ACC) #define DEFAULT_RX_FEATURE FEATURE_RX_SERIAL #define DEFAULT_FEATURES (FEATURE_BLACKBOX) diff --git a/src/main/target/REVO/target.mk b/src/main/target/REVO/target.mk index 2711b19dac..3d8b57a8a6 100644 --- a/src/main/target/REVO/target.mk +++ b/src/main/target/REVO/target.mk @@ -3,5 +3,7 @@ FEATURES += VCP ONBOARDFLASH TARGET_SRC = \ drivers/accgyro_spi_mpu6000.c \ + drivers/accgyro_mpu6500.c \ + drivers/accgyro_spi_mpu6500.c \ drivers/barometer_ms5611.c \ drivers/compass_hmc5883l.c From c9e190fd7a4170de6c2c7349d0119d9c81729e0a Mon Sep 17 00:00:00 2001 From: blckmn Date: Sat, 5 Nov 2016 06:31:31 +1100 Subject: [PATCH 2/4] Leaving beeper defined so it can be assigned to a motor pin on revo --- src/main/target/REVO/target.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/target/REVO/target.h b/src/main/target/REVO/target.h index f3a065f73b..f6517b3632 100644 --- a/src/main/target/REVO/target.h +++ b/src/main/target/REVO/target.h @@ -41,12 +41,14 @@ #define LED0 PB5 // Disable LED1, conflicts with AirbotF4/Flip32F4 beeper -#if !defined(AIRBOTF4) -#define LED1 PB4 -#endif - +#if defined(AIRBOTF4) #define BEEPER PB4 #define BEEPER_INVERTED +#else +#define LED1 PB4 +#define BEEPER NONE +#endif + #define INVERTER PC0 // PC0 used as inverter select GPIO #define INVERTER_USART USART1 From c4f0bb18b8cf77022fadb128749662d98d21e435 Mon Sep 17 00:00:00 2001 From: blckmn Date: Sat, 5 Nov 2016 10:17:04 +1100 Subject: [PATCH 3/4] Revolt adjustments. LED will be enabled once remapping is turned on for LEDs --- src/main/target/REVO/target.c | 6 +++++- src/main/target/REVO/target.h | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/target/REVO/target.c b/src/main/target/REVO/target.c index 77aa1d7d0e..ef6023948b 100644 --- a/src/main/target/REVO/target.c +++ b/src/main/target/REVO/target.c @@ -34,6 +34,10 @@ const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { { TIM3, IO_TAG(PB1), TIM_Channel_4, TIM3_IRQn, TIM_USE_MOTOR, 1, GPIO_AF_TIM3, DMA1_Stream2, DMA_Channel_5, DMA1_ST2_HANDLER }, // S2_OUT { TIM2, IO_TAG(PA3), TIM_Channel_4, TIM2_IRQn, TIM_USE_MOTOR, 1, GPIO_AF_TIM2, DMA1_Stream6, DMA_Channel_3, DMA1_ST6_HANDLER }, // S3_OUT { TIM2, IO_TAG(PA2), TIM_Channel_3, TIM2_IRQn, TIM_USE_MOTOR, 1, GPIO_AF_TIM2, DMA1_Stream1, DMA_Channel_3, DMA1_ST1_HANDLER }, // S4_OUT - { TIM5, IO_TAG(PA1), TIM_Channel_2, TIM5_IRQn, TIM_USE_MOTOR | TIM_USE_LED, 1, GPIO_AF_TIM5, DMA1_Stream4, DMA_Channel_6, DMA1_ST4_HANDLER }, // S5_OUT +#ifdef REVOLT + { TIM4, IO_TAG(PB6), TIM_Channel_1, TIM4_IRQn, TIM_USE_LED, 0, GPIO_AF_TIM4, DMA1_Stream0, DMA_Channel_2, DMA1_ST0_HANDLER }, // LED for REVOLT +#else + { TIM5, IO_TAG(PA1), TIM_Channel_2, TIM5_IRQn, TIM_USE_MOTOR | TIM_USE_LED, 1, GPIO_AF_TIM5, DMA1_Stream4, DMA_Channel_6, DMA1_ST4_HANDLER }, // S5_OUT / LED for REVO { TIM5, IO_TAG(PA0), TIM_Channel_1, TIM5_IRQn, TIM_USE_MOTOR, 1, GPIO_AF_TIM5, DMA1_Stream2, DMA_Channel_6, DMA1_ST2_HANDLER }, // S6_OUT +#endif }; diff --git a/src/main/target/REVO/target.h b/src/main/target/REVO/target.h index f6517b3632..f5540f713b 100644 --- a/src/main/target/REVO/target.h +++ b/src/main/target/REVO/target.h @@ -40,8 +40,8 @@ #define USE_DSHOT #define LED0 PB5 -// Disable LED1, conflicts with AirbotF4/Flip32F4 beeper -#if defined(AIRBOTF4) +// Disable LED1, conflicts with AirbotF4/Flip32F4/Revolt beeper +#if defined(AIRBOTF4) || defined(REVOLT) #define BEEPER PB4 #define BEEPER_INVERTED #else From 4c0273c119fa8ac44daf91bcc17011aea6c232bc Mon Sep 17 00:00:00 2001 From: blckmn Date: Sat, 5 Nov 2016 11:13:58 +1100 Subject: [PATCH 4/4] Revolt has only 11 usable timers defined. --- src/main/target/REVO/target.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/target/REVO/target.h b/src/main/target/REVO/target.h index f5540f713b..dacaff8980 100644 --- a/src/main/target/REVO/target.h +++ b/src/main/target/REVO/target.h @@ -46,11 +46,12 @@ #define BEEPER_INVERTED #else #define LED1 PB4 +// Leave beeper here but with none as io - so disabled unless mapped. #define BEEPER NONE #endif - -#define INVERTER PC0 // PC0 used as inverter select GPIO +// PC0 used as inverter select GPIO +#define INVERTER PC0 #define INVERTER_USART USART1 #define MPU6000_CS_PIN PA4 @@ -168,7 +169,12 @@ #define TARGET_IO_PORTA 0xffff #define TARGET_IO_PORTB 0xffff #define TARGET_IO_PORTC 0xffff -#define TARGET_IO_PORTD 0xffff +#define TARGET_IO_PORTD (BIT(2)) +#ifdef REVOLT +#define USABLE_TIMER_CHANNEL_COUNT 11 +#else #define USABLE_TIMER_CHANNEL_COUNT 12 +#endif + #define USED_TIMERS ( TIM_N(2) | TIM_N(3) | TIM_N(5) | TIM_N(12) | TIM_N(8) | TIM_N(9) )