Hi,
with Raspi OS using GForth and wiringPi with this GForth interface: >https://github.com/kristopherjohnson/wiringPi_gforth
there is a line:
c-function wiringPiISR wiringPiISR n n func -- n
In C this would be used like:
wiringPiISR(INT_PIN, INT_FALLING_EDGE, MyInterrupt)
void myInterrupt(void) { .... }
Is there a way to attach a GForth word to the interrupt?
Hi,
with Raspi OS using GForth and wiringPi with this GForth interface: https://github.com/kristopherjohnson/wiringPi_gforth
there is a line:
c-function wiringPiISR wiringPiISR n n func -- n
In C this would be used like:
wiringPiISR(INT_PIN, INT_FALLING_EDGE, MyInterrupt)
void myInterrupt(void) { .... }
Is there a way to attach a GForth word to the interrupt?
I don't know enough about the internal organisation of GForth.
Thanks, in advance!
Christof
On 26 juli 2022 om 17:07:07 UTC+2 Christof Eberspaecher wrote:
Hi,
with Raspi OS using GForth and wiringPi with this GForth interface: https://github.com/kristopherjohnson/wiringPi_gforth
there is a line:
c-function wiringPiISR wiringPiISR n n func -- n
In C this would be used like:
wiringPiISR(INT_PIN, INT_FALLING_EDGE, MyInterrupt)
void myInterrupt(void) { .... }
Is there a way to attach a GForth word to the interrupt?
I don't know enough about the internal organisation of GForth.
Thanks, in advance!Marker wiringPiInt.fs \ Testet on a Raspberry zero under the Bullseye
Christof
c-library MywiringPi
s" wiringPi" add-lib
\ **** wiringPi wrapper ****
\c #include <wiringPi.h>
c-function pinMode pinMode n n -- void ( pin mode - )
c-function digitalWrite digitalWrite n n -- void ( pin value - )
c-function digitalRead digitalRead n -- n ( pin - value )
c-function wiringPiSetupGpio wiringPiSetupGpio void -- n ( - res )
c-function pullUpDnControl pullUpDnControl n n -- void ( pin pud - void ) c-function wiringPiISR wiringPiISR n n a -- n ( pin mode funct - res ) c-function piBoardRev piBoardRev void -- n ( - piBoardRev )
c-callback ISR_Gpio1 a -- n ( xt -- n )
c-callback ISR_Gpio2 a -- n ( xt -- n )
c-callback ISR_Gpio3 a -- n ( xt -- n )
end-c-library
\ Pin modes
0 constant INPUT
1 constant OUTPUT
2 constant PWM_OUTPUT
3 constant GPIO_CLOCK
4 constant SOFT_PWM_OUTPUT
5 constant SOFT_TONE_OUTPUT
6 constant PWM_TONE_OUTPUT
0 constant LOW
1 constant HIGH
\ Interrupt levels
0 constant INT_EDGE_SETUP
1 constant INT_EDGE_FALLING
2 constant INT_EDGE_RISING
3 constant INT_EDGE_BOTH
\ Pull up/down/none
0 constant PUD_OFF \ no pull up/down
1 constant PUD_DOWN \ pull to ground
2 constant PUD_UP \ pull to 3.3v
\ PWM
0 constant PWM_MODE_MS
1 constant PWM_MODE_BAL
: InitWiringPi ( - ) wiringPiSetupGpio abort" wiringPiSetupGpio failed" ;
\ Test
InitWiringPi \ 1 time only
22 value pin
: testOutput ( pin - )
to pin
pin OUTPUT pinMode
pin HIGH digitalWrite
pin digitalRead cr .
2000 ms
pin LOW digitalWrite ;
: IntDetected1 ( - ) cr 1 . ." interrupt detected" ;
: IntDetected2 ( - ) cr 2 . ." interrupt detected" ;
: IntDetected3 ( - ) cr 3 . ." interrupt detected" ;
: testInput1 ( pin - )
to pin
pin INPUT pinMode
pin INT_EDGE_BOTH ['] IntDetected1 ISR_Gpio1 wiringPiISR drop ;
: testInput2 ( pin - )
to pin
pin INPUT pinMode
pin INT_EDGE_BOTH ['] IntDetected2 ISR_Gpio2 wiringPiISR drop ;
: testInput3 ( pin - )
to pin
pin INPUT pinMode
pin INT_EDGE_BOTH ['] IntDetected3 ISR_Gpio3 wiringPiISR drop ;
cr .s .( Start 1: ) 22 testInput1 .s
cr .s .( Start 2: ) 22 testInput2 .s
cr .s .( Start 3: ) 25 testInput3 .s
\ 25 testOutput \ to test
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 475 |
Nodes: | 16 (2 / 14) |
Uptime: | 18:49:02 |
Calls: | 9,487 |
Calls today: | 6 |
Files: | 13,617 |
Messages: | 6,121,093 |