Skip to content

Commit

Permalink
Incorporate raspberrypi#273
Browse files Browse the repository at this point in the history
  • Loading branch information
dhalbert committed Mar 26, 2021
1 parent 9323b67 commit e258d99
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/rp2_common/hardware_i2c/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ uint i2c_set_baudrate(i2c_inst_t *i2c, uint baudrate) {
i2c->hw->fs_scl_lcnt = lcnt;
i2c->hw->fs_spklen = lcnt < 16 ? 1 : lcnt / 16;

// Set hold time of SDA during transmit to 2. The TCS34725 color sensor
// and the SH1107 OLED display driver do not work well without this change,
// and there may be other devices that would benefit as well.
// There is no discernable slowdown in timing traces.
i2c->hw->sda_hold =
I2C_IC_SDA_HOLD_IC_SDA_RX_HOLD_RESET << I2C_IC_SDA_HOLD_IC_SDA_RX_HOLD_LSB |
2 << I2C_IC_SDA_HOLD_IC_SDA_TX_HOLD_LSB;
i2c->hw->enable = 1;
return freq_in / period;
}
Expand Down

0 comments on commit e258d99

Please sign in to comment.