Skip to content

How to get a GPIO change interrupt on the RP2040? #50

Answered by tabemann
robzed asked this question in Q&A
Discussion options

You must be logged in to vote

Good catch! That should read:

gpio import
variable old-handler
13 constant io-irq
io-irq 16 + constant io-vector
: register-my-gpio-handler ( -- )
  io-vector interrupt::vector@ old-handler !
  true 21 PROC0_INTE_GPIO_EDGE_HIGH! true 21 PROC0_INTE_GPIO_EDGE_LOW!
  true 22 PROC0_INTE_GPIO_EDGE_HIGH! true 22 PROC0_INTE_GPIO_EDGE_LOW!
  [:
    old-handler @ execute
    22 PROC0_INTS_GPIO_EDGE_HIGH@ 22 PROC0_INTS_GPIO_EDGE_LOW@ or if
      do-something 22 INTR_GPIO_EDGE_HIGH! 22 INTR_GPIO_EDGE_LOW!
    then
    21 PROC0_INTS_GPIO_EDGE_HIGH@ 21 PROC0_INTS_GPIO_EDGE_LOW@ or if
      s" ." do-something-else 21 INTR_GPIO_EDGE_HIGH! 21 INTR_GPIO_EDGE_LOW!
    then
  ;] io-vector interrupt::vector!
;

Replies: 4 comments 6 replies

Comment options

You must be logged in to vote
1 reply
@robzed
Comment options

Comment options

You must be logged in to vote
2 replies
@robzed
Comment options

@tabemann
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@tabemann
Comment options

Answer selected by robzed
@robzed
Comment options

@tabemann
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants