MIOS32_I2S
Defines |
#define | MIOS32_I2S_PERIPHERAL_FRQ (MIOS32_SYS_CPU_FREQUENCY) |
#define | MIOS32_I2S_DIV2 1 |
#define | MIOS32_I2S_CLK_INIT { MIOS32_SYS_LPC_PINSEL(2, 11, 3); } |
#define | MIOS32_I2S_WS_INIT { MIOS32_SYS_LPC_PINSEL(2, 12, 3); } |
#define | MIOS32_I2S_SDA_INIT { MIOS32_SYS_LPC_PINSEL(2, 13, 3); } |
#define | MIOS32_I2S_MCLK_INIT { MIOS32_SYS_LPC_PINSEL(4, 29, 1); } |
#define | MIOS32_I2S_DMA_REQ 5 |
#define | MIOS32_I2S_DMA_CHN 5 |
#define | MIOS32_I2S_WS_PORT GPIOB |
#define | MIOS32_I2S_WS_PIN GPIO_Pin_12 |
#define | MIOS32_I2S_CK_PORT GPIOB |
#define | MIOS32_I2S_CK_PIN GPIO_Pin_13 |
#define | MIOS32_I2S_SD_PORT GPIOB |
#define | MIOS32_I2S_SD_PIN GPIO_Pin_15 |
#define | MIOS32_I2S_MCLK_PORT GPIOC |
#define | MIOS32_I2S_MCLK_PIN GPIO_Pin_6 |
#define | MIOS32_I2S_WS_PORT GPIOA |
#define | MIOS32_I2S_WS_PIN GPIO_Pin_4 |
#define | MIOS32_I2S_WS_PINSRC GPIO_PinSource4 |
#define | MIOS32_I2S_CK_PORT GPIOC |
#define | MIOS32_I2S_CK_PIN GPIO_Pin_10 |
#define | MIOS32_I2S_CK_PINSRC GPIO_PinSource10 |
#define | MIOS32_I2S_SD_PORT GPIOC |
#define | MIOS32_I2S_SD_PIN GPIO_Pin_12 |
#define | MIOS32_I2S_SD_PINSRC GPIO_PinSource12 |
#define | MIOS32_I2S_MCLK_PORT GPIOC |
#define | MIOS32_I2S_MCLK_PIN GPIO_Pin_7 |
#define | MIOS32_I2S_MCLK_PINSRC GPIO_PinSource7 |
Functions |
s32 | MIOS32_I2S_Init (u32 mode) |
s32 | MIOS32_I2S_Start (u32 *buffer, u16 len, void *_callback) |
s32 | MIOS32_I2S_Stop (void) |
void | DMA1_Channel5_IRQHandler (void) |
void | DMA1_Stream5_IRQHandler (void) |
Detailed Description
I2S Functions
I2S Functions
Approach: I2S pins are connected to J8 of the MBHP_CORE_STM32 module Optionally a master clock is available for 8x oversampling, which has to be explicitely enabled via MIOS32_I2S_ENABLE_MCLK, and has to be connected to J15b:E (pinning see below)
Due to pin conflicts with default setting of MIOS32_SRIO, MIOS_I2S is disabled by default, and has to be enabled via MIOS32_USE_I2S in mios32_config.h<BR> MIOS32_SRIO should either be disabled via MIOS32_DONT_USE_SRIO, or mapped to SPI0 (-> J16 of MBHP_CORE_STM32 module) via MIOS32_SRIO_SPI 0
I2S is configured for standard Philips format with 2x16 bits for L/R channel at 48 kHz by default. Other protocols/sample rates can be selected via MIOS32_I2S_* defines
DMA Channel 5 is used to transfer sample values to the SPI in background. An application specific callback function is invoked whenever the transfer of the lower or upper half of the sample buffer is completed. This allows the application to update the already uploaded sample buffer half with new data while the next half is transfered.
Accordingly, the sample buffer size together with the sample rate defines the time span between audio buffer updates.
Calculation of the "refill rate" (transfer time of one sample buffer half)
2 * sample rate / (sample buffer size)
e.g.: 1.3 mS @ 48 kHz and 2*64 byte buffer
The sample buffer consists of 32bit words, LSBs for left channel, MSBs for right channel
Demo application: $MIOS32_PATH/apps/examples/i2s
- Note:
- this module can be optionally *ENABLED* in a local mios32_config.h file (included from mios32.h) by adding 'define MIOS32_USE_I2S'
Define Documentation
#define MIOS32_I2S_CK_PIN GPIO_Pin_10 |
#define MIOS32_I2S_CK_PIN GPIO_Pin_13 |
#define MIOS32_I2S_CK_PINSRC GPIO_PinSource10 |
#define MIOS32_I2S_CK_PORT GPIOC |
#define MIOS32_I2S_CK_PORT GPIOB |
#define MIOS32_I2S_CLK_INIT { MIOS32_SYS_LPC_PINSEL(2, 11, 3); } |
#define MIOS32_I2S_DIV2 1 |
#define MIOS32_I2S_DMA_CHN 5 |
#define MIOS32_I2S_DMA_REQ 5 |
#define MIOS32_I2S_MCLK_INIT { MIOS32_SYS_LPC_PINSEL(4, 29, 1); } |
#define MIOS32_I2S_MCLK_PIN GPIO_Pin_7 |
#define MIOS32_I2S_MCLK_PIN GPIO_Pin_6 |
#define MIOS32_I2S_MCLK_PINSRC GPIO_PinSource7 |
#define MIOS32_I2S_MCLK_PORT GPIOC |
#define MIOS32_I2S_MCLK_PORT GPIOC |
#define MIOS32_I2S_PERIPHERAL_FRQ (MIOS32_SYS_CPU_FREQUENCY) |
#define MIOS32_I2S_SD_PIN GPIO_Pin_12 |
#define MIOS32_I2S_SD_PIN GPIO_Pin_15 |
#define MIOS32_I2S_SD_PINSRC GPIO_PinSource12 |
#define MIOS32_I2S_SD_PORT GPIOC |
#define MIOS32_I2S_SD_PORT GPIOB |
#define MIOS32_I2S_SDA_INIT { MIOS32_SYS_LPC_PINSEL(2, 13, 3); } |
#define MIOS32_I2S_WS_INIT { MIOS32_SYS_LPC_PINSEL(2, 12, 3); } |
#define MIOS32_I2S_WS_PIN GPIO_Pin_4 |
#define MIOS32_I2S_WS_PIN GPIO_Pin_12 |
#define MIOS32_I2S_WS_PINSRC GPIO_PinSource4 |
#define MIOS32_I2S_WS_PORT GPIOA |
#define MIOS32_I2S_WS_PORT GPIOB |
Function Documentation
void DMA1_Channel5_IRQHandler |
( |
void |
|
) |
|
DMA1 Channel interrupt is triggered on HT and TC interrupts
- Note:
- shouldn't be called directly from application
void DMA1_Stream5_IRQHandler |
( |
void |
|
) |
|
DMA1 Channel interrupt is triggered on HT and TC interrupts
- Note:
- shouldn't be called directly from application
s32 MIOS32_I2S_Init |
( |
u32 |
mode |
) |
|
Initializes I2S interface
- Parameters:
-
[in] | mode | currently only mode 0 supported |
- Returns:
- < 0 if initialisation failed
s32 MIOS32_I2S_Start |
( |
u32 * |
buffer, |
|
|
u16 |
len, |
|
|
void * |
_callback | |
|
) |
| | |
Starts DMA driven I2S transfers
- Parameters:
-
[in] | *buffer | pointer to sample buffer (contains L/R halfword) |
[in] | len | size of audio buffer |
[in] | _callback | callback function:
called when the lower (state == 0) or upper (state == 1) range of the sample buffer has been transfered, so that it can be updated |
- Returns:
- < 0 if initialisation failed
s32 MIOS32_I2S_Stop |
( |
void |
|
) |
|
Stops DMA driven I2S transfers
- Returns:
- < 0 if initialisation failed