HPM APP
HPMicro Application solution
i2s_dma_chain.h File Reference
#include "board.h"

Go to the source code of this file.

Macros

#define APP_DMA_TX   BOARD_APP_HDMA
 I2S TX DMA configuration ;I2S发送数据的DMA相关配置 More...
 
#define DMA_CHANNEL   (1U)
 
#define DMA_MUX_CHANNEL   DMA_SOC_CHN_TO_DMAMUX_CHN(APP_DMA_TX, DMA_CHANNEL)
 
#define DMA_MUX_SRC   HPM_DMA_SRC_I2S1_TX
 
#define TX_DATA_LEN   (32U)
 
#define I2S_SAMPLE_RATE_HZ   (16000U)
 I2S TX I2S format ;I2S发送数据格式 More...
 
#define I2S_SAMPLE_CHANNEL   (2U)
 
#define I2S_SAMPLE_BITDEPTH   i2s_audio_depth_32_bits
 
#define I2S_CHANNEL_LENGTH   i2s_channel_length_32_bits
 
#define I2S_DAO   DAO_I2S
 
#define I2S_DAO_CLK_NAME   clock_i2s1
 
#define I2S_DAO_DATA_LINE   (0U)
 
#define I2S_DAO_MCLK_FREQ_IN_HZ   (24576000UL)
 
#define CODEC_I2C   BOARD_APP_I2C_BASE
 CODEC used for microphone I2S configuration ;麦克风使用的CODEC的相关配置 More...
 
#define CODEC_I2S   BOARD_APP_I2S_BASE
 
#define CODEC_I2S_CLK_NAME   BOARD_APP_I2S_CLK_NAME
 
#define CODEC_I2S_DATA_LINE   BOARD_APP_I2S_RX_DATA_LINE
 
#define CODEC_BIT_WIDTH   (32U)
 
#define CODEC_SAMPLE_RATE_HZ   (16000U)
 
#define APP_DMA_RX   BOARD_APP_HDMA
 I2S RX DMA configuration ;I2S接收数据的DMA相关配置 More...
 
#define I2S_MASTER_RX_LINE   CODEC_I2S_DATA_LINE
 
#define DMA_RX_CHANNEL   (0U)
 
#define DMA_MUX_RX_CHANNEL   DMA_SOC_CHN_TO_DMAMUX_CHN(APP_DMA_RX, DMA_RX_CHANNEL)
 
#define DMA_MUX_RX_SRC   HPM_DMA_SRC_I2S0_RX
 
#define SAMPLE_FREQ   CODEC_SAMPLE_RATE_HZ
 sampling rate of audio,this routine uses 16000Hz ;音频数据的采样率,本例程使用的是16000Hz More...
 
#define SINWAVE_FREQ   (1000u)
 the frequency of the sine wave played, in this routine is 1000Hz ;播放的正弦波频率,本例程使用的是1000Hz More...
 
#define FFT_SHIFT   7
 shift base 2 logarithm value of the sample number and it can be set from 4 to 14 ;以2为底的数据个数的对数值,可以设置为4到14 More...
 
#define FFT_POINTS   (1 << FFT_SHIFT)
 The number of FFT operation points, must be a power of 2 and within the range of 2^4 to 2^14 ;FFT运算的点数,必须是2的幂次方,且范围在2的4次方到2的14次方之间 More...
 
#define FFT_RESULT_SHIFT   18
 The FFT operation result shifted,the FFT calculation results in larger values,reduced the result in size ;FFT运算结果移位,FFT计算后数值较大,对结果进行缩小处理 More...
 
#define FFT_POINTS_DUAL   (FFT_POINTS * 2)
 double the number of FFT operation points, FFT operates on monaural data, but the received buff stores binaural data ;FFT运算点数2倍,FFT运算的是单声道数据,接收buff中存放的是双声道数据 More...
 
#define FFT_RESULT_INDEX   (FFT_POINTS * SINWAVE_FREQ / SAMPLE_FREQ)
 FFT calculation result index, index position corresponding to 1kHz ;FFT计算结果索引,1kHz对应的索引位置 More...
 
#define TEST_DELAY_COUNT   20
 FFT calculation result printing interval, print the result every 20 calculations, for testing purposes only. ;FFT计算结果打印间隔,每计算20次打印一次结果,仅供测试时使用 More...
 

Typedefs

typedef float rfft_type_t
 

Functions

void i2s_dao_config (uint32_t sample_rate, uint8_t audio_depth, uint8_t channel_num)
 DAO I2S configuration ;DAO I2S配置 More...
 
