Skip to content

Commit

Permalink
sn32: drivers: add i2c support
Browse files Browse the repository at this point in the history
  • Loading branch information
dexter93 committed Jun 7, 2024
1 parent 7827de2 commit bd57909
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions platforms/chibios/drivers/i2c_master.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ static const I2CConfig i2cconfig = {
#elif defined(WB32F3G71xx) || defined(WB32FQ95xx)
I2C1_OPMODE,
I2C1_CLOCK_SPEED,
#elif defined(SN32F2)
I2C1_OPMODE,
I2C1_CLOCK_SPEED,
0,
#else
// This configures the I2C clock to 400khz assuming a 72Mhz clock
// For more info : https://www.st.com/en/embedded-software/stsw-stm32126.html
Expand Down Expand Up @@ -139,12 +143,15 @@ __attribute__((weak)) void i2c_init(void) {
palSetLineMode(I2C1_SDA_PIN, PAL_MODE_INPUT);

chThdSleepMilliseconds(10);
#if defined(USE_GPIOV1)
#if !defined(SN32F2)
// SN32 family autoconfigures the pins
# if defined(USE_GPIOV1)
palSetLineMode(I2C1_SCL_PIN, I2C1_SCL_PAL_MODE);
palSetLineMode(I2C1_SDA_PIN, I2C1_SDA_PAL_MODE);
#else
# else
palSetLineMode(I2C1_SCL_PIN, PAL_MODE_ALTERNATE(I2C1_SCL_PAL_MODE) | PAL_OUTPUT_TYPE_OPENDRAIN);
palSetLineMode(I2C1_SDA_PIN, PAL_MODE_ALTERNATE(I2C1_SDA_PAL_MODE) | PAL_OUTPUT_TYPE_OPENDRAIN);
# endif
#endif
}
}
Expand Down

0 comments on commit bd57909

Please sign in to comment.