|
本帖最后由 10xjzheng 于 2016-5-12 12:47 编辑
找不到上位机板块就发到这里了,这里人比较多,刚学C#不久,这也是编写的第一个简单实用的上位机,真的是很简单的一个程序,
高手勿笑,笑也可以,记得给意见,主要留给初学者,简单修改之后可以自定义。
话说跨出了编写软件来解决自己问题的第一步,^_^.
软件界面如下:
我的IAP升级文件是在原来的bin文件前面加上16个字节的附加数据,多个字节为小端模式。
- union _FW_INFO
- {
- struct _INFO
- {
- uint16_t ver_num;
- uint32_t fw_length;
- uint16_t fw_crc;
- uint8_t Rev[6];//保持为0xFF
- uint16_t Head_CRC;
- } INFO;
- uint8_t INFO_BUF[16];
- };
复制代码 2个字节的软件版本、4个字节的固件长度、2个字节的固件CRC校验值、6个字节的备用字节(都填充为0xFF)、2个字节前面这14个字节的校验头。
单片机中计算CRC的函数
- //CRC计算
- /*
- * This implementation uses an initial value of 0, while some implementations
- * of CRC-16-CCIT uses an initial value of 0xFFFF. If you wish to
- * precalculate the CRC before uploading the binary to the bootloader you
- * can use this function. However, keep in mind that the 'v' and 'c' commands
- * computes the crc of the entire flash, so any bytes not used by your
- * application will have the value 0xFF.
- */
- uint16_t CRC_calc(uint16_t InitCRC,uint8_t *start, uint8_t *end)
- {
- uint16_t crc = InitCRC;
- uint8_t *data;
- for (data = start; data<=end; data++)
- {
- crc = (crc >> 8) | (crc << 8);
- crc ^= *data;
- crc ^= (crc & 0xff) >> 4;
- crc ^= crc << 12;
- crc ^= (crc & 0xff) << 5;
- }
- return crc;
- }
复制代码
附上原工程,用的是VS2010。
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|