This commit is contained in:
parent
79fa713abd
commit
57f44c9d58
|
@ -0,0 +1,68 @@
|
||||||
|
|
||||||
|
#include "BootConfig.h"
|
||||||
|
|
||||||
|
BootConfig* BootConfig::Current = nullptr;
|
||||||
|
|
||||||
|
BootConfig::BootConfig() :ConfigBase()
|
||||||
|
{
|
||||||
|
_Name = "Boot";
|
||||||
|
_Start = &Stat;
|
||||||
|
_End = &TagEnd;
|
||||||
|
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BootConfig::Init()
|
||||||
|
{
|
||||||
|
ConfigBase::Init();
|
||||||
|
|
||||||
|
Stat.HasApp = 1; // 没有APP位置固件
|
||||||
|
Stat.NeedUpDate = 0; // 不需要升级
|
||||||
|
|
||||||
|
App.WorkeAddr = 0x8010000; // 64KB位置
|
||||||
|
App.Depositary = 0x8010000; // 64KB位置
|
||||||
|
App.Length = 0x30000; // 192KB
|
||||||
|
App.Checksum = 0xffffffff; // 特殊判断不校验
|
||||||
|
}
|
||||||
|
|
||||||
|
BootConfig * BootConfig::Create()
|
||||||
|
{
|
||||||
|
static BootConfig bc;
|
||||||
|
if (!Current)
|
||||||
|
{
|
||||||
|
Current = &bc;
|
||||||
|
bc.Init();
|
||||||
|
}
|
||||||
|
return &bc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************** 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;
|
||||||
|
}
|
|
@ -0,0 +1,100 @@
|
||||||
|
#ifndef __BootConfig__H__
|
||||||
|
#define __BootConfig__H__
|
||||||
|
|
||||||
|
#include "Sys.h"
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
|
||||||
|
#pragma pack(push)
|
||||||
|
#pragma pack(1)
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint HasApp : 1; // 有可运行APP
|
||||||
|
uint NeedUpDate : 1; // 需要跟新
|
||||||
|
uint Reserved : 30; // 保留
|
||||||
|
}BootStat;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint WorkeAddr; // 运行地址
|
||||||
|
uint Depositary; // 存放地址
|
||||||
|
uint Length; // 固件大小
|
||||||
|
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;
|
||||||
|
|
||||||
|
static BootConfig* Current;
|
||||||
|
static BootConfig* Create();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/****************** PinConfig ********************/
|
||||||
|
|
||||||
|
|
||||||
|
#pragma pack(push)
|
||||||
|
#pragma pack(1)
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
SPI _spi;
|
||||||
|
Pin irq;
|
||||||
|
Pin rst;
|
||||||
|
Pin power;
|
||||||
|
bool powerInvert;
|
||||||
|
Pin led;
|
||||||
|
}W5500Pin;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
SPI _spi;
|
||||||
|
Pin ce;
|
||||||
|
Pin irq;
|
||||||
|
Pin power;
|
||||||
|
bool powerInvert;
|
||||||
|
Pin led;
|
||||||
|
}NRFPin;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
W5500Pin W5500;
|
||||||
|
NRFPin Nrf;
|
||||||
|
Pin UserKey1; // 默认重启
|
||||||
|
Pin UserKey2; // 默认设置
|
||||||
|
Pin UserLed1; // 默认蓝色
|
||||||
|
Pin UserLed2; // 默认红色
|
||||||
|
}PINS;
|
||||||
|
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
class PinConfig : public ConfigBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PINS AllPin;
|
||||||
|
uint IsEff;
|
||||||
|
byte TagEnd; // 数据区结束标识符
|
||||||
|
|
||||||
|
PinConfig();
|
||||||
|
virtual void Init();
|
||||||
|
// virtual void Load();
|
||||||
|
// virtual void Save()const;
|
||||||
|
|
||||||
|
static PinConfig* Current;
|
||||||
|
static PinConfig* Create();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue