好,那就看一下判断接收完程序
if(Usart1Flage ==1)//数据接收完成{
addr2= FLASH_APP2_ADDR;//存储数据的地址Usart1Flage =0;//清零if(((*(vu32*)(FLASH_APP2_ADDR+4))&0xFF000000)==0x08000000)//判断是否为0X08XXXXXX.{
printf("准备执行APP代码!!\r\n");
UserDataAddr= FLASH_DATA_ADDR;//存储其余的数据地址ReadDat16 =0x55;//写入标志告诉IAP程序有可更新的用户程序STMFLASH_Write(UserDataAddr,&ReadDat16,1);
UserDataAddr+=2;
printf("写入0x55标志!!\r\n");
ReadDat16= (u16)((Usart1RecCntCopy>>16)&0xffff);//存储接收到多少数据高位STMFLASH_Write(UserDataAddr,&ReadDat16,1);
UserDataAddr+=2;
ReadDat16= (u16)(Usart1RecCntCopy&0xffff);//存储接收到多少数据低位STMFLASH_Write(UserDataAddr,&ReadDat16,1);
UserDataAddr+=2;
Usart1RecCntCopy=0;
printf("开始复位重启!!\r\n");
Reset_MCU();
}else{
printf("非FLASH应用程序,无法执行!\r\n");
}//printf("Cnt=%d\r\n",Usart1RecCntCopy);//for(i=0;i>8)<=15)//{//printf("0%x ",ReadDat16>>8);//}//else//{//printf("%x ",ReadDat16>>8);//}//}//addr1 = FLASH_APP1_ADDR;//for(i=0;i<40;i++)//{//STMFLASH_Erase(addr1,1024);//擦除FLASH_APP1_ADDR地址以及以上40页//addr1 +=2048;//}//addr1 = FLASH_APP1_ADDR;}
|