|

楼主 |
发表于 2015-8-13 17:22:07
|
显示全部楼层
回 eric2013 的帖子
eric2013:这个没有哦,主要的函数看官方的参考手册。 (2015-08-12 21:57)  麻烦再看一下这样配置为什么I2S_MCK和SCK脚没输出固定频率波形
GPIO_InitTypeDef GPIO_InitStructure;
I2S_InitTypeDef I2S_InitStructure;
RCC_I2SCLKConfig(RCC_I2S2CLKSource_PLLI2S);
RCC_PLLI2SCmd(ENABLE);
GPIO_PinAFConfig(GPIO_AK5351_SCLK, Pin_AK5351_SCLK , GPIO_AF_SPI2);
GPIO_PinAFConfig(GPIO_AK5351_SCLK, Pin_AK5351_LRCK , GPIO_AF_SPI2);
GPIO_PinAFConfig(GPIO_AK5351_SCLK, Pin_AK5351_SDATA, GPIO_AF_SPI2);
GPIO_PinAFConfig(GPIO_AK5351_MCLK, Pin_AK5351_MCLK, GPIO_AF_SPI2);
/* Configure SPI2 pins: CK, WS and SD */
GPIO_InitStructure.GPIO_Pin = Pin_AK5351_SCLK | Pin_AK5351_LRCK | Pin_AK5351_SDATA;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIO_AK5351_SCLK, &GPIO_InitStructure);
//MCLK
GPIO_InitStructure.GPIO_Pin = Pin_AK5351_MCLK;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIO_AK5351_MCLK, &GPIO_InitStructure);
//开启PD FSYNC
//GPIO_PinAFConfig(GPIO_AK5351_PD,Pin_AK5351_PD, GPIO_AF_I2S3ext);
GPIO_InitStructure.GPIO_Pin =Pin_AK5351_PD;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIO_AK5351_PD, &GPIO_InitStructure);
//
GPIO_InitStructure.GPIO_Pin =Pin_AK5351_FSYNC;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIO_AK5351_FSYNC, &GPIO_InitStructure);
RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, ENABLE);
RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, DISABLE);
//设定I2S
//飞利浦标准
I2S_InitStructure.I2S_Standard = I2S_Standard_Phillips;
//32bit数据格式
I2S_InitStructure.I2S_DataFormat = I2S_DataFormat_32b;
//MCLK输出
I2S_InitStructure.I2S_MCLKOutput = I2S_MCLKOutput_Enable;
//采样率4.8K
I2S_InitStructure.I2S_AudioFreq = I2S_AudioFreq_32k ;//(u32)4800
//无数据同步时钟拉低
I2S_InitStructure.I2S_CPOL = I2S_CPOL_High;
//初始化I2S_2
I2S_InitStructure.I2S_Mode = I2S_Mode_MasterRx;
I2S_Init(SPI2, &I2S_InitStructure);
//启动I2S_2
I2S_Cmd(SPI2, ENABLE);
//Reset ADC FSYNC=H
GPIO_ResetBits(GPIO_AK5351_PD, Pin_AK5351_PD);
GPIO_ResetBits(GPIO_AK5351_FSYNC,Pin_AK5351_FSYNC);
bsp_DelayMS(5);
GPIO_SetBits(GPIO_AK5351_PD, Pin_AK5351_PD);
//配置I2S_2读取中断
SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_RXNE, ENABLE);
//等待读取中断结束(ADC准备过程)
while (RxLeftIdx<DataLength*2 ||RxRightIdx<DataLength*2);
RxLeftIdx=0;
RxRightIdx=0;
SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_RXNE, DISABLE); |
|