[TODO] Missing SPI4/5/6 (+DMA) for STM32F429/439

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

Moderator: RoccoMarco

Post Reply
User avatar
TexZK
Posts: 57
Joined: Sat Sep 22, 2012 7:06 pm

[TODO] Missing SPI4/5/6 (+DMA) for STM32F429/439

Post by TexZK »

Hello! I'm trying to write a simple driver for STM32F429I-DISCO's ILI9341 LCD controller to test my ongoing LTDC driver, but I've found that it requires the SPI5, which is missing from Chibi's F4xx bindings.
I've done a plain copypasta of the SPI1/2/3 code, but it won't compile until valid DMA mask values are assigned, and I don't know where to find this information (I'm new to this DMA stuff)...
Can somebody help me? :oops:

PS: Is there a way to use SPI in half-duplex mode? ST's demo is using only MOSI, but I would like to read registers from the ILI9341, which works in half-duplex mode.
tinito
Posts: 112
Joined: Tue Jun 07, 2011 10:32 am
Has thanked: 1 time
Been thanked: 1 time

Re: Missing SPI4/5/6 (+DMA) for STM32F429/439

Post by tinito »

Hi TexZK,

you can find the description of DMA streams and channels in the reference manual (table 43-44 of RM0090), you should add the default values for SPI4-5-6 streams and channels in spi_lld.h:

Code: Select all

#if !defined(STM32_SPI_SPI1_RX_DMA_STREAM) || defined(__DOXYGEN__)
#define STM32_SPI_SPI1_RX_DMA_STREAM        STM32_DMA_STREAM_ID(2, 0)
#endif


and then update the macros in spi_lld.c:

Code: Select all

#define SPI1_RX_DMA_CHANNEL                                                 \
  STM32_DMA_GETCHANNEL(STM32_SPI_SPI1_RX_DMA_STREAM,                        \
                       STM32_SPI1_RX_DMA_CHN)
tinito
Posts: 112
Joined: Tue Jun 07, 2011 10:32 am
Has thanked: 1 time
Been thanked: 1 time

Re: Missing SPI4/5/6 (+DMA) for STM32F429/439

Post by tinito »

ps: for the half-duplex operation, I guess it is selected by configuring bits BIDIMODE and BIDIOE in SPI_CR1
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Missing SPI4/5/6 (+DMA) for STM32F429/439

Post by Giovanni »

The whole SPI driver requires an update with changes also in mcuconf.h and stm32_rcc.h. Adding this thread to the TODO list.

Giovanni
User avatar
TexZK
Posts: 57
Joined: Sat Sep 22, 2012 7:06 pm

Re: [TODO] Missing SPI4/5/6 (+DMA) for STM32F429/439

Post by TexZK »

Here are my updated files + current untested LTDC driver.
Attachments
spi456_ltdc_wip.zip
SPI4/5/6 + LTDC [WIP]
(37.1 KiB) Downloaded 483 times
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: [TODO] Missing SPI4/5/6 (+DMA) for STM32F429/439

Post by Giovanni »

Hi,

I only merged the SPI-related changes, there was a minor issue with SPI6 DMA defaults. The SPI changes have been compile-tested here, some real world testing would be appreciated. I merged it both in trunk and 2.6.x.

The LTDC will have to wait because:
1) You made changes to old hal_lld.c/.h so there were merging issues (the new settings were also missing from the hal_lld.h settings section).
2) I have to review it being new code.

Please review your code using the latest trunk code then resubmit the changed files.

thanks,
Giovanni
chibby
Posts: 66
Joined: Wed Oct 22, 2014 11:20 am

Re: [TODO] Missing SPI4/5/6 (+DMA) for STM32F429/439

Post by chibby »

I have this hardware, so would be able to test.
Post Reply