Skip to content

Commit

Permalink
Rework i2c part to use one segment per transfer
Browse files Browse the repository at this point in the history
Using requests with multiple 32-byte segments doesn't always
work. Split very transaction in segments of 32 bytes. For the writes,
check that devce chip is ready to process it first. For the read, ask
a status byte for every segemnt.

This fixes 24C eeprom writes, as well as i2cdetect.

  # i2cdetect -r 1
  WARNING! This program can confuse your I2C bus, cause data loss and worse!
  I will probe file /dev/i2c-1 using receive byte commands.
  I will probe address range 0x08-0x77.
  Continue? [Y/n]
       0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
  00:                         -- -- -- -- -- -- -- --
  10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  70: -- -- -- -- -- -- -- --

  # i2cdetect -q 1
  WARNING! This program can confuse your I2C bus, cause data loss and worse!
  I will probe file /dev/i2c-1 using quick write commands.
  I will probe address range 0x08-0x77.
  Continue? [Y/n]
       0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
  00:                         -- -- -- -- -- -- -- --
  10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  70: -- -- -- -- -- -- -- --

Issue gschorcht#13, based on PR gschorcht#7.
  • Loading branch information
bibimbop committed May 17, 2023
1 parent bbdbc85 commit 35ae155
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 204 deletions.
4 changes: 0 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,6 @@ Caveats
The ch341 doesn't work with a Wii nunchuk, possibly because the
pull-up value is too low (1500 ohms).

i2c AT24 eeproms can be read but not programmed properly because the
at24 linux driver tries to write a byte at a time, and doesn't wait at
all (or enough) between writes. Data corruption on writes does occur.

The GPIOs
---------

Expand Down
Loading

0 comments on commit 35ae155

Please sign in to comment.