照人家提供的代码来的,但是为啥播放不了音频啊?
static void I2S_Mode_Config(SPI_I2S_STANDARD_TypeDef usStandard, SPI_I2S_DATAFORMAT_TypeDef usWordLen, SPI_I2S_AUDIO_FREQ_TypeDef usAudioFreq, SPI_I2S_TRANS_MODE_TypeDef usMode)
{
I2S_InitTypeDef I2S_InitStructure;
if ((usMode == I2S_Mode_SlaveTx) && (usMode == I2S_Mode_SlaveRx)) {
return;
}
RCC_APB1PeriphClockCmd(RCC_APB1ENR_SPI3, ENABLE);
SPI_DeInit(SPI3);
RCC_APB1PeriphClockCmd(RCC_APB1ENR_SPI3, ENABLE);
if (usMode == I2S_Mode_MasterTx) {
I2S_InitStructure.I2S_Mode = I2S_Mode_MasterTx;
I2S_InitStructure.I2S_Standard = usStandard;
I2S_InitStructure.I2S_DataFormat = usWordLen;
I2S_InitStructure.I2S_MCLKOutput = I2S_MCLKOutput_Enable;
I2S_InitStructure.I2S_AudioFreq = usAudioFreq;
I2S_InitStructure.I2S_CPOL = I2S_CPOL_Low;
I2S_Init(SPI3, &I2S_InitStructure);
}
else if (usMode == I2S_Mode_MasterRx) {
I2S_InitStructure.I2S_Mode = I2S_Mode_MasterRx;
I2S_InitStructure.I2S_Standard = usStandard;
I2S_InitStructure.I2S_DataFormat = usWordLen;
I2S_InitStructure.I2S_MCLKOutput = I2S_MCLKOutput_Enable;
I2S_InitStructure.I2S_AudioFreq = usAudioFreq;
I2S_InitStructure.I2S_CPOL = I2S_CPOL_Low;
I2S_Init(SPI3, &I2S_InitStructure);
}
SPI_DMACmd(SPI3, ENABLE);
I2S_Cmd(SPI3, ENABLE);
}
|