void dma_chain_transfer_config_tx (void)
 I2S TX DMA chain configuration ;I2S发送数据的DMA链配置 More...
 
void dma_auto_config_tx (void)
 I2S TX DMA chain start ;I2S发送数据的DMA链启动 More...
 
void i2s_dma_tx_init (void)
 I2S TX and DMA chain init ;发送数据的I2S和DMA链初始化 More...
 
void fft_cal (rfft_type_t *buf, rfft_type_t *output, uint16_t points, uint16_t shift)
 FFT calculation:perform FFT calculation on the received audio data ;FFT计算:对接收到音频数据进行FFT运算 More...
 
void dma_chain_transfer_config_rx (void)
 I2S RX DMA chain configuration ;I2S接收数据的DMA链配置 More...
 
void dma_auto_config_rx (void)
 I2S RX DMA chain start ;I2S接收数据的DMA链启动 More...
 
void codec_i2s_init (void)
 CODEC used for microphone I2S init ;麦克风使用的CODEC I2S初始化 More...
 
void i2s_dma_rx_init (void)
 I2S RX and DMA chain init ;接收数据的I2S和DMA链初始化 More...
 
void rx_data_process (void)
 processing received data ;处理接收的数据 More...
 

Macro Definition Documentation

◆ APP_DMA_RX

#define APP_DMA_RX   BOARD_APP_HDMA

I2S RX DMA configuration ;I2S接收数据的DMA相关配置

◆ APP_DMA_TX

#define APP_DMA_TX   BOARD_APP_HDMA

I2S TX DMA configuration ;I2S发送数据的DMA相关配置

◆ CODEC_BIT_WIDTH

#define CODEC_BIT_WIDTH   (32U)

◆ CODEC_I2C

#define CODEC_I2C   BOARD_APP_I2C_BASE

CODEC used for microphone I2S configuration ;麦克风使用的CODEC的相关配置

◆ CODEC_I2S

#define CODEC_I2S   BOARD_APP_I2S_BASE

◆ CODEC_I2S_CLK_NAME

#define CODEC_I2S_CLK_NAME   BOARD_APP_I2S_CLK_NAME

◆ CODEC_I2S_DATA_LINE

#define CODEC_I2S_DATA_LINE   BOARD_APP_I2S_RX_DATA_LINE

◆ CODEC_SAMPLE_RATE_HZ

#define CODEC_SAMPLE_RATE_HZ   (16000U)

◆ DMA_CHANNEL

#define DMA_CHANNEL   (1U)

◆ DMA_MUX_CHANNEL

#define DMA_MUX_CHANNEL   DMA_SOC_CHN_TO_DMAMUX_CHN(APP_DMA_TX, DMA_CHANNEL)

◆ DMA_MUX_RX_CHANNEL

#define DMA_MUX_RX_CHANNEL   DMA_SOC_CHN_TO_DMAMUX_CHN(APP_DMA_RX, DMA_RX_CHANNEL)

◆ DMA_MUX_RX_SRC

#define DMA_MUX_RX_SRC   HPM_DMA_SRC_I2S0_RX

◆ DMA_MUX_SRC

#define DMA_MUX_SRC   HPM_DMA_SRC_I2S1_TX

◆ DMA_RX_CHANNEL

#define DMA_RX_CHANNEL   (0U)

◆ FFT_POINTS

#define FFT_POINTS   (1 << FFT_SHIFT)

The number of FFT operation points, must be a power of 2 and within the range of 2^4 to 2^14 ;FFT运算的点数,必须是2的幂次方,且范围在2的4次方到2的14次方之间

◆ FFT_POINTS_DUAL

#define FFT_POINTS_DUAL   (FFT_POINTS * 2)

double the number of FFT operation points, FFT operates on monaural data, but the received buff stores binaural data ;FFT运算点数2倍,FFT运算的是单声道数据,接收buff中存放的是双声道数据

◆ FFT_RESULT_INDEX

#define FFT_RESULT_INDEX   (FFT_POINTS * SINWAVE_FREQ / SAMPLE_FREQ)

FFT calculation result index, index position corresponding to 1kHz ;FFT计算结果索引,1kHz对应的索引位置

◆ FFT_RESULT_SHIFT

#define FFT_RESULT_SHIFT   18

The FFT operation result shifted,the FFT calculation results in larger values,reduced the result in size ;FFT运算结果移位,FFT计算后数值较大,对结果进行缩小处理

◆ FFT_SHIFT

#define FFT_SHIFT   7

shift base 2 logarithm value of the sample number and it can be set from 4 to 14 ;以2为底的数据个数的对数值,可以设置为4到14

◆ I2S_CHANNEL_LENGTH

