DMA_InitTypeDef DMA_INI RCC_AHBPeriphClockCm RCC_AHBPeriph_DMA1 ENABLE

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
DMA_InitTypeDef DMA_INI;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
DMA_DeInit(DMA1_Channel3);
DMA_INI.DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DR);
DMA_INI.DMA_MemoryBaseAddr = (uint32_t)BUF;
DMA_INI.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_INI.DMA_BufferSize = 480;
DMA_INI.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_INI.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_INI.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_INI.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_INI.DMA_Mode = DMA_Mode_Normal;
DMA_INI.DMA_Priority = DMA_Priority_VeryHigh;
DMA_INI.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel3, &DMA_INI);
NVIC_EnableIRQ(DMA1_Channel3_IRQn);
DMA_ITConfig(DMA1_Channel3, DMA_IT_TC, ENABLE);
SPI_I2S_DMACmd(SPI1, SPI_I2S_DMAReq_Tx, ENABLE);
SPI_I2S_ITConfig(SPI1, SPI_I2S_IT_TXE, ENABLE);
DMA_Cmd(DMA1_Channel3, ENABLE);