Skip to content

Commit a06b572

Browse files
committed
Incorporate raspberrypi#273
1 parent 9323b67 commit a06b572

File tree

1 file changed

+6
-0
lines changed
  • src/rp2_common/hardware_i2c

1 file changed

+6
-0
lines changed

src/rp2_common/hardware_i2c/i2c.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ uint i2c_set_baudrate(i2c_inst_t *i2c, uint baudrate) {
8585
i2c->hw->fs_scl_lcnt = lcnt;
8686
i2c->hw->fs_spklen = lcnt < 16 ? 1 : lcnt / 16;
8787

88+
// Set hold time of SDA during transmit to 2. The TCS34725 color sensor
89+
// does not work without this change, and perhaps it helps other I2C
90+
// devices as well. There is no discernable change slowdown in timing traces.
91+
i2c->hw->sda_hold =
92+
I2C_IC_SDA_HOLD_IC_SDA_RX_HOLD_RESET << I2C_IC_SDA_HOLD_IC_SDA_RX_HOLD_LSB |
93+
2 << I2C_IC_SDA_HOLD_IC_SDA_TX_HOLD_LSB;
8894
i2c->hw->enable = 1;
8995
return freq_in / period;
9096
}

0 commit comments

Comments
 (0)