Dma class for RPI2040 #9169
rkompass
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I did a dma class for RPi Pico. https://github.com/rkompass/RPi2040_mPy
The idea was to minimize configuration by writing helper functions that check the type of source and destination and deliver the details. Optional arguments exist for overriding the thus computed defaults.
The use may be as simple as
if you have source and destination elements of known types, e.g. arrays of matching data types.
Helper functions (and use examples) exist at present for
Helper functions for I2C and SPI are certainly possible.
The dma class initializer per default selects a free dma channel and marks it as used, until it is freed again with dma.deinit().
Either source or destination (similar) objects may be grouped as tuples, to be cycled through. This is achieved with the cycle= optional argument. The dma in this case recursively instantiates a second dma to work as slave and do the transfer while the master is programmed to do the reconfiguration of the slave. An example for that is given in rp2_dma_test5.py.
The class is written in uPy Python code with many mem32's. Some functions are done in viper.
It was inspired by https://github.com/robert-hh/RP2040-Examples/tree/master/rp2_util.
The dma is not able to elicit interrupts as I have no idea how to show the uPy system how to handle interrupts from a new source.
(I may write a .irq() member function that sets the relevant bits in the control word, but what will happen then? Didn't try that out so far.)
Would be nice to get some feedback on this. There were several approaches to dm recently e.g. ](#7641) and one point mentioned was that the python API would be a critical matter.
Perhaps you like this API or something should be made more 'pythonic'?
In the end I think we will have a dma class programmed in C but who knows? Apart from the interrupt I don't see a problem to have it in python, given that it may be freezed.
The first example given measures time and memory consumption btw. Memory consumption is about 10 kB for this class.
Beta Was this translation helpful? Give feedback.
All reactions