summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-03-04 06:52:46 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-03-04 06:52:46 -0600
commit08cd63d3a18806a8709f0c5b41b72b233cfccb45 (patch)
tree8c8fb13830e91788675be0ec1f6e58c20c068cf3
parent47d2dcda128a6a19bbedcc71856f5e029b063847 (diff)
downloadpx4-nuttx-08cd63d3a18806a8709f0c5b41b72b233cfccb45.tar.gz
px4-nuttx-08cd63d3a18806a8709f0c5b41b72b233cfccb45.tar.bz2
px4-nuttx-08cd63d3a18806a8709f0c5b41b72b233cfccb45.zip
Add missing SPI callback functions to the STM32 SPI driver. From Freddie Chopin
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_spi.c36
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_spi.h52
2 files changed, 82 insertions, 6 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32_spi.c b/nuttx/arch/arm/src/stm32/stm32_spi.c
index 6cbdff6ec..8ba869240 100644
--- a/nuttx/arch/arm/src/stm32/stm32_spi.c
+++ b/nuttx/arch/arm/src/stm32/stm32_spi.c
@@ -285,7 +285,11 @@ static const struct spi_ops_s g_sp1iops =
.sndblock = spi_sndblock,
.recvblock = spi_recvblock,
#endif
- .registercallback = 0,
+#ifdef CONFIG_SPI_CALLBACK
+ .registercallback = stm32_spi1register, /* provided externally */
+#else
+ .registercallback = 0, /* not implemented */
+#endif
};
static struct stm32_spidev_s g_spi1dev =
@@ -324,7 +328,11 @@ static const struct spi_ops_s g_sp2iops =
.sndblock = spi_sndblock,
.recvblock = spi_recvblock,
#endif
- .registercallback = 0,
+#ifdef CONFIG_SPI_CALLBACK
+ .registercallback = stm32_spi2register, /* provided externally */
+#else
+ .registercallback = 0, /* not implemented */
+#endif
};
static struct stm32_spidev_s g_spi2dev =
@@ -363,7 +371,11 @@ static const struct spi_ops_s g_sp3iops =
.sndblock = spi_sndblock,
.recvblock = spi_recvblock,
#endif
- .registercallback = 0,
+#ifdef CONFIG_SPI_CALLBACK
+ .registercallback = stm32_spi3register, /* provided externally */
+#else
+ .registercallback = 0, /* not implemented */
+#endif
};
static struct stm32_spidev_s g_spi3dev =
@@ -402,7 +414,11 @@ static const struct spi_ops_s g_sp4iops =
.sndblock = spi_sndblock,
.recvblock = spi_recvblock,
#endif
- .registercallback = 0,
+#ifdef CONFIG_SPI_CALLBACK
+ .registercallback = stm32_spi4register, /* provided externally */
+#else
+ .registercallback = 0, /* not implemented */
+#endif
};
static struct stm32_spidev_s g_spi4dev =
@@ -441,7 +457,11 @@ static const struct spi_ops_s g_sp5iops =
.sndblock = spi_sndblock,
.recvblock = spi_recvblock,
#endif
- .registercallback = 0,
+#ifdef CONFIG_SPI_CALLBACK
+ .registercallback = stm32_spi5register, /* provided externally */
+#else
+ .registercallback = 0, /* not implemented */
+#endif
};
static struct stm32_spidev_s g_spi5dev =
@@ -480,7 +500,11 @@ static const struct spi_ops_s g_sp6iops =
.sndblock = spi_sndblock,
.recvblock = spi_recvblock,
#endif
- .registercallback = 0,
+#ifdef CONFIG_SPI_CALLBACK
+ .registercallback = stm32_spi6register, /* provided externally */
+#else
+ .registercallback = 0, /* not implemented */
+#endif
};
static struct stm32_spidev_s g_spi6dev =
diff --git a/nuttx/arch/arm/src/stm32/stm32_spi.h b/nuttx/arch/arm/src/stm32/stm32_spi.h
index 2ee090958..ddcc0f083 100644
--- a/nuttx/arch/arm/src/stm32/stm32_spi.h
+++ b/nuttx/arch/arm/src/stm32/stm32_spi.h
@@ -136,6 +136,58 @@ uint8_t stm32_spi6status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
int stm32_spi6cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
#endif
+/****************************************************************************
+ * Name: stm32_spi1/2/...register
+ *
+ * Description:
+ * If the board supports a card detect callback to inform the SPI-based
+ * MMC/SD drvier when an SD card is inserted or removed, then
+ * CONFIG_SPI_CALLBACK should be defined and the following function(s) must
+ * be implemented. These functiosn implements the registercallback method
+ * of the SPI interface (see include/nuttx/spi/spi.h for details)
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * callback - The funtion to call on the media change
+ * arg - A caller provided value to return with the callback
+ *
+ * Returned Value:
+ * 0 on success; negated errno on failure.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SPI_CALLBACK
+#ifdef CONFIG_STM32_SPI1
+EXTERN int stm32_spi1register(FAR struct spi_dev_s *dev,
+ spi_mediachange_t callback, void *arg);
+#endif
+
+#ifdef CONFIG_STM32_SPI2
+EXTERN int stm32_spi2register(FAR struct spi_dev_s *dev,
+ spi_mediachange_t callback, void *arg);
+#endif
+
+#ifdef CONFIG_STM32_SPI3
+EXTERN int stm32_spi3register(FAR struct spi_dev_s *dev,
+ spi_mediachange_t callback, void *arg);
+#endif
+
+#ifdef CONFIG_STM32_SPI4
+EXTERN int stm32_spi4register(FAR struct spi_dev_s *dev,
+ spi_mediachange_t callback, void *arg);
+#endif
+
+#ifdef CONFIG_STM32_SPI5
+EXTERN int stm32_spi5register(FAR struct spi_dev_s *dev,
+ spi_mediachange_t callback, void *arg);
+#endif
+
+#ifdef CONFIG_STM32_SPI6
+EXTERN int stm32_spi6register(FAR struct spi_dev_s *dev,
+ spi_mediachange_t callback, void *arg);
+#endif
+#endif
+
#undef EXTERN
#if defined(__cplusplus)
}