board: nucleo-l432kc: Add spi driver registering function and Make it is called on appinit.

This commit is contained in:
Jeonghyun Kim 2021-08-27 00:06:27 +09:00 committed by Xiang Xiao
parent 1717ffdb38
commit f53792fea0
3 changed files with 42 additions and 14 deletions

View File

@ -129,6 +129,16 @@ extern struct spi_dev_s *g_spi2;
int stm32l4_gpio_initialize(void);
#endif
/****************************************************************************
* Name: stm32l4_spiregister
*
* Description:
* Called to register spi character driver of initialized spi device for the Nucleo-L432KC board.
*
****************************************************************************/
void stm32l4_spiregister(void);
/****************************************************************************
* Name: stm32l4_spiinitialize
*

View File

@ -217,6 +217,12 @@ int board_app_initialize(uintptr_t arg)
}
#endif
#ifdef CONFIG_SPI_DRIVER
stm32l4_spiregister();
// driver registering must be processed in appinit.
//If called it during board_init, registering failed due to heap doesn't be initialized yet.
#endif
#ifdef HAVE_AT45DB
/* Initialize and register the ATDB FLASH file system. */

View File

@ -57,6 +57,32 @@ struct spi_dev_s *g_spi2;
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: stm32l4_spiregister
*
* Description:
* Called to register spi character driver of initialized spi device for the Nucleo-L432KC board.
*
****************************************************************************/
void stm32l4_spiregister(void)
{
#ifdef CONFIG_STM32L4_SPI1
int ret = spi_register(g_spi1, 1);
if (ret < 0)
{
spierr("ERROR: FAILED to register driver of SPI port 1\n");
}
#endif
#ifdef CONFIG_STM32L4_SPI2
int ret = spi_register(g_spi2, 2);
if (ret < 0)
{
spierr("ERROR: FAILED to register driver of SPI port 2\n");
}
#endif
}
/****************************************************************************
* Name: stm32l4_spiinitialize
*
@ -79,13 +105,6 @@ void stm32l4_spiinitialize(void)
else
{
spiinfo("INFO: SPI port 1 initialized\n");
#ifdef CONFIG_SPI_DRIVER
ret = spi_register(g_spi1, 1);
if (ret < 0)
{
spierr("ERROR: FAILED to register driver of SPI port 1\n");
}
#endif
}
/* Setup CS, EN & IRQ line IOs */
@ -106,13 +125,6 @@ void stm32l4_spiinitialize(void)
else
{
spiinfo("INFO: SPI port 2 initialized\n");
#ifdef CONFIG_SPI_DRIVER
ret = spi_register(g_spi2, 2);
if (ret < 0)
{
spierr("ERROR: FAILED to register driver of SPI port 2\n");
}
#endif
}
/* Setup CS, EN & IRQ line IOs */