i2c pin configuration.
Posted: Mon Mar 23, 2020 4:52 pm
Hi,
First time using I2C on STM32 / Chibios.
How am I supposed to initialize the pins for I2C use?
This seems to work, but I find it not "neat" to have to poke the pullup registers by hand.
What doesn't help is that the "demos" and "examples" often don't show how to configure pins as they have poked the configuration into the board setup file.
First time using I2C on STM32 / Chibios.
How am I supposed to initialize the pins for I2C use?
Code: Select all
if (strcmp (argv[1], "init") == 0) {
palSetPadMode (GPIOB, 6, PAL_MODE_OUTPUT_PUSHPULL);
for (i=0;i<100;i++)
palTogglePad (GPIOB, 6);
palSetPadMode (GPIOB, 6, PAL_STM32_MODE_ALTERNATE | PAL_STM32_OTYPE_OPENDRAIN
| PAL_STM32_ALTERNATE(1));
palSetPadMode (GPIOB, 7, PAL_STM32_MODE_ALTERNATE | PAL_STM32_OTYPE_OPENDRAIN
| PAL_STM32_ALTERNATE(1));
GPIOB -> PUPDR |= 1 << (6*2);
GPIOB -> PUPDR |= 1 << (7*2);
i2cStart(&I2CD1, &i2cfg1);
What doesn't help is that the "demos" and "examples" often don't show how to configure pins as they have poked the configuration into the board setup file.