aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2019-12-21 18:22:49 +0000
committerGitHub <noreply@github.com>2019-12-21 18:22:49 +0000
commit376419a4f7e0489111a9ac24acc847342fe9d64d (patch)
tree7956534e51eb87d62af3c4ba81f19118a7a04ef9
parent05b479d349aafb8298b43fcbfcddc4440336de9c (diff)
downloadqmk_firmware-376419a4f7e0489111a9ac24acc847342fe9d64d.tar.gz
qmk_firmware-376419a4f7e0489111a9ac24acc847342fe9d64d.zip
Add central location for ChibiOS defines (#7542)
* Add central location for chibios defines * Add central location for chibios defines - actually add files this time.... * Add Copyright header * Update include order to resolve i2cv1 build errors
-rw-r--r--drivers/arm/i2c_master.c3
-rw-r--r--drivers/arm/i2c_master.h28
-rw-r--r--quantum/backlight/backlight_arm.c4
-rw-r--r--quantum/quantum.h1
-rw-r--r--tmk_core/common/chibios/chibios_config.h24
5 files changed, 36 insertions, 24 deletions
diff --git a/drivers/arm/i2c_master.c b/drivers/arm/i2c_master.c
index b9eff0ad2..21aefd497 100644
--- a/drivers/arm/i2c_master.c
+++ b/drivers/arm/i2c_master.c
@@ -24,9 +24,8 @@
24 * STM32_I2C_USE_I2C1 is TRUE in the mcuconf.h file. Pins B6 and B7 are used 24 * STM32_I2C_USE_I2C1 is TRUE in the mcuconf.h file. Pins B6 and B7 are used
25 * but using any other I2C pins should be trivial. 25 * but using any other I2C pins should be trivial.
26 */ 26 */
27
28#include "i2c_master.h"
29#include "quantum.h" 27#include "quantum.h"
28#include "i2c_master.h"
30#include <string.h> 29#include <string.h>
31#include <hal.h> 30#include <hal.h>
32 31
diff --git a/drivers/arm/i2c_master.h b/drivers/arm/i2c_master.h
index 31cbfb977..346513ad8 100644
--- a/drivers/arm/i2c_master.h
+++ b/drivers/arm/i2c_master.h
@@ -27,10 +27,6 @@
27#include "ch.h" 27#include "ch.h"
28#include <hal.h> 28#include <hal.h>
29 29
30#if defined(STM32F1XX) || defined(STM32F1xx) || defined(STM32F2xx) || defined(STM32F4xx) || defined(STM32F4XX) || defined(STM32L0xx) || defined(STM32L1xx)
31# define USE_I2CV1
32#endif
33
34#ifdef I2C1_BANK 30#ifdef I2C1_BANK
35# define I2C1_SCL_BANK I2C1_BANK 31# define I2C1_SCL_BANK I2C1_BANK
36# define I2C1_SDA_BANK I2C1_BANK 32# define I2C1_SDA_BANK I2C1_BANK
@@ -51,20 +47,6 @@
51# define I2C1_SDA 7 47# define I2C1_SDA 7
52#endif 48#endif
53 49
54#if defined(STM32F1XX) || defined(STM32F1xx)
55# define USE_GPIOV1
56#endif
57
58#ifndef USE_GPIOV1
59// The default PAL alternate modes are used to signal that the pins are used for I2C
60# ifndef I2C1_SCL_PAL_MODE
61# define I2C1_SCL_PAL_MODE 4
62# endif
63# ifndef I2C1_SDA_PAL_MODE
64# define I2C1_SDA_PAL_MODE 4
65# endif
66#endif
67
68#ifdef USE_I2CV1 50#ifdef USE_I2CV1
69# ifndef I2C1_OPMODE 51# ifndef I2C1_OPMODE
70# define I2C1_OPMODE OPMODE_I2C 52# define I2C1_OPMODE OPMODE_I2C
@@ -99,6 +81,16 @@
99# define I2C_DRIVER I2CD1 81# define I2C_DRIVER I2CD1
100#endif 82#endif
101 83
84#ifndef USE_GPIOV1
85// The default PAL alternate modes are used to signal that the pins are used for I2C
86# ifndef I2C1_SCL_PAL_MODE
87# define I2C1_SCL_PAL_MODE 4
88# endif
89# ifndef I2C1_SDA_PAL_MODE
90# define I2C1_SDA_PAL_MODE 4
91# endif
92#endif
93
102typedef int16_t i2c_status_t; 94typedef int16_t i2c_status_t;
103 95
104#define I2C_STATUS_SUCCESS (0) 96#define I2C_STATUS_SUCCESS (0)
diff --git a/quantum/backlight/backlight_arm.c b/quantum/backlight/backlight_arm.c
index 3f94ccef8..8c6909a4a 100644
--- a/quantum/backlight/backlight_arm.c
+++ b/quantum/backlight/backlight_arm.c
@@ -10,10 +10,6 @@
10# error "Backlight support for STMF072 is not available. Please disable." 10# error "Backlight support for STMF072 is not available. Please disable."
11# endif 11# endif
12 12
13# if defined(STM32F1XX) || defined(STM32F1xx)
14# define USE_GPIOV1
15# endif
16
17// GPIOV2 && GPIOV3 13// GPIOV2 && GPIOV3
18# ifndef BACKLIGHT_PAL_MODE 14# ifndef BACKLIGHT_PAL_MODE
19# define BACKLIGHT_PAL_MODE 2 15# define BACKLIGHT_PAL_MODE 2
diff --git a/quantum/quantum.h b/quantum/quantum.h
index b9e7eea24..053b33b91 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -22,6 +22,7 @@
22#endif 22#endif
23#if defined(PROTOCOL_CHIBIOS) 23#if defined(PROTOCOL_CHIBIOS)
24# include "hal.h" 24# include "hal.h"
25# include "chibios_config.h"
25#endif 26#endif
26 27
27#include "wait.h" 28#include "wait.h"
diff --git a/tmk_core/common/chibios/chibios_config.h b/tmk_core/common/chibios/chibios_config.h
new file mode 100644
index 000000000..272529608
--- /dev/null
+++ b/tmk_core/common/chibios/chibios_config.h
@@ -0,0 +1,24 @@
1/* Copyright 2019
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#if defined(STM32F1XX)
19# define USE_GPIOV1
20#endif
21
22#if defined(STM32F1XX) || defined(STM32F2XX) || defined(STM32F4XX) || defined(STM32L1XX)
23# define USE_I2CV1
24#endif