新手上路
- 积分
- 22
- 金钱
- 22
- 注册时间
- 2020-1-13
- 在线时间
- 7 小时
|
3金钱
搞了一天了,就是不能正常播放wav文件,哪位大哥帮忙看下是软件问题还是硬件问题。
IIS配置:
#define OPEN_MCK
uint32_t buf_addr1,buf_addr2,buf_size;
uint8_t buf_n,buf_fin;
static void Es7134lv_GPIO_Init(void);
static void Es7134lv_IIS_Init(void);
void Es7134lv_Init(void)
{
Es7134lv_GPIO_Init();
Es7134lv_IIS_Init();
}
static void Es7134lv_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable GPIOB, GPIOC and AFIO clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE);
/* I2S2 SD, CK and WS pins configuration */
/*I2S2_SD-PB15;I2S2_ CK-PB13;I2S2_WS-PB12*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_15;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
#ifdef OPEN_MCK
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
#endif
}
static void Es7134lv_IIS_Init(void)
{
I2S_InitTypeDef I2S_InitStructure;
/* Enable I2S peripheral clocks*/
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE);
/*Reset SPI2*/
SPI_I2S_DeInit(SPI2);
I2S_InitStructure.I2S_Mode = I2S_Mode_MasterTx;
I2S_InitStructure.I2S_Standard = I2S_Standard_Phillips;
I2S_InitStructure.I2S_DataFormat = I2S_DataFormat_16b;
I2S_InitStructure.I2S_AudioFreq = I2S_AudioFreq_8k;
#ifdef OPEN_MCK
I2S_InitStructure.I2S_MCLKOutput = I2S_MCLKOutput_Enable;
#else
I2S_InitStructure.I2S_MCLKOutput = I2S_MCLKOutput_Disable;
#endif
/*I2S clock steady state is low level */
I2S_InitStructure.I2S_CPOL = I2S_CPOL_Low;
I2S_Init(SPI2, &I2S_InitStructure);
// SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_RXNE, DISABLE);
I2S_Cmd(SPI2, ENABLE);
// SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_RXNE, ENABLE); //±¾ÏîÄ¿2»Dè½óêÕ£¬2aêÔoó¿éé¾3y
}
读取WAV数据播放:
void Es7134lv_IIS_SendData(u8 *data, uint32_t len)
{
int i = 0;
for(i=0; i<len; i++)
{
SPI_I2S_SendData(SPI2, data);
}
}
while(voice1_start_add < voice1_len)
{
W25QXX_Read(voice_buff, voice1_start_add, 1024);
Es7134lv_IIS_SendData(voice_buff, 1024);
voice1_start_add += 1024;
printf("voice1_start_add:%d\r\n", voice1_start_add);
}
原理图:
语音芯片:
功放芯片
功放:
语音芯片
|
|