再看我的用户程序的一个地方,,感觉自己罗嗦了
if(AppFlage ==1)//接收到更新程序{if(rbCanRead(&pRb)>1)
{
rbRead(&pRb, &ReadDat,2);//读取两个数据ReadDat16 = (u16)ReadDat[1]<<8;
ReadDat16= ReadDat16|ReadDat[0];
STMFLASH_Write(addr2,&ReadDat16,1);
addr2+=2;
}
}elseif(AppFlage ==0)
{if(rbCanRead(&pRb)==8)
{
rbRead(&pRb, &TestData,8);//读取数据if(TestData[3] ==0x20&& TestData[7] ==0x08)//判断是否是更新程序{
AppFlage=1;//要更新程序for(i=0;i<4;i++)//先写入这八位数据{
ReadDat16= (u16)TestData[(i<<1)+1]<<8;
ReadDat16= ReadDat16|TestData[i<<1];
STMFLASH_Write(addr2,&ReadDat16,1);
addr2+=2;
}
}
}
}
|