From a7cf1a7c352ea653ad90ff67931159e9ebba1590 Mon Sep 17 00:00:00 2001 From: jflyper Date: Mon, 7 May 2018 10:02:29 +0900 Subject: [PATCH] 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 f2d281c32..65b4c7470 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 a09745e66..edacd082e 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 42a2f65af..50d4dbc4f 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