summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/chibios/i2c_master.c8
-rw-r--r--drivers/chibios/i2c_master.h9
-rw-r--r--drivers/oled/oled_driver.c10
-rw-r--r--drivers/oled/oled_driver.h4
-rw-r--r--keyboards/handwired/onekey/teensy_32/config.h6
-rw-r--r--keyboards/handwired/onekey/teensy_32/halconf.h2
-rw-r--r--keyboards/handwired/onekey/teensy_32/mcuconf.h6
-rw-r--r--keyboards/handwired/onekey/teensy_lc/config.h6
-rw-r--r--keyboards/handwired/onekey/teensy_lc/halconf.h2
-rw-r--r--keyboards/handwired/onekey/teensy_lc/mcuconf.h6
-rw-r--r--tmk_core/common/chibios/chibios_config.h7
11 files changed, 54 insertions, 12 deletions
diff --git a/drivers/chibios/i2c_master.c b/drivers/chibios/i2c_master.c
index ede915fa4a..4bd8e2af76 100644
--- a/drivers/chibios/i2c_master.c
+++ b/drivers/chibios/i2c_master.c
@@ -32,7 +32,9 @@
static uint8_t i2c_address;
static const I2CConfig i2cconfig = {
-#ifdef USE_I2CV1
+#if defined(USE_I2CV1_CONTRIB)
+ I2C1_CLOCK_SPEED,
+#elif defined(USE_I2CV1)
I2C1_OPMODE,
I2C1_CLOCK_SPEED,
I2C1_DUTY_CYCLE,
@@ -62,8 +64,8 @@ __attribute__((weak)) void i2c_init(void) {
chThdSleepMilliseconds(10);
#if defined(USE_GPIOV1)
- palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);
- palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);
+ palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, I2C1_SCL_PAL_MODE);
+ palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, I2C1_SDA_PAL_MODE);
#else
palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_ALTERNATE(I2C1_SCL_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_ALTERNATE(I2C1_SDA_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
diff --git a/drivers/chibios/i2c_master.h b/drivers/chibios/i2c_master.h
index 3d3891289f..b3e234e161 100644
--- a/drivers/chibios/i2c_master.h
+++ b/drivers/chibios/i2c_master.h
@@ -81,7 +81,14 @@
# define I2C_DRIVER I2CD1
#endif
-#ifndef USE_GPIOV1
+#ifdef USE_GPIOV1
+# ifndef I2C1_SCL_PAL_MODE
+# define I2C1_SCL_PAL_MODE PAL_MODE_STM32_ALTERNATE_OPENDRAIN
+# endif
+# ifndef I2C1_SDA_PAL_MODE
+# define I2C1_SDA_PAL_MODE PAL_MODE_STM32_ALTERNATE_OPENDRAIN
+# endif
+#else
// 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
diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c
index 977b701783..f1990567f7 100644
--- a/drivers/oled/oled_driver.c
+++ b/drivers/oled/oled_driver.c
@@ -82,14 +82,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define I2C_CMD 0x00
#define I2C_DATA 0x40
#if defined(__AVR__)
-// already defined on ARM
-# define I2C_TIMEOUT 100
-# define I2C_TRANSMIT_P(data) i2c_transmit_P((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), I2C_TIMEOUT)
+# define I2C_TRANSMIT_P(data) i2c_transmit_P((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), OLED_I2C_TIMEOUT)
#else // defined(__AVR__)
-# define I2C_TRANSMIT_P(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), I2C_TIMEOUT)
+# define I2C_TRANSMIT_P(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), OLED_I2C_TIMEOUT)
#endif // defined(__AVR__)
-#define I2C_TRANSMIT(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), I2C_TIMEOUT)
-#define I2C_WRITE_REG(mode, data, size) i2c_writeReg((OLED_DISPLAY_ADDRESS << 1), mode, data, size, I2C_TIMEOUT)
+#define I2C_TRANSMIT(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), OLED_I2C_TIMEOUT)
+#define I2C_WRITE_REG(mode, data, size) i2c_writeReg((OLED_DISPLAY_ADDRESS << 1), mode, data, size, OLED_I2C_TIMEOUT)
#define HAS_FLAGS(bits, flags) ((bits & flags) == flags)
diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h
index af6e5a2b61..5c21c0cc8e 100644
--- a/drivers/oled/oled_driver.h
+++ b/drivers/oled/oled_driver.h
@@ -150,6 +150,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# endif
#endif
+#if !defined(OLED_I2C_TIMEOUT)
+# define OLED_I2C_TIMEOUT 100
+#endif
+
// OLED Rotation enum values are flags
typedef enum {
OLED_ROTATION_0 = 0,
diff --git a/keyboards/handwired/onekey/teensy_32/config.h b/keyboards/handwired/onekey/teensy_32/config.h
index 0d82a05786..a4839135a0 100644
--- a/keyboards/handwired/onekey/teensy_32/config.h
+++ b/keyboards/handwired/onekey/teensy_32/config.h
@@ -22,3 +22,9 @@
#define MATRIX_COL_PINS { D5 }
#define MATRIX_ROW_PINS { B2 }
#define UNUSED_PINS
+
+// i2c_master defines
+#define I2C1_SCL 0 // A2 on pinout = B0
+#define I2C1_SDA 1 // A3 on pinout = B1
+#define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATIVE_2
+#define I2C1_SDA_PAL_MODE PAL_MODE_ALTERNATIVE_2
diff --git a/keyboards/handwired/onekey/teensy_32/halconf.h b/keyboards/handwired/onekey/teensy_32/halconf.h
index 16f32117d5..de0f29ce6e 100644
--- a/keyboards/handwired/onekey/teensy_32/halconf.h
+++ b/keyboards/handwired/onekey/teensy_32/halconf.h
@@ -79,7 +79,7 @@
* @brief Enables the I2C subsystem.
*/
#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
-#define HAL_USE_I2C FALSE
+#define HAL_USE_I2C TRUE
#endif
/**
diff --git a/keyboards/handwired/onekey/teensy_32/mcuconf.h b/keyboards/handwired/onekey/teensy_32/mcuconf.h
index 13a9e3333f..327f5c9aa3 100644
--- a/keyboards/handwired/onekey/teensy_32/mcuconf.h
+++ b/keyboards/handwired/onekey/teensy_32/mcuconf.h
@@ -42,4 +42,10 @@
* 5 for Teensy 3.x */
#define KINETIS_USB_USB0_IRQ_PRIORITY 5
+/*
+ * I2C driver settings
+ */
+#define KINETIS_I2C_USE_I2C0 TRUE
+#define KINETIS_I2C_I2C0_PRIORITY 4
+
#endif /* _MCUCONF_H_ */
diff --git a/keyboards/handwired/onekey/teensy_lc/config.h b/keyboards/handwired/onekey/teensy_lc/config.h
index 0d82a05786..a4839135a0 100644
--- a/keyboards/handwired/onekey/teensy_lc/config.h
+++ b/keyboards/handwired/onekey/teensy_lc/config.h
@@ -22,3 +22,9 @@
#define MATRIX_COL_PINS { D5 }
#define MATRIX_ROW_PINS { B2 }
#define UNUSED_PINS
+
+// i2c_master defines
+#define I2C1_SCL 0 // A2 on pinout = B0
+#define I2C1_SDA 1 // A3 on pinout = B1
+#define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATIVE_2
+#define I2C1_SDA_PAL_MODE PAL_MODE_ALTERNATIVE_2
diff --git a/keyboards/handwired/onekey/teensy_lc/halconf.h b/keyboards/handwired/onekey/teensy_lc/halconf.h
index 16f32117d5..de0f29ce6e 100644
--- a/keyboards/handwired/onekey/teensy_lc/halconf.h
+++ b/keyboards/handwired/onekey/teensy_lc/halconf.h
@@ -79,7 +79,7 @@
* @brief Enables the I2C subsystem.
*/
#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
-#define HAL_USE_I2C FALSE
+#define HAL_USE_I2C TRUE
#endif
/**
diff --git a/keyboards/handwired/onekey/teensy_lc/mcuconf.h b/keyboards/handwired/onekey/teensy_lc/mcuconf.h
index ea576df5bc..f73bec3dc3 100644
--- a/keyboards/handwired/onekey/teensy_lc/mcuconf.h
+++ b/keyboards/handwired/onekey/teensy_lc/mcuconf.h
@@ -42,4 +42,10 @@
* 5 for Teensy 3.x */
#define KINETIS_USB_USB0_IRQ_PRIORITY 2
+/*
+ * I2C driver settings
+ */
+#define KINETIS_I2C_USE_I2C0 TRUE
+#define KINETIS_I2C_I2C0_PRIORITY 4
+
#endif /* _MCUCONF_H_ */
diff --git a/tmk_core/common/chibios/chibios_config.h b/tmk_core/common/chibios/chibios_config.h
index 2725296083..1dd979f6ac 100644
--- a/tmk_core/common/chibios/chibios_config.h
+++ b/tmk_core/common/chibios/chibios_config.h
@@ -22,3 +22,10 @@
#if defined(STM32F1XX) || defined(STM32F2XX) || defined(STM32F4XX) || defined(STM32L1XX)
# define USE_I2CV1
#endif
+
+// teensy
+#if defined(K20x) || defined(KL2x)
+# define USE_I2CV1
+# define USE_I2CV1_CONTRIB // for some reason a bunch of ChibiOS-Contrib boards only have clock_speed
+# define USE_GPIOV1
+#endif