Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Real Programmers think better when playing Adventure or Rogue.


devel / comp.lang.forth / Raspi OS wiringPi - How to attach an Interrupt to a Word?

SubjectAuthor
* Raspi OS wiringPi - How to attach an Interrupt to a Word?Christof Eberspaecher
+- Re: Raspi OS wiringPi - How to attach an Interrupt to a Word?Anton Ertl
`* Re: Raspi OS wiringPi - How to attach an Interrupt to a Word?Jos Ven
 `- Re: Raspi OS wiringPi - How to attach an Interrupt to a Word?Christof Eberspaecher

1
Raspi OS wiringPi - How to attach an Interrupt to a Word?

<f1a33fbd-5ec5-4e55-8dc4-b6515344f3a5n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19389&group=comp.lang.forth#19389

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:408a:b0:6b6:1aa6:21ec with SMTP id f10-20020a05620a408a00b006b61aa621ecmr13500023qko.735.1658848026842;
Tue, 26 Jul 2022 08:07:06 -0700 (PDT)
X-Received: by 2002:a05:6214:1bca:b0:474:4a5:6ba8 with SMTP id
m10-20020a0562141bca00b0047404a56ba8mr15061580qvc.114.1658848026570; Tue, 26
Jul 2022 08:07:06 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Tue, 26 Jul 2022 08:07:06 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=77.181.84.223; posting-account=qjKo8woAAADX2G4lnOrWMOI0EutZnVRt
NNTP-Posting-Host: 77.181.84.223
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f1a33fbd-5ec5-4e55-8dc4-b6515344f3a5n@googlegroups.com>
Subject: Raspi OS wiringPi - How to attach an Interrupt to a Word?
From: chwebe...@gmail.com (Christof Eberspaecher)
Injection-Date: Tue, 26 Jul 2022 15:07:06 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1497
 by: Christof Eberspaeche - Tue, 26 Jul 2022 15:07 UTC

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

Re: Raspi OS wiringPi - How to attach an Interrupt to a Word?

<2022Jul27.090152@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19408&group=comp.lang.forth#19408

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Raspi OS wiringPi - How to attach an Interrupt to a Word?
Date: Wed, 27 Jul 2022 07:01:52 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 25
Message-ID: <2022Jul27.090152@mips.complang.tuwien.ac.at>
References: <f1a33fbd-5ec5-4e55-8dc4-b6515344f3a5n@googlegroups.com>
Injection-Info: reader01.eternal-september.org; posting-host="ccd4200479b56440afdefd9b82d04f76";
logging-data="2588367"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/lhe9o7mmrXqAGfnjzopc0"
Cancel-Lock: sha1:T5So9AueEaxiXxuGzLmLmNwKIfY=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Wed, 27 Jul 2022 07:01 UTC

Christof Eberspaecher <chwebersp@gmail.com> writes:
>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?

Gforth's C interface supports callbacks, which should be of use for
this application:

https://gforth.org/manual/Callbacks.html

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2022: http://www.euroforth.org/ef22/cfp.html

Re: Raspi OS wiringPi - How to attach an Interrupt to a Word?

<822b7702-ffd0-4b34-aa97-17bdda3f9e56n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19410&group=comp.lang.forth#19410

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:a01:b0:6b5:c4e3:65af with SMTP id i1-20020a05620a0a0100b006b5c4e365afmr16224958qka.192.1658922172786;
Wed, 27 Jul 2022 04:42:52 -0700 (PDT)
X-Received: by 2002:a05:620a:1981:b0:6b5:cccf:62e1 with SMTP id
bm1-20020a05620a198100b006b5cccf62e1mr16033946qkb.376.1658922172604; Wed, 27
Jul 2022 04:42:52 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 27 Jul 2022 04:42:52 -0700 (PDT)
In-Reply-To: <f1a33fbd-5ec5-4e55-8dc4-b6515344f3a5n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=213.10.199.198; posting-account=nkqetwkAAACepkf86cwWAMB6YF6pRh3F
NNTP-Posting-Host: 213.10.199.198
References: <f1a33fbd-5ec5-4e55-8dc4-b6515344f3a5n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <822b7702-ffd0-4b34-aa97-17bdda3f9e56n@googlegroups.com>
Subject: Re: Raspi OS wiringPi - How to attach an Interrupt to a Word?
From: jos...@planet.nl (Jos Ven)
Injection-Date: Wed, 27 Jul 2022 11:42:52 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 4221
 by: Jos Ven - Wed, 27 Jul 2022 11:42 UTC

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!
> Christof

Marker wiringPiInt.fs \ Testet on a Raspberry zero under the Bullseye

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

Re: Raspi OS wiringPi - How to attach an Interrupt to a Word?

<4b3b8bc2-6392-486d-835e-5b8c5a52da01n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19414&group=comp.lang.forth#19414

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:11cb:b0:31f:e7e:3fb8 with SMTP id n11-20020a05622a11cb00b0031f0e7e3fb8mr19406139qtk.625.1658931886175;
Wed, 27 Jul 2022 07:24:46 -0700 (PDT)
X-Received: by 2002:ad4:594a:0:b0:474:47fe:d500 with SMTP id
eo10-20020ad4594a000000b0047447fed500mr12757477qvb.88.1658931885984; Wed, 27
Jul 2022 07:24:45 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 27 Jul 2022 07:24:45 -0700 (PDT)
In-Reply-To: <822b7702-ffd0-4b34-aa97-17bdda3f9e56n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.179.156.88; posting-account=qjKo8woAAADX2G4lnOrWMOI0EutZnVRt
NNTP-Posting-Host: 77.179.156.88
References: <f1a33fbd-5ec5-4e55-8dc4-b6515344f3a5n@googlegroups.com> <822b7702-ffd0-4b34-aa97-17bdda3f9e56n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4b3b8bc2-6392-486d-835e-5b8c5a52da01n@googlegroups.com>
Subject: Re: Raspi OS wiringPi - How to attach an Interrupt to a Word?
From: chwebe...@gmail.com (Christof Eberspaecher)
Injection-Date: Wed, 27 Jul 2022 14:24:46 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 4604
 by: Christof Eberspaeche - Wed, 27 Jul 2022 14:24 UTC

Jos Ven schrieb am Mittwoch, 27. Juli 2022 um 13:42:53 UTC+2:
> 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!
> > Christof
> Marker wiringPiInt.fs \ Testet on a Raspberry zero under the Bullseye
>
> 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

Thank you both very much, Anton and Jos!
I must say, that the docu of Gforth is not easy to understand for me sometimes. So I appreciate the example code very much!
The goal ist to read a quadrature encoder.
Christof

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor