Update June 21 2012: This initial interface revamp was later changed -- see below
Hey all,
The DMA peripherals on STM32F2/F4 are incompatible with STM32F1. I came up with a new API that should roughly work with both, and I'd love some feedback on it before I take it any further, as it's a fairly radical departure from the past (don't worry, the old functions are still there on F1, so old code will continue to work on existing boards).
The patches are currently here, rebased on top of the current LeafLabs libmaple dev branch:
https://github.com/mbolivar/libmaple/tree/series-of-tubes/
The main commit which introduces the new API is here. What's new is (hopefully) thoroughly explained in the commit message and in comments that are part of the patch:
https://github.com/mbolivar/libmaple/commit/fba31701d9b16a15f0e7dde01622ef487db31a55
There are still some things that just aren't portable between F1 and F2/F4, but they're carefully segregated into what a dma_tube
is, and the data structure (struct dma_tube_config
) that's passed to a new DMA transfer setup function, dma_tube_cfg()
. That way, you can keep parallel dma_tube_config
s around, one for each series you need to support, so the same code will work with both kinds of DMA controller. (If you're lucky or are doing something simple, a single struct dma_tube_config
will often suffice on both series.) dma_tube_cfg()
is intended to replace dma_setup_xfer()
.
The portable, common interface is in libmaple/include/libmaple/dma.h (so it'll be included as <libmaple/dma.h>
; this is part of a larger change we're introducing -- again, don't worry, you can still #include "dma.h"
for now). It should feel very familiar to you; the only real difference is the configuration procedure described above. The nonportable bits live under libmaple/stm32f1 and libmaple/stm32f2. So F1 routines live in libmaple/stm32f1/dma.c, and the F1 series DMA header <series/dma.h>
lives in libmaple/stm32f1/include/series/dma.h (the series headers are included by <libmaple/dma.h>
to fill in the blanks on what the MCU series supports). Similarly for F2.
Please let me know what you think about the new API. I'd really, especially love feedback if you've got experience with STM32 series outside of F1, F2, F4. I really want to get this one right, so we don't have to keep changing the interface every time we want to add a new family of MCUs.
edit: fixed some typos in the commit message and force-pushed, updated link to relevant commit
edits 2/3: added some more information