#define I2S_CHANNEL_LENGTH   i2s_channel_length_32_bits

◆ I2S_DAO

#define I2S_DAO   DAO_I2S

◆ I2S_DAO_CLK_NAME

#define I2S_DAO_CLK_NAME   clock_i2s1

◆ I2S_DAO_DATA_LINE

#define I2S_DAO_DATA_LINE   (0U)

◆ I2S_DAO_MCLK_FREQ_IN_HZ

#define I2S_DAO_MCLK_FREQ_IN_HZ   (24576000UL)

◆ I2S_MASTER_RX_LINE

#define I2S_MASTER_RX_LINE   CODEC_I2S_DATA_LINE

◆ I2S_SAMPLE_BITDEPTH

#define I2S_SAMPLE_BITDEPTH   i2s_audio_depth_32_bits

◆ I2S_SAMPLE_CHANNEL

#define I2S_SAMPLE_CHANNEL   (2U)

◆ I2S_SAMPLE_RATE_HZ

#define I2S_SAMPLE_RATE_HZ   (16000U)

I2S TX I2S format ;I2S发送数据格式

◆ SAMPLE_FREQ

#define SAMPLE_FREQ   CODEC_SAMPLE_RATE_HZ

sampling rate of audio,this routine uses 16000Hz ;音频数据的采样率,本例程使用的是16000Hz

◆ SINWAVE_FREQ

#define SINWAVE_FREQ   (1000u)

the frequency of the sine wave played, in this routine is 1000Hz ;播放的正弦波频率,本例程使用的是1000Hz

◆ TEST_DELAY_COUNT

#define TEST_DELAY_COUNT   20

FFT calculation result printing interval, print the result every 20 calculations, for testing purposes only. ;FFT计算结果打印间隔,每计算20次打印一次结果,仅供测试时使用

◆ TX_DATA_LEN

#define TX_DATA_LEN   (32U)

Typedef Documentation

◆ rfft_type_t

typedef float rfft_type_t

Function Documentation

◆ codec_i2s_init()

void codec_i2s_init ( void  )

CODEC used for microphone I2S init ;麦克风使用的CODEC I2S初始化

◆ dma_auto_config_rx()

void dma_auto_config_rx ( void  )

I2S RX DMA chain start ;I2S接收数据的DMA链启动

◆ dma_auto_config_tx()

void dma_auto_config_tx ( void  )

I2S TX DMA chain start ;I2S发送数据的DMA链启动

◆ dma_chain_transfer_config_rx()

void dma_chain_transfer_config_rx ( void  )

I2S RX DMA chain configuration ;I2S接收数据的DMA链配置

◆ dma_chain_transfer_config_tx()

void dma_chain_transfer_config_tx ( void  )

I2S TX DMA chain configuration ;I2S发送数据的DMA链配置

◆ fft_cal()

void fft_cal ( rfft_type_t buf,
rfft_type_t output,
uint16_t  points,
uint16_t  shift 
)

FFT calculation:perform FFT calculation on the received audio data ;FFT计算:对接收到音频数据进行FFT运算

Parameters
[in]bufdata buff that requires FFT calculation;需要进行FFT计算的数据buff
[in]outputthe sample depth of audio data,; ;FFT计算结果的输出buff
[in]pointsthe number of data requiring FFT calculation;需要进行FFT计算的数据个数
[in]shiftbase 2 logarithm value of the sample number and it can be set from 4 to 14 ;以2为底的数据个数的对数值,可以设置为4到14

◆ i2s_dao_config()

void i2s_dao_config ( uint32_t  sample_rate,
uint8_t  audio_depth,
uint8_t  channel_num 
)

DAO I2S configuration ;DAO I2S配置

Parameters
[in]sample_ratethe sample rate of audio data;播放音频的采样率
[in]audio_depththe sample depth of audio data,the supports sample depth are as follows: ;音频数据的通道宽度采样深度,支持的采样深度如下:
  • i2s_audio_depth_16_bits: 16bits sample depth;16位采样深度
  • i2s_audio_depth_24_bits: 24bits sample depth;24位采样深度
  • i2s_audio_depth_32_bits: 32bits sample depth;32位采样深度
[in]channel_numthe num of channels;通道数量

◆ i2s_dma_rx_init()

void i2s_dma_rx_init ( void  )

I2S RX and DMA chain init ;接收数据的I2S和DMA链初始化

◆ i2s_dma_tx_init()

void i2s_dma_tx_init ( void  )

I2S TX and DMA chain init ;发送数据的I2S和DMA链初始化

◆ rx_data_process()

void rx_data_process ( void  )

processing received data ;处理接收的数据