diff --git a/cpu/stm32/periph/i2c_2.c b/cpu/stm32/periph/i2c_2.c index f2814961b4dd..0c29a0a69602 100644 --- a/cpu/stm32/periph/i2c_2.c +++ b/cpu/stm32/periph/i2c_2.c @@ -205,22 +205,8 @@ static void _init(i2c_t dev) I2C_TypeDef *i2c = i2c_config[dev].dev; uint32_t ccr = 0; - /* read speed configuration */ - switch (i2c_config[dev].speed) { - case I2C_SPEED_LOW: - /* 10Kbit/s */ - ccr = i2c_config[dev].clk / 20000; - break; - - case I2C_SPEED_NORMAL: - /* 100Kbit/s */ - ccr = i2c_config[dev].clk / 200000; - break; - - case I2C_SPEED_FAST: - ccr = i2c_config[dev].clk / 800000; - break; - } + /* apply speed configuration */ + ccr = i2c_config[dev].clk / (i2c_config[dev].speed << 1); /* make peripheral soft reset */ i2c->CR1 |= I2C_CR1_SWRST;