comp.lang.ada
 help / color / mirror / Atom feed
From: "Björn Lundin" <b.f.lundin@gmail.com>
Subject: Re: GNATCOLL-Mmap example
Date: Fri, 31 Jan 2020 17:59:49 +0100
Date: 2020-01-31T17:59:49+01:00	[thread overview]
Message-ID: <r11me6$i07$1@dont-email.me> (raw)
In-Reply-To: <d62dca95-7349-47eb-8858-46980fbb0088@googlegroups.com>

Den 2020-01-28 kl. 19:53, skrev Bob Goddard:
> On Tuesday, 28 January 2020 08:25:25 UTC, Dmitry A. Kazakov  wrote:
>> On 2020-01-25 22:52, Bob Goddard wrote:
>>
>>> I need to map the RPi's GPIO memory addresses so that I can do what I need to do.
>>
>> See files under:
>>
>>      /sys/class/gpio
>>
>> You can use standard Ada I/O to read and set GPIO pins. E.g.
>>
>>      /sys/class/gpio/gpio/XXX/value
> 
> This was the way I started, but could not get it to read anything. It just blocks trying to read a single character. My c code works fine using the wiringPi libs.
> 
>


Or you just write a wrapper to wiringPi.
I wrote one for _writing_ to gpio-pins

it is at
https://www.dropbox.com/s/svf6e3as0qyx5nr/gpio.zip?dl=0

and is _very_ simple.

it has no support for reading, but that would be trivial to add


add
   package Linker is
    for Default_Switches ("ada") use ("-L/usr/local/lib",
                                      "-lwiringPi");
   end Linker;

to your gpr-file assuming you are using gnat


call Gpio.Setup first - then set mode of pin

Gpio.Pin_Mode(pin, Gpio.Output);

and the write to it

Gpio.Digital_Write(Pin, False);


I used it to write to a small stepper motor
28YBJ-48 
<https://www.banggood.com/sv/28YBJ-48-DC-5V-4-Phase-5-Wire-Stepper-Motor-With-ULN2003-Driver-Board-p-74397.html>




-- 
Björn


  parent reply	other threads:[~2020-01-31 16:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-25 21:52 GNATCOLL-Mmap example Bob Goddard
2020-01-28  2:10 ` Stephen Leake
2020-01-28  5:59   ` J-P. Rosen
2020-01-28  8:25 ` Dmitry A. Kazakov
2020-01-28 18:53   ` Bob Goddard
2020-01-28 20:07     ` Dmitry A. Kazakov
2020-01-28 20:17       ` Bob Goddard
2020-01-29  8:19         ` Dmitry A. Kazakov
2020-01-29 21:56           ` Bob Goddard
2020-01-30  2:45             ` Dennis Lee Bieber
2020-01-31 16:59     ` Björn Lundin [this message]
2020-01-28 19:11   ` Philip Munts
2020-01-28 20:15     ` Dmitry A. Kazakov
2020-01-28 20:18     ` Philip Munts
2020-01-28 22:06       ` Bob Goddard
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox