upgrade.h
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef __UPGRADE_H_
#define __UPGRADE_H_
#include "stm32f1xx.h"
//#include "dji_upgrade.h"
#include "data_processing.h"
#include "my_typedef.h"
//长度位
#define LENGTH_BIT_H 3
#define LENGTH_BIT_L 4
//应答位
#define ANSWER_BIT 5
//功能位
#define FUNC_BIT_1 7
#define FUNC_BIT_2 8
//数据位
#define DATA_BIT 9
#define USB_RECIVE_BUFF_SIZE (1024*10) //接收缓存区大小
#define MAX_FILE_SIZE (128*4*1024-1024) //最大支持升级文件大小
//typedef enum{
// S3 = 0x73,
//}t_dev_type;//设备号
//typedef enum{
//Upgrade_Stage_IDEL = 0,
//Upgrade_Stage_Ready = 1,
//Upgrade_Stage_GetMd5 = 2,
//Upgrade_Stage_OnGoing = 3,
//Upgrade_Stage_End = 4,
//Upgrade_Stage_Reboot = 5,
//Upgrade_Stage_Error = 6,
//} t_upgrade_state;//升级状态
//typedef struct {
// uint32_t state;//升级状态
// T_UpgradeEndInfo upgradeEndInfo;//大疆的结构体
// uint32_t filesize;//文件大小
// uint8_t md5code[32];//MD5校验码
//}t_user_upgrade;//升级相关内容
extern t_queue_info *frameHandle;
extern myUpgrade_t upgrade_parm; // 存储升级参数
extern uint8_t devConnetState; // 设备握手成功标志
uint8_t upgrade_check(void);//升级检查
//uint8_t DataFrame_Analyse(uint8_t *frame, uint16_t len);
int8_t Write_UpgradeFile(uint32_t offset, const uint8_t *data, uint16_t dataLen);
int8_t UpgradeFile_Write(uint8_t *buf, uint16_t len);
void AnswerUpgradeFrame(uint8_t func, uint8_t data);
int8_t UpgradeFile_MD5Create(void);
int8_t UpgradeFileMD5Code_Get(uint8_t *buf, uint32_t len);
int8_t UpgradePreparation(void);
#endif