config

Configures a I2C interface. PB8=SCL PB9=SDA
Author: Johannes Taelman
License: BSD
Github: gpio/i2c/config.axo

Inlets

None

Outlets

None

Init
// setup the pins
palSetPadMode(GPIOB, 8,
              PAL_MODE_ALTERNATE(4) | PAL_STM32_PUDR_PULLUP |
                  PAL_STM32_OTYPE_OPENDRAIN); // SCL
palSetPadMode(GPIOB, 9,
              PAL_MODE_ALTERNATE(4) | PAL_STM32_PUDR_PULLUP |
                  PAL_STM32_OTYPE_OPENDRAIN); // SDA
static const I2CConfig i2cfg = {
    OPMODE_I2C,
    400000,
    FAST_DUTY_CYCLE_2,
};
i2cStart(&I2CD1, &i2cfg);
Dispose
i2cStop(&I2CD1);
palSetPadMode(GPIOB, 8, PAL_MODE_INPUT_ANALOG);
palSetPadMode(GPIOB, 9, PAL_MODE_INPUT_ANALOG);

Privacy

© 2024 Zrna Research