合并配置文件
This commit is contained in:
parent
7ccb708e82
commit
316edf267b
|
@ -24,6 +24,7 @@ void BootConfig::Init()
|
|||
App.Depositary = 0x8010000; // 64KB位置
|
||||
App.Length = 0x30000; // 192KB
|
||||
App.Checksum = 0xffffffff; // 特殊判断不校验
|
||||
AllPin.IsEff = 0; // 不是有效的
|
||||
}
|
||||
|
||||
BootConfig * BootConfig::Create()
|
||||
|
@ -42,49 +43,16 @@ void BootConfig::Show() const
|
|||
debug_printf("BootConfig HasApp %d NeedUpData %d SearchPinCfg %d\r\n", Stat.HasApp, Stat.NeedUpDate, Stat.SearchPinCfg);
|
||||
debug_printf("WorkeAddr 0x%08X Length 0x%08X Depositary 0x%08X Checksum 0x%08X\r\n", App.WorkeAddr, App.Length, App.Depositary, App.Checksum);
|
||||
debug_printf("UpdateAddr 0x%08X Length 0x%08X Depositary 0x%08X Checksum 0x%08X\r\n", Update.WorkeAddr, Update.Length, Update.Depositary, Update.Checksum);
|
||||
}
|
||||
|
||||
/****************** PinConfig ********************/
|
||||
|
||||
PinConfig* PinConfig::Current = nullptr;
|
||||
|
||||
PinConfig::PinConfig() :ConfigBase()
|
||||
{
|
||||
_Name = "Boot";
|
||||
_Start = &AllPin;
|
||||
_End = &TagEnd;
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
void PinConfig::Init()
|
||||
{
|
||||
ConfigBase::Init();
|
||||
IsEff = 0;
|
||||
}
|
||||
|
||||
PinConfig * PinConfig::Create()
|
||||
{
|
||||
static PinConfig pc;
|
||||
if (!Current)
|
||||
{
|
||||
Current = &pc;
|
||||
pc.Init();
|
||||
}
|
||||
|
||||
return &pc;
|
||||
}
|
||||
|
||||
void PinConfig::Show() const
|
||||
{
|
||||
debug_printf("PinConfig\r\n");
|
||||
if (IsEff)
|
||||
if (AllPin.IsEff)
|
||||
{
|
||||
debug_printf("MsgPort COM%d BaudRate %d\r\n", AllPin.MsgPort+1,AllPin.MsgPortBaudRate);
|
||||
debug_printf("W5500 SPI%d \r\n",AllPin.W5500._spi+1);
|
||||
debug_printf("MsgPort COM%d BaudRate %d\r\n", AllPin.MsgPort + 1, AllPin.MsgPortBaudRate);
|
||||
debug_printf("W5500 SPI%d \r\n", AllPin.W5500._spi + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug_printf("Pins is Not Eff !! \r\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
39
BootConfig.h
39
BootConfig.h
|
@ -24,32 +24,7 @@ typedef struct
|
|||
uint Checksum; // 校验码
|
||||
}FirmwareInfo;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
class BootConfig : public ConfigBase
|
||||
{
|
||||
public:
|
||||
BootStat Stat;
|
||||
FirmwareInfo App;
|
||||
FirmwareInfo Update;
|
||||
byte TagEnd; // 数据区结束标识符
|
||||
|
||||
BootConfig();
|
||||
virtual void Init();
|
||||
// virtual void Load();
|
||||
// virtual void Save()const;
|
||||
virtual void Show() const;
|
||||
|
||||
static BootConfig* Current;
|
||||
static BootConfig* Create();
|
||||
};
|
||||
|
||||
|
||||
/****************** PinConfig ********************/
|
||||
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -81,25 +56,29 @@ typedef struct
|
|||
Pin UserKey2; // 默认设置
|
||||
Pin UserLed1; // 默认蓝色
|
||||
Pin UserLed2; // 默认红色
|
||||
uint IsEff; // 是有效的配置
|
||||
}PINS;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
class PinConfig : public ConfigBase
|
||||
class BootConfig : public ConfigBase
|
||||
{
|
||||
public:
|
||||
BootStat Stat;
|
||||
FirmwareInfo App;
|
||||
FirmwareInfo Update;
|
||||
|
||||
PINS AllPin;
|
||||
uint IsEff; // 有效的
|
||||
byte TagEnd; // 数据区结束标识符
|
||||
|
||||
PinConfig();
|
||||
BootConfig();
|
||||
virtual void Init();
|
||||
// virtual void Load();
|
||||
// virtual void Save()const;
|
||||
virtual void Show() const;
|
||||
|
||||
static PinConfig* Current;
|
||||
static PinConfig* Create();
|
||||
static BootConfig* Current;
|
||||
static BootConfig* Create();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -190,11 +190,11 @@ void Token::Setup(ushort code, const char* name, COM message, int baudRate)
|
|||
// 把引脚放进 Boot区 的 PinConfig 内
|
||||
Flash flash;
|
||||
const uint bootCfgAddr = 0x800fc00; // 63K位置
|
||||
Config Cfg(flash,bootCfgAddr,sizeof(PinConfig));
|
||||
Config Cfg(flash,bootCfgAddr,1 << 10);
|
||||
Config::Current = &Cfg;
|
||||
static PinConfig pinCfg;
|
||||
pinCfg.Load();
|
||||
PinConfig::Current = &pinCfg;
|
||||
static BootConfig bootCfg;
|
||||
bootCfg.Load();
|
||||
BootConfig::Current = &bootCfg;
|
||||
#endif
|
||||
// Flash最后一块作为配置区
|
||||
Config::Current = &Config::CreateFlash();
|
||||
|
|
Loading…
Reference in New Issue