You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/06/06 19:21:05 UTC

[incubator-nuttx] 03/05: chip: stm32l4: Register spi character driver when both spi port and driver available

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 1717ffdb38c89540b081c9eefad3acd69f011d55
Author: Jeonghyun Kim <ki...@gmail.com>
AuthorDate: Mon Aug 23 23:27:26 2021 +0900

    chip: stm32l4: Register spi character driver when both spi port and driver available
---
 boards/arm/stm32l4/nucleo-l432kc/src/stm32_spi.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/boards/arm/stm32l4/nucleo-l432kc/src/stm32_spi.c b/boards/arm/stm32l4/nucleo-l432kc/src/stm32_spi.c
index 6c71751829..9f40ce1ff8 100644
--- a/boards/arm/stm32l4/nucleo-l432kc/src/stm32_spi.c
+++ b/boards/arm/stm32l4/nucleo-l432kc/src/stm32_spi.c
@@ -30,6 +30,7 @@
 #include <errno.h>
 
 #include <nuttx/spi/spi.h>
+#include <nuttx/spi/spi_transfer.h>
 #include <arch/board/board.h>
 
 #include "chip.h"
@@ -78,6 +79,13 @@ 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 */
@@ -98,6 +106,13 @@ 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 */