Skip to content

Exporting the dmaChannel type and its methods #22

@hb9cwp

Description

@hb9cwp

Currently, I am porting a Numerically Controlled Oscillator (NOC) from C++ to TinyGo for a Software Defined Radio (SDR) project on RPi Pico 2W targets. The NCO uses PIO with DMA to output square waves IO pins in the 10..100 MHz frequency range.

The package piolib in rp2-pio/piolib/dma.go provides an implementation of DMA functions. However, it does not export the main type dmaChannel type although it does export some of its methods only.

Which makes the reuse of this partial DMA SDK harder than necessary, unless
a) I put my implementation of a specific NCO in the piolib/, similar to spi or ws2812b, so that it can access the unexported DMA types and methods;
b) I wrap and export types and methods of piolib/dma.go, or reimplement just what the NCO requires;
c) We change piolib/dma.go so that it exports its types and methods, as @tdunning proposed recently in #16 (comment) as well.

About c), @soypat replied in #16 (comment):

That said I still am unsure of exporting the dmaChannel type since this package is not quite the ideal place to be pulling DMA logic from. Eventually when we do put the DMA logic in its final resting place (probably tinygo machine package) it will bring along these methods :)

What would be a sustainable way to proceed? Should we modify piolib/dma.go and also update it for RP2350 1)? Or, has the time come to try and consolidate DMA in a new machine package that exports most of its components 2)?

  1. RP2350 has 16 DMA channels compared to 12 on RP2040.
  2. Static assignments of DMA channels to peripherals e.g. for spi0DMAChannel and spi1DMAChannel only, are done in two (redundant?) places rp2-pio/piolib/dma.go as well as in src/machine/machine_rp2.go.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions