Firmware SPI.transfer with buffer / DMA

Hi all,

I’m playing with AdaFruits 320x240 ILI9340 hooked up to one of my cores.
All the library code is illuminating, if a little odd as some setup code doesn’t map to the data spec sheets, but if you take it out the display looks bad.

Trying to do some some optimising on the library - mainly around shuttling chunks of data to the display and so trying to us the SPI transfer call using the DMA.
The firmware documents detail a call for SPI.transfer() that takes a tx_buffer, rx_buffer, size and callback handler, using the DMA.

// INO file
// In global
int RowBufferByteSize = 480; // 240 rows, 2 byte per pixel
byte RowBuffer[480]; // needed hard-coded number for compiler?

// In screen clear function (c is passed in so I can change it and see action of call)
memset(RowBuffer, c, RowBufferByteSize);
SPI.transfer(RowBuffer, NULL, RowBufferByteSize, NULL); // Syncronous as callback is NULL

However, when I call it, it appears no data gets pushed over the interface. The screen stays set as it was, no change at all.
If I pass a byte at a time, it’s all fine, but that seems a pretty inefficient way to use the SPI sub system.

I’m just about to dig out the scope to check this, but the reaction from the screen appears that this call is actually just a stub and as I’m pretty new to the SPI interface (I’ve only used the I2C and GPIO on the Cores so far as access control systems for work), I thought I’d drop a line into here before digging into the code base.

From looking around on here it looks like the SPI DMA calls are implemented to communicate with the WiFi module, so I thought it’d be coded, but wanted to tap the knowledge of the community :slight_smile:



It looks like this is only implemented on the Photon/P1. I’m sorry about that - as a first step I’ll update the docs to reflect that.

We’d welcome any PRs that implement this for the Core.

1 Like

Ah ok - thanks - My Photons should be here in a day or so, so will swap over to those then.

Electrons will be replacing the Cores eventually so I want to get something fun for the Cores to do.

I’ll look at the code for the Photon and see how it looks for the Core - may be easier to leave it as is for now :smile:

Hi @mdma,

Which branch and where’s the Photon’s code for the SPI hal source code?
Easy to find on the Core in the repo, but can’t see the code for the Photon - have looked at the develop branch and an SPI speed branch, but can’t find it through digging around?!?!



The SPI DMA code for the Photon code is here

It’s in a common stm32f2xx folder since the same code will be used on the Electron. excite!

1 Like