Forum > Beginners

Extend WiringPi wrapper "hwiringpi"

(1/4) > >>

Mountaineer:
Hi folks!
I tried to extend WiringPi wrapper "hwiringpi" from:
https://forum.lazarus.freepascal.org/index.php/topic,17404.msg95833.html#msg95833

I tried to add the function "wiringPiISR"...
(wiringPi reference: int wiringPiISR (int pin, int edgeType,  void (*function)(void)) ;)
But I don't know how to code the last parameter "void (*function)(void))" in the Pascal wrapper.

Please help!

Thaddy:
It is a pointer to a - pascal speak - procedure.
You can either declare it as var or access it with @

It is quite easy, but today I have little time.
If this clue does not help, plz report back. Sunday I have more time.
(But I think by then it will be answered)

Note the var option is usually better, in this case!

Mountaineer:
Hello Thaddy,
thanks for your reply!

I want to try the following:

Function wiringPiISR (pin:longint; edgeType:longint;  var callback):longint;cdecl;external;

Is this correct?

ccrause:

--- Quote from: Mountaineer on May 08, 2021, 05:15:18 pm ---Function wiringPiISR (pin:longint; edgeType:longint;  var callback):longint;cdecl;external;

Is this correct?

--- End quote ---
That may not work, but test it to be sure.  I prefer to use a typed parameter, that way the compiler can help ensure that you only pass a procedure with the correct signature:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---type  TIsrProc = procedure(); cdecl;  // cdecl probably not required here function wiringPiISR(pin: longint; edgeType: longint; var callback: TIsrProc); longint; cdecl; external; procedure myISR; cdecl; // not necessary since no parameters are passed. beginend; begin  wiringPiISR(1, 1, @myISR);  end.
Edit: added comment.

Mountaineer:
Hello ccrause,

thank you very much for the code example!
I'm a newbie therfore I need such detailed information!

cheers,

Mountaineer

Navigation

[0] Message Index

[#] Next page

Go to full version