[fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?
bo.berglund at gmail.com
Sun Apr 2 21:29:52 CEST 2023
On Sun, 2 Apr 2023 07:31:43 +0200, Christo Crause via fpc-pascal
<fpc-pascal at lists.freepascal.org> wrote:
>On Sat, Apr 1, 2023 at 9:57?PM Bo Berglund via fpc-pascal <
>fpc-pascal at lists.freepascal.org> wrote:
>> Can I use Linux file system commands to read/write the data on the i2c
>> memory device and if so how from fpc?
>To some extent it is possible to handle i2c transactions as file read/write
>operations, but some ioctl calls are required to configure e.g. the device
>address . Take note that only a subset of i2c functionality is available
>using read/write calls. Lazi2cdev  uses this approach.
>For finer control over the i2c transactions (for example combined
>write/read transactions) low level ioctl calls are available in Linux. I
>wrote an i2c class  using this approach.
I have now tested the two demos in github  and they seem to work OK.
The i2cscan works and shows exactly the same as sudo i2cdetect -y 1 does from
the i2c-tools package I installed via apt.
i2c_read_reg works too inasmuch as it does not error out, but it returns FF
whatever addres I read like the i2c-tools command does.
I am not sure that it is correct though, for that I need to create an i2c_write
demo app first so I can write values at different locations and read them back.
The EEPROM has until now not been used so it is in its factory state with no
Is there a reason that there is no i2c_write_reg demo in the github package?
I will try to write one so I can test that as well...
Developer in Sweden
More information about the fpc-pascal