diff options
Diffstat (limited to 'platforms/chibios/drivers/i2c_master.c')
-rw-r--r-- | platforms/chibios/drivers/i2c_master.c | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/platforms/chibios/drivers/i2c_master.c b/platforms/chibios/drivers/i2c_master.c index 0d5fb1e985..1d7fe27633 100644 --- a/platforms/chibios/drivers/i2c_master.c +++ b/platforms/chibios/drivers/i2c_master.c @@ -29,17 +29,37 @@ #include "i2c_master.h" #include "gpio.h" #include "chibios_config.h" -#include <string.h> #include <ch.h> #include <hal.h> +#ifndef I2C_DRIVER +# define I2C_DRIVER I2CD1 +#endif + #ifndef I2C1_SCL_PIN # define I2C1_SCL_PIN B6 #endif + +#ifndef I2C1_SCL_PAL_MODE +# ifdef USE_GPIOV1 +# define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATE_OPENDRAIN +# else +# define I2C1_SCL_PAL_MODE 4 +# endif +#endif + #ifndef I2C1_SDA_PIN # define I2C1_SDA_PIN B7 #endif +#ifndef I2C1_SDA_PAL_MODE +# ifdef USE_GPIOV1 +# define I2C1_SDA_PAL_MODE PAL_MODE_ALTERNATE_OPENDRAIN +# else +# define I2C1_SDA_PAL_MODE 4 +# endif +#endif + #ifdef USE_I2CV1 # ifndef I2C1_OPMODE # define I2C1_OPMODE OPMODE_I2C @@ -70,27 +90,6 @@ # endif #endif -#ifndef I2C_DRIVER -# define I2C_DRIVER I2CD1 -#endif - -#ifdef USE_GPIOV1 -# ifndef I2C1_SCL_PAL_MODE -# define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATE_OPENDRAIN -# endif -# ifndef I2C1_SDA_PAL_MODE -# define I2C1_SDA_PAL_MODE PAL_MODE_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 -# endif -# ifndef I2C1_SDA_PAL_MODE -# define I2C1_SDA_PAL_MODE 4 -# endif -#endif - static const I2CConfig i2cconfig = { #if defined(USE_I2CV1_CONTRIB) I2C1_CLOCK_SPEED, |