TX发送函数如下:
1 void USART1_SendDMA(uint8_t* buf,int len)
2 {
3 DMA_InitTypeDef DMA_InitStruct;
5 DMA_ITConfig(DMA1_Channel4,DMA_IT_TC,ENABLE);
6
7 DMA_Cmd(DMA1_Channel4,DISABLE); 8
9 DMA_InitStruct.DMA_PeripheralBaseAddr = (u32)(&USART1->DR);
10 DMA_InitStruct.DMA_MemoryBaseAddr = (u32)buf;
11 DMA_InitStruct.DMA_DIR = DMA_DIR_PeripheralDST;
12 DMA_InitStruct.DMA_BufferSize = len;
13 DMA_InitStruct.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
14 DMA_InitStruct.DMA_MemoryInc = DMA_MemoryInc_Enable;
15 DMA_InitStruct.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
16 DMA_InitStruct.DMA_MemoryDataSize = DMA_PeripheralDataSize_Byte;
17 DMA_InitStruct.DMA_Mode = DMA_Mode_Normal;
18 DMA_InitStruct.DMA_Priority = DMA_Priority_VeryHigh;
19 DMA_InitStruct.DMA_M2M = DMA_M2M_Disable;
20 DMA_Init(DMA1_Channel4,&DMA_InitStruct);
21
22 DMA_Cmd(DMA1_Channel4,ENABLE);
23 }
|