[Lazarus] FPC interface for reading I2C devices on Raspberry Pi?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] FPC interface for reading I2C devices on Raspberry Pi?

Free Pascal - Lazarus mailing list
I would like to be able to communicate on the I2C bus from my
FPC/Lazarus programs on Raspberry Pi.

There are at least two cases:
1) Reading devices like RTC chips and other sensors.
2) Reading/writing data stored in EEPROM chips

Since the Raspbian system is a Debian Linux derivative I am hoping
there could be a simple way using file I/O, but I don't know how...

Any suggestions?
Software to install in Raspbian?
Packages to install in Lazarus?

I am already using the GPIO I/O via the PiGpio unit and it works well
to read and write I/O pins...


--
Bo Berglund
Developer in Sweden

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] FPC interface for reading I2C devices on Raspberry Pi?

Free Pascal - Lazarus mailing list
On Tue, 12 Nov 2019 10:11:49 +0100, Bo Berglund via lazarus
<[hidden email]> wrote:

>I would like to be able to communicate on the I2C bus from my
>FPC/Lazarus programs on Raspberry Pi.
>
>There are at least two cases:
>1) Reading devices like RTC chips and other sensors.
>2) Reading/writing data stored in EEPROM chips
>
>Since the Raspbian system is a Debian Linux derivative I am hoping
>there could be a simple way using file I/O, but I don't know how...
>
>Any suggestions?
>Software to install in Raspbian?
>Packages to install in Lazarus?
>
>I am already using the GPIO I/O via the PiGpio unit and it works well
>to read and write I/O pins...

After consulting with the Lazarus Forum I got some suggestions and now
I have found a unit TMSLCLRaspiHW.pas from TMS Software, which
implements I2C operations on Raspberry Pi.

But it uses this setting:

{$mode delphi}

whereas my existing application files use this setting:

{$mode objfpc}{$H+}

Can these settings be mixed among units in the same application or
does it have to be a common setting amongst all units?


--
Bo Berglund
Developer in Sweden

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] FPC interface for reading I2C devices on Raspberry Pi?

Free Pascal - Lazarus mailing list
On Tue, 12 Nov 2019 14:53:46 +0100
Bo Berglund via lazarus <[hidden email]> wrote:

> On Tue, 12 Nov 2019 10:11:49 +0100, Bo Berglund via lazarus
> <[hidden email]> wrote:
>
> >I would like to be able to communicate on the I2C bus from my
> >FPC/Lazarus programs on Raspberry Pi.
> >
> >There are at least two cases:
> >1) Reading devices like RTC chips and other sensors.
> >2) Reading/writing data stored in EEPROM chips
> >
> >Since the Raspbian system is a Debian Linux derivative I am hoping
> >there could be a simple way using file I/O, but I don't know how...
> >
> >Any suggestions?
> >Software to install in Raspbian?
> >Packages to install in Lazarus?
> >
> >I am already using the GPIO I/O via the PiGpio unit and it works well
> >to read and write I/O pins...  
>
> After consulting with the Lazarus Forum I got some suggestions and now
> I have found a unit TMSLCLRaspiHW.pas from TMS Software, which
> implements I2C operations on Raspberry Pi.
>
> But it uses this setting:
>
> {$mode delphi}
>
> whereas my existing application files use this setting:
>
> {$mode objfpc}{$H+}
>
> Can these settings be mixed among units

Yes

Mattias
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] FPC interface for reading I2C devices on Raspberry Pi?

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list


On Tue, 12 Nov 2019, Bo Berglund via lazarus wrote:

> On Tue, 12 Nov 2019 10:11:49 +0100, Bo Berglund via lazarus
> <[hidden email]> wrote:
>
>> I would like to be able to communicate on the I2C bus from my
>> FPC/Lazarus programs on Raspberry Pi.
>>
>> There are at least two cases:
>> 1) Reading devices like RTC chips and other sensors.
>> 2) Reading/writing data stored in EEPROM chips
>>
>> Since the Raspbian system is a Debian Linux derivative I am hoping
>> there could be a simple way using file I/O, but I don't know how...
>>
>> Any suggestions?
>> Software to install in Raspbian?
>> Packages to install in Lazarus?
>>
>> I am already using the GPIO I/O via the PiGpio unit and it works well
>> to read and write I/O pins...
>
> After consulting with the Lazarus Forum I got some suggestions and now
> I have found a unit TMSLCLRaspiHW.pas from TMS Software, which
> implements I2C operations on Raspberry Pi.
>
> But it uses this setting:
>
> {$mode delphi}
>
> whereas my existing application files use this setting:
>
> {$mode objfpc}{$H+}
>
> Can these settings be mixed among units in the same application or
> does it have to be a common setting amongst all units?

It can be mixed. The setting applies to the unit in which it was found,
other units can have another setting.

Michael.
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus