DMA初始化如下:
static void DMA_Configuration(rt_uint32_t addr, rt_size_t size)
{
DMA_InitTypeDef DMA_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_AHB1PeriphClockCmd(CODEC_I2S_RCC_AHB, ENABLE);
DMA_DeInit(AUDIO_I2S_DMA_STREAM);
/* DMA Channel configuration ----------------------------------------------*/
DMA_Cmd(AUDIO_I2S_DMA_STREAM, DISABLE);
DMA_InitStructure.DMA_Channel = AUDIO_I2S_DMA_CHANNEL;
DMA_InitStructure.DMA_PeripheralBaseAddr = (rt_uint32_t)(&(CODEC_I2S_PORT->DR));
// DMA_InitStructure.DMA_PeripheralBaseAddr = 0x4000380C;
DMA_InitStructure.DMA_Memory0BaseAddr = (rt_uint32_t) addr;
DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;
DMA_InitStructure.DMA_BufferSize = size;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_1QuarterFull;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
DMA_Init(AUDIO_I2S_DMA_STREAM, &DMA_InitStructure);
/* Enable SPI DMA Tx request */
SPI_I2S_DMACmd(CODEC_I2S_PORT, SPI_I2S_DMAReq_Tx, ENABLE);
DMA_ITConfig(AUDIO_I2S_DMA_STREAM, DMA_IT_TC, ENABLE);
DMA_Cmd(AUDIO_I2S_DMA_STREAM, ENABLE);
// DMA_ITConfig(CODEC_I2S_DMA, DMA_IT_TC, ENABLE);
// DMA_Cmd(CODEC_I2S_DMA, ENABLE);
// /* Enable SPI DMA Tx request */
// SPI_I2S_DMACmd(CODEC_I2S_PORT, SPI_I2S_DMAReq_Tx, ENABLE);
//
// if ((CODEC_I2S->I2SCFGR & I2S_ENABLE_MASK) == 0)
// {
// I2S_Cmd(CODEC_I2S, ENABLE);
// }
/* DMA IRQ Channel configuration */
NVIC_InitStructure.NVIC_IRQChannel = AUDIO_I2S_DMA_IRQ;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
谢谢
一周热门 更多>