//根据地址存储数据到flash static BOOL Store_CarInfo_Flash(u32 addr, const void *data, uint8 len) { int rlen = 0; //实际读写Flash的长度 uint16 verify = 0; u8 *pdata = (u8 *)data; verify = Calc_Check_Sum(pdata, len - 2); memcpy(&pdata[len-2], &verify, 2); rlen = BlockDeviceWrite(MX251608D_Dev, addr, pdata, len); if(rlen < 0) //写入数据 { debug(Debug_Error,"写Flash操作出错,addr:0x%06x\r\n",addr); return FALSE; //存储失败返回 } if(rlen != len) //写入的数据个数和希望写入的数据个数不匹配 { debug(Debug_Notify,"写Flash数据不匹配出错\r\n"); return FALSE; //存储失败返回 } return TRUE; }
void WriteToBlockDevice() { BlockDeviceWrite(0, sizeof(DataModelMap), (uint8_t*)&map ); }