Is it possible to access the SPI DMA on a Raspberry Pi running Raspbian without using custom drivers by directly reading and writing to the associated hardware registers? I assume the register addresses are defined in the documentation somewhere, so I was wondering if it's possible to write a program that reads and writes values to those addresses the same way you would with a simple microcontroller?

Since there is a kernel involved, would you have to read/write to /dev/mem or something similar?

  • What are you actually trying to do (see XY problem)? /dev/mem will be tricky with DMA, since you also need to handle interrupts for anything useful. Could you not just use spidev? – domen Feb 14 at 9:06
  • I was under the impression that spidev did not allow for DMA. I want to be able to load a lot of data into a buffer, and have that data fire off at a fixed rate without thinking about it. Which is why I was looking into using DMA. I haven't done a deep dive into the documentation, but I was assume that I would only receive a DMA interrupt when the buffer was empty. For that, I could possibly just poll the interrupt flag? – newothegreat Feb 14 at 12:01
  • Do you have any indication your way will be less CPU intensive than the existing way (if that's actually what you are aiming for - you haven't told yet)? spidev just exposes an interface to userspace, whether DMA and IRQ are used will depend on SPI controller driver. – domen Feb 14 at 13:41
  • Yes you can use SPI to control ICs by manualling controlling the pins. maybe just a GPIO library or two, but those mostly handle the namespace of pins more then anything. – colin rosati Feb 14 at 16:05
  • I'm mostly concerned about the timing. I need to send out a frame of 48 (3x16) bits at a rate of 1k -10k frame per second (TDB). I figured I could write the new data to the DMA FIFO buffer as soon as it arrives (it is asynchronous to the SPI write) and let the SPI DMA hardware handle the timing and so forth. – newothegreat Feb 14 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.