From e8591ae8e4f94e1080326509bc80cfa0c9d88c26 Mon Sep 17 00:00:00 2001 From: zvecr Date: Wed, 4 Dec 2019 00:26:49 +0000 Subject: [PATCH 1/4] Add central location for chibios defines --- drivers/arm/i2c_master.h | 28 ++++++++++------------------ quantum/backlight/backlight_arm.c | 4 ---- quantum/quantum.h | 1 + 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/arm/i2c_master.h b/drivers/arm/i2c_master.h index 31cbfb9774a7..346513ad8086 100644 --- a/drivers/arm/i2c_master.h +++ b/drivers/arm/i2c_master.h @@ -27,10 +27,6 @@ #include "ch.h" #include -#if defined(STM32F1XX) || defined(STM32F1xx) || defined(STM32F2xx) || defined(STM32F4xx) || defined(STM32F4XX) || defined(STM32L0xx) || defined(STM32L1xx) -# define USE_I2CV1 -#endif - #ifdef I2C1_BANK # define I2C1_SCL_BANK I2C1_BANK # define I2C1_SDA_BANK I2C1_BANK @@ -51,20 +47,6 @@ # define I2C1_SDA 7 #endif -#if defined(STM32F1XX) || defined(STM32F1xx) -# define USE_GPIOV1 -#endif - -#ifndef USE_GPIOV1 -// The default PAL alternate modes are used to signal that the pins are used for I2C -# ifndef I2C1_SCL_PAL_MODE -# define I2C1_SCL_PAL_MODE 4 -# endif -# ifndef I2C1_SDA_PAL_MODE -# define I2C1_SDA_PAL_MODE 4 -# endif -#endif - #ifdef USE_I2CV1 # ifndef I2C1_OPMODE # define I2C1_OPMODE OPMODE_I2C @@ -99,6 +81,16 @@ # define I2C_DRIVER I2CD1 #endif +#ifndef USE_GPIOV1 +// The default PAL alternate modes are used to signal that the pins are used for I2C +# ifndef I2C1_SCL_PAL_MODE +# define I2C1_SCL_PAL_MODE 4 +# endif +# ifndef I2C1_SDA_PAL_MODE +# define I2C1_SDA_PAL_MODE 4 +# endif +#endif + typedef int16_t i2c_status_t; #define I2C_STATUS_SUCCESS (0) diff --git a/quantum/backlight/backlight_arm.c b/quantum/backlight/backlight_arm.c index 3f94ccef8ecd..8c6909a4ae83 100644 --- a/quantum/backlight/backlight_arm.c +++ b/quantum/backlight/backlight_arm.c @@ -10,10 +10,6 @@ # error "Backlight support for STMF072 is not available. Please disable." # endif -# if defined(STM32F1XX) || defined(STM32F1xx) -# define USE_GPIOV1 -# endif - // GPIOV2 && GPIOV3 # ifndef BACKLIGHT_PAL_MODE # define BACKLIGHT_PAL_MODE 2 diff --git a/quantum/quantum.h b/quantum/quantum.h index 2ee261e60d6b..b5de3c7393b3 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -22,6 +22,7 @@ #endif #if defined(PROTOCOL_CHIBIOS) # include "hal.h" +# include "chibios_config.h" #endif #include "wait.h" From d0d4c3e170194e05471cf204cc8866ee6bea5efc Mon Sep 17 00:00:00 2001 From: zvecr Date: Wed, 4 Dec 2019 01:19:13 +0000 Subject: [PATCH 2/4] Add central location for chibios defines - actually add files this time.... --- tmk_core/common/chibios/chibios_config.h | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tmk_core/common/chibios/chibios_config.h diff --git a/tmk_core/common/chibios/chibios_config.h b/tmk_core/common/chibios/chibios_config.h new file mode 100644 index 000000000000..432513bcbb35 --- /dev/null +++ b/tmk_core/common/chibios/chibios_config.h @@ -0,0 +1,9 @@ +#pragma once + +#if defined(STM32F1XX) +# define USE_GPIOV1 +#endif + +#if defined(STM32F1XX) || defined(STM32F2XX) || defined(STM32F4XX) || defined(STM32L1XX) +# define USE_I2CV1 +#endif From c330d2d12640a915ae01d7d94bf8f16be5d34cee Mon Sep 17 00:00:00 2001 From: zvecr Date: Wed, 4 Dec 2019 01:28:19 +0000 Subject: [PATCH 3/4] Add Copyright header --- tmk_core/common/chibios/chibios_config.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tmk_core/common/chibios/chibios_config.h b/tmk_core/common/chibios/chibios_config.h index 432513bcbb35..272529608343 100644 --- a/tmk_core/common/chibios/chibios_config.h +++ b/tmk_core/common/chibios/chibios_config.h @@ -1,3 +1,18 @@ +/* Copyright 2019 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #pragma once #if defined(STM32F1XX) From eb92b5351f2cde17ffb8ed733e28f9f249da1179 Mon Sep 17 00:00:00 2001 From: zvecr Date: Thu, 5 Dec 2019 13:08:06 +0000 Subject: [PATCH 4/4] Update include order to resolve i2cv1 build errors --- drivers/arm/i2c_master.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/arm/i2c_master.c b/drivers/arm/i2c_master.c index b9eff0ad2e8b..21aefd497ccf 100644 --- a/drivers/arm/i2c_master.c +++ b/drivers/arm/i2c_master.c @@ -24,9 +24,8 @@ * STM32_I2C_USE_I2C1 is TRUE in the mcuconf.h file. Pins B6 and B7 are used * but using any other I2C pins should be trivial. */ - -#include "i2c_master.h" #include "quantum.h" +#include "i2c_master.h" #include #include