[Gambas-user] Shared WiringPi library for RasPi

Christer Johansson lists at ...2828...
Tue Apr 2 16:53:40 CEST 2013


Finally got some free time to get back into Gambas and I've been trying to
get I/O interrupt to work on the Raspberry Pi.

I made a simple CLI test program with the following code...

MMain.Module
------------

' Gambas module file

' Setting up shared library wiringPi with bcm2835 pin naming
Public Extern wiringPiSetupGpio() As Integer In "libwiringPi:1"
Public Extern wiringPiISR(iPin As Integer, iEdgeType As Integer, pFunction
As Pointer) As Integer In "libwiringPi:1"

Public Sub Main()

  ' Init library
  If wiringPiSetupGpio() = 0 Then
    Print "wiringPi Init OK..."
  Else
    Print "wiringPi Init Failed!"
    Quit
  Endif

  ' Set up falling edge interrupt (1) on GPIO18 pin. Pin is connected to
3.3V via 10k pullup
  wiringPiISR(18, 1, Class1.InterruptHandler)

  ' Loop forever
  Do
    Wait 1
    Print "Waiting...."
  Loop

End

Class1.class
------------

' Gambas class file

Export

Static Public Function InterruptHandler() As Integer
  Print "IRQ handler activated"
End

Code compiles OK but when I pull GPIO18 pin low (i.e generating the
interrupt) it
crashes with a "Stack overflow" error message. Without doubt it's me doing
something wrong
but after 2 days trying I wonder if anyone see what I'm missing??

Attached is also a C example that uses the same library. Also if anyone is
interested in the
latest (130207) libwiringPi.so file just let me know and I will send it to
the list...

PS: I'm currently still on Gambas 3.3.4...

[System]
OperatingSystem=Linux
Kernel=3.6.11+
Architecture=armv6l
Memory=188880 kB
DistributionVendor=debian
DistributionRelease=6.0.5
Desktop=Xfce

[Gambas 2]
Version=2.24.0
Path=/usr/bin/gbx2

[Gambas 3]
Version=3.3.4
Path=/usr/local/bin/gbx3

[Libraries]
Qt4=libQtCore.so.4.6.3
GTK+=libgtk-x11-2.0.so.0.2000.1


> -----Original Message-----
> From: Benoît Minisini [mailto:gambas at ...1...]
> Sent: Monday, February 18, 2013 10:35 AM
> To: mailing list for gambas users
> Subject: Re: [Gambas-user] Shared WiringPi library for RasPi
>
>
> Le 18/02/2013 10:12, Christer Johansson a écrit :
> > Now a question to all the C pro's... I'm hoping to be able to get HW
> > interrupts working on the GPIO with Gambas 3. Declaring
> delay() above
> > was easy enough but the interrupt function looks like...
> >
> >    int wiringPiISR (int pin, int edgeType, void (*function)(void));
> >
> > So how do you declare the above in Gambas 3? I.e register a
> function that
> > will be called to handle the interrupt? Any pointers appreciated...
> >
>
> Extern wiringPiIsr(iPin As Integer, iEdgeType As Integer, pFunction As
Pointer) In "lib..."
>
> ...
>
> And then you use the name of a static function as 'pFunction' argument
when calling wiringPiIsr.
>
> Gambas will automatically create a internal callback that will execute the
Gambas
> function through the interpreter as if it would be called directly like a
C function.
>
> Regards,
>
> --
> Benoît Minisini
>
> --------------------------------------------------------------
> ----------------
> The Go Parallel Website, sponsored by Intel - in partnership
> with Geeknet,
> is your hub for all things parallel software development,
> from weekly thought
> leadership blogs to news, videos, case studies, tutorials, tech docs,
> whitepapers, evaluation guides, and opinion stories. Check
> out the most
> recent posts - join the conversation now.
> http://goparallel.sourceforge.net/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
-------------- next part --------------
A non-text attachment was scrubbed...
Name: isr.c
Type: application/octet-stream
Size: 2627 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20130402/b1f93675/attachment.obj>


More information about the User mailing list