[Lazarus] Accessing GPIO on RaspberryPi2 from Lazarus/FPC

Bo Berglund bo.berglund at gmail.com
Sun Oct 11 00:27:17 CEST 2015


On Thu, 08 Oct 2015 23:30:10 +0200, Bo Berglund
<bo.berglund at gmail.com> wrote:

>I have found a description of a unit implementing an interface to the
>gpio driver in the Free Pascal documentation. It is here:
>http://wiki.freepascal.org/Lazarus_on_Raspberry_Pi#5._PiGpio_Low-level_native_pascal_unit_.28GPIO_control_instead_of_wiringPi_c_library.29
>
>However, it specifically lists the BCM2835 chip and not the BCM2836
>which is used on the Pi2.
>
>So I wonder if anyone here knows about an updated gpio.pas file which
>works on the Pi2?

I have solved the problem now. This is how I modified pigpio.pas:
1) I added a define for RPI2 and used it in a conditional to set the
REG_GPIO constant to $3F000 or $20000

2) I changed the device from /dev/mem to /dev/gpiomem
This allowed the generated program to run as user pi.

3) I also added the Pi connector mapping defines into pigpio.pas so
that any user program does not have to enter this in its own code.
Just use RPI_P12 or similar in the user code.

Apart from this pigpio.pas stays the same as before.

Thanks to all that helped me come to this result!

-- 
Bo Berglund
Developer in Sweden





More information about the Lazarus mailing list