91 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			91 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
#ifndef SYSTEM_UPDATA_H__
 | 
						||
#define SYSTEM_UPDATA_H__
 | 
						||
 | 
						||
 | 
						||
#include "main.h"
 | 
						||
 | 
						||
 | 
						||
 | 
						||
//定义文件升级时缓存区大小
 | 
						||
#define UPDATA_BUFF_SIZE 4096
 | 
						||
 | 
						||
// 发送文件时单包数据最大尺寸
 | 
						||
#define SEND_FILE_PACK_MAXSIZE 100
 | 
						||
 | 
						||
//定义下载数据结构体
 | 
						||
typedef struct
 | 
						||
{
 | 
						||
	int step;
 | 
						||
	char name[256];
 | 
						||
	u32 dataLen;
 | 
						||
	u32 saveAddr;
 | 
						||
	int packet_all;
 | 
						||
	int packet_now;
 | 
						||
	u8 dataBuff[UPDATA_BUFF_SIZE];
 | 
						||
	int buffUsed;
 | 
						||
}SysFile_UpdataStruct;
 | 
						||
 | 
						||
 | 
						||
// 定义发送数据的结构体
 | 
						||
typedef struct
 | 
						||
{
 | 
						||
    char *name;
 | 
						||
    char *path;
 | 
						||
	int packet_all;
 | 
						||
	int packet_now;
 | 
						||
    int file_size;
 | 
						||
    int size_left;
 | 
						||
    int (*send_data)(void *data,int len);// 发送函数,返回0成功
 | 
						||
    int (*progress)(int now,int all);// 反馈进度的函数
 | 
						||
}SysFile_SendStruct;
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
//读取一个文件
 | 
						||
u8 *SysFile_GetFileByName (char *name,u32 *size);
 | 
						||
 | 
						||
 | 
						||
//通过SD卡进行系统文件升级
 | 
						||
void SysFile_Updata(char *FileName,char *FilePath);
 | 
						||
 | 
						||
//通过协议进行系统文件升级
 | 
						||
void SysFile_UpdataByCom (void);
 | 
						||
 | 
						||
 | 
						||
//通过USB进行系统文件升级,在中断中调用这个函数
 | 
						||
void SysFile_UpdataByIrq (u8 *data,int len);
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
// 初始化
 | 
						||
int SysFile_SendFileInit(SysFile_SendStruct *send,char *name,char *path,
 | 
						||
    int (*send_data)(void *data,int len),int (*progress)(int now,int all));
 | 
						||
 | 
						||
// 发送文件名,返回0成功
 | 
						||
int SysFile_SendFileName(SysFile_SendStruct *send);
 | 
						||
 | 
						||
// 发送文件尺寸,返回0成功
 | 
						||
int SysFile_SendFileInfo(SysFile_SendStruct *send);
 | 
						||
 | 
						||
// 发送文件数据,返回0成功
 | 
						||
int SysFile_SendFileData(SysFile_SendStruct *send);
 | 
						||
 | 
						||
// 打包,成功返回0
 | 
						||
int SysFile_PackData(u8 *out,u8 *in,int in_size);
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
#endif
 | 
						||
 |