The "standard" I2C driver (NOT the "fallback" driver) works for me on PB8/9, using the same configuration data as you. (I am using a driver which also supports I2C slave, but the master part is basically the same).
You definitely need to configure the ports as open drain outputs as Giovanni suggested, and set up the alternate functions correctly.
Make sure that you have not activated SDA1 and SCL1 on more than one pin each.
My configuration pre-dates using the XML configuration file; from board.h I have:
Code: Select all
#define GPIOB_I2C1_SCL 8U
#define GPIOB_I2C1_SDA 9U
#define VAL_GPIOB_MODER :
PIN_MODE_ALTERNATE(GPIOB_I2C1_SCL) | \
PIN_MODE_ALTERNATE(GPIOB_I2C1_SDA) | \
#define VAL_GPIOB_OTYPER :
PIN_OTYPE_OPENDRAIN(GPIOB_I2C1_SCL) | \
PIN_OTYPE_OPENDRAIN(GPIOB_I2C1_SDA) | \
#define VAL_GPIOB_OSPEEDR :
PIN_OSPEED_100M(GPIOB_I2C1_SCL) | \
PIN_OSPEED_100M(GPIOB_I2C1_SDA) | \
#define VAL_GPIOB_PUPDR :
PIN_PUPDR_FLOATING(GPIOB_I2C1_SCL) | \
PIN_PUPDR_FLOATING(GPIOB_I2C1_SDA) | \
#define VAL_GPIOB_ODR :
PIN_ODR_HIGH(GPIOB_I2C1_SCL) | \
PIN_ODR_HIGH(GPIOB_I2C1_SDA) | \
#define VAL_GPIOB_AFRH (PIN_AFIO_AF(GPIOB_I2C1_SCL, 4) | \
PIN_AFIO_AF(GPIOB_I2C1_SDA, 4) | \
Not sure whether that driver works without DMA; pretty certain I had it enabled.
Code: Select all
#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)