DMA support for Pi Pico rp2 port

树莓派 PICO 和 RP2040 相关应用讨论
回复
头像
shaoziyang
帖子: 3917
注册时间: 2019年 10月 21日 13:48

DMA support for Pi Pico rp2 port

#1

帖子 shaoziyang »

rp2 对 DMA 功能支持已加入 pull request 了。
This PR implements fairly complete support for the DMA controller in the rp2 series of microcontrollers. It provides a class for accessing the DMA channels through a high-level, pythonic interface, a class for setting and manipulating the DMA channel configurations and a utility function that makes it easier to implement complex scatter-gather type chained DMA configurations.

Creating an instance of the rp2.DMA class claims one of the processor's DMA channels. A sensible, per-channel default value for the configuration register can be fetched from the default_config attribute and the components of this configuration can be manipulated through its own attributes.

The read, write, count and config attributes provide read/write access to the respective registers of the DMA controller and while the setup() method allows any or all of these values to be set simultaneously and adds a trigger keyword argument to allow the setup to immediately be triggered. The read and write attributes (or keywords in setuo()) accept either actual addresses or any object that supports the buffer interface. The active attribute provides read/write control of the channel's activity, allowing the user to start and stop the channel and test if it is running.

Standard Micropython interrupt handlers are supported through the irq() method and the channel can be released either by deleting it and allowing it to be garbage-collected or with the explicit close() method.

Direct, unfettered access to the DMA controllers registers is provided through a proxy array() object returned by the registers attribute that maps directly onto the memory-mapped registers. This is necessary for more fine-grained control and is helpful for allowing chaining of DMA channels.

A utility function called buffer_address() is also added to the rp2 module that returns the address of the memory buffer underlying any object that supports the buffer interface. This is necessary for building DMA scatter-gather lists. Passing the registers value to this function returns the address of the registers themselves.

I've tried to strike a balance between simplicity and comprehensiveness but I'm sure that others will have suggestions!

 

https://github.com/micropython/micropython/pull/7641
 

回复

  • 随机主题
    回复总数
    阅读次数
    最新文章