Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1251

Python • Re: Determine which state machine generated an IRQ

$
0
0
As a workaround, you could use different handlers for each PIO statemachine. Then you have a 1--1 relation between statemachine and handler.
If the source code for the handler is almost identical, then this would result in a duplication of code. Could be resolved using the following pattern:

Code:

def handler(sm, identifier=None):    """interrupt handler, handler method for all the statemachine interrupts       keep runtime short !"""    assert identifier is not None    # to the heavy lifting here    def handler_0(sm):    """interrupt handler, registered for sm 0"""    handler(sm, identifier=0)def handler_1(sm):    """interrupt handler, registered for sm 1"""    handler(sm, identifier=1)

Statistics: Posted by ghp — Sat Mar 15, 2025 5:29 am



Viewing all articles
Browse latest Browse all 1251

Trending Articles