Sending the same word over SPI many times

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

Moderators: RoccoMarco, barthess

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

Sending the same word over SPI many times

Postby kapacuk » Tue Jun 12, 2018 11:43 am

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: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Sending the same word over SPI many times

Postby Giovanni » Tue Jun 12, 2018 11:59 am

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

Postby kapacuk » Tue Jun 12, 2018 12:24 pm

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: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Sending the same word over SPI many times

Postby Giovanni » Tue Jun 12, 2018 1:10 pm

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: 380
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 13 times

Re: Sending the same word over SPI many times

Postby rew » Sun Jul 08, 2018 5:18 pm

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.


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 19 guests