[fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

Christo Crause christo.crause at gmail.com
Sun Apr 2 07:31:43 CEST 2023


On Sat, Apr 1, 2023 at 9:57 PM Bo Berglund via fpc-pascal <
fpc-pascal at lists.freepascal.org> wrote:

> Question:
> Can I use Linux file system commands to read/write the data on the i2c
> EEPROM
> 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 [1]. Take note that only a subset of i2c functionality is available
using read/write calls. Lazi2cdev [2] 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 [3] using this approach.

1. https://www.kernel.org/doc/html/latest/i2c/dev-interface.html
2. https://github.com/laz2wiringpi/lazI2cdev/blob/master/i2cdev_base.pas
2. https://github.com/ccrause/rpiplc_pas/blob/main/native/i2c.pas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20230402/8fd9f900/attachment.htm>


More information about the fpc-pascal mailing list