diff --git a/configs/stm32f429i-disco/src/stm32_ili93414ws.c b/configs/stm32f429i-disco/src/stm32_ili93414ws.c index accefd2dc26..c5a2a6c60e6 100644 --- a/configs/stm32f429i-disco/src/stm32_ili93414ws.c +++ b/configs/stm32f429i-disco/src/stm32_ili93414ws.c @@ -1173,7 +1173,7 @@ FAR struct ili9341_lcd_s *stm32_ili93414ws_initialize(void) lcddbg("initialize ili9341 4-wire serial subdriver\n"); lcdvdbg("initialize spi device: %d\n", ILI93414WS_SPI_DEVICE); - spi = up_spiinitialize(ILI9341WS_SPI_DEVICE); + spi = stm32_spi5initialize(); if (spi) { diff --git a/configs/stm32f429i-disco/src/stm32_spi.c b/configs/stm32f429i-disco/src/stm32_spi.c index 2cda281789c..5eb95de8541 100644 --- a/configs/stm32f429i-disco/src/stm32_spi.c +++ b/configs/stm32f429i-disco/src/stm32_spi.c @@ -54,7 +54,7 @@ #include "stm32f429i-disco.h" #if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3) ||\ - defined(CONFIG_STM32_SPI4) || defined(CONFIG_STM32_SPI5) + defined(CONFIG_STM32_SPI4) || defined(CONFIG_STM32_SPI5) /************************************************************************************ * Definitions @@ -78,6 +78,14 @@ # define spivdbg(x...) #endif +/************************************************************************************ + * Private Data + ************************************************************************************/ + +#ifdef CONFIG_STM32_SPI5 +FAR struct spi_dev_s *g_spidev5 = NULL; +#endif + /************************************************************************************ * Private Functions ************************************************************************************/ @@ -283,4 +291,35 @@ int stm32_spi5cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd) #endif /* CONFIG_SPI_CMDDATA */ +/****************************************************************************** + * Name: stm32_spi5initialize + * + * Description: + * Initialize the selected SPI port. + * As long as the method up_spiinitialize recognized the initialized state of + * the spi device by the spi enable flag of the cr1 register, it isn't safe to + * disable the spi device outside of the nuttx spi interface structure. But + * this has to be done as long as the nuttx spi interface doesn't support + * bidirectional data transfer for multiple devices share one spi bus. This + * wrapper does nothing else than store the initialized state of the spi + * device after the first initializing and should be used by each driver who + * shares the spi5 bus. + * + * Input Parameter: + * + * Returned Value: + * Valid SPI device structure reference on success; a NULL on failure + * + ******************************************************************************/ +#ifdef CONFIG_STM32_SPI5 +FAR struct spi_dev_s *stm32_spi5initialize(void) +{ + if (!g_spidev5) + { + g_spidev5 = up_spiinitialize(5); + } + + return g_spidev5; +} +#endif #endif /* CONFIG_STM32_SPI1 || CONFIG_STM32_SPI2 */ diff --git a/configs/stm32f429i-disco/src/stm32f429i-disco.h b/configs/stm32f429i-disco/src/stm32f429i-disco.h index 61a93a98e94..9a0aaf79421 100644 --- a/configs/stm32f429i-disco/src/stm32f429i-disco.h +++ b/configs/stm32f429i-disco/src/stm32f429i-disco.h @@ -258,6 +258,31 @@ int nsh_archinitialize(void); FAR struct ili9341_lcd_s *stm32_ili93414ws_initialize(void); #endif +#ifdef CONFIG_STM32_SPI5 +/****************************************************************************** + * Name: stm32_spi5initialize + * + * Description: + * Initialize the selected SPI port. + * As long as the method up_spiinitialize recognized the initialized state of + * the spi device by the spi enable flag of the cr1 register, it isn't safe to + * disable the spi device outside of the nuttx spi interface structure. But + * this has to be done as long as the nuttx spi interface doesn't support + * bidirectional data transfer for multiple devices share one spi bus. This + * wrapper does nothing else than store the initialized state of the spi + * device after the first initializing and should be used by each driver who + * shares the spi5 bus. + * + * Input Parameter: + * + * Returned Value: + * Valid SPI device structure reference on succcess; a NULL on failure + * + ******************************************************************************/ + +FAR struct spi_dev_s *stm32_spi5initialize(void); +#endif + #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_STM32F429I_DISCO_SRC_STM32F429I_DISCO_H */