差异
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
#include "../main/SystemInclude.h"
|
||||
|
||||
u16 systmeState ;
|
||||
u16 UPGRADECammand ;
|
||||
u16 CodeCRC ;
|
||||
u16 jumpError ;
|
||||
u16 systmeState;
|
||||
//u16 UPGRADECammand ;
|
||||
//u16 CodeCRC ;
|
||||
u16 jumpError;
|
||||
//******************************************************************************
|
||||
// for internel modbus
|
||||
u32 securityID; //
|
||||
//u32 securityID; //
|
||||
|
||||
//*****************************************************************************
|
||||
//for modbus >16bit register define
|
||||
@@ -16,16 +16,17 @@ u64 flowAccumulationHex;
|
||||
u32 minFlowRate,maxFlowRate,minAnalogOutput,maxAnalogOutput;
|
||||
u32 alarmAcc,alarmUpperFlowRate,alarmLowerFlowRate;
|
||||
u32 reverseFlowRateMin, reverseFlowRateMax;
|
||||
u32 keyPassWord;
|
||||
//*******************************************************************************
|
||||
__SystemProcess_Union_TypeDef systemProcess;
|
||||
|
||||
//*******************************************************************************
|
||||
__SystemProcess_Union_TypeDef systemProcessing; //<2F><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>״̬
|
||||
__SystemState_Union_TypeDef currentMode;
|
||||
__Hardware_Status_Bit_TypeDef HWState;
|
||||
__Alarm_State_TypeDef systemAlarm;
|
||||
|
||||
//******************************************************************************
|
||||
u16 curveMode;
|
||||
u16 SysLcd, SysLoopChip;// currentSysState;
|
||||
u16 testTypeCounter, MEMSErrorCounter;
|
||||
u16 testTypeCounter;//, MEMSErrorCounter;
|
||||
u16 systemVoltage, batteryGrid;
|
||||
u16 calibType;
|
||||
// for code CRC
|
||||
@@ -33,9 +34,7 @@ u16 APPCodeCRC;
|
||||
u32 securityID;
|
||||
u16 IDvalidTime, comCounter, comResetCounter, AutoOffsetCounter, timePeriod, autoTxdCounter, SysVolErrorCount;
|
||||
u32 ModeExitTime;
|
||||
u16 language;
|
||||
__Display_Status_Bit_TypeDef displayMode;
|
||||
u16 roughTestCounter, testCounter;
|
||||
// for save data
|
||||
u16 timeCompute;
|
||||
//for system
|
||||
@@ -46,16 +45,13 @@ u8 Dis1[15], timer[8];
|
||||
u16 displayUpdate, displayCNT;
|
||||
//u8 flowRateUnit, AccUnit;
|
||||
//------------------------------------------------------------------------------
|
||||
// for ADC Sampling
|
||||
u16 reverseScale, zeroSuppression, calibFlowGain;
|
||||
//------------------------------------------------------------------------------
|
||||
// for flowRate
|
||||
u32 currentFlowRate, factoryFlowRate;
|
||||
//------------------------------------------------------------------------------
|
||||
u16 calibTemperature;
|
||||
//u16 calibTemperature;
|
||||
//------------------------------------------------------------------------------
|
||||
// for acc pulse output
|
||||
u16 samplingInterval, samplingIntervalTarget, factoryInterval, responseTimeIndex;
|
||||
u16 samplingInterval, samplingIntervalTarget, responseTimeIndex;
|
||||
u16 updatePulseTime;
|
||||
//------------------------------------------------------------------------------
|
||||
u16 tmpIA;
|
||||
@@ -68,11 +64,11 @@ TypeLongLong tempDev;
|
||||
//------------------------------------------------------------------------------
|
||||
const u8 ProductModel[12] = PRODUCT_MOD;
|
||||
const u8 SoftVersion[12] = VERSION;
|
||||
const u8 SoftBuildDate[10] = BUILD_MV;
|
||||
const u8 SoftBuildDate[10] = BUILD_DATE;
|
||||
const u8 PulseOutGain[] ={32,16,8,4,2,1}; //
|
||||
const u8 FilterMax[] ={1, 2, 4, 8, 16, 32}; // filter depth
|
||||
const u16 Timing[] ={BASE_125MS, BASE_250MS, BASE_500MS, BASE_1000MS, BASE_2000MS, BASE_4000MS};
|
||||
const u16 TimeVaule[] ={4096, 8192, 16384, 32768, 65535}; //2048, 0.125s<EFBFBD><EFBFBD>0.25s, 0.5s, 1s, 2s, 4s
|
||||
const u16 TimeVaule[] ={2048,4096, 8192, 16384, 32768, 65535}; //2048, 0.125s<EFBFBD><EFBFBD>0.25s, 0.5s, 1s, 2s, 4s
|
||||
const u16 UpdateTimeVaule[] ={3000, 3850, 7372, 8192, 16384, 16384}; // 0.235s, 0.45s, 0.5s, 1s, 2s
|
||||
const u16 FRUnitForHour[] ={28800, 14400, 7200, 3600, 1800, 900};
|
||||
const u16 FRUnitForMinute[] ={480, 240, 120, 60, 30, 15};
|
||||
@@ -80,60 +76,54 @@ const u16 FRUnitForMinute[] ={480, 240, 120, 60, 30, 15};
|
||||
const u8 BuildDate[] = __DATE__; // "Oct 30 2010"
|
||||
/******************************************************************************/
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
void EnterUserMode(void)
|
||||
{
|
||||
currentMode.Bit.CalibMode = 0;
|
||||
currentMode.Bit.IntCalibMode = 0;
|
||||
|
||||
currentMode.Bit.CalibMode = 0;
|
||||
currentMode.Bit.IntCalibMode = 0;
|
||||
currentMode.Bit.FactoryTestMode = 0;
|
||||
currentMode.Bit.DebugMode = 0;
|
||||
|
||||
currentMode.Bit.DigitOutput = 1;
|
||||
currentMode.Bit.ComModeOperate = 0;
|
||||
currentMode.Bit.DebugMode = 0;
|
||||
currentMode.Bit.DigitOutput = 1;
|
||||
currentMode.Bit.ComModeOperate = 0;
|
||||
ModeExitTime = 0;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
void EnterCalibMode(void)
|
||||
{
|
||||
currentMode.Bit.CalibMode = 1;
|
||||
currentMode.Bit.IntCalibMode = 1;
|
||||
currentMode.Bit.CalibMode = 1;
|
||||
currentMode.Bit.IntCalibMode = 1;
|
||||
currentMode.Bit.FactoryTestMode = 0;
|
||||
currentMode.Bit.DebugMode = 0;
|
||||
currentMode.Bit.DigitOutput = 1;
|
||||
currentMode.Bit.ComModeOperate = 1;
|
||||
currentMode.Bit.DebugMode = 0;
|
||||
currentMode.Bit.DigitOutput = 1;
|
||||
currentMode.Bit.ComModeOperate = 1;
|
||||
ModeExitTime = 0;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
void EnterZeroCalibMode(void)
|
||||
{
|
||||
currentMode.Bit.CalibMode = 1;
|
||||
currentMode.Bit.IntCalibMode = 1;
|
||||
currentMode.Bit.ZeroCalib = 1;
|
||||
|
||||
currentMode.Bit.CalibMode = 1;
|
||||
currentMode.Bit.IntCalibMode = 1;
|
||||
currentMode.Bit.ZeroCalib = 1;
|
||||
currentMode.Bit.FactoryTestMode = 0;
|
||||
currentMode.Bit.DebugMode = 0;
|
||||
currentMode.Bit.DigitOutput = 1;
|
||||
currentMode.Bit.ComModeOperate = 1;
|
||||
currentMode.Bit.DebugMode = 0;
|
||||
currentMode.Bit.DigitOutput = 1;
|
||||
currentMode.Bit.ComModeOperate = 1;
|
||||
ModeExitTime = 0;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
void EnterBatteryMode(void)
|
||||
{
|
||||
currentMode.Bit.CalibMode = 0;
|
||||
currentMode.Bit.IntCalibMode = 0;
|
||||
currentMode.Bit.CalibMode = 0;
|
||||
currentMode.Bit.IntCalibMode = 0;
|
||||
currentMode.Bit.FactoryTestMode = 0;
|
||||
currentMode.Bit.DebugMode = 0;
|
||||
|
||||
currentMode.Bit.DigitOutput = 1;
|
||||
currentMode.Bit.ComModeOperate = 1;
|
||||
|
||||
currentMode.Bit.DebugMode = 0;
|
||||
currentMode.Bit.DigitOutput = 1;
|
||||
currentMode.Bit.ComModeOperate = 1;
|
||||
currentMode.Bit.ExtPowerInput = 0;
|
||||
ModeExitTime = 0;
|
||||
currentMode.Bit.ExtPowerInput = 0;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
@@ -154,91 +144,86 @@ void EnterGcfTestMode(void)
|
||||
{
|
||||
currentMode.Bit.CalibMode = 0;
|
||||
currentMode.Bit.FactoryTestMode = 0;
|
||||
currentMode.Bit.DebugMode = 0;
|
||||
|
||||
currentMode.Bit.DebugMode = 0;
|
||||
currentMode.Bit.ExtPowerInput = 1;
|
||||
currentMode.Bit.DigitOutput = 1;
|
||||
currentMode.Bit.ComModeOperate = 1;
|
||||
ModeExitTime = 0;
|
||||
}
|
||||
|
||||
////******************************************************************************
|
||||
/******************************************************************************/
|
||||
void ModeExitCount(void)
|
||||
{
|
||||
//----------------------------------------------------------------------------
|
||||
// ONE SENCOND
|
||||
// 16384*30 / 128
|
||||
IDvalidTime += timePeriod;
|
||||
if(IDvalidTime >= ID_VALID_TIME) {
|
||||
IDvalidTime = 0;
|
||||
securityID = 0;
|
||||
HWState.EnableCheckCorr = 1;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// comm return counter
|
||||
if(currentMode.Bit.CalibMode) {
|
||||
comCounter += timePeriod;
|
||||
if(comCounter >= comResetCounter) {
|
||||
comCounter = 0;
|
||||
comResetCounter = TIMING_500mS;
|
||||
currentMode.Bit.DigitOutput = 1;
|
||||
systemProcessing.Bit.WriteHandle = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// mode return counter
|
||||
ModeExitTime += (u32)timePeriod;
|
||||
if(ModeExitTime >= (u32)EXIT_7200S) {
|
||||
ModeExitTime = 0;
|
||||
EnterUserMode();
|
||||
// currentMode.Bit.ComModeOperate = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
void ManagePrimaryTimeInterval(void)
|
||||
{
|
||||
u32 currentPerPulse;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
samplingIntervalForTotal = samplingInterval;
|
||||
timePeriod = TimeVaule[samplingInterval];
|
||||
timePeriod >>= 7;
|
||||
|
||||
samplingInterval = samplingIntervalTarget;
|
||||
ResetPrimaryTimer(TimeVaule[samplingInterval]);
|
||||
|
||||
samplingIntervalTarget = factoryInterval;//
|
||||
|
||||
if(currentMode.Bit.CalibMode)
|
||||
{
|
||||
//currentPerPulse = (s16)calibUnitPerPuls;
|
||||
sampleState.EnableRoughTest = 0;
|
||||
HWState.EnableCheck = 1;
|
||||
samplingIntervalTarget = (u16)EXT_POWER_PERIOD_TIME;
|
||||
}
|
||||
else
|
||||
{
|
||||
//currentPerPulse = (s16)factoryUnitPerPuls;
|
||||
if(currentMode.Bit.ExtPowerInput)
|
||||
{
|
||||
HWState.EnableCheck = 1;
|
||||
samplingIntervalTarget = (u16)EXT_POWER_PERIOD_TIME;
|
||||
currentMode.Bit.TurnOffSystem = 0;
|
||||
sampleState.EnableRoughTest = 0;
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
#ifndef ENABLE_ACCPULSE
|
||||
#pragma message("[undefined] ENABLE_ACCPULSE")
|
||||
#elif(ENABLE_ACCPULSE)
|
||||
currentPerPulse = InitPulseUnit(currentPerPulse);
|
||||
if(currentPerPulse != unitPerPulse) lastRemaining = 0;
|
||||
unitPerPulse = currentPerPulse;
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
if((currentMode.Bit.DebugMode)||(currentMode.Bit.ZeroCalib))
|
||||
{
|
||||
sampleState.EnableRoughTest = 0;
|
||||
testCounter = 5;
|
||||
}
|
||||
else if(MEMSErrorCounter != 0) testCounter = 2;
|
||||
else testCounter = 60;
|
||||
//if(samplingInterval < 3) sampleState.EnableRoughTest = 0;
|
||||
if(currentMode.Bit.CalibMode) samplingIntervalTarget = (u16)EXT_POWER_PERIOD_TIME;
|
||||
else samplingIntervalTarget = factoryInterval;//
|
||||
currentMode.Bit.TurnOffSystem = 0;
|
||||
}
|
||||
|
||||
|
||||
u32 ReadParameterFromMemory(u16 parameterAdr, u16 parameterLen, u32 parameterDefault)
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>------------------------------------------------------------
|
||||
void EnterMainEntry(void)
|
||||
{
|
||||
tempDev.DWord[0] = 0;
|
||||
|
||||
if(1) ReadParameterFromFlash(tempDev.Byte , parameterAdr , parameterLen , VENDER_PARAMS_PAGE);
|
||||
else ReadMultiByteFromEEPROM(parameterAdr, tempDev.Byte, parameterLen, PARA_EEPROM);
|
||||
// samplingInterval = 1;
|
||||
|
||||
parameterLen--;
|
||||
|
||||
if(tempDev.Byte[parameterLen] != CRC8(tempDev.Byte, parameterLen))
|
||||
{
|
||||
tempDev.DWord[0] = (u32)parameterDefault;
|
||||
isReadParameterOK = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
tempDev.Byte[parameterLen] = 0;
|
||||
isReadParameterOK = 1;
|
||||
}
|
||||
|
||||
return tempDev.DWord[0];
|
||||
// ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>жϴ<D0B6><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
StartPrimaryTimer(TimeVaule[samplingInterval]); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
lptimer_register_irq_callback(PrimaryTimer, PrimaryTimer_IRQ_Callback);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
void BackupParameterToFlash(void)
|
||||
{
|
||||
//FY WriteShortParameterToBuffer(UPGRADECammand, UPGRADE_APP, UPGRADE_APP_WIDTH);
|
||||
//FY WriteShortParameterToBuffer(localAddress, SLAVER_ADDR, SLAVER_ADDR_WIDTH);
|
||||
//WriteShortParameterToBuffer(baudRate, BAUD_RATE, BAUD_RATE_WIDTH);
|
||||
// clear_WDT();
|
||||
// Clear_WDT();
|
||||
//
|
||||
// disable_interrupts();
|
||||
////FY WriteMultiByteToInfoSegment(PARAMETER_BASE, FlashBuf, PARA_LEN);
|
||||
@@ -249,81 +234,80 @@ void BackupParameterToFlash(void)
|
||||
|
||||
//******************************************************************************
|
||||
//ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
u32 sn ;
|
||||
void SystemParameterInit(void)
|
||||
{
|
||||
currentMode.Bit.ComModeOperate = 0;
|
||||
//==============================================================================
|
||||
// <20>ȶ<EFBFBD>ȡ<EFBFBD>¶ȣ<C2B6><C8A3>ж<EFBFBD>ģʽ
|
||||
StaticTemperatureInit();
|
||||
ManagePrimaryTimeInterval();
|
||||
//==============================================================================
|
||||
meterSN1 = ReadParameterFromMemory(SERIES_BASE+0*SENSOR_SN_WIDTH ,SENSOR_SN_WIDTH ,0);
|
||||
meterSN2 = ReadParameterFromMemory(SERIES_BASE+1*SENSOR_SN_WIDTH ,SENSOR_SN_WIDTH ,0);
|
||||
meterSN3 = ReadParameterFromMemory(SERIES_BASE+2*SENSOR_SN_WIDTH ,SENSOR_SN_WIDTH ,0);
|
||||
meterSN4 = ReadParameterFromMemory(SERIES_BASE+3*SENSOR_SN_WIDTH ,SENSOR_SN_WIDTH ,0);
|
||||
meterSN5 = ReadParameterFromMemory(SERIES_BASE+4*SENSOR_SN_WIDTH ,SENSOR_SN_WIDTH ,0);
|
||||
meterSN6 = ReadParameterFromMemory(SERIES_BASE+5*SENSOR_SN_WIDTH ,SENSOR_SN_WIDTH ,0);
|
||||
//==============================================================================
|
||||
// for meter factor
|
||||
MeterFactor = ReadParameterFromMemory(METER_FACTOR, METER_FACTOR_WIDTH, METER_PARAMETER_DEFAULT);
|
||||
// for GDCF
|
||||
GCFCoefA = (s32)ReadParameterFromMemory(GCF_A, GCF_A_WIDTH, (u32)GCF_A_DEFAULT);
|
||||
GDCFactor = (u16)ReadParameterFromMemory(GCF_B, GCF_B_WIDTH, GCF_DEFAULT);
|
||||
GCFCoefC = (s32)ReadParameterFromMemory(GCF_C, GCF_C_WIDTH, GCF_C_DEFAULT);
|
||||
ComputeGCFFactor();
|
||||
|
||||
clear_WDT();
|
||||
//offset Air & Gas
|
||||
offsetAir = ReadParameterFromMemory(OFFSET_AIR ,OFFSET_AIR_WIDTH ,32768);
|
||||
offsetGas = ReadParameterFromMemory(OFFSET_GAS ,OFFSET_GAS_WIDTH ,32768);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
InternalShortParameterInit();
|
||||
InternalLongParameterInit();
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
offsetGCFX = (u16)ReadParameterFromMemory(OFFSET_GCFX, OFFSET_GCFX_WIDTH, 32768);
|
||||
// <20>ȶ<EFBFBD>ȡ<EFBFBD>¶ȣ<C2B6><C8A3>ж<EFBFBD>ģʽ
|
||||
ManagePrimaryTimeInterval();
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Clear_WDT();
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
ReadMultiByteFromMemory(SERIES_BASE, (u8 *)&meterSN1, SERIES_DEPTH);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
localAddress = (u16)ReadShortParameterFromMemory(SLAVER_ADDR, SLAVER_ADDR_DEFAULT);
|
||||
#ifndef ENABLE_USER_I2C
|
||||
#pragma message("[undefined] ENABLE_USER_I2C")
|
||||
#elif(ENABLE_USER_I2C)
|
||||
I2CAddr = localAddress;
|
||||
#endif
|
||||
|
||||
// for GDCF
|
||||
// GCFCoefA = (s32)ReadParameterFromEEPROM(GCF_A, GCF_A_WIDTH, (u32)GCF_A_DEFAULT);
|
||||
GDCFactor = (u16)ReadShortParameterFromMemory(GCF_B, GCF_DEFAULT);
|
||||
// GCFCoefC = (s32)ReadParameterFromEEPROM(GCF_C, GCF_C_WIDTH, GCF_C_DEFAULT);
|
||||
ComputeGCFFactor();
|
||||
|
||||
Clear_WDT();
|
||||
offsetGas = (u16)ReadShortParameterFromMemory(GAS_OFFSET, 32768);
|
||||
//------------------------------------------------------------------------------
|
||||
// offsetGCFX = (u16)ReadParameterFromEEPROM(OFFSET_GCFX, OFFSET_GCFX_WIDTH, 32768);
|
||||
//------------------------------------------------------------------------------
|
||||
factoryInterval = (u16)ReadParameterFromMemory(SAMPLE_PERIOD, SAMPLE_PERIOD_WIDTH, SAMPLE_PERIOD_DEFAULT);
|
||||
samplingInterval = factoryInterval;
|
||||
samplingTiming = SetupResponseTime(factoryInterval, SAMPLE_PERIOD_DEFAULT);
|
||||
responseTimeIndex = (u16)ReadParameterFromMemory(RESPONSE_TIME, RESPONSE_TIME_WIDTH, RESPONSE_TIME_DEFAULT);
|
||||
samplingTiming = SetupResponseTime(factoryInterval, SAMPLE_PERIOD_DEFAULT);
|
||||
|
||||
responseTimeIndex = (u16)ReadShortParameterFromMemory(RESPONSE_TIME, RESPONSE_TIME_DEFAULT);
|
||||
responseTime = SetupResponseTime(responseTimeIndex, RESPONSE_TIME_DEFAULT);
|
||||
|
||||
// for max current Loop flowrate
|
||||
maxFlowRate = ReadParameterFromMemory(MAX_FLOW, MAX_FLOW_WIDTH, MAX_FR_DEFAULT);
|
||||
minFlowRate = ReadParameterFromMemory(MIN_FLOW, MIN_FLOW_WIDTH, MIN_FR_DEFAULT); // V2004
|
||||
|
||||
// for read caluibration temperation
|
||||
calibTemperature = (u16)ReadParameterFromMemory(CALIB_TEMPERATURE, CALIB_TEMPERATURE_WIDTH, TEMPRETURE_OFFSET);
|
||||
|
||||
// read
|
||||
reverseScale = (u16)ReadParameterFromMemory(REVERSE_SCALE, REVERSE_SCALE_WIDTH, REVERSE_SCALE_DEFAULT);
|
||||
|
||||
// read display langauge unit
|
||||
language = (u8)(u16)ReadParameterFromMemory(DIS_LANGUAGE, DIS_LANGUAGE_WIDTH, (u16)DIS_LANGUAGE_DEFAULT);
|
||||
|
||||
// read zero Suppression
|
||||
zeroSuppression = (u16)ReadParameterFromMemory(ZERO_SUPPRESSION, ZERO_SUPPRESSION_WIDTH, ZERO_SUPPRESSION_DEFAULT);
|
||||
|
||||
clear_WDT();
|
||||
maxFlowRate = ReadLongParameterFromMemory(OUT_MAX_FLOW, MAX_FR_DEFAULT);
|
||||
tempL.DWord = maxFlowRate;
|
||||
maxFlowRateH = tempL.Word[1];
|
||||
maxFlowRateL = tempL.Word[0];
|
||||
|
||||
minFlowRate = ReadLongParameterFromMemory(OUT_MIN_FLOW, MIN_FR_DEFAULT); // V2004
|
||||
tempL.DWord = minFlowRate;
|
||||
minFlowRateH = tempL.Word[1];
|
||||
minFlowRateL = tempL.Word[0];
|
||||
|
||||
Clear_WDT();
|
||||
//read uart DecimalPoint
|
||||
uartDecimalPoint = (u16)ReadParameterFromMemory(COM_DECIMAL_POINT, COM_DECIMAL_POINT_WIDTH, COM_DECIMAL_POINT_DEFAULT);
|
||||
|
||||
uartDecimalPoint = (u16)ReadShortParameterFromMemory(COM_DECIMAL, COM_DECIMAL_POINT_DEFAULT);
|
||||
//============================================================================
|
||||
// for AUTO TXD DATA
|
||||
timingTxdStart = (u16)ReadParameterFromMemory(TIMING_TXD_START, TIMING_TXD_START_WIDTH, TIMING_TXD_START_DEFAULT);
|
||||
timingTxdLen = (u16)ReadParameterFromMemory(TIMING_TXD_LEN, TIMING_TXD_LEN_WIDTH, TIMING_TXD_LEN_DEFAULT);
|
||||
timingTxdTime = (u16)ReadParameterFromMemory(TIMING_TXD_TIME, TIMING_TXD_TIME_WIDTH, TIMING_TXD_TIME_DEFAULT);
|
||||
timingTxdStart = (u16)ReadShortParameterFromMemory(TIMING_TXD_START, TIMING_TXD_START_DEFAULT);
|
||||
timingTxdLen = (u16)ReadShortParameterFromMemory(TIMING_TXD_LEN, TIMING_TXD_LEN_DEFAULT);
|
||||
timingTxdTime = (u16)ReadShortParameterFromMemory(TIMING_TXD_TIME, TIMING_TXD_TIME_DEFAULT);
|
||||
|
||||
clear_WDT();
|
||||
// key setup password
|
||||
//============================================================================
|
||||
#ifndef ENABLE_KEY_FUNCTION
|
||||
#pragma message("[undefined] ENABLE_KEY_FUNCTION")
|
||||
#elif(ENABLE_KEY_FUNCTION)
|
||||
keyPassWord = ReadParameterFromMemory(KEY_PASSWORD, KEY_PASSWORD_WIDTH, KEY_PASSWORD_DEFAULT);
|
||||
keyPassWord = ReadParameterFromEEPROM(KEY_PASSWORD, KEY_PASSWORD_WIDTH, KEY_PASSWORD_DEFAULT);
|
||||
#endif
|
||||
|
||||
//============================================================================
|
||||
UnitConverterInit();
|
||||
|
||||
//============================================================================
|
||||
#ifndef ENABLE_ACCPULSE
|
||||
#pragma message("[undefined] ENABLE_ACCPULSE")
|
||||
@@ -331,32 +315,12 @@ void SystemParameterInit(void)
|
||||
PulseParameterInit();
|
||||
#endif
|
||||
|
||||
//============================================================================
|
||||
// RHCircuitParameterInit();
|
||||
|
||||
//============================================================================
|
||||
GasAnalysisParameterInit();
|
||||
|
||||
//============================================================================
|
||||
SaveParameterInit();
|
||||
|
||||
//============================================================================
|
||||
AdjustOffsetInit();
|
||||
|
||||
//============================================================================
|
||||
#ifndef ENABLE_PLUG_IN_FLOWRATE
|
||||
#pragma message("[undefined] ENABLE_PLUG_IN_FLOWRATE")
|
||||
#elif(ENABLE_PLUG_IN_FLOWRATE)
|
||||
PipeFlowRateComputeInit();
|
||||
#endif
|
||||
|
||||
//============================================================================
|
||||
#ifndef ENABLE_A_TYPE_FLOWRATE
|
||||
#pragma message("[undefined] ENABLE_A_TYPE_FLOWRATE")
|
||||
#elif(ENABLE_A_TYPE_FLOWRATE)
|
||||
ATypeFlowRateInit();
|
||||
#endif
|
||||
|
||||
|
||||
//==============================================================================
|
||||
// retrieve device coefficients
|
||||
#ifndef ENABLE_DCOEF
|
||||
@@ -381,69 +345,30 @@ void SystemParameterInit(void)
|
||||
// for modbus
|
||||
InitUseBusParameter();
|
||||
|
||||
//==============================================================================
|
||||
// for system hardware
|
||||
#ifndef ENABLE_4_20MA_OUTPUT
|
||||
#pragma message("[undefined] ENABLE_4_20MA_OUTPUT")
|
||||
#elif(ENABLE_4_20MA_OUTPUT)
|
||||
CurrentLoopInit();
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
#ifndef ENABLE_USE_EDM7791
|
||||
#pragma message("[undefined] ENABLE_USE_EDM7791")
|
||||
#elif(ENABLE_USE_EDM7791)
|
||||
|
||||
#ifndef ENABLE_EDM7791_ALL
|
||||
#pragma message("[undefined] ENABLE_EDM7791_ALL")
|
||||
#elif(ENABLE_EDM7791_ALL)
|
||||
SysLcd = (u16)ReadParameterFromMemory(SYS_LCD, SYS_LCD_WIDTH, SYS_LCD_DEFAULT);
|
||||
#else
|
||||
#ifndef ENABLE_EMD779103D
|
||||
#pragma message("[undefined] ENABLE_EMD779103D")
|
||||
#elif(ENABLE_EMD779103D)
|
||||
SysLcd = EDM779103D;
|
||||
#endif
|
||||
|
||||
#ifndef ENABLE_EMD779106D
|
||||
#pragma message("[undefined] ENABLE_EMD779106D")
|
||||
#elif(ENABLE_EMD779106D)
|
||||
SysLcd = EDM779106D;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// V2004
|
||||
#ifndef ENABLE_ALARM_ACC
|
||||
#pragma message("[undefined] ENABLE_ALARM_ACC")
|
||||
#elif(ENABLE_ALARM_ACC)
|
||||
alarmAcc = ReadParameterFromMemory(ALARM_ACC, ALARM_ACC_WIDTH, ALARM_ACC_DEFAULT);
|
||||
alarmAcc = ReadParameterFromEEPROM(ALARM_ACC, ALARM_ACC_WIDTH, ALARM_ACC_DEFAULT);
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
#ifndef ENABLE_OFFSET_CORRECT
|
||||
#pragma message("[undefined] ENABLE_OFFSET_CORRECT")
|
||||
#elif(ENABLE_OFFSET_CORRECT)
|
||||
ComputeOffsetDriftInit();
|
||||
#endif
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifndef ENABLE_LEAK_DETECT
|
||||
#pragma message("[undefined] ENABLE_LEAK_DETECT")
|
||||
#elif(ENABLE_LEAK_DETECT)
|
||||
minLeakFlowRate = (u16)ReadParameterFromMemory(MIN_LEAK_FLOW, MIN_LEAK_FLOW_WIDTH, MIN_LEAK_FLOW_DEFAULT);
|
||||
maxLeakFlowRate = (u16)ReadParameterFromMemory(MAX_LEAK_FLOW, MAX_LEAK_FLOW_WIDTH, MAX_LEAK_FLOW_DEFAULT);
|
||||
leakDetectTime = (u16)ReadParameterFromMemory(LEAK_TIME, LEAK_TIME_WIDTH, LEAK_TIME_DEFAULT);
|
||||
minLeakFlowRate = (u16)ReadParameterFromEEPROM(MIN_LEAK_FLOW, MIN_LEAK_FLOW_WIDTH, MIN_LEAK_FLOW_DEFAULT);
|
||||
maxLeakFlowRate = (u16)ReadParameterFromEEPROM(MAX_LEAK_FLOW, MAX_LEAK_FLOW_WIDTH, MAX_LEAK_FLOW_DEFAULT);
|
||||
leakDetectTime = (u16)ReadParameterFromEEPROM(LEAK_TIME, LEAK_TIME_WIDTH, LEAK_TIME_DEFAULT);
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#ifndef ENABLE_FLOW_GAIN
|
||||
#pragma message("[undefined] ENABLE_FLOW_GAIN")
|
||||
#elif(ENABLE_FLOW_GAIN)
|
||||
calibFlowGain = (u16)ReadParameterFromMemory(FLOW_GAIN, FLOW_GAIN_WIDTH, FLOW_GAIN_DEFAULT);
|
||||
if(JudgeFlowRateGain(calibFlowGain)) calibFlowGain = FLOW_GAIN_DEFAULT;
|
||||
|
||||
//==============================================================================
|
||||
#ifndef REC_ACC_PER
|
||||
#pragma message("[undefined] REC_ACC_PER")
|
||||
#elif(REC_ACC_PER)
|
||||
RetrieveLastAccumulation();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
@@ -494,27 +419,6 @@ void SystemHardWareAutoCheck(void)
|
||||
// }
|
||||
|
||||
// 7) Check external RTC and read current time
|
||||
//===========================================================================
|
||||
#ifndef ENABLE_EXT_RTC
|
||||
#pragma message("[undefined] ENABLE_EXT_RTC")
|
||||
#elif(ENABLE_EXT_RTC)
|
||||
if(ExtRTCDataRead(USR1) == 1) Dis1[CHK_RTC] = 0;
|
||||
else if(TestExtRTCReady())
|
||||
{
|
||||
if(ExtRTCInit())
|
||||
{
|
||||
Dis1[CHK_RTC] = 1;
|
||||
systemAlarm.Bit.RTC_ALARM = 1;
|
||||
}
|
||||
}
|
||||
else Dis1[CHK_RTC] = 2;
|
||||
|
||||
if(Dis1[CHK_RTC] == 0) ExtRTCTimeRead(); // read IS1208 time
|
||||
else ReadCurrentTime();
|
||||
|
||||
#else
|
||||
// ReadCurrentTime();
|
||||
#endif
|
||||
//FY SetRTCCurrentTime(); // set time to MCU RTC
|
||||
|
||||
// 7)Check external temprature
|
||||
@@ -535,28 +439,19 @@ void SystemHardWareInit(void)
|
||||
/*SPI Bus Init=========================================================================*/
|
||||
//TurnOffAnalogCircuit();
|
||||
/*IIC Bus Init=========================================================================*/
|
||||
SI2C_Init();
|
||||
// SI2C_Init();
|
||||
|
||||
/*Memory Init==========================================================================*/
|
||||
EEPROMInit();
|
||||
|
||||
//if(REC_ACC_PER) FRAMInit();// Acc flowrate save enable bit
|
||||
/*external tempreture Init============================================================*/
|
||||
HWState.EnableTempTest= 1;
|
||||
HWState.EnableTempInit=1;
|
||||
WriteWordRegister(CONFIG, SHUT_DOWN);//<2F><><EFBFBD>üĴ<C3BC><C4B4><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
/*RTC Init=============================================================================*/
|
||||
//FY SetRTCCalendarMode();
|
||||
/*External RTC=========================================================================*/
|
||||
#ifndef ENABLE_EXT_RTC
|
||||
#pragma message("[undefined] ENABLE_EXT_RTC")
|
||||
#elif(ENABLE_EXT_RTC)
|
||||
if(TestExtRTCReady()) ExtRTCInit();
|
||||
#endif
|
||||
// HWState.EnableTempTest= 1;
|
||||
// HWState.EnableTempInit=1;
|
||||
// WriteWordRegister(CONFIG, SHUT_DOWN);//<2F><><EFBFBD>üĴ<C3BC><C4B4><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
|
||||
|
||||
|
||||
void SystemInterfaceInit(void)
|
||||
{
|
||||
//uart init============================================================================
|
||||
@@ -566,25 +461,24 @@ void SystemInterfaceInit(void)
|
||||
MainUartInit(baudRateVaule[baudRate]);
|
||||
StartDMAForRxdMainUartData();
|
||||
#endif
|
||||
|
||||
//iic init============================================================================
|
||||
// #ifndef ENABLE_USER_I2C
|
||||
// #pragma message("[undefined] ENABLE_USER_I2C")
|
||||
// #elif(ENABLE_USER_I2C)
|
||||
// I2C_Slave_Init(100000 , 0x02);
|
||||
// I2CAddr = localAddress;
|
||||
// meterSN1=0x3031; meterSN2=0x3233; meterSN3=0x3435;
|
||||
// meterSN4=0x3637; meterSN5=0x3839; meterSN6=0x4041;
|
||||
// #endif
|
||||
#ifndef ENABLE_USER_I2C
|
||||
#pragma message("[undefined] ENABLE_USER_I2C")
|
||||
#elif(ENABLE_USER_I2C)
|
||||
I2C_Slave_Init(100000 , 0x02);
|
||||
I2CAddr = localAddress;
|
||||
#endif
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
void InitGlobalVar(void)
|
||||
void InitGlobalVar(void)
|
||||
{
|
||||
u8 I;
|
||||
|
||||
jumpError = 0;
|
||||
|
||||
clear_WDT();
|
||||
Clear_WDT();
|
||||
//TXDMode = ENABLE_TXD_USE_DMA;
|
||||
|
||||
displayUpdate = 0;
|
||||
@@ -610,21 +504,14 @@ void InitGlobalVar(void)
|
||||
// 0x80~0xf0
|
||||
protocol = 0;
|
||||
localAddress = 1;
|
||||
baudRate = BPS_115200;
|
||||
minFlowRate = 0;
|
||||
maxFlowRate = 0;
|
||||
baudRate = BPS_38400; // BPS_9600 BPS_115200
|
||||
minAnalogOutput = 0;
|
||||
maxAnalogOutput = 0;
|
||||
GDCFactor = 0;
|
||||
GDCFactorAType = 0;
|
||||
filterTime = 0;
|
||||
factoryInterval = 0;
|
||||
offsetGas = 0;
|
||||
offsetGasA = 0;
|
||||
flowUnit = 0;
|
||||
VHHParameterAir = 0;
|
||||
VHHParameterScale = 0;
|
||||
unitPerPulse = 0;
|
||||
alarmFunction = 0;
|
||||
alarmOutDelay = 0;
|
||||
alarmAcc = 0;
|
||||
@@ -651,48 +538,21 @@ void InitGlobalVar(void)
|
||||
densityFSParameter = 0;
|
||||
#endif
|
||||
|
||||
displayMode.NeedForInit = 1;
|
||||
|
||||
munWriteParams = WP_NOT;//<2F><>Ƭ<EFBFBD><C6AC><EFBFBD><EFBFBD>Ҫд<D2AA><D0B4>
|
||||
displayMode.NeedForInit = 1;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
void SystemInitProcess(void)
|
||||
{
|
||||
if(systmeState != 0xAA55)
|
||||
{
|
||||
if(CodeCRC == 0) alarmState &= ~BL_CRC_ERROR;
|
||||
else alarmState |= BL_CRC_ERROR;
|
||||
InitGlobalVar();
|
||||
}
|
||||
SystemHardWareInit(); //ϵͳӲ<CDB3><D3B2><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
SystemHardWareAutoCheck();
|
||||
SystemParameterInit(); //ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
SystemInterfaceInit(); //ϵͳ<CFB5>ӿڳ<D3BF>ʼ<EFBFBD><CABC> //USER_UART
|
||||
InitGlobalVar(); //ȫ<>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
SystemHardWareInit(); //ϵͳӲ<CDB3><D3B2><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
SystemHardWareAutoCheck(); //
|
||||
SystemParameterInit(); //ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
SystemInterfaceInit(); //ϵͳ<CFB5>ӿڳ<D3BF>ʼ<EFBFBD><CABC> //USER_UART
|
||||
systmeState = 0xAA55;
|
||||
}
|
||||
|
||||
|
||||
|
||||
u32 sleeptime ;
|
||||
void LPTIMER1_IRQ_Callback()//
|
||||
{
|
||||
StartNormolFlowMeasurement();//ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD>źŵIJ<C5B5><C4B2><EFBFBD>
|
||||
// LHL_GPIO_TogglePin(pGPIO1, GPIO_PIN_7);
|
||||
|
||||
// sleeptime++;
|
||||
// if (sleeptime == 40){ mcuModeSleeping = 1 ; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void EnterMainEntry(void)
|
||||
{
|
||||
samplingInterval = 0;
|
||||
StartPrimaryTimerInterval(TimeVaule[samplingInterval]);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
lptimer_register_irq_callback(PrimaryTimer,LPTIMER1_IRQ_Callback);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user