stm32_ota/USER/USERCMD/usercmd.h

82 lines
3.9 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#ifndef __USERCMD_H
#define __USERCMD_H
#include <string.h>
#include <stdint.h>
#include "stm32f10x.h"
#include "user_flash.h"
#include "userapp.h"
#include "ec20module.h"
/******************************************************************************
*内部使用的常变量定义
*******************************************************************************/
/*配置:缓冲区大小*/
#define IAPFLASHCONFIGLEN sizeof(IAPConfig_s) //宏定义IAPConfig_s结构体长度
#define FOLDER_MAXLEN 64 //文件夹路径的最大字符串长度
#define USERNAME_MAXLEN 64 //用户名的最大字符串长度
#define PASSWORD_MAXLEN 64 //用户名密码的最大字符串长度
/*配置:参数控制*/
#define IS_IapFlag_ALL_PERIPH(PERIPH) (((PERIPH) == 0x30) || \
((PERIPH) == 0x31) ) //IAPConfig_s结构体中IapFlag参数校验
#define IS_RunAppNum_ALL_PERIPH(PERIPH) (((PERIPH) == 0x30) || \
((PERIPH) == 0x31) || \
((PERIPH) == 0x32) || \
((PERIPH) == 0x33)) //IAPConfig_s结构体中RunAppNum参数校验
#define IS_JumpResult_ALL_PERIPH(JumpResult)(((PERIPH) == 0x30) || \
((PERIPH) == 0x31) ) //IAPConfig_s结构体中JumpResult参数校验
#define IS_VolumeRank_ALL_PERIPH(PERIPH) (((PERIPH) >= 0x31) && \
((PERIPH) <= 0x39) )
/******************************************************************************
*用户自定义数据类型
*******************************************************************************/
/*IAP本地FLASH存储格式*/
typedef struct
{
char Head ; //固定字符:'['
char IapFlag ; //'0'\'1' //BootLoader需要读然后判断是否进行APP升级。
uint8_t RunAppNum ; //'1'\'2'\'3' //BootLoader需要读然后跳转。 APP启动开始需要改此位。
uint8_t JumpResult ; //'0'\'1' //APP需要读此位然后设置app.limitRank
char BootVers[VERSION_LEN+1] ; //记录BootLoader版本号
char FtpFolder[FOLDER_MAXLEN] ; //app的bin文件存放再ftp服务器的文件夹boot将从此文件夹下载新程序
char FtpUsername[USERNAME_MAXLEN] ; //FTP服务器登陆的用户名
char FtpPassword[PASSWORD_MAXLEN] ; //FTP服务器登陆密码
char FtpIP[MAX_IP_LEN] ; //FTP服务器的IP
char TcpIP[MAX_IP_LEN] ; //TCP服务器的IP
char TcpPort[PORT_MAXLEN] ; //TCP服务器的PORT
char Reserve ; //预留,采用一页FLASH存储IAP配置信息所以用户可根据需要增加IAPConfig_s结构体参数。
char Tail ; //固定字符:']'
}IAPConfig_s ; //IAP配置信息结构体类型
/*IAP本地FLASH存储格式共用体*/
typedef union
{
IAPConfig_s sIapFlash ; //IAPConfig_s结构体类型变量
uint8_t iapFlashBuffer[IAPFLASHCONFIGLEN] ;
}IAPFlash_u ; //IAP配置信息共用体类型
/******************************************************************************
*供外部使用的常变量声明
*******************************************************************************/
/*用来保存FLASH内的配置信息*/
extern IAPFlash_u uIapFlash ; //声明IAPFlash_u共用体变量
/*****************************************
*供内部使用的函数声明
****************************************/
/*****************************************
*对外接口函数声明
****************************************/
extern void InitIapFlashConfig( IAPFlash_u *config ) ; //先从FLASH读出IAPFlash信息然后对IAPFlash_u类型的全局变量初始化最终再写入FLASH中
extern void Get_uIapFlash(IAPFlash_u *config) ; //从内部flash中IAPCONFIG_AREA_ADDR地址读取一页获取FLASH中的IAP信息
extern void Set_uIapFlash(IAPFlash_u *config); //将新的IAP信息写入FLASH
#endif