Skip to content

Commit

Permalink
Update i2c_master.xc
Browse files Browse the repository at this point in the history
Added proposed fix from xmos#89
  • Loading branch information
jseaber committed Aug 27, 2024
1 parent 82e82f2 commit e2e75e1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib_i2c/src/i2c_master.xc
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,13 @@ static int tx8(
static const unsigned kbits_per_second,
unsigned &fall_time)
{
// Data is transmitted MSB first
// Data is transmitted MSB first; Added proposed fix from https://github.com/xmos/lib_i2c/issues/89
data = bitrev(data) >> 24;
for (int i = 8; i != 0; i--) {
p_sda <: data & 0x1;
if (data & 1)
p_sda :> void;
else
p_sda <: 0;
data >>= 1;
high_pulse(p_scl, kbits_per_second, fall_time);
}
Expand Down

0 comments on commit e2e75e1

Please sign in to comment.