From b20640beafdbafffc124264fa82c54c4f98ec6b7 Mon Sep 17 00:00:00 2001 From: jflyper Date: Mon, 7 May 2018 01:21:31 +0900 Subject: [PATCH 1/3] Config for NERO --- src/main/target/STM32F7X2/config/NERO.config | 79 ++++++++++++++++++++ src/main/target/STM32F7X2/target.h | 34 +++++---- 2 files changed, 100 insertions(+), 13 deletions(-) create mode 100644 src/main/target/STM32F7X2/config/NERO.config diff --git a/src/main/target/STM32F7X2/config/NERO.config b/src/main/target/STM32F7X2/config/NERO.config new file mode 100644 index 0000000000..2e4653b3aa --- /dev/null +++ b/src/main/target/STM32F7X2/config/NERO.config @@ -0,0 +1,79 @@ +// Usual lawyer stuff here + +# Basic I/O +resource LED 1 B06 +resource LED 2 B05 +resource LED 3 B04 +resource beeper C1 +set beeper_od = OFF +set beeper_inversion = ON + +# Buses +resource I2C_SCL 1 B08 +resource I2C_SDA 1 B09 + +resource SPI_SCK 1 A05 +resource SPI_MISO 1 A06 +resource SPI_MOSI 1 A07 + +resource SPI_SCK 2 B13 +resource SPI_MISO 2 B14 +resource SPI_MOSI 2 B15 + +resource SPI_SCK 3 C10 +resource SPI_MISO 3 C11 +resource SPI_MOSI 3 C12 + +# Timers +# First four timers +# timer is zero origin +timer A0 1 +timer A1 1 +timer A2 1 +timer A3 1 +resource MOTOR 1 A0 +resource MOTOR 2 A1 +resource MOTOR 3 A2 +resource MOTOR 4 A3 + +# Remaining timers +timer B0 1 +timer B1 1 +timer C7 1 +timer C8 1 +timer C9 1 + +# DMA stream conflict if burst mode is not used +# Need to specify dmaopt +set dshot_burst = ON + +resource LED_STRIP B0 + +resource PPM C7 + +# Serial ports + +resource SERIAL_TX 1 A9 +resource SERIAL_RX 1 A10 + +resource SERIAL_TX 3 B10 +resource SERIAL_RX 3 B11 + +resource SERIAL_TX 6 C6 +resource SERIAL_RX 6 C7 + +# ADC + +resource ADC_BATT 1 C03 + +# Remaining + +resource ESCSERIAL 1 C07 +resource SDCARD_CS 1 A15 +resource SDCARD_DETECT 1 D02 + +# Some configs + +FEATURE RX_SERIAL +set serialrx_provider = SBUS +serial 5 64 115200 57600 0 115200 diff --git a/src/main/target/STM32F7X2/target.h b/src/main/target/STM32F7X2/target.h index 9a9b190f1b..80f789d501 100644 --- a/src/main/target/STM32F7X2/target.h +++ b/src/main/target/STM32F7X2/target.h @@ -23,27 +23,32 @@ #define USBD_PRODUCT_STRING "S7X2" +#define USE_BEEPER + #define DEFAULT_VOLTAGE_METER_SOURCE VOLTAGE_METER_ADC -// MPU6500 interrupt +// MPU interrupt #define USE_EXTI #define USE_MPU_DATA_READY_SIGNAL //#define DEBUG_MPU_DATA_READY_INTERRUPT +#define MPU_INT_EXTI PB15 // XXX Should be gone #define USE_ACC -#define USE_FAKE_ACC -#define USE_ACC_MPU6050 -#define ACC_MPU6050_ALIGN CW270_DEG - #define USE_GYRO -#define USE_FAKE_GYRO -#define USE_GYRO_MPU6050 -#define GYRO_MPU6050_ALIGN CW270_DEG -// MPU6050 interrupts -#define USE_MPU_DATA_READY_SIGNAL -#define MPU_INT_EXTI PB15 -#define USE_EXTI +#define USE_FAKE_ACC +#define USE_FAKE_GYRO + +#define USE_ACC_SPI_MPU6500 +#define USE_GYRO_SPI_MPU6500 +// Other USE_ACCs and USE_GYROs should follow + +// Should be gone +#define MPU6500_CS_PIN PC4 // XXX Should be gone +#define MPU6500_SPI_INSTANCE SPI1 // XXX Should be gone +#define ACC_MPU6500_ALIGN CW0_DEG +#define GYRO_MPU6500_ALIGN CW0_DEG + #define USE_MAG #define USE_FAKE_MAG @@ -66,12 +71,15 @@ #define USE_VCP #define USE_UART1 +#define USE_UART2 #define USE_UART3 +#define USE_UART4 +#define USE_UART5 #define USE_UART6 #define USE_SOFTSERIAL1 #define USE_SOFTSERIAL2 -#define SERIAL_PORT_COUNT 6 +#define SERIAL_PORT_COUNT 9 #define USE_ESCSERIAL From f0efe1f8d81d8f0136737fa6f217f7cf563c64ea Mon Sep 17 00:00:00 2001 From: jflyper Date: Mon, 7 May 2018 10:02:29 +0900 Subject: [PATCH 2/3] Move defaults out of pg files --- src/main/pg/bus_i2c.c | 135 ------------------- src/main/pg/bus_spi.c | 19 --- src/main/target/common_defaults_post.h | 174 +++++++++++++++++++++++++ 3 files changed, 174 insertions(+), 154 deletions(-) diff --git a/src/main/pg/bus_i2c.c b/src/main/pg/bus_i2c.c index f2d281c32e..65b4c74700 100644 --- a/src/main/pg/bus_i2c.c +++ b/src/main/pg/bus_i2c.c @@ -39,141 +39,6 @@ #include "pg/bus_i2c.h" -#ifdef I2C_FULL_RECONFIGURABILITY -#if I2CDEV_COUNT >= 1 -#ifndef I2C1_SCL -#define I2C1_SCL NONE -#endif -#ifndef I2C1_SDA -#define I2C1_SDA NONE -#endif -#endif - -#if I2CDEV_COUNT >= 2 -#ifndef I2C2_SCL -#define I2C2_SCL NONE -#endif -#ifndef I2C2_SDA -#define I2C2_SDA NONE -#endif -#endif - -#if I2CDEV_COUNT >= 3 -#ifndef I2C3_SCL -#define I2C3_SCL NONE -#endif -#ifndef I2C3_SDA -#define I2C3_SDA NONE -#endif -#endif - -#if I2CDEV_COUNT >= 4 -#ifndef I2C4_SCL -#define I2C4_SCL NONE -#endif -#ifndef I2C4_SDA -#define I2C4_SDA NONE -#endif -#endif - -#else // I2C_FULL_RECONFIGURABILITY - -// Backward compatibility for exisiting targets - -#ifdef STM32F1 -#ifndef I2C1_SCL -#define I2C1_SCL PB8 -#endif -#ifndef I2C1_SDA -#define I2C1_SDA PB9 -#endif -#ifndef I2C2_SCL -#define I2C2_SCL PB10 -#endif -#ifndef I2C2_SDA -#define I2C2_SDA PB11 -#endif -#endif // STM32F1 - -#ifdef STM32F3 -#ifndef I2C1_SCL -#define I2C1_SCL PB6 -#endif -#ifndef I2C1_SDA -#define I2C1_SDA PB7 -#endif -#ifndef I2C2_SCL -#define I2C2_SCL PA9 -#endif -#ifndef I2C2_SDA -#define I2C2_SDA PA10 -#endif -#endif // STM32F3 - -#ifdef STM32F4 -#ifndef I2C1_SCL -#define I2C1_SCL PB6 -#endif -#ifndef I2C1_SDA -#define I2C1_SDA PB7 -#endif -#ifndef I2C2_SCL -#define I2C2_SCL PB10 -#endif -#ifndef I2C2_SDA -#define I2C2_SDA PB11 -#endif -#ifndef I2C3_SCL -#define I2C3_SCL PA8 -#endif -#ifndef I2C3_SDA -#define I2C3_SDA PC9 -#endif -#endif // STM32F4 - -#ifdef STM32F7 -#ifndef I2C1_SCL -#define I2C1_SCL PB6 -#endif -#ifndef I2C1_SDA -#define I2C1_SDA PB7 -#endif -#ifndef I2C2_SCL -#define I2C2_SCL PB10 -#endif -#ifndef I2C2_SDA -#define I2C2_SDA PB11 -#endif -#ifndef I2C3_SCL -#define I2C3_SCL PA8 -#endif -#ifndef I2C3_SDA -#define I2C3_SDA PB4 -#endif -#ifndef I2C4_SCL -#define I2C4_SCL PD12 -#endif -#ifndef I2C4_SDA -#define I2C4_SDA PD13 -#endif -#endif // STM32F7 - -#endif // I2C_FULL_RECONFIGURABILITY - -// Default values for internal pullup - -#if defined(USE_I2C_PULLUP) -#define I2C1_PULLUP true -#define I2C2_PULLUP true -#define I2C3_PULLUP true -#define I2C4_PULLUP true -#else -#define I2C1_PULLUP false -#define I2C2_PULLUP false -#define I2C3_PULLUP false -#define I2C4_PULLUP false -#endif - typedef struct i2cDefaultConfig_s { I2CDevice device; ioTag_t ioTagScl, ioTagSda; diff --git a/src/main/pg/bus_spi.c b/src/main/pg/bus_spi.c index a09745e66c..edacd082e4 100644 --- a/src/main/pg/bus_spi.c +++ b/src/main/pg/bus_spi.c @@ -29,25 +29,6 @@ #include "bus_spi.h" -// Pin defaults for backward compatibility -#ifndef SPI1_SCK_PIN -#define SPI1_SCK_PIN PA5 -#define SPI1_MISO_PIN PA6 -#define SPI1_MOSI_PIN PA7 -#endif - -#ifndef SPI2_SCK_PIN -#define SPI2_SCK_PIN PB13 -#define SPI2_MISO_PIN PB14 -#define SPI2_MOSI_PIN PB15 -#endif - -#ifndef SPI3_SCK_PIN -#define SPI3_SCK_PIN PB3 -#define SPI3_MISO_PIN PB4 -#define SPI3_MOSI_PIN PB5 -#endif - typedef struct spiDefaultConfig_s { SPIDevice device; ioTag_t sck; diff --git a/src/main/target/common_defaults_post.h b/src/main/target/common_defaults_post.h index 42a2f65af4..50d4dbc4f1 100644 --- a/src/main/target/common_defaults_post.h +++ b/src/main/target/common_defaults_post.h @@ -18,6 +18,8 @@ * If not, see . */ +// pg/max7456 + #ifndef MAX7456_CLOCK_CONFIG_DEFAULT #define MAX7456_CLOCK_CONFIG_DEFAULT MAX7456_CLOCK_CONFIG_OC #endif @@ -25,3 +27,175 @@ #ifndef MAX7456_SPI_CS_PIN #define MAX7456_SPI_CS_PIN NONE #endif + +// pg/bus_i2c + +#ifdef I2C_FULL_RECONFIGURABILITY +#ifdef USE_I2C_DEVICE_1 +#define I2C1_SCL NONE +#define I2C1_SDA NONE +#endif + +#ifdef USE_I2C_DEVICE_2 +#define I2C2_SCL NONE +#define I2C2_SDA NONE +#endif + +#ifdef USE_I2C_DEVICE_3 +#define I2C3_SCL NONE +#define I2C3_SDA NONE +#endif + +#ifdef USE_I2C_DEVICE_4 +#define I2C4_SCL NONE +#define I2C4_SDA NONE +#endif + +#else // I2C_FULL_RECONFIGURABILITY + +// Backward compatibility for exisiting targets + +#ifdef STM32F1 +#ifndef I2C1_SCL +#define I2C1_SCL PB8 +#endif +#ifndef I2C1_SDA +#define I2C1_SDA PB9 +#endif +#ifndef I2C2_SCL +#define I2C2_SCL PB10 +#endif +#ifndef I2C2_SDA +#define I2C2_SDA PB11 +#endif +#endif // STM32F1 + +#ifdef STM32F3 +#ifndef I2C1_SCL +#define I2C1_SCL PB6 +#endif +#ifndef I2C1_SDA +#define I2C1_SDA PB7 +#endif +#ifndef I2C2_SCL +#define I2C2_SCL PA9 +#endif +#ifndef I2C2_SDA +#define I2C2_SDA PA10 +#endif +#endif // STM32F3 + +#ifdef STM32F4 +#ifndef I2C1_SCL +#define I2C1_SCL PB6 +#endif +#ifndef I2C1_SDA +#define I2C1_SDA PB7 +#endif +#ifndef I2C2_SCL +#define I2C2_SCL PB10 +#endif +#ifndef I2C2_SDA +#define I2C2_SDA PB11 +#endif +#ifndef I2C3_SCL +#define I2C3_SCL PA8 +#endif +#ifndef I2C3_SDA +#define I2C3_SDA PC9 +#endif +#endif // STM32F4 + +#ifdef STM32F7 +#ifndef I2C1_SCL +#define I2C1_SCL PB6 +#endif +#ifndef I2C1_SDA +#define I2C1_SDA PB7 +#endif +#ifndef I2C2_SCL +#define I2C2_SCL PB10 +#endif +#ifndef I2C2_SDA +#define I2C2_SDA PB11 +#endif +#ifndef I2C3_SCL +#define I2C3_SCL PA8 +#endif +#ifndef I2C3_SDA +#define I2C3_SDA PB4 +#endif +#ifndef I2C4_SCL +#define I2C4_SCL PD12 +#endif +#ifndef I2C4_SDA +#define I2C4_SDA PD13 +#endif +#endif // STM32F7 + +#endif // I2C_FULL_RECONFIGURABILITY + +// Default values for internal pullup + +#if defined(USE_I2C_PULLUP) +#define I2C1_PULLUP true +#define I2C2_PULLUP true +#define I2C3_PULLUP true +#define I2C4_PULLUP true +#else +#define I2C1_PULLUP false +#define I2C2_PULLUP false +#define I2C3_PULLUP false +#define I2C4_PULLUP false +#endif + +// pg/bus_spi + +#ifdef SPI_FULL_RECONFIGURABILITY + +#ifdef USE_SPI_DEVICE_1 +#define SPI1_SCK_PIN NONE +#define SPI1_MISO_PIN NONE +#define SPI1_MOSI_PIN NONE +#endif + +#ifdef USE_SPI_DEVICE_2 +#define SPI2_SCK_PIN NONE +#define SPI2_MISO_PIN NONE +#define SPI2_MOSI_PIN NONE +#endif + +#ifdef USE_SPI_DEVICE_3 +#define SPI3_SCK_PIN NONE +#define SPI3_MISO_PIN NONE +#define SPI3_MOSI_PIN NONE +#endif + +#ifdef USE_SPI_DEVICE_4 +#define SPI4_SCK_PIN NONE +#define SPI4_MISO_PIN NONE +#define SPI4_MOSI_PIN NONE +#endif + +#else + +// Pin defaults for backward compatibility + +#ifndef SPI1_SCK_PIN +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 +#endif + +#ifndef SPI2_SCK_PIN +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 +#endif + +#ifndef SPI3_SCK_PIN +#define SPI3_SCK_PIN PB3 +#define SPI3_MISO_PIN PB4 +#define SPI3_MOSI_PIN PB5 +#endif +#endif From 969aaa4123faf95ab64356260d7556f4b3564ebe Mon Sep 17 00:00:00 2001 From: jflyper Date: Mon, 7 May 2018 10:03:04 +0900 Subject: [PATCH 3/3] Per mikeller's comment --- src/main/target/STM32F7X2/config/NERO.config | 20 ++++++++++++-------- src/main/target/STM32F7X2/target.h | 12 ++++++------ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/main/target/STM32F7X2/config/NERO.config b/src/main/target/STM32F7X2/config/NERO.config index 2e4653b3aa..807b8715c4 100644 --- a/src/main/target/STM32F7X2/config/NERO.config +++ b/src/main/target/STM32F7X2/config/NERO.config @@ -1,12 +1,18 @@ -// Usual lawyer stuff here +# Usual lawyer stuff here? + +# Name: NERO +# Description: NERO Standard target configuration +# XXX We need something that remembers which config was loaded + +defaults nosave # Basic I/O resource LED 1 B06 resource LED 2 B05 resource LED 3 B04 resource beeper C1 -set beeper_od = OFF set beeper_inversion = ON +set beeper_od = OFF # Buses resource I2C_SCL 1 B08 @@ -36,19 +42,17 @@ resource MOTOR 2 A1 resource MOTOR 3 A2 resource MOTOR 4 A3 +# DMA stream conflict if burst mode is not used +# XXX Need a mechanism to specify dmaopt +set dshot_burst = ON + # Remaining timers timer B0 1 timer B1 1 timer C7 1 timer C8 1 timer C9 1 - -# DMA stream conflict if burst mode is not used -# Need to specify dmaopt -set dshot_burst = ON - resource LED_STRIP B0 - resource PPM C7 # Serial ports diff --git a/src/main/target/STM32F7X2/target.h b/src/main/target/STM32F7X2/target.h index 80f789d501..01338d9a82 100644 --- a/src/main/target/STM32F7X2/target.h +++ b/src/main/target/STM32F7X2/target.h @@ -36,9 +36,6 @@ #define USE_ACC #define USE_GYRO -#define USE_FAKE_ACC -#define USE_FAKE_GYRO - #define USE_ACC_SPI_MPU6500 #define USE_GYRO_SPI_MPU6500 // Other USE_ACCs and USE_GYROs should follow @@ -51,14 +48,14 @@ #define USE_MAG -#define USE_FAKE_MAG #define USE_MAG_HMC5883 #define USE_MAG_QMC5883 #define MAG_HMC5883_ALIGN CW270_DEG_FLIP #define USE_BARO -#define USE_FAKE_BARO #define USE_BARO_MS5611 +#define USE_BARO_BMP280 +#define USE_BARO_LPS #define USE_SDCARD @@ -67,6 +64,9 @@ #define USE_I2C #define USE_I2C_DEVICE_1 +#define USE_I2C_DEVICE_2 +#define USE_I2C_DEVICE_3 +#define I2C_FULL_RECONFIGURABILITY #define USE_VCP @@ -84,10 +84,10 @@ #define USE_ESCSERIAL #define USE_SPI - #define USE_SPI_DEVICE_1 #define USE_SPI_DEVICE_2 #define USE_SPI_DEVICE_3 +#define SPI_FULL_RECONFIGURABILITY #define USE_ADC