7 months, 3 weeks ago.

DMA driver for mbed-os 5

Is there any chance for DMA periphery to get an official support by mbed in the form of a driver, like every standard MCU periphery (UART, SPI, I2C ... etc) ?


Let's asume UART periphery is used somewhere and DMA acceleration is needed:

For now using of the method set_dma_usage_xx() is pretty useless. It just sets the value of a variable _xx_usage, which is internal for the SerialBase driver, and this has no impact on the low level implementation of the serial_api driver.

I get it that serial_api is platform implementer's responsibility, but there is no way serial_api to understand, that DMA has to be used. I mean no parameter is passed to the serial_api, and the control remains in upper level driver. SerialBase is mbed's responsibility, I presume.

Is there any working example with DMA enhanced periphery at all?

Comment on this question

1 Answer

5 months, 3 weeks ago.

The HAL allows use of DMA; if you search for calls to dma_channel_allocate() you will see that it is used on some targets for serial and SPI, as well as other uses of DMA for USB host and crypto acceleration on some targets.

I also wish there were a more general way to use DMA for other purposes, but there doesn't seem to be one right now.

I've used the DMA peripheral in the KL25Z directly for driving RGB LEDs:

Import programMulti_WS2811_test

Test program for my Multi_WS2811 library that started out as a fork of heroic/WS2811. My library uses hardware DMA on the FRDM-KL25Z to drive up to 16 strings of WS2811 or WS2812 LEDs in parallel.

Here are the files that use dma_channel__allocate():

  • mbed-os/targets/TARGET_Silicon_Labs/TARGET_EFM32/spi_api.c
  • mbed-os/targets/TARGET_Silicon_Labs/TARGET_EFM32/serial_api.c
  • mbed-os/targets/TARGET_Atmel/TARGET_SAM_CortexM0P/sercom_dma.c
  • mbed-os/targets/TARGET_NUVOTON/TARGET_NUC472/spi_api.c
  • mbed-os/targets/TARGET_NUVOTON/TARGET_NUC472/serial_api.c
  • mbed-os/targets/TARGET_NUVOTON/TARGET_M451/spi_api.c
  • mbed-os/targets/TARGET_NUVOTON/TARGET_M451/serial_api.c
  • mbed-os/targets/TARGET_NUVOTON/TARGET_M480/spi_api.c
  • mbed-os/targets/TARGET_NUVOTON/TARGET_M480/serial_api.c
  • mbed-os/targets/TARGET_NUVOTON/TARGET_M2351/spi_api.c
  • mbed-os/targets/TARGET_NUVOTON/TARGET_M2351/serial_api.c
  • mbed-os/targets/TARGET_NUVOTON/TARGET_NANO100/spi_api.c
  • mbed-os/targets/TARGET_NUVOTON/TARGET_NANO100/serial_api.c
  • mbed-os/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K24F/spi_api.c
  • mbed-os/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K24F/serial_api.c
  • mbed-os/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/spi_api.c
  • mbed-os/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/serial_api.c


You need to log in to post a question