Sending the same word over SPI many times

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
kapacuk
Posts: 5
Joined: Fri Apr 06, 2018 2:30 pm

Sending the same word over SPI many times

Post by kapacuk »

Hello,

I'm using ChibiOS on STM32F103, communicating with a TFT display over SPI. I order to fill the screen (or part of the screen) with the same colour efficiently, I would like to be able to send the same 16-bit word over SPI many times in one DMA transaction. If I understand it correctly, the best way to do so would to set up a DMA transfer with the cleared STM32_DMA_CR_MINC flag. Unfortunately, there is no way to do it in ChibiOS - the spi_lld_exchange function always sets the MINC flag. Do you think it would be a good idea to expose this flag to the user somehow? Maybe change spi_lld_exchange to accept an optional boolean parameter, or something like this?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Sending the same word over SPI many times

Post by Giovanni »

Hi,

What you need is a small change in spiIgnore(), it already sends the same data to SPI without MINC, it just sends always 0xFFFF. You just need to change the variable holding the 0xFFFF.

Giovanni
kapacuk
Posts: 5
Joined: Fri Apr 06, 2018 2:30 pm

Re: Sending the same word over SPI many times

Post by kapacuk »

Thanks Giovanni, that would work for me. Should I submit a pull request, or will you make the change yourself?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Sending the same word over SPI many times

Post by Giovanni »

This is something already planned but I cannot guarantee an availability date, this requires an API change or extension.

I suggest you make the change locally then, optionally, submit a patch in "small change request" forum.

Giovanni
rew
Posts: 383
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 14 times

Re: Sending the same word over SPI many times

Post by rew »

In a language that accepts optional arguments to functions, you'd extend the spiignore() function with an argument that defaults to "0xffff".

In the case at hand where this is not possible I would suggest you add a function that HAS the argument and redefine spiignore to call the new function with 0xffff as the argument.
Post Reply