aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@110e8d01-0319-4d1e-a829-52ad28d1bb01>2018-12-09 14:21:00 +0000
committergdisirio <gdisirio@110e8d01-0319-4d1e-a829-52ad28d1bb01>2018-12-09 14:21:00 +0000
commit984f865b45b110915616c3c9629fe47b064bed99 (patch)
tree5c309c9eea9290c1de4fbfab0f2f0d32ad91f21d
parentb50ee022aa4fbc8d09b6a62308e99beb32bb722e (diff)
downloadChibiOS-984f865b45b110915616c3c9629fe47b064bed99.tar.gz
ChibiOS-984f865b45b110915616c3c9629fe47b064bed99.tar.bz2
ChibiOS-984f865b45b110915616c3c9629fe47b064bed99.zip
I2S updated.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12469 110e8d01-0319-4d1e-a829-52ad28d1bb01
-rw-r--r--os/hal/include/hal_i2s.h63
-rw-r--r--os/hal/ports/STM32/LLD/SPIv1/hal_i2s_lld.h125
-rw-r--r--os/hal/ports/STM32/LLD/SPIv2/hal_i2s_lld.h125
-rw-r--r--os/hal/templates/hal_i2s_lld.h59
-rw-r--r--readme.txt2
5 files changed, 135 insertions, 239 deletions
diff --git a/os/hal/include/hal_i2s.h b/os/hal/include/hal_i2s.h
index 5d9e3cc57..9811423f5 100644
--- a/os/hal/include/hal_i2s.h
+++ b/os/hal/include/hal_i2s.h
@@ -62,8 +62,71 @@ typedef enum {
I2S_COMPLETE = 4 /**< Transmission complete. */
} i2sstate_t;
+/**
+ * @brief Type of a structure representing an I2S driver.
+ */
+typedef struct hal_i2s_driver I2SDriver;
+
+/**
+ * @brief Type of a structure representing an I2S driver configuration.
+ */
+typedef struct hal_i2s_config I2SConfig;
+
+/**
+ * @brief I2S notification callback type.
+ *
+ * @param[in] i2sp pointer to the @p I2SDriver object
+ * @param[in] offset offset in buffers of the data to read/write
+ * @param[in] n number of samples to read/write
+ */
+typedef void (*i2scallback_t)(I2SDriver *i2sp, size_t offset, size_t n);
+
+/* Including the low level driver header, it exports information required
+ for completing types.*/
#include "hal_i2s_lld.h"
+/**
+ * @brief Structure representing an I2S driver.
+ */
+struct hal_i2s_driver {
+ /**
+ * @brief Driver state.
+ */
+ i2sstate_t state;
+ /**
+ * @brief Current configuration data.
+ */
+ const I2SConfig *config;
+ /* End of the mandatory fields.*/
+ i2s_lld_driver_fields;
+};
+
+/**
+ * @brief Driver configuration structure.
+ */
+struct hal_i2s_config {
+ /**
+ * @brief Transmission buffer pointer.
+ * @note Can be @p NULL if TX is not required.
+ */
+ const void *tx_buffer;
+ /**
+ * @brief Receive buffer pointer.
+ * @note Can be @p NULL if RX is not required.
+ */
+ void *rx_buffer;
+ /**
+ * @brief TX and RX buffers size as number of samples.
+ */
+ size_t size;
+ /**
+ * @brief Callback function called during streaming.
+ */
+ i2scallback_t end_cb;
+ /* End of the mandatory fields.*/
+ i2s_lld_config_fields;
+};
+
/*===========================================================================*/
/* Driver macros. */
/*===========================================================================*/
diff --git a/os/hal/ports/STM32/LLD/SPIv1/hal_i2s_lld.h b/os/hal/ports/STM32/LLD/SPIv1/hal_i2s_lld.h
index 3a193ed1d..37b3f2ac5 100644
--- a/os/hal/ports/STM32/LLD/SPIv1/hal_i2s_lld.h
+++ b/os/hal/ports/STM32/LLD/SPIv1/hal_i2s_lld.h
@@ -297,105 +297,44 @@
/* Driver data structures and types. */
/*===========================================================================*/
-/**
- * @brief Type of a structure representing an I2S driver.
- */
-typedef struct I2SDriver I2SDriver;
-
-/**
- * @brief I2S notification callback type.
- *
- * @param[in] i2sp pointer to the @p I2SDriver object
- * @param[in] offset offset in buffers of the data to read/write
- * @param[in] n number of samples to read/write
- */
-typedef void (*i2scallback_t)(I2SDriver *i2sp, size_t offset, size_t n);
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
/**
- * @brief Driver configuration structure.
- * @note It could be empty on some architectures.
+ * @brief Low level fields of the I2S driver structure.
*/
-typedef struct {
- /**
- * @brief Transmission buffer pointer.
- * @note Can be @p NULL if TX is not required.
- */
- const void *tx_buffer;
- /**
- * @brief Receive buffer pointer.
- * @note Can be @p NULL if RX is not required.
- */
- void *rx_buffer;
- /**
- * @brief TX and RX buffers size as number of samples.
- */
- size_t size;
- /**
- * @brief Callback function called during streaming.
- */
- i2scallback_t end_cb;
- /* End of the mandatory fields.*/
- /**
- * @brief Configuration of the I2SCFGR register.
- * @details See the STM32 reference manual, this register is used for
- * the I2S configuration, the following bits must not be
- * specified because handled directly by the driver:
- * - I2SMOD
- * - I2SE
- * - I2SCFG
- * .
- */
- int16_t i2scfgr;
- /**
- * @brief Configuration of the I2SPR register.
- * @details See the STM32 reference manual, this register is used for
- * the I2S clock setup.
- */
- int16_t i2spr;
-} I2SConfig;
+#define i2s_lld_driver_fields \
+ /* Pointer to the SPIx registers block.*/ \
+ SPI_TypeDef *spi; \
+ /* Calculated part of the I2SCFGR register.*/ \
+ uint16_t cfg; \
+ /* Receive DMA stream or @p NULL.*/ \
+ const stm32_dma_stream_t *dmarx; \
+ /* Transmit DMA stream or @p NULL.*/ \
+ const stm32_dma_stream_t *dmatx; \
+ /* RX DMA mode bit mask.*/ \
+ uint32_t rxdmamode; \
+ /* TX DMA mode bit mask.*/ \
+ uint32_t txdmamode
/**
- * @brief Structure representing an I2S driver.
+ * @brief Low level fields of the I2S configuration structure.
*/
-struct I2SDriver {
- /**
- * @brief Driver state.
- */
- i2sstate_t state;
- /**
- * @brief Current configuration data.
- */
- const I2SConfig *config;
- /* End of the mandatory fields.*/
- /**
- * @brief Pointer to the SPIx registers block.
- */
- SPI_TypeDef *spi;
- /**
- * @brief Calculated part of the I2SCFGR register.
- */
- uint16_t cfg;
- /**
- * @brief Receive DMA stream or @p NULL.
- */
- const stm32_dma_stream_t *dmarx;
- /**
- * @brief Transmit DMA stream or @p NULL.
- */
- const stm32_dma_stream_t *dmatx;
- /**
- * @brief RX DMA mode bit mask.
- */
- uint32_t rxdmamode;
- /**
- * @brief TX DMA mode bit mask.
- */
- uint32_t txdmamode;
-};
-
-/*===========================================================================*/
-/* Driver macros. */
-/*===========================================================================*/
+#define i2s_lld_config_fields \
+ /* Configuration of the I2SCFGR register. \
+ NOTE: See the STM32 reference manual, this register is used for \
+ the I2S configuration, the following bits must not be \
+ specified because handled directly by the driver: \
+ - I2SMOD \
+ - I2SE \
+ - I2SCFG \
+ */ \
+ int16_t i2scfgr; \
+ /* Configuration of the I2SPR register. \
+ NOTE: See the STM32 reference manual, this register is used for \
+ the I2S clock setup.*/ \
+ int16_t i2spr
/*===========================================================================*/
/* External declarations. */
diff --git a/os/hal/ports/STM32/LLD/SPIv2/hal_i2s_lld.h b/os/hal/ports/STM32/LLD/SPIv2/hal_i2s_lld.h
index 5d634d3b6..acf92e1d8 100644
--- a/os/hal/ports/STM32/LLD/SPIv2/hal_i2s_lld.h
+++ b/os/hal/ports/STM32/LLD/SPIv2/hal_i2s_lld.h
@@ -297,105 +297,44 @@
/* Driver data structures and types. */
/*===========================================================================*/
-/**
- * @brief Type of a structure representing an I2S driver.
- */
-typedef struct I2SDriver I2SDriver;
-
-/**
- * @brief I2S notification callback type.
- *
- * @param[in] i2sp pointer to the @p I2SDriver object
- * @param[in] offset offset in buffers of the data to read/write
- * @param[in] n number of samples to read/write
- */
-typedef void (*i2scallback_t)(I2SDriver *i2sp, size_t offset, size_t n);
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
/**
- * @brief Driver configuration structure.
- * @note It could be empty on some architectures.
+ * @brief Low level fields of the I2S driver structure.
*/
-typedef struct {
- /**
- * @brief Transmission buffer pointer.
- * @note Can be @p NULL if TX is not required.
- */
- const void *tx_buffer;
- /**
- * @brief Receive buffer pointer.
- * @note Can be @p NULL if RX is not required.
- */
- void *rx_buffer;
- /**
- * @brief TX and RX buffers size as number of samples.
- */
- size_t size;
- /**
- * @brief Callback function called during streaming.
- */
- i2scallback_t end_cb;
- /* End of the mandatory fields.*/
- /**
- * @brief Configuration of the I2SCFGR register.
- * @details See the STM32 reference manual, this register is used for
- * the I2S configuration, the following bits must not be
- * specified because handled directly by the driver:
- * - I2SMOD
- * - I2SE
- * - I2SCFG
- * .
- */
- int16_t i2scfgr;
- /**
- * @brief Configuration of the I2SPR register.
- * @details See the STM32 reference manual, this register is used for
- * the I2S clock setup.
- */
- int16_t i2spr;
-} I2SConfig;
+#define i2s_lld_driver_fields \
+ /* Pointer to the SPIx registers block.*/ \
+ SPI_TypeDef *spi; \
+ /* Calculated part of the I2SCFGR register.*/ \
+ uint16_t cfg; \
+ /* Receive DMA stream or @p NULL.*/ \
+ const stm32_dma_stream_t *dmarx; \
+ /* Transmit DMA stream or @p NULL.*/ \
+ const stm32_dma_stream_t *dmatx; \
+ /* RX DMA mode bit mask.*/ \
+ uint32_t rxdmamode; \
+ /* TX DMA mode bit mask.*/ \
+ uint32_t txdmamode
/**
- * @brief Structure representing an I2S driver.
+ * @brief Low level fields of the I2S configuration structure.
*/
-struct I2SDriver {
- /**
- * @brief Driver state.
- */
- i2sstate_t state;
- /**
- * @brief Current configuration data.
- */
- const I2SConfig *config;
- /* End of the mandatory fields.*/
- /**
- * @brief Pointer to the SPIx registers block.
- */
- SPI_TypeDef *spi;
- /**
- * @brief Calculated part of the I2SCFGR register.
- */
- uint16_t cfg;
- /**
- * @brief Receive DMA stream or @p NULL.
- */
- const stm32_dma_stream_t *dmarx;
- /**
- * @brief Transmit DMA stream or @p NULL.
- */
- const stm32_dma_stream_t *dmatx;
- /**
- * @brief RX DMA mode bit mask.
- */
- uint32_t rxdmamode;
- /**
- * @brief TX DMA mode bit mask.
- */
- uint32_t txdmamode;
-};
-
-/*===========================================================================*/
-/* Driver macros. */
-/*===========================================================================*/
+#define i2s_lld_config_fields \
+ /* Configuration of the I2SCFGR register. \
+ NOTE: See the STM32 reference manual, this register is used for \
+ the I2S configuration, the following bits must not be \
+ specified because handled directly by the driver: \
+ - I2SMOD \
+ - I2SE \
+ - I2SCFG \
+ */ \
+ int16_t i2scfgr; \
+ /* Configuration of the I2SPR register. \
+ NOTE: See the STM32 reference manual, this register is used for \
+ the I2S clock setup.*/ \
+ int16_t i2spr
/*===========================================================================*/
/* External declarations. */
diff --git a/os/hal/templates/hal_i2s_lld.h b/os/hal/templates/hal_i2s_lld.h
index c6ec80b8b..5b01183b4 100644
--- a/os/hal/templates/hal_i2s_lld.h
+++ b/os/hal/templates/hal_i2s_lld.h
@@ -57,64 +57,19 @@
/* Driver data structures and types. */
/*===========================================================================*/
-/**
- * @brief Type of a structure representing an I2S driver.
- */
-typedef struct I2SDriver I2SDriver;
-
-/**
- * @brief I2S notification callback type.
- *
- * @param[in] i2sp pointer to the @p I2SDriver object
- * @param[in] offset offset in buffers of the data to read/write
- * @param[in] n number of samples to read/write
- */
-typedef void (*i2scallback_t)(I2SDriver *i2sp, size_t offset, size_t n);
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
/**
- * @brief Driver configuration structure.
- * @note It could be empty on some architectures.
+ * @brief Low level fields of the I2S driver structure.
*/
-typedef struct {
- /**
- * @brief Transmission buffer pointer.
- * @note Can be @p NULL if TX is not required.
- */
- const void *tx_buffer;
- /**
- * @brief Receive buffer pointer.
- * @note Can be @p NULL if RX is not required.
- */
- void *rx_buffer;
- /**
- * @brief TX and RX buffers size as number of samples.
- */
- size_t size;
- /**
- * @brief Callback function called during streaming.
- */
- i2scallback_t end_cb;
- /* End of the mandatory fields.*/
-} I2SConfig;
+#define i2s_lld_driver_fields
/**
- * @brief Structure representing an I2S driver.
+ * @brief Low level fields of the I2S configuration structure.
*/
-struct I2SDriver {
- /**
- * @brief Driver state.
- */
- i2sstate_t state;
- /**
- * @brief Current configuration data.
- */
- const I2SConfig *config;
- /* End of the mandatory fields.*/
-};
-
-/*===========================================================================*/
-/* Driver macros. */
-/*===========================================================================*/
+#define i2s_lld_config_fields
/*===========================================================================*/
/* External declarations. */
diff --git a/readme.txt b/readme.txt
index 8748818c4..2b0694eda 100644
--- a/readme.txt
+++ b/readme.txt
@@ -78,7 +78,7 @@
- NEW: Low level drivers simplification. There is a new template of LLD, now
driver and configuration types are defined in the HLD, LLD just exports
macros with the fields to be added to the structures.
- So far the drivers updated are: ADC, DAC, RTC, SPI, TRNG, WSPI.
+ So far the drivers updated are: ADC, DAC, I2S, RTC, SPI, TRNG, WSPI.
- NEW: Added UART7/8 support to STM32 UART USARTv1 driver.
- NEW: Added persistent storage interface to the STM32 RTCv2 driver.
- NEW: STM32 RTCv2 driver now supports callbacks on events.