DownFiles.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*****************************************************************************
  2. DownFiles.h
  3. *****************************************************************************/
  4. #ifndef _DOWN_FILES_H
  5. #define _DOWN_FILES_H
  6. /*****************************************************************************/
  7. #include <stm32f0xx.h>
  8. #include "FileSys.h"
  9. #include "stdint.h"
  10. #include "iap.h"
  11. #define DOWNLOAD_DIFFERENT_FILE_ONLY //只下载不同的文件
  12. typedef struct
  13. {//头
  14. uint32_t magic; // UPDATE_MAGIC
  15. uint8_t protocol;
  16. uint8_t code;
  17. char dev_id[UPDATE_DEV_ID_SIZE];
  18. uint16_t tid;
  19. uint16_t count; // 除本结构外后续数据长度
  20. } __attribute__((packed)) SUT_DF_HEAD; //sizeof()=4+2+16+2+2=26
  21. typedef struct
  22. {//MCU请求文件列表
  23. SUT_DF_HEAD Head;
  24. uint16_t FileNameLenMax;//本地允许的文件名最大长度
  25. uint16_t FileCountMax; //本地允许的文件个数最大值
  26. uint32_t FileAllDataLenMax;//所有文件数据总和最大长度
  27. } __attribute__((packed)) SUT_DF_LIST_REQ;
  28. typedef struct
  29. {//PC回应文件列表
  30. SUT_DF_HEAD Head;
  31. SUT_FILE_LIST FileList;
  32. uint16_t FileListCRC;
  33. } __attribute__((packed)) SUT_DF_LIST_RSP;
  34. typedef struct
  35. {//MCU请求文件数据
  36. SUT_DF_HEAD Head;
  37. SUT_FILE_INFO FileInfo;//文件信息
  38. uint16_t FileIndex; //当前文件在文件列表中的索引位置
  39. uint32_t offset;//当前文件数据偏移
  40. uint32_t length;//接收允许的数据长度
  41. } __attribute__((packed)) SUT_DF_DATA_REQ;
  42. typedef struct
  43. {//PC回应文件数据
  44. SUT_DF_HEAD Head;
  45. SUT_FILE_INFO FileInfo;
  46. uint16_t FileIndex; //当前文件在文件列表中的索引位置
  47. uint32_t offset;//当前文件数据偏移
  48. uint32_t length;//当前文件传输长度
  49. uint8_t data[4096+2];//当前文件传输数据包 后面可能还有数据 后面还有CRC校验
  50. } __attribute__((packed)) SUT_DF_DATA_RSP;//最大可能:26+44+2+4+4+4096+2=4178
  51. void DFGetFileList(void);//向PC发起请求获取资源文件列表,启动下载
  52. int DFRecvMsgHandle(unsigned char *pData, unsigned short DataLen);
  53. /*****************************************************************************/
  54. #endif
  55. /*****************************************************************************/