I2S updated.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12469 110e8d01-0319-4d1e-a829-52ad28d1bb01
This commit is contained in:
parent
b50ee022aa
commit
984f865b45
|
@ -62,8 +62,71 @@ typedef enum {
|
||||||
I2S_COMPLETE = 4 /**< Transmission complete. */
|
I2S_COMPLETE = 4 /**< Transmission complete. */
|
||||||
} i2sstate_t;
|
} 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"
|
#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. */
|
/* Driver macros. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
|
@ -297,106 +297,45 @@
|
||||||
/* Driver data structures and types. */
|
/* 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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Driver configuration structure.
|
|
||||||
* @note It could be empty on some architectures.
|
|
||||||
*/
|
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Structure representing an I2S driver.
|
|
||||||
*/
|
|
||||||
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. */
|
/* Driver macros. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Low level fields of the I2S driver structure.
|
||||||
|
*/
|
||||||
|
#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 Low level fields of the I2S configuration structure.
|
||||||
|
*/
|
||||||
|
#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. */
|
/* External declarations. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
|
@ -297,106 +297,45 @@
|
||||||
/* Driver data structures and types. */
|
/* 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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Driver configuration structure.
|
|
||||||
* @note It could be empty on some architectures.
|
|
||||||
*/
|
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Structure representing an I2S driver.
|
|
||||||
*/
|
|
||||||
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. */
|
/* Driver macros. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Low level fields of the I2S driver structure.
|
||||||
|
*/
|
||||||
|
#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 Low level fields of the I2S configuration structure.
|
||||||
|
*/
|
||||||
|
#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. */
|
/* External declarations. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
|
@ -57,65 +57,20 @@
|
||||||
/* Driver data structures and types. */
|
/* 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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Driver configuration structure.
|
|
||||||
* @note It could be empty on some architectures.
|
|
||||||
*/
|
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Structure representing an I2S driver.
|
|
||||||
*/
|
|
||||||
struct I2SDriver {
|
|
||||||
/**
|
|
||||||
* @brief Driver state.
|
|
||||||
*/
|
|
||||||
i2sstate_t state;
|
|
||||||
/**
|
|
||||||
* @brief Current configuration data.
|
|
||||||
*/
|
|
||||||
const I2SConfig *config;
|
|
||||||
/* End of the mandatory fields.*/
|
|
||||||
};
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver macros. */
|
/* Driver macros. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Low level fields of the I2S driver structure.
|
||||||
|
*/
|
||||||
|
#define i2s_lld_driver_fields
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Low level fields of the I2S configuration structure.
|
||||||
|
*/
|
||||||
|
#define i2s_lld_config_fields
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* External declarations. */
|
/* External declarations. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
- NEW: Low level drivers simplification. There is a new template of LLD, now
|
- 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
|
driver and configuration types are defined in the HLD, LLD just exports
|
||||||
macros with the fields to be added to the structures.
|
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 UART7/8 support to STM32 UART USARTv1 driver.
|
||||||
- NEW: Added persistent storage interface to the STM32 RTCv2 driver.
|
- NEW: Added persistent storage interface to the STM32 RTCv2 driver.
|
||||||
- NEW: STM32 RTCv2 driver now supports callbacks on events.
|
- NEW: STM32 RTCv2 driver now supports callbacks on events.
|
||||||
|
|
Loading…
Reference in New Issue