void Data_UpLoad(void) { // Sent_Data->Verific[0]=1; // // Sent_Data->Verific[1]=2; // Sent_Data->Verific[2]=3; // // Sent_Data->Verific[3]=4; // Sent_Data->Verific[4]=5; // Sent_Data->Pixels_width=Image_Width; // // Sent_Data->Pixels_height=Image_Height; // Sent_Data->Parameter_Num=Par_Num; // Sent_Data->Coefficient_Num=DataNum; while(DMA_IsComplete(DMA_UART_CHx) == FALSE);//判断DMA UART是否发送完毕 Set_Uart_DMA_DAddr((uint32_t)Sent_Data);//设置DMA UART发送源地址 Set_Uart_DMA_Enable(ENABLE);//开始发送 }
int main(void) { DMA_InitTypeDef DMA_InitStruct1; SystemClockSetup(ClockSource_EX50M,CoreClock_100M); DelayInit(); LED_Init(LED_PinLookup_CHKATOM, kNumOfLED); UART_DebugPortInit(UART4_RX_C14_TX_C15, 115200); DisplayCPUInfo(); //开启UART 发送中断/DMA功能 UART_ITConfig(UART4,UART_IT_TDRE,ENABLE); //使能UART4 TX DMA发送 UART_DMACmd(UART4,UART_DMAReq_Tx,ENABLE); DMA_InitStruct1.Channelx = DMA_CH0; //使用DMA0通道 (0-15) DMA_InitStruct1.DMAAutoClose = ENABLE; //传输完毕后自动关闭 DMA_InitStruct1.EnableState = ENABLE; //初始化后立即开始传输 DMA_InitStruct1.MinorLoopLength = sizeof(UARTSendBuffer); //传输次数 DMA_InitStruct1.PeripheralDMAReq = UART4_TRAN_DMAREQ; //UART 传输完成触发 DMA_InitStruct1.TransferBytes = 1; //每次传输一个字节 //配置目的地址传输参数 DMA_InitStruct1.DestBaseAddr = (uint32_t)&(UART4->D); //指向目的地址 DMA_InitStruct1.DestDataSize = DMA_DST_8BIT; //数组为1Byte DMA_InitStruct1.DestMajorInc = 0; //执行一次大循环后 地址不增加 DMA_InitStruct1.DestMinorInc = 0; //每次传输完地址不增加 //配置源地址传输参数 DMA_InitStruct1.SourceBaseAddr = (uint32_t)UARTSendBuffer; DMA_InitStruct1.SourceDataSize = DMA_SRC_8BIT; DMA_InitStruct1.SourceMajorInc = 0; DMA_InitStruct1.SourceMinorInc = 1; //每次传输1个字节后地址自动加1 将后面的数据继续发送 DMA_Init(&DMA_InitStruct1); //等待传输完成 while(DMA_IsComplete(DMA_CH0) == FALSE); while(1) { } }
void UART_Send_Con(void) { #if(Send_Mode==PicMODE)//暂时不发 { Set_DataToCon(); // SetFlashDataToCon(); // //初始化基本参数 // Sent_Data->Verific[0]=1; // // Sent_Data->Verific[1]=2; // Sent_Data->Verific[2]=3; // // Sent_Data->Verific[3]=4; // Sent_Data->Verific[4]=5; // Sent_Data->Pixels_width=Image_Width; // // Sent_Data->Pixels_height=Image_Height; // Sent_Data->Coefficient_Num=DataNum; // Sent_Data->Parameter_Num=Par_Num; while(DMA_IsComplete(DMA_UART_CHx) == FALSE);//判断DMA UART是否发送完毕 Set_Uart_DMA_DAddr((uint32_t)Sent_Data);//设置DMA UART发送源地址 Set_Uart_DMA_Enable(ENABLE);//开始发送 } #endif #if(Send_Mode==ParMODE) { Set_DataToCon(); // SetFlashDataToCon(); //初始化基本参数 // Sent_Data->Verific[0]=1; // // Sent_Data->Verific[1]=2; // Sent_Data->Verific[2]=3; // // Sent_Data->Verific[3]=4; // Sent_Data->Verific[4]=5; // Sent_Data->Pixels_width=Image_Width; // // Sent_Data->Pixels_height=Image_Height; // Sent_Data->Parameter_Num=Par_Num; // Sent_Data->Coefficient_Num=DataNum; while(DMA_IsComplete(DMA_UART_CHx) == FALSE);//判断DMA UART是否发送完毕 Set_Uart_DMA_DAddr((uint32_t)Sent_Data);//设置DMA UART发送源地址 Set_Uart_DMA_Enable(ENABLE);//开始发送 } #endif }