Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Discussion options

You must be logged in to vote

It's important to shut everything down, otherwise the RP2 can be left in an unstable state. My approach is to run the application in a try...finally bock, ensuring that any exit will shut down cleanly:

obj = MyObject()  # A class using SM and DMA instances
try:
    asyncio.run(application())  # Code that uses obj
finally:
    obj.deinit()  # Shut down

The deinit method looks like this

    def deinit(self):
        self._dma.active(0)
        self._dma.close()
        self._csn.irq(None)  # Disable intarrupt
        self._sm.active(0)  # Stop the SM

Replies: 2 comments 5 replies

Comment options

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

@peterhinch
Comment options

Answer selected by JackCode0011
@JackCode0011
Comment options

Comment options

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

@GitHubsSilverBullet
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants