stm32f429i-disco: add wrapper for spi5 evice

initializing

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 store the
initialized state of the spi device after the first initializing and should be
used by each driver who shares the spi5 bus.

Note! Understand this as temporary workaround.

Signed-off-by: Marco Krahl <ocram.lhark@gmail.com>
This commit is contained in:
Gregory Nutt 2014-10-20 15:36:11 -06:00
parent 4c470720d0
commit c688cda22a
3 changed files with 66 additions and 2 deletions

View File

@ -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)
{

View File

@ -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 */

View File

@ -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 */