Skip to content
Permalink
Browse files

drivers: i2c: i2c_esp32: fix configuring speed

the driver was actually using 1/4th instead of 1/2th and
1/8th instead of 1/4th periods.

Signed-off-by: Michael Zimmermann <sigmaepsilon92@gmail.com>
  • Loading branch information...
M1cha authored and nashif committed May 18, 2019
1 parent 72177da commit 8ae17cb2069712a5fd5950c4c0ddcf5acbe4a505
Showing with 3 additions and 2 deletions.
  1. +3 −2 drivers/i2c/i2c_esp32.c
@@ -139,14 +139,15 @@ static int i2c_esp32_configure_speed(const struct i2c_esp32_config *config,
return -ENOTSUP;
}

period = (APB_CLK_FREQ / freq_hz) / 2U;
period = (APB_CLK_FREQ / freq_hz);

period /= 2U; /* Set hold and setup times to 1/2th of period */

esp32_set_mask32(period << I2C_SCL_LOW_PERIOD_S,
I2C_SCL_LOW_PERIOD_REG(config->index));
esp32_set_mask32(period << I2C_SCL_HIGH_PERIOD_S,
I2C_SCL_HIGH_PERIOD_REG(config->index));

period /= 2U; /* Set hold and setup times to 1/2th of period */
esp32_set_mask32(period << I2C_SCL_START_HOLD_TIME_S,
I2C_SCL_START_HOLD_REG(config->index));
esp32_set_mask32(period << I2C_SCL_RSTART_SETUP_TIME_S,

0 comments on commit 8ae17cb

Please sign in to comment.
You can’t perform that action at this time.