2026-03-20 21:16:58 +08:00
|
|
|
|
/********************************************************************************************************
|
|
|
|
|
|
**-------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
********************************************************************************************************/
|
|
|
|
|
|
#ifndef __AccCompute_h__
|
|
|
|
|
|
#define __AccCompute_h__
|
|
|
|
|
|
|
|
|
|
|
|
//for Accumulation Flowrate define
|
|
|
|
|
|
#define HIGHEST_INTEGER 0
|
|
|
|
|
|
#define LOWEST_DECIMAL 5
|
|
|
|
|
|
#define CRC_CHK 6
|
|
|
|
|
|
#define MIN_BIT 7 // <20><><EFBFBD><EFBFBD>С<EFBFBD><D0A1>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뱣<EFBFBD><EBB1A3><EFBFBD><EFBFBD>CRCЧ<43><D0A7>
|
|
|
|
|
|
#define ACC_MAX 8
|
|
|
|
|
|
|
|
|
|
|
|
//#define ACC_INT1 0
|
|
|
|
|
|
//#define ACC_INT2 1
|
|
|
|
|
|
//#define ACC_INT3 2
|
|
|
|
|
|
//#define ACC_INT4 3
|
|
|
|
|
|
//#define ACC_INT5 4
|
|
|
|
|
|
//#define ACC_INT6 5
|
|
|
|
|
|
//#define ACC_INT7 6
|
|
|
|
|
|
//#define ACC_INT8 7
|
|
|
|
|
|
//#define ACC_INT9 8
|
|
|
|
|
|
//#define ACC_INT10 9
|
|
|
|
|
|
//#define ACC_INT11 10
|
|
|
|
|
|
//#define ACC_INT12 11
|
|
|
|
|
|
//#define ACC_INT13 12
|
|
|
|
|
|
//#define ACC_INT14 13
|
|
|
|
|
|
|
|
|
|
|
|
#define ACC_INT1 0
|
|
|
|
|
|
#define ACC_INT2 1
|
|
|
|
|
|
#define ACC_INT3 2
|
|
|
|
|
|
#define ACC_INT4 3
|
|
|
|
|
|
#define ACC_INT5 4
|
|
|
|
|
|
#define ACC_INT6 5
|
|
|
|
|
|
#define ACC_INT7 6
|
|
|
|
|
|
#define ACC_INT8 7
|
|
|
|
|
|
#define ACC_DOT1 8 //total:12, 4Decimal
|
|
|
|
|
|
#define ACC_DOT2 9 //total:12, 4Decimal
|
|
|
|
|
|
#define ACC_DOT3 10 //total:12, 4Decimal
|
|
|
|
|
|
#define ACC_DOT4 11 //total:12, 4Decimal
|
|
|
|
|
|
#define ACC_DOT5 12 //total:12, 4Decimal
|
|
|
|
|
|
#define ACC_DOT6 13 //total:12, 4Decimal
|
|
|
|
|
|
#define ACC_END 14 //total:12, 4Decimal
|
|
|
|
|
|
|
|
|
|
|
|
#define ACC_DOT ACC_INT9 //total:12, 4Decimal
|
|
|
|
|
|
#define ACC_DOT_END 12 //total:11, 4Decimal
|
|
|
|
|
|
#define ACC_DOT_BIT4 12
|
|
|
|
|
|
|
|
|
|
|
|
#define UART_ACC_DOT ACC_INT9 //total:11, 3Decimal
|
|
|
|
|
|
#define UART_ACC_DOT_END 11 //total:11, 3Decimal
|
|
|
|
|
|
#define ACC_DOT_BIT3 11
|
|
|
|
|
|
|
|
|
|
|
|
//******************************************************************************
|
|
|
|
|
|
// ACC Data save
|
|
|
|
|
|
// For FRAM(< 0x0800)
|
|
|
|
|
|
// For EEPROM(< 0x0200)
|
2026-03-20 21:19:04 +08:00
|
|
|
|
#define REC_BASE 0x0100 // the start EEPROM address of acc data
|
|
|
|
|
|
#define REC_WIDTH 14
|
|
|
|
|
|
#define BLOCK_WIDTH 7 // 0x100(256) + 14*4 = 0x138(312)
|
|
|
|
|
|
#define BLOCK2_START 0x140 // 0x180(256) + 14*4 = 0x1B8
|
|
|
|
|
|
#define REC_DEPTH 4
|
2026-03-20 21:16:58 +08:00
|
|
|
|
|
2026-03-20 21:19:04 +08:00
|
|
|
|
#define REC_PULSE_REMAINING 0x01D0 // 0x1D0(256) + 20 = 0x1E4
|
|
|
|
|
|
#define PULSE_REMAINING_WIDTH 5
|
|
|
|
|
|
#define PULSE_REMAINING_CRC (PULSE_REMAINING_WIDTH-1)
|
2026-03-20 21:16:58 +08:00
|
|
|
|
|
2026-03-20 21:19:04 +08:00
|
|
|
|
#define PULSE_COUNTER 0x01F0 // 0x1D0(256) + 20 = 0x1E4
|
|
|
|
|
|
#define PULSE_COUNTER_WIDTH 5
|
|
|
|
|
|
#define PULSE_COUNTER_CRC (PULSE_COUNTER_WIDTH-1)
|
2026-03-20 21:16:58 +08:00
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
//#define REC_BASE_WIDTH ()
|
|
|
|
|
|
|
|
|
|
|
|
//******************************************************************************
|
|
|
|
|
|
extern u8 Total[], Dis2[];
|
|
|
|
|
|
extern u8 MemoryPointer;
|
|
|
|
|
|
extern u64 flowTotalBuffer;
|
|
|
|
|
|
extern u32 lastRemaining, AccComputeTimeBase;
|
|
|
|
|
|
extern u16 totalPulse;
|
|
|
|
|
|
//extern float flowAccCumulationRemaining;
|
|
|
|
|
|
extern u16 flowAccCumulationRemaining, samplingIntervalForTotal;
|
|
|
|
|
|
//******************************************************************************
|
|
|
|
|
|
void ReleaseTotalToDisArray(void);
|
|
|
|
|
|
void ReleaseToIntAndDecimalBuf(void);
|
|
|
|
|
|
void ReleaseToIntAndDecimalBufForUart(void);
|
|
|
|
|
|
void SendToTotalArray(void);
|
|
|
|
|
|
u16 FRAMWriteTotal(void);
|
|
|
|
|
|
u16 FRAMCheckSaveTotalFlow(u8 Pointer);
|
|
|
|
|
|
u16 RetrieveLastAccumulationFromFRAM(void);
|
|
|
|
|
|
void RetrieveLastAccumulation(void);
|
|
|
|
|
|
void ComputeFlowRateToTotal(void);
|
|
|
|
|
|
void ReadACCFRByCom(void);
|
|
|
|
|
|
void SetupACCArray(void);
|
|
|
|
|
|
void WriteACCFRByCom(void);
|
|
|
|
|
|
void ClearACC(void);
|
|
|
|
|
|
u16 CompareAcc(u8 *compaerA, u8 *compaerB);
|
|
|
|
|
|
//******************************************************************************
|
|
|
|
|
|
#endif
|
|
|
|
|
|
//******************************************************************************
|