| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- /*****************************************************************************
- DownFiles.h
- *****************************************************************************/
- #ifndef _DOWN_FILES_H
- #define _DOWN_FILES_H
- /*****************************************************************************/
- #include <stm32f0xx.h>
- #include "FileSys.h"
- #include "stdint.h"
- #include "iap.h"
- #define DOWNLOAD_DIFFERENT_FILE_ONLY //只下载不同的文件
- typedef struct
- {//头
- uint32_t magic; // UPDATE_MAGIC
- uint8_t protocol;
- uint8_t code;
- char dev_id[UPDATE_DEV_ID_SIZE];
- uint16_t tid;
- uint16_t count; // 除本结构外后续数据长度
- } __attribute__((packed)) SUT_DF_HEAD; //sizeof()=4+2+16+2+2=26
- typedef struct
- {//MCU请求文件列表
- SUT_DF_HEAD Head;
- uint16_t FileNameLenMax;//本地允许的文件名最大长度
- uint16_t FileCountMax; //本地允许的文件个数最大值
- uint32_t FileAllDataLenMax;//所有文件数据总和最大长度
- } __attribute__((packed)) SUT_DF_LIST_REQ;
- typedef struct
- {//PC回应文件列表
- SUT_DF_HEAD Head;
- SUT_FILE_LIST FileList;
- uint16_t FileListCRC;
- } __attribute__((packed)) SUT_DF_LIST_RSP;
- typedef struct
- {//MCU请求文件数据
- SUT_DF_HEAD Head;
- SUT_FILE_INFO FileInfo;//文件信息
- uint16_t FileIndex; //当前文件在文件列表中的索引位置
- uint32_t offset;//当前文件数据偏移
- uint32_t length;//接收允许的数据长度
- } __attribute__((packed)) SUT_DF_DATA_REQ;
- typedef struct
- {//PC回应文件数据
- SUT_DF_HEAD Head;
- SUT_FILE_INFO FileInfo;
- uint16_t FileIndex; //当前文件在文件列表中的索引位置
- uint32_t offset;//当前文件数据偏移
- uint32_t length;//当前文件传输长度
- uint8_t data[4096+2];//当前文件传输数据包 后面可能还有数据 后面还有CRC校验
- } __attribute__((packed)) SUT_DF_DATA_RSP;//最大可能:26+44+2+4+4+4096+2=4178
- void DFGetFileList(void);//向PC发起请求获取资源文件列表,启动下载
- int DFRecvMsgHandle(unsigned char *pData, unsigned short DataLen);
- /*****************************************************************************/
- #endif
- /*****************************************************************************/
|