Skip to content

Commit

Permalink
cpu/stm32: allow arbitrary I2C clocks
Browse files Browse the repository at this point in the history
  • Loading branch information
maribu committed Dec 10, 2023
1 parent 54b1bec commit 10641ae
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions cpu/stm32/periph/i2c_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 10641ae

Please sign in to comment.