#include "iap.h" #include "CommandsDefine.h" #include "ProjectConfig.h" #include "Helper.h" #include "usart.h" #include "sys.h" /* 发起开始更新 正确的响应:从App跳转到Boot.如果已经在Boot中,返回错误Error0x03_AlreadyAtBoot 发送格式: 包起始标识 +CMD0x05_Request_UpdateStart +[2字节的数据长度,=00] +包尾标识 返回:无。在发起此命令后,应用端应该在稍后检查是否运行在Boot,然后才开始更新 */ void CMD0x05_Request_UpdateStart_process(u8 *pData,u16 dataLen,u8 bIsContentBitInverted_Recv,u8 bIsContentBitInverted_SendBack) { #ifdef RUNNING_WHERE_AT_BOOT Updating=0; u8 bOk=1; u8 dataBytes=1; if (bIsContentBitInverted_SendBack) dataBytes*=2; if (bIsContentBitInverted_Recv) { if (!Helper_CheckInvertBytesIsRegist(pData,dataLen)) { bOk=0; goto response; } } if (dataLen<2) { bOk=0; goto response; } UpdateWhat=pData[0];// UpdateVerifyStage1OK=0; UpdateVerifyStage2OK=0; UpdateRecvedContentBytes=0; if (UpdateWhat!=RUNNING_AT_APP) { if (pData[1]==0x00) { iap_load_app(0x080c0000);//执行FLASH APP代码 } } Updating =1; //response!!! response: USART_WR_BUF[0] = bOk; USART6_Send(CMD0x05_Request_UpdateStart,dataBytes,bIsContentBitInverted_SendBack); #else //清除APP有效位 iap_clear_appstate(); //重启 __set_FAULTMASK(1); NVIC_SystemReset(); #endif }