optical/NxFuncs/stiap/stapp.h
2025-09-04 09:45:08 +08:00

77 lines
1.5 KiB
C

#ifndef __STAPP_H__
#define __STAPP_H__
#include "config.h"
//-----------------------------------------------------
#define APP_SAVE_NONE 0
#define APP_SAVE_NORFLASH 1 // 外部norflash中
#define APP_SAVE_EXRAM 2 // 外部RAM中
#define APP_SAVE_INFLASH 3 // 直接在FLASH区域中(Cortex-M4处理器禁止使用该方式)
#ifndef APP_SAVE_TO
#define APP_SAVE_TO APP_SAVE_NONE //
#endif
//-----------------------------------------------------
// 升级文件头
typedef struct
{
// 0x00
char fileName[32]; // 文件名称
// 0x20
u32 dataSize; // 数据字节数
u32 dataChecksum; // 数据累加校验和
// 0x28
u8 reserved1[0x30-0x28]; // 保留区1
// 0x30
u8 reserved2[0x64-0x30]; // 保留区2
// 0x64
u8 reserved3[0x80-0x64]; // 保留区3
// 0x80
u8 reserved4[0x100-0x80]; // 保留区4
}__attribute__ ((packed)) AppFileHead;
// 数据文件控制结构
typedef struct
{
int enflag; // 文件有效标志
AppFileHead fileHead; // 升级文件头描述
u8 pAppBuff[1024]; // 升级数据存储地址
}AppFileCtrl;
//-----------------------------------------------------
#ifdef _IN_STAPP_C
AppFileCtrl g_appFile;
#else
extern AppFileCtrl g_appFile;
#endif
//-----------------------------------------------------
// 支持的数据包长度
#define SUPPORT_LEN_1 128 // for xmodem
#define SUPPORT_LEN_2 1024 // for xmodem or ethernet
void InitSaveApp(void);
int SaveAppData(int idx, u8 * pBuf, int len, u32 ofst);
int IsAppReceiveDone(void);
int IsSaveDataCorrect(void);
void StartAppUpdate(int reboot);
u32 GetAppSaveDataCrc(u32 addr, u32 size);
//-----------------------------------------------------
#endif