From 2743df1e644f0e9f7cf2e4aee912736949c8c91c Mon Sep 17 00:00:00 2001 From: v01d Date: Sat, 13 Aug 2016 18:57:50 -0300 Subject: [PATCH] teensy 3.x i2c --- configs/teensy-3.x/include/board.h | 8 ++++---- configs/teensy-3.x/src/k20_i2c.c | 32 ++++++------------------------ configs/teensy-3.x/src/teensy-3x.h | 3 +++ 3 files changed, 13 insertions(+), 30 deletions(-) diff --git a/configs/teensy-3.x/include/board.h b/configs/teensy-3.x/include/board.h index d0c5c0002b..b95734a04a 100644 --- a/configs/teensy-3.x/include/board.h +++ b/configs/teensy-3.x/include/board.h @@ -234,11 +234,11 @@ #ifdef CONFIG_KINETIS_I2C0 #ifdef CONFIG_TEENSY_3X_I2C_ALT_PINS -# define PIN_I2C0_SCL (PIN_I2C0_SCL_1 | PIN_ALT2_OPENDRAIN | PIN_ALT2_SLOW | PIN_ALT2_HIGHDRIVE) -# define PIN_I2C0_SDA (PIN_I2C0_SDA_1 | PIN_ALT2_OPENDRAIN | PIN_ALT2_SLOW | PIN_ALT2_HIGHDRIVE) +# define PIN_I2C0_SCL (PIN_I2C0_SCL_1 | PIN_ALT2_OPENDRAIN | PIN_ALT2_SLOW) +# define PIN_I2C0_SDA (PIN_I2C0_SDA_1 | PIN_ALT2_OPENDRAIN | PIN_ALT2_SLOW) #else -# define PIN_I2C0_SCL (PIN_I2C0_SCL_2 | PIN_ALT2_OPENDRAIN | PIN_ALT2_SLOW /*| PIN_ALT2_HIGHDRIVE*/) -# define PIN_I2C0_SDA (PIN_I2C0_SDA_2 | PIN_ALT2_OPENDRAIN | PIN_ALT2_SLOW /*| PIN_ALT2_HIGHDRIVE*/) +# define PIN_I2C0_SCL (PIN_I2C0_SCL_2 | PIN_ALT2_OPENDRAIN | PIN_ALT2_SLOW) +# define PIN_I2C0_SDA (PIN_I2C0_SDA_2 | PIN_ALT2_OPENDRAIN | PIN_ALT2_SLOW) #endif #endif diff --git a/configs/teensy-3.x/src/k20_i2c.c b/configs/teensy-3.x/src/k20_i2c.c index be546056fc..b6393b11d1 100644 --- a/configs/teensy-3.x/src/k20_i2c.c +++ b/configs/teensy-3.x/src/k20_i2c.c @@ -2,24 +2,6 @@ * Included Files ************************************************************************************/ -#if 0 -#include - -#include -#include -#include - -#include -#include -#include - -#include "up_arch.h" -#include "chip.h" -#include "kinetis.h" -#include "teensy-3x.h" -#include "kinetis_i2c.h" -#endif - #include #include @@ -35,7 +17,6 @@ #include "kinetis_i2c.h" #include "teensy-3x.h" - #if defined(CONFIG_KINETIS_I2C0) || defined(CONFIG_KINETIS_I2C1) /************************************************************************************ @@ -52,23 +33,22 @@ void kinetis_i2cdev_initialize(void) { - FAR struct i2c_master_s *i2c; + i2c_dev = NULL; #if defined(CONFIG_KINETIS_I2C0) - i2c = kinetis_i2cbus_initialize(0); + i2c_dev = kinetis_i2cbus_initialize(0); #if defined(CONFIG_I2C_DRIVER) - i2c_register(i2c, 0); + i2c_register(i2c_dev, 0); #endif #endif - #if defined(CONFIG_KINETIS_I2C1) - i2c = kinetis_i2cbus_initialize(1); +#error Not yet supported in kinetis driver + i2c_dev = kinetis_i2cbus_initialize(1); #if defined(CONFIG_I2C_DRIVER) - i2c_register(i2c, 1); + i2c_register(i2c_dev, 1); #endif #endif } - #endif /* CONFIG_KINETIS_I2C0 || CONFIG_KINETIS_I2C1 */ diff --git a/configs/teensy-3.x/src/teensy-3x.h b/configs/teensy-3.x/src/teensy-3x.h index a50f5b0606..030ac3d2cd 100644 --- a/configs/teensy-3.x/src/teensy-3x.h +++ b/configs/teensy-3.x/src/teensy-3x.h @@ -44,6 +44,7 @@ #include #include #include +#include /************************************************************************************ * Pre-processor Definitions @@ -76,6 +77,8 @@ * Public data ************************************************************************************/ +FAR struct i2c_master_s* i2c_dev; + #ifndef __ASSEMBLY__ /************************************************************************************