📄 memory.h
字号:
#ifndef _MEMORY_H_
#define _MEMORY_H_
#ifdef __SYSTEM_VAR__
#define EXT
#else
#define EXT extern
#endif
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
#define SOFTWARE_VERSION 112
#define PLCC_PACKAGE_IO 0 // define for the developement board for PLCC package of p2.0, p2.1, p2.6, p2.7
#define TSSOP_PACKAGE_IO 0 // define for the formal board for TSSOP package of P0.0 ~ p0.3
#define TSSOP_PACKAGE_IO_SECOND 1 // define for the formal board for TSSOP package of P0.0 ~ p0.3 & p2.4
#define INCLUDE_WATCHDOG
//#define INCLUDE_UART_CODE
#define INCLUDE_I2C_CODE
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// define for the system OS
EXT unsigned char data TCounter;
EXT unsigned char data OS_FETCH_EVENT;
#define OS_EVENT_IDLE 0
#define OS_EVENT_4MS 1
#define OS_EVENT_8MS 2
#define OS_EVENT_16MS 3
#define OS_EVENT_32MS 4
#define OS_EVENT_64MS 5
#define OS_EVENT_128MS 6
#define OS_EVENT_256MS 7
#define OS_EVENT_512MS 8
#define OS_EVENT_RECOUNT 9
EXT uchar idata KeyData;
#if 1
struct Source{
uchar Event:4,MD:4;
};
EXT struct Source SRC;
#define KeyEvent SRC.Event
#define Mode SRC.MD
#else
EXT uchar idata KeyEvent,Mode;
#endif
// define for the KeyEvent
#define IDLE 0
#define PRESS_DOWN 1
#define PRESS_HOLD 2
#define PRESS_UP_SHORT 3
#define PRESS_UP_LONG 4
// define for the Mode
#define SYS_IDLE 0
#define SYS_WORK_PRE 0x01
#define SYS_READY 0x02
#define SYS_EXIT 0x03
#define SYS_SCREEN_TEST_SELF 0x04
/////////////////////////////////////////////////////////////////////////////////
// define for the system Timer
EXT bit FTimer64ms,FTimer256ms,FTimer512ms; //,FTimer128ms,FTimer1s,FTimer2s;
EXT uchar idata Timer4ms,Timer64ms,Counter32ms;
//EXT uchar idata ,Timer8ms,Timer16ms,Timer64ms,Timer128ms,Timer256ms,Counter32ms;
// define for the virtual Timer----Timer2ms
#define T4ms_8ms 2
#define T4ms_16ms 4
#define T4ms_32ms 8
#define T4ms_64ms 16
#define T4ms_80ms 20
#define T4ms_96ms 24
#define T4ms_128ms 32
#define T4ms_256ms 64
#define T4ms_512ms 128
#define T4ms_1SEC 255
// define for the virtual Timer----Timer8ms
#define T8ms_32ms 4
#define T8ms_64ms 8
#define T8ms_96ms 12
#define T8ms_128ms 16
#define T8ms_256ms 32
#define T8ms_1SEC 125
#define T8ms_1SEC256ms 157
#define T8ms_2SEC 250
// define for the virtual Timer----Timer16ms
#define T16ms_32ms 2
#define T16ms_128ms 8
#define T16ms_256ms 16
#define T16ms_512ms 32
#define T16ms_1SEC 64
#define T16ms_1SEC5 96
#define T16ms_2SEC 128
#define T16ms_2SEC5 160
#define T16ms_3SEC 192
// define for the virtual Timer----Timer64ms
#define T64ms_64ms 1
#define T64ms_128ms 2
#define T64ms_192ms 3
#define T64ms_256ms 4
#define T64ms_384ms 6
#define T64ms_512ms 8
#define T64ms_1SEC 16
#define T64ms_1SEC128ms 18
#define T64ms_1SEC256ms 20
#define T64ms_1SEC384ms 22
#define T64ms_1SEC5 24
#define T64ms_2SEC 32
#define T64ms_2SEC5 44
#define T64ms_3SEC 46
#define T64ms_3SEC5 54
#define T64ms_5SEC 78 //78*64MS=5SEC
#define T64ms_10SEC 156 //156*64MS=10SEC
#define T64ms_15SEC 235 //235*64MS=15SEC
#define T64ms_16SEC 250 //250*64MS=16SEC
#define T64ms_16SEC5 255 //255*64MS=16SEC5
// define for the virtual Timer----Timer128ms
#define T128ms_512ms 4
#define T128ms_1SEC 8
#define T128ms_1SEC5 10
#define T128ms_2SEC 16
#define T128ms_2SEC5 20
#define T128ms_3SEC 24
#define T128ms_3SEC5 28
#define T128ms_4SEC 32
#define T128ms_4SEC5 36 //36*128MS=4.5SEC
#define T128ms_5SEC 40 //40*128MS=5SEC
#define T128ms_6SEC 48 //48*128MS=5SEC
#define T128ms_7SEC 56 //56*128MS=5SEC
#define T128ms_8SEC 62 //70*128MS=5SEC
#define T128ms_10SEC 78 //78*128MS=10SEC
#define T128ms_15SEC 117
#define T128ms_30SEC 234
// define for the virtual timer----Timer256ms
#define T256ms_1SEC 4
#define T256ms_2SEC 8
#define T256ms_3SEC 12
#define T256ms_5SEC 20
#define T256ms_6SEC 24
#define T256ms_7SEC 28
#define T256ms_10SEC 40
#define T256ms_12SEC 48
#define T256ms_15SEC 60
#define T256ms_18SEC 72
#define T256ms_20SEC 80
#define T256ms_25SEC5 100
#define T256ms_30SEC 117
#define T256ms_40SEC 157
#define T256ms_50SEC 196
#define T256ms_1MIN 235
/////////////////////////////////////////////////////////////////////////////////
// define for the VFD display
#define BUF_SIZE 37 // define for the front display buffer
#define LN1_SIZE 4
#define LN2_SIZE 4
#define LN3_SIZE 4
#define STR_SIZE 24
typedef struct _SegBuffer{ // define struct map for the VFD.FrontBuffer
uchar PillarS12:1,PillarS11:1,Protect:1,Alarm:1, PillarS10:1,PillarS9:1,Open:1,Close:1; // [0]
uchar PillarS8:1,PillarS7:1,PillarS6:1,PillarS5:1, PillarS4:1,PillarS3:1,PillarS2:1,PillarS1:1;// [1]
uchar empty1:1,U1:1,U1_2:1,U1Ln:1, I1:1,P:1,U2:1,U2_3:1; // [2]
uchar U2Ln:1,I2:1,Q:1,U3_1:1, U3:1,U3Ln:1,I3:1,S:1 ; // [3]
uchar none0[4]; // [4] ~ [7] LN2_SIZE
uchar V:1,KW:1,KV:1,MW:1, MVar:1,A:1,KVar:1,KA:1; // [8]
uchar Var:1,Peak:1,MVA:1,Min:1, KVA:1,Average:1,VA:1,Total:1; // [9]
uchar none1[4]; // [10] ~[13] LN2_SIZE
uchar none2[4]; // [14] ~[17] LN3_SIZE
uchar DI_S13:1,DI_S12:1,DI_S11:1,DI_S10:1, DI_S9:1,DI_Grid:1,EP:1, EQ:1; // [18]
uchar DO_Grid:1,DO_S6:1,DO_S5:1,DO_S4:1, DO_S3:1,DO_S2:1,DO_S1:1,Pulse:1; // [19]
uchar none3[16]; // [20] ~[35] STR_SIZE
uchar AEC:1,W:1,DI_S14:1; // [36]
// bit AEC,W,DI_S14; // [36]
} SegBuffer,*PSegBuffer;
//EXT bit Seg_AEC, Seg_W, Seg_DI1;
//EXT bit Seg_AEC_Bak, Seg_W_Bak, Seg_DI1_Bak; // segment bakup
EXT bit bGrid; // for VFD fresh Grid flag
EXT uchar idata FrameNum,cNum;
EXT bit bIconUpdate, bLn1Update,bLn2Update,bLn3UpDate,bStrLnUpdate; // VFD screen fresh flag
typedef struct _Buffer
{uchar FrontBuff[BUF_SIZE];
// uchar U1Ln[LN1_SIZE]; //abcd== [0],[1], [2],[3],
// uchar U2Ln[LN2_SIZE];
// uchar U3Ln[LN3_SIZE];
uchar StrLn[STR_SIZE];
uchar BakupBuff[BUF_SIZE];
} Buffer,*PBuffer;
EXT Buffer idata VFD;
//////////////////////////////////////////////////////
EXT void * lpStruct; // point to VFD display buffer (front)
#define P2Struct(Dest_Struct, Src_Pointer) (*(Dest_Struct *)Src_Pointer)
#define Seg_PillarS1 ((P2Struct(SegBuffer, lpStruct)).PillarS1)
#define Seg_PillarS2 ((P2Struct(SegBuffer, lpStruct)).PillarS2)
#define Seg_PillarS3 ((P2Struct(SegBuffer, lpStruct)).PillarS3)
#define Seg_PillarS4 ((P2Struct(SegBuffer, lpStruct)).PillarS4)
#define Seg_PillarS5 ((P2Struct(SegBuffer, lpStruct)).PillarS5)
#define Seg_PillarS6 ((P2Struct(SegBuffer, lpStruct)).PillarS6)
#define Seg_PillarS7 ((P2Struct(SegBuffer, lpStruct)).PillarS7)
#define Seg_PillarS8 ((P2Struct(SegBuffer, lpStruct)).PillarS8)
#define Seg_Close ((P2Struct(SegBuffer, lpStruct)).Close)
#define Seg_Open ((P2Struct(SegBuffer, lpStruct)).Open)
#define Seg_PillarS9 ((P2Struct(SegBuffer, lpStruct)).PillarS9)
#define Seg_PillarS10 ((P2Struct(SegBuffer, lpStruct)).PillarS10)
#define Seg_Alarm ((P2Struct(SegBuffer, lpStruct)).Alarm)
#define Seg_Protect ((P2Struct(SegBuffer, lpStruct)).Protect)
#define Seg_PillarS11 ((P2Struct(SegBuffer, lpStruct)).PillarS11)
#define Seg_PillarS12 ((P2Struct(SegBuffer, lpStruct)).PillarS12)
// uchar empty1:1,U1:1,U1_2:1,U1Ln:1, I1:1,P:1,U2:1,U2_3:1; // [2]
// uchar U2Ln:1,I2:1,Q:1,U3_1:1, U3:1,U3Ln:1,I3:1,S:1, ; // [3]
#define Seg_NONE1 ((P2Struct(SegBuffer, lpStruct)).empty)
#define Seg_U1 ((P2Struct(SegBuffer, lpStruct)).U1)
#define Seg_U1_2 ((P2Struct(SegBuffer, lpStruct)).U1_2)
#define Seg_U1Ln ((P2Struct(SegBuffer, lpStruct)).U1Ln)
#define Seg_I1 ((P2Struct(SegBuffer, lpStruct)).I1)
#define Seg_P ((P2Struct(SegBuffer, lpStruct)).P)
#define Seg_U2 ((P2Struct(SegBuffer, lpStruct)).U2)
#define Seg_U2_3 ((P2Struct(SegBuffer, lpStruct)).U2_3)
#define Seg_U2Ln ((P2Struct(SegBuffer, lpStruct)).U2Ln)
#define Seg_I2 ((P2Struct(SegBuffer, lpStruct)).I2)
#define Seg_Q ((P2Struct(SegBuffer, lpStruct)).Q)
#define Seg_U3_1 ((P2Struct(SegBuffer, lpStruct)).U3_1)
#define Seg_U3 ((P2Struct(SegBuffer, lpStruct)).U3)
#define Seg_U3Ln ((P2Struct(SegBuffer, lpStruct)).U3Ln)
#define Seg_I3 ((P2Struct(SegBuffer, lpStruct)).I3)
#define Seg_S ((P2Struct(SegBuffer, lpStruct)).S)
// uchar V:1,KW:1,KV:1,MW:1, MVar:1,A:1,KVar:1,KA:1; // [8]
// uchar Var:1,Peak:1,MVA:1,Min:1, KVA:1,Average:1,VA:1,Total:1; // [9]
#define Seg_V ((P2Struct(SegBuffer, lpStruct)).V)
#define Seg_KW ((P2Struct(SegBuffer, lpStruct)).KW)
#define Seg_KV ((P2Struct(SegBuffer, lpStruct)).KV)
#define Seg_MW ((P2Struct(SegBuffer, lpStruct)).MW)
#define Seg_MVar ((P2Struct(SegBuffer, lpStruct)).MVar)
#define Seg_A ((P2Struct(SegBuffer, lpStruct)).A)
#define Seg_KVar ((P2Struct(SegBuffer, lpStruct)).KVar)
#define Seg_KA ((P2Struct(SegBuffer, lpStruct)).KA)
#define Seg_Var ((P2Struct(SegBuffer, lpStruct)).Var)
#define Seg_Peak ((P2Struct(SegBuffer, lpStruct)).Peak)
#define Seg_MVA ((P2Struct(SegBuffer, lpStruct)).MVA)
#define Seg_Min ((P2Struct(SegBuffer, lpStruct)).Min)
#define Seg_KVA ((P2Struct(SegBuffer, lpStruct)).KVA)
#define Seg_Average ((P2Struct(SegBuffer, lpStruct)).Average)
#define Seg_VA ((P2Struct(SegBuffer, lpStruct)).VA)
#define Seg_Total ((P2Struct(SegBuffer, lpStruct)).Total)
// uchar DI_S13:1,DI_S12:1,DI_S11:1,DI_S10:1, DI_S9:1,DI_Grid:1,EP:1, EQ:1; // [18]
// uchar DO_Grid:1,DO_S6:1,DO_S5:1,DO_S4:1, DO_S3:1,DO_S2:1,DO_S1:1,Pulse:1; // [19]
#define Seg_DI2 ((P2Struct(SegBuffer, lpStruct)).DI_S13)
#define Seg_DI3 ((P2Struct(SegBuffer, lpStruct)).DI_S12)
#define Seg_DI4 ((P2Struct(SegBuffer, lpStruct)).DI_S11)
#define Seg_DI5 ((P2Struct(SegBuffer, lpStruct)).DI_S10)
#define Seg_DI6 ((P2Struct(SegBuffer, lpStruct)).DI_S9)
#define Seg_DI_Grid ((P2Struct(SegBuffer, lpStruct)).DI_Grid)
#define Seg_EP ((P2Struct(SegBuffer, lpStruct)).EP)
#define Seg_EQ ((P2Struct(SegBuffer, lpStruct)).EQ)
#define Seg_DO_Grid ((P2Struct(SegBuffer, lpStruct)).DO_Grid)
#define Seg_DO1 ((P2Struct(SegBuffer, lpStruct)).DO_S6)
#define Seg_DO2 ((P2Struct(SegBuffer, lpStruct)).DO_S5)
#define Seg_DO3 ((P2Struct(SegBuffer, lpStruct)).DO_S4)
#define Seg_DO4 ((P2Struct(SegBuffer, lpStruct)).DO_S3)
#define Seg_DO5 ((P2Struct(SegBuffer, lpStruct)).DO_S2)
#define Seg_DO6 ((P2Struct(SegBuffer, lpStruct)).DO_S1)
#define Seg_Pulse ((P2Struct(SegBuffer, lpStruct)).Pulse)
// uchar AEC:1,W:1,DI_S14:1; // [36]
#define Seg_AEC ((P2Struct(SegBuffer, lpStruct)).AEC)
#define Seg_W ((P2Struct(SegBuffer, lpStruct)).W)
#define Seg_DI1 ((P2Struct(SegBuffer, lpStruct)).DI_S14)
///////////////////////////////////////////////////////////////////////
// uchar FlashLn1:1,FlashLn2:1,FlashLn3:1,Flashstr1:1, ScrollStr1:1,FlashProtect:1,FlashAlarm:1,FlashOpen:1; // [37]
// uchar FlashClose:1,FlashU1:1,FlashU1_2:1,FlashI1:1, FlashP:1,FlashU2:1,FlashU2_3:1,FlashI2:1; // [38]
// uchar FlashQ:1,FlashU3_1:1,FlashU3:1,FlashI3:1, FlashS:1,FlashPulse:1,FlashEQ:1,FlashEP:1; // [39]
typedef struct {
// b0 b1 b2 ...... b7
uchar FlashClose:1,FlashU1:1,FlashU1_2:1,FlashOpen:1, FlashI1:1,FlashP:1,FlashU2:1,FlashU2_3:1; // [0]
uchar FlashProtect:1,FlashI2:1,FlashQ:1,FlashU3_1:1, FlashU3:1,FlashAlarm:1,FlashI3:1,FlashS:1; // [1]
uchar FlashLn1:1,FlashLn2:1,FlashLn3:1,Flashstr1:1, ScrollStr1:1,FlashPulse:1,FlashEP:1,FlashEQ:1; // [2]
} F_BIT;
union FLASH_BIT{
F_BIT FLash;
uchar FlashScroll[3];
};
EXT union FLASH_BIT bBit;
#define bFlashClose (bBit.FLash.FlashClose)
#define bFlashU1 (bBit.FLash.FlashU1)
#define bFlashU1_2 (bBit.FLash.FlashU1_2)
#define bFlashOpen (bBit.FLash.FlashOpen)
#define bFlashI1 (bBit.FLash.FlashI1)
#define bFlashP (bBit.FLash.FlashP)
#define bFlashU2 (bBit.FLash.FlashU2)
#define bFlashU2_3 (bBit.FLash.FlashU2_3)
#define bFlashProtect (bBit.FLash.FlashProtect)
#define bFlashI2 (bBit.FLash.FlashI2)
#define bFlashQ (bBit.FLash.FlashQ)
#define bFlashU3_1 (bBit.FLash.FlashU3_1)
#define bFlashU3 (bBit.FLash.FlashU3)
#define bFlashAlarm (bBit.FLash.FlashAlarm)
#define bFlashI3 (bBit.FLash.FlashI3)
#define bFlashS (bBit.FLash.FlashS)
#define bFlashLine1 (bBit.FLash.FlashLn1)
#define bFlashLine2 (bBit.FLash.FlashLn2)
#define bFlashLine3 (bBit.FLash.FlashLn3)
#define bFlashStr1 (bBit.FLash.Flashstr1)
// #define bScrollStr1 (bBit.FLash.ScrollStr1)
// #define bFlashPulse (bBit.FLash.FlashPulse)
#define bFlashEP (bBit.FLash.FlashEP)
#define bFlashEQ (bBit.FLash.FlashEQ)
/////////////////////////////////////////////////
#define DispIcon(icon,OnOff) ((icon)=(OnOff))
/////////////////////////////////////////////////////////////////////////////////
union Word_Char{
uchar uc[2];
int IntData;
};
EXT union Word_Char WD;
#define RXD_BUF_SIZE 27
EXT uchar idata RxIndex, RxLen,TxIndex,TxLen;
EXT uchar idata RxDBuff[RXD_BUF_SIZE];
EXT uchar idata TxDBuff[4];
EXT uchar idata CommTimer;
//EXT uchar idata *UartPt;
EXT bit bRxDProcessEnd;
EXT uchar idata Percent, PerModulus;
EXT uchar idata SelfTestUnit;
EXT bit bSelfTest;
EXT bit bDBKeyHoldEn;
EXT uchar idata RollStatus;
#define bit_roll_enable 1
#define bit_roll_str 2 // 1:indicate scroll the string,0:indicate scroll space
// #define bit_roll_special 4 // 1:indicate roll special,0:indicate roll normal
#define bit_roll_start_funt 0x0c // b3,b2
#define bit_roll_end_funt 0x30 // b5,b4
#define bit_roll_times 0xc0 // b7,b6
EXT bit bUartFuncSelectEn; // 1--- use Uart for Master; 0---use I2C for Master
EXT bit bIicBusy;
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -