aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-03-18 20:30:06 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-03-18 20:30:06 +0000
commite5c320a0d1a00915f88b379f27e981b89a787e33 (patch)
treeeb12879d39f700094105ce2134ab49e140850979
parent470b447644555caaa62910d7f19da1804f81b464 (diff)
downloadChibiOS-e5c320a0d1a00915f88b379f27e981b89a787e33.tar.gz
ChibiOS-e5c320a0d1a00915f88b379f27e981b89a787e33.tar.bz2
ChibiOS-e5c320a0d1a00915f88b379f27e981b89a787e33.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4050 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--os/hal/include/i2s.h12
-rw-r--r--os/hal/platforms/STM32/i2s_lld.c45
-rw-r--r--os/hal/platforms/STM32/i2s_lld.h1
-rw-r--r--os/hal/src/i2s.c21
4 files changed, 76 insertions, 3 deletions
diff --git a/os/hal/include/i2s.h b/os/hal/include/i2s.h
index ee2fabf6e..241bb5ec7 100644
--- a/os/hal/include/i2s.h
+++ b/os/hal/include/i2s.h
@@ -86,6 +86,18 @@ typedef struct I2SDriver I2SDriver;
}
/**
+ * @brief Starts a I2S data exchange in continuous mode.
+ *
+ * @param[in] i2sp pointer to the @p I2SDriver object
+ *
+ * @iclass
+ */
+#define i2sStartExchangeContinuousI(i2sp) { \
+ i2s_lld_start_exchange_continuous(i2sp); \
+ (i2sp)->state = I2S_ACTIVE; \
+}
+
+/**
* @brief Stops the ongoing data exchange.
* @details The ongoing data exchange, if any, is stopped, if the driver
* was not active the function does nothing.
diff --git a/os/hal/platforms/STM32/i2s_lld.c b/os/hal/platforms/STM32/i2s_lld.c
index 8a0ec368d..692988385 100644
--- a/os/hal/platforms/STM32/i2s_lld.c
+++ b/os/hal/platforms/STM32/i2s_lld.c
@@ -62,6 +62,15 @@
*/
void i2s_lld_init(void) {
+#if STM32_I2S_USE_I2S2
+ spiObjectInit(&I2SD2);
+ I2SD2.spi = SPI2;
+#endif
+
+#if STM32_I2S_USE_I2S3
+ spiObjectInit(&I2SD3);
+ I2SD3.spi = SPI3;
+#endif
}
/**
@@ -73,8 +82,30 @@ void i2s_lld_init(void) {
*/
void i2s_lld_start(I2SDriver *i2sp) {
+ /* If in stopped state then enables the SPI and DMA clocks.*/
if (i2sp->state == I2S_STOP) {
- /* Clock activation.*/
+#if STM32_SPI_USE_SPI2
+ if (&SPID2 == spip) {
+ bool_t b;
+ b = dmaStreamAllocate(spip->dma,
+ STM32_I2S_I2S2_IRQ_PRIORITY,
+ (stm32_dmaisr_t)i2s_lld_serve_rx_interrupt,
+ (void *)spip);
+ chDbgAssert(!b, "spi_lld_start(), #1", "stream already allocated");
+ rccEnableSPI2(FALSE);
+ }
+#endif
+#if STM32_SPI_USE_SPI3
+ if (&SPID3 == spip) {
+ bool_t b;
+ b = dmaStreamAllocate(spip->dma,
+ STM32_I2S_I2S3_IRQ_PRIORITY,
+ (stm32_dmaisr_t)i2s_lld_serve_rx_interrupt,
+ (void *)spip);
+ chDbgAssert(!b, "spi_lld_start(), #2", "stream already allocated");
+ rccEnableSPI3(FALSE);
+ }
+#endif
}
/* Configuration.*/
}
@@ -94,7 +125,6 @@ void i2s_lld_stop(I2SDriver *i2sp) {
}
}
-
/**
* @brief Starts a I2S data exchange.
*
@@ -107,6 +137,17 @@ void i2s_lld_start_exchange(I2SDriver *i2sp) {
}
/**
+ * @brief Starts a I2S data exchange in continuous mode.
+ *
+ * @param[in] i2sp pointer to the @p I2SDriver object
+ *
+ * @notapi
+ */
+void i2s_lld_start_exchange_continuous(I2SDriver *i2sp) {
+
+}
+
+/**
* @brief Stops the ongoing data exchange.
* @details The ongoing data exchange, if any, is stopped, if the driver
* was not active the function does nothing.
diff --git a/os/hal/platforms/STM32/i2s_lld.h b/os/hal/platforms/STM32/i2s_lld.h
index a2870419d..c56ab8ccb 100644
--- a/os/hal/platforms/STM32/i2s_lld.h
+++ b/os/hal/platforms/STM32/i2s_lld.h
@@ -311,6 +311,7 @@ extern "C" {
void i2s_lld_start(I2SDriver *i2sp);
void i2s_lld_stop(I2SDriver *i2sp);
void i2s_lld_start_exchange(I2SDriver *i2sp);
+ void i2s_lld_start_exchange_continuous(I2SDriver *i2sp);
void i2s_lld_stop_exchange(I2SDriver *i2sp);
#ifdef __cplusplus
}
diff --git a/os/hal/src/i2s.c b/os/hal/src/i2s.c
index e0c547847..99e4246ad 100644
--- a/os/hal/src/i2s.c
+++ b/os/hal/src/i2s.c
@@ -128,12 +128,31 @@ void i2sStartExchange(I2SDriver *i2sp) {
chDbgCheck(i2sp != NULL "i2sStartExchange");
chSysLock();
- chDbgAssert(i2sp->state == I2S_READY, "i2sStartExchange(), #1", "not ready");
+ chDbgAssert(i2sp->state == I2S_READY,
+ "i2sStartExchange(), #1", "not ready");
i2sStartExchangeI(i2sp);
chSysUnlock();
}
/**
+ * @brief Starts a I2S data exchange in continuous mode.
+ *
+ * @param[in] i2sp pointer to the @p I2SDriver object
+ *
+ * @api
+ */
+void i2sStartExchangeContinuous(I2SDriver *i2sp) {
+
+ chDbgCheck(i2sp != NULL "i2sStartExchangeContinuous");
+
+ chSysLock();
+ chDbgAssert(i2sp->state == I2S_READY,
+ "i2sStartExchangeContinuous(), #1", "not ready");
+ i2sStartExchangeContinuousI(i2sp);
+ chSysUnlock();
+}
+
+/**
* @brief Stops the ongoing data exchange.
* @details The ongoing data exchange, if any, is stopped, if the driver
* was not active the function does nothing.