diff options
author | Ryan <fauxpark@gmail.com> | 2025-01-26 23:48:46 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-26 13:48:46 +0100 |
commit | ef29a46c87e3a82459b3af4158f7888d55c0b22b (patch) | |
tree | 9f5ea0f7f46393923e207aeb09dc1242e573be16 /platforms/chibios/drivers/i2c_master.c | |
parent | 291d154d7b13efb83f24c76df26277f32b9f0a58 (diff) |
Unify i2c_master headers (#24846)
* Unify i2c_master headers
* More documentation improvements
* Reorganise PAL mode defaults
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, |