QuakeGod
2022-09-29 e1f35018c4dec304b00f50d9dbe12204fd57a623
update infoblock step 1
21个文件已修改
2个文件已添加
7582 ■■■■■ 已修改文件
.gitignore 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Inc/GlobalDef.h 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Inc/KBus.h 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Inc/KLink.h 76 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Inc/KMachine.h 223 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Inc/PLCfunctions.h 220 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Inc/functions.h 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MDK-ARM/F030C8T6_Test2.uvguix.QuakeGod 385 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MDK-ARM/F030C8T6_Test2.uvoptx 99 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MDK-ARM/F030C8T6_Test2.uvprojx 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MDK-ARM/JLinkLog.txt 4250 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Src/BSP.c 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Src/GlobalDef.c 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Src/KBus.c 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Src/KLink.c 169 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Src/KMachine.c 343 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Src/ModbusRTU.c 312 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Src/ModbusRTU.h 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Src/PLCfunctions.c 869 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Src/functions.c 199 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Src/main.c 187 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Src/stm32f0xx_it.c 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Src/system_stm32f0xx.c 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.gitignore
@@ -1,4 +1,7 @@
Thumbs.db
*.TMP
MDK-ARM/F030C8T6_Test2/*
MDK-ARM/*.uvguix.*
MDK-ARM/*.uvoptx
MDK-ARM/JLinkLog.txt
Inc/GlobalDef.h
@@ -16,7 +16,10 @@
    4  //New Master 16 in16 out V1.2
    5  //Slave 8 in 8 out V1.2
*/
#define XLAT_FREQ 12
#define DefaultUart1Baud 230400
#define DefaultUart2Baud 1000000
enum enBOARD_TYPE
{
@@ -35,7 +38,8 @@
    BOARD_V30_MINI    =11,        //11  Mini Board
};
#define BOARD_TYPE 11
#define XLAT_FREQ 8
#define BOARD_TYPE 9
extern int GetBoardType(void);
@@ -76,7 +80,6 @@
extern stUartStat Uart1Stat;
extern stUartStat Uart2Stat;
extern const unsigned int DefaultUart1Baud;
extern unsigned int Uart1Baud;
extern unsigned int Uart2Baud;
Inc/KBus.h
@@ -43,13 +43,14 @@
extern unsigned char BufferIn[16];
extern unsigned char BufferOut[16];
extern int nAddr;
extern int nChilds;
extern unsigned char nAddr;
extern unsigned char nChilds;
extern int ChildStat[16];
extern int nCurPollId;
extern int nSeq;
extern unsigned char nCurPollId;
extern unsigned char nSeq;
extern int MasterRecved;
extern volatile int MasterRecved;
extern volatile int MasterRecvOK;
extern volatile int SlaveRecved;
extern unsigned int SendTimeuS;
extern volatile int RecvTimeuS;
@@ -189,7 +190,7 @@
typedef struct tagPacket
    {
        unsigned char Sign;        //起始标记        
        unsigned char DstAddr;    //目标地址
        unsigned char DstHost;    //目标地址
        unsigned char SrcAddr;    //源地址
        unsigned char nCMD;        //命令
        unsigned char nSEQ;        //序列号
Inc/KLink.h
@@ -61,7 +61,9 @@
        KLCmdSetPass,
        KLCmdEraseAll,
        KLCmdReadProgram,
        KLCmdStartProgram,
        KLCmdWriteProgram,
        KLCmdFinishProgram,
        KLCmdRead1Bit = 0x21,                //ReadSingleBit
        KLCmdWrite1Bit = 0x22,                //WriteSingleBit
@@ -90,6 +92,7 @@
        KLCmdWriteSysCfg,
        KLCmdSaveSysCfg,
        KLCmdSaveRunStat,
        KLCmdReadRunStat,
        
        KLCmdEraseFlashPage = 0x61,
        KLCmdWriteToFlash = 0x62,
@@ -102,8 +105,11 @@
        KLCmdResetMachine,
        KLCmdGetUid,
        KLCmdSetTime,
        KLCmdMC,
        KLCmdGetSN,
        KLCmdReadFactData,
        KLCmdWriteFactData,
        KLCmdMC = 0x70,
        KLCmdMD,
        KLCmdMG,
        
@@ -119,56 +125,6 @@
        KLInfoTypeEventLogCount = 3,
    };
    
    enum enKLCoilTypes
    {
        KLCoilTypeX = 0,        //X Input
        KLCoilTypeY = 1,        //Y Output
        KLCoilTypeR = 2,        //R register
        KLCoilTypeLX = 3,        //Link register
        KLCoilTypeLY = 4,        //Link register
        KLCoilTypeT = 5,        //Timer
        KLCoilTypeC = 5,        //Counter
        KLCoilTypeLR = 6,        //Link register
    };
    enum enKLDataTypes
    {
        KLDataTypeWX = 0,
        KLDataTypeWY = 1,
        KLDataTypeWR = 2,
        KLDataTypeWLX = 3,
        KLDataTypeWLY = 4,
        KLDataTypeDT = 5,
        KLDataTypeSDT = 6,
        KLDataTypeWSR = 7,
        KLDataTypeSV = 8,
        KLDataTypeEV = 9,
        KLDataTypeLD = 10,
        KLDataSysCfg = 25,
        KLDataTypeFlash = 33 ,
        KLDataTypeTest = 254,
    };
enum enKLDataCounts
{
    KLCoilXCount=256,
    KLCoilYCount=256,
    KLCoilRCount=256,
    KLCoilTCount=64,
    KLCoilCCount=64,
    KLCoilLCount=128,
    KLDataDTCount = 256,
    KLDataSDTCount = 256,
    KLDataWXCount = 16,
    KLDataWYCount = 16,
    KLDataWRCount = 16,
    KLDataSVCount = 64,
    KLDataEVCount = 64,
    KLDataLDCount = 64,
    KLDataWLCount = 8,
};
extern unsigned char KLPacketBuf1[256];
extern unsigned char KLPacketBuf2[256];
@@ -204,7 +160,7 @@
typedef struct tagKLReqPktHdr
{
    unsigned char ReqStSgn;        //
    unsigned char DstAddr;        //
    unsigned char DstHost;        //
    unsigned char Stat;                //
    unsigned char nCMD;                //
    unsigned char nType1;            //
@@ -214,7 +170,7 @@
typedef struct tagKLPingReqPkt
{
    unsigned char ReqStSgn;        //
    unsigned char DstAddr;        //
    unsigned char DstHost;        //
    unsigned char nCMD;                //
    unsigned char nSize;            //
    
@@ -223,7 +179,7 @@
typedef struct tagKLRplyPktHdr
{
    unsigned char RplyStSgn;    //
    unsigned char DstAddr;        //
    unsigned char DstHost;        //
    unsigned char nStatus;        //    
    unsigned char nRplyCMD;        //
    unsigned char nSize1;            //
@@ -235,7 +191,7 @@
{
        unsigned char StSign;        //起始标记
        unsigned char SrcAddr;    //源地址
        unsigned char DstAddr;    //目标地址
        unsigned char DstHost;    //目标地址
        unsigned char nCMD;        //命令
    
}stKLPtHdr, * pKLPktHdr;
@@ -245,7 +201,7 @@
{
        unsigned char StSign;        //起始标记        
        unsigned char SrcAddr;    //源地址
        unsigned char DstAddr;    //目标地址
        unsigned char DstHost;    //目标地址
        unsigned char nCMD;        //命令
        unsigned char nType;
        unsigned char nAddr;    //
@@ -256,7 +212,7 @@
    {
        unsigned char StSign;        //起始标记        
        unsigned char SrcAddr;    //源地址
        unsigned char DstAddr;    //目标地址
        unsigned char DstHost;    //目标地址
        unsigned char nCMD;        //命令
        unsigned char nSEQ;        //序列号
        unsigned char LoadLen;    //数据载荷长度    不包括头部5个字节,不包括尾部BCC。
@@ -264,12 +220,12 @@
    }stKLPacket,* pKLPacket;    
*/
unsigned char KLBCC(void * pData, int nSize);
unsigned char KLBCC(const void * pData, int nSize);
//
    /* Make a Packet and return Packet Length */
int KLMakeReqPacket(void * pBuf1,uchar Src, uchar Dst, uchar nType, uchar nSEQ, uchar DataLen, void *pData );
int KLMakeRplyPacket(void * pBuf1, uchar Dst, uchar Status, uchar nCmd, uchar DataLen, void *pData );
int KLMakeRplyPacket(void * pBuf1, uchar Dst, uchar Status, uchar nCmd, uchar DataLen, const void *pData );
/*   */
int KLCheckPacket(void * pBuf1,int len1);
Inc/KMachine.h
@@ -16,7 +16,7 @@
#define STORE_PRG_PAGESIZE (0x00000400)                            //Page Size = 1K
#define STORE_PRG_PAGES 4                                                    //use 4 pages
#define ALT_PRG_BASE (FLASH_BASE + 0x00009000)        //36k //and FLASH_BANK1_END
#define ALT_PRG_BASE (FLASH_BASE + 0x0000A000)        //36k //and FLASH_BANK1_END
#define ALT_PRG_PAGESIZE (0x00000400)                            //Page Size = 1K
#define ALT_PRG_PAGES 4                                                    //use 4 pages
@@ -24,7 +24,7 @@
#define STORE_SYSREG_PAGESIZE (0x00000400)                            //Page Size = 1K
#define STORE_SYSREG_PAGES 1                                                        //use 1 pages
#define STORE_RUNSTAT_BASE (FLASH_BASE + 0x0000B000)        //44k K //and
#define STORE_RUNSTAT_BASE (FLASH_BASE + 0x0000A800)        //44k K //and
#define STORE_RUNSTAT_PAGESIZE (0x00000400)                            //Page Size = 1K
#define STORE_RUNSTAT_PAGES 1                                                        //use 1 pages
@@ -32,6 +32,7 @@
#define STORE_LOG_BASE (FLASH_BASE + 0x0000C000)        //48k and FLASH_BANK1_END
#define STORE_LOG_PAGESIZE (0x00000400)                            //Page Size = 1K
#define STORE_LOG_PAGES 4                                                        //use 4 pages
typedef unsigned char uchar;
typedef unsigned char UCHAR;
@@ -97,6 +98,23 @@
    
    EventType
};
typedef struct tagInfoBlock
{
    USHORT nDeviceType;
    USHORT ProgVer;
    USHORT KlinkVer;
    USHORT nCapacity;
    UCHAR nDInput;
    UCHAR nDOutput;
    UCHAR nAInput;
    UCHAR nAOutput;
    UCHAR nHInput;
    UCHAR nHOutput;
    UCHAR nExt1;
    UCHAR nEXT2;
}stKMInfoBlock;
typedef struct tagKMFuncParam
{
    USHORT EnablePLC:1;        //使能内部PLC功能
@@ -107,7 +125,7 @@
typedef struct tagComPortParam
{
    USHORT PortType:4;                /* 0-4=None,Odd,Even,Mark,Space    */
    USHORT PortType:4;                /* 0-5=Com,Gen,KLink,KBus,KNet,RTU */
  USHORT ByteSize:2;        /* 0-1=Number of bits/byte, 7-8    */
    USHORT Parity:4;                    /* 0-4=None,Odd,Even,Mark,Space    */
  USHORT StopBits:2;        /* 0,1,2 = 1, 1.5, 2               */
@@ -159,19 +177,34 @@
    unsigned short EndSign1;
}stKMSysCfg,* pKMSysCfg;
/*
typedef struct tagFactData
{
    USHORT Sign;                    //
    USHORT nLength;                //
    UCHAR LOT_NO[16];            //
    UINT MANDate;                    //
    UINT SN;                            //
    UINT REV1[24];                //
    USHORT rev9;
    USHORT CRC;
}stFactData;
*/
typedef struct tagFactoryData        //工厂量产参数,数据
{
    unsigned short Sign1;
    unsigned short Seq1;
    unsigned int nModelNo;
    unsigned int nModelVer;
    unsigned int SN1;
    unsigned int nProtocalVer;
     unsigned int nProductDateTime;
    unsigned int nLotNo;
    unsigned int nDefaultFunc;
    char ModelStr[16];
    char SNStr[16];
    USHORT Sign1;
    USHORT Seq1;
    USHORT nModelNo;
    USHORT nModelVer;
    UINT nLotNo;
     UINT nProductDateTime;
    UINT SN1;
    UINT nProtocalVer;
    UINT nDefaultFunc;
    UCHAR ModelStr[16];
    UCHAR LOT_NO[16];            //
    UCHAR SNStr[16];
    unsigned short CRC1;
    unsigned short EndSign1;
    
@@ -191,11 +224,15 @@
{
    unsigned short Sign1;
    unsigned short Seq1;
    unsigned short PowerCount;    //
    unsigned short Reserved1;
    unsigned int UpTime;        //Seconds;
    unsigned int UserData1;
    unsigned int Reserved2[3];
    volatile unsigned short PowerCount;    //
    volatile unsigned short Reserved1;
    volatile unsigned int UpTime;        //Seconds;
    volatile unsigned int UserData1;
    volatile unsigned short WorkMode;
    volatile unsigned short WorkMode2;
    volatile unsigned short nBinProgBank;
    volatile unsigned short nBinProgSize;
    unsigned int Reserved2[1];
    unsigned short CRC1;
    unsigned short EndSign1;
}stRunStat, *pRunStat;
@@ -206,24 +243,138 @@
//stStoreCfg * GetNextStoreCfgAddr(stStoreCfg * CurCfg );
extern stKMSysCfg KMSysCfg;
#define TYPECOIL 0x00
#define TYPEDATA 0x80
    enum enKLCoilTypes
    {
        KLCoilTypeX = 0 | TYPECOIL ,        //X Input
        KLCoilTypeY = 1 | TYPECOIL,        //Y Output
        KLCoilTypeR = 2 | TYPECOIL,        //R register
        KLCoilTypeLX = 3 | TYPECOIL,        //Link register
        KLCoilTypeLY = 4 | TYPECOIL,        //Link register
        KLCoilTypeT = 5 | TYPECOIL,        //Timer
        KLCoilTypeC = 6 | TYPECOIL,        //Counter
        KLCoilTypeLR = 7 | TYPECOIL,        //Link register
        KLCoilTypeSR = 8 | TYPECOIL,        //Link register
    };
    enum enKLDataTypes
    {
        KLDataTypeDEC = 0 | TYPEDATA,
        KLDataTypeHEX = 1 | TYPEDATA,
        KLDataTypeFloat = 2 | TYPEDATA,
        KLDataTypeWX = 3 | TYPEDATA,
        KLDataTypeWY = 4 | TYPEDATA,
        KLDataTypeWR = 5 | TYPEDATA,
        KLDataTypeWLX = 6 | TYPEDATA,
        KLDataTypeWLY = 7 | TYPEDATA,
        KLDataTypeDT = 8 | TYPEDATA,
        KLDataTypeSDT = 9 | TYPEDATA,
        KLDataTypeWSR = 10 | TYPEDATA,
        KLDataTypeSV = 11 | TYPEDATA,
        KLDataTypeEV = 12 | TYPEDATA,
        KLDataTypeLD = 13 | TYPEDATA,
        KLDataSysCfg = 25 | TYPEDATA,
        KLDataTypeFlash = 33 | TYPEDATA,
        KLDataTypeTest = 254 | TYPEDATA,
    };
enum enKLDataCounts
    {
        KLDataDTCount = 256,
        KLDataSDTCount = 256,
        KLDataWXCount = 16,
        KLDataWYCount = 16,
        KLDataWRCount = 16,
        KLDataLDCount = 64,
        KLDataWLCount = 8,
        KLCoilXCount = KLDataWXCount * 16,
        KLCoilYCount = KLDataWYCount * 16,
        KLCoilRCount = KLDataWRCount * 16,
        KLCoilTCount = 64,
        KLCoilCCount = KLCoilTCount,
        KLDataSVCount = KLCoilTCount,
        KLDataEVCount = KLCoilTCount,
        KLCoilLXCount = 128,
        KLCoilLYCount = 128,
        KLCoilLRCount = 128,
        KLCoilSRCount = 128,
    };
#define TOTAL_WDFS (16)        //Total DF Count
#define TOTAL_CurVAL (16)        //
#define TOTALTIMERS (64)
typedef struct tagTimerStat
{
    unsigned short nScale:2;//Time Scale, 0:1ms 1:10ms 2:100ms 3:1S
    unsigned short nType:1;    //0 : timer 1:counter ;
    unsigned short nDir:1;        //0 : count down. 1 count up;
    unsigned short nInited:1;
    unsigned short bSet:1;
    unsigned short bTon:1;
}stTimerStat;
typedef struct tagTimer
{
    unsigned int LastActTime;
    union {
        unsigned short StatByte;
     struct
    {
        unsigned short nScale:2;    //Time Scale, 0:1ms 1:10ms 2:100ms 3:1S
        unsigned short nType:1;        //0 : timer 1    :    counter ;
        unsigned short nDir:1;        //0 : count down. 1 count up;
        unsigned short nInited:1;
        unsigned short bSet:1;
        unsigned short bTon:1;
    };
//        stTimerStat Stat;
    };
}stTimer;
typedef struct tagKMem
{
    unsigned short WX[16];        //本机的X和Y
    unsigned short WY[16];        //本机的X和Y
    unsigned short WR[64];
    unsigned short DT[256];
    unsigned short WDFs[TOTAL_WDFS];
    unsigned char CurVALs[TOTAL_CurVAL];
    unsigned char CurVAL;
    stTimer Timers[TOTALTIMERS];
    unsigned short WX[KLDataWXCount];        //本机的X和Y
    unsigned short WY[KLDataWYCount];        //本机的X和Y
    unsigned short WR[KLDataWRCount];
    unsigned short WT[16];
    unsigned short WC[16];
    unsigned short EV[KLDataEVCount];
    unsigned short SV[KLDataSVCount];
    unsigned short WLX[16];        //虚拟的X和Y,远程通讯时映射用。
    unsigned short WLY[16];
    unsigned short WLR[16];
    unsigned short WSR[16];
    unsigned short DT[KLDataDTCount];
    
    // 配置寄存器
    // 系统状态寄存器
    // 特殊寄存器
    // 调试,监控寄存器
    union {
        unsigned int SDD[128];
        unsigned short SDT[256];
        unsigned char SDB[512];
        unsigned int SDD[KLDataSDTCount/2];
        unsigned short SDT[KLDataSDTCount];
        unsigned char SDB[KLDataSDTCount*2];
        struct {
            unsigned int EffJumperSW;
            unsigned int CurJumperSW;
@@ -252,11 +403,19 @@
extern stKMem KMem;
extern const stKMInfoBlock KMInfoBlock;
int KMachineInit(void);
int ReadFlashMem(void * pBuf, void * pAddrFlash, int nSize);
int WriteToFlashMemNoErase(void * pBuf, void * pAddrFlash, unsigned int nSize);
int EraseAndWriteToFlashMem(void * pBuf, void * pAddrFlash, unsigned int nSize);
int ReadFlashMem(void * pBuf, void * pAddrFlash, int nByteSize);
int WriteToFlashMemNoErase(void * pBuf, void * pAddrFlash, unsigned int nByteSize);
int EraseAndWriteToFlashMem(void * pBuf, void * pAddrFlash, unsigned int nByteSize);
int ReadFactoryData(void * pDatabuf, int nByteCount);
int WriteFactoryData(void * pDataBuf, int nByteCount);
// active Program bank
int ReadProgram(int nProgByteAddr, void *pBuf, int nByteSize, int nBank);
int WriteProgram(int nProgByteAddr, void * pBuf, int nByteSize, int nBank);
int WriteSysCfgToFlash(pKMSysCfg theKMSysCfg);
int ReadSysCfgFromFlash(pKMSysCfg theKMSysCfg);
@@ -267,4 +426,10 @@
int LoadRunStat(pRunStat theRunStat);
int SaveRunStat(pRunStat theRunStat);
unsigned char GetCoilValue(unsigned char nCoilType, unsigned short nCoilAddr);
int SetCoilValue(unsigned char nCoilType, unsigned short nCoilAddr, unsigned char nCoilValue);
int GetVarData(int nDataType, int nDataAddr);
int SetVarData(int nDataType, int nDataAddr, int nDataValue);
#endif    /* __KLPROTOCOL_H__ */
Inc/PLCfunctions.h
@@ -10,15 +10,6 @@
#include "GlobalDef.h"
#include "KMachine.h"
#define TOTAL_WDFS (16)        //Total DF Count
#define TOTAL_CurVAL (8)        //
//extern unsigned short X[256];
//extern unsigned short Y[256];
//extern unsigned short R[256];
#define TOTALTIMERS (64)
#define TICK_OF_MS (10)        //1ms
#define TICK_OF_RS (100)        //10mS
#define TICK_OF_XS (1000)            //100mS
@@ -26,49 +17,138 @@
#pragma anon_unions
typedef struct tagTimerStat
typedef struct tagPLCMem
{
    unsigned short nScale:2;//Time Scale, 0:1ms 1:10ms 2:100ms 3:1S
    unsigned short nType:1;    //0 : timer 1:counter ;
    unsigned short nDir:1;        //0 : count down. 1 count up;
    unsigned short nInited:1;
    unsigned short bSet:1;
    unsigned short bTon:1;
    int bPLCRunning;
    int nScanCount;
    char ProgTrace[512];
    
}stTimerStat;
}stPLCMem;
extern stPLCMem PLCMem;
typedef struct tagTimer
int InitPLC(void);
int StartPLC(void);
int StopPLC(void);
enum enPLCOPs
{
    unsigned short SV;
    unsigned short EV;
    unsigned int LastActTime;
    union {
        unsigned short StatByte;
     struct
    {
        unsigned short nScale:2;    //Time Scale, 0:1ms 1:10ms 2:100ms 3:1S
        unsigned short nType:1;        //0 : timer 1    :    counter ;
        unsigned short nDir:1;        //0 : count down. 1 count up;
        unsigned short nInited:1;
        unsigned short bSet:1;
        unsigned short bTon:1;
    };
//        stTimerStat Stat;
    };
}stTimer;
        OP_NONE = 0,
        OP_NOP = 0,
        OP_ST = 1,        //
        OP_ST_ = 2,        //
        OP_AN = 3,        //
        OP_AN_ = 4,        //
        OP_OR = 5,        //
        OP_OR_ = 6,        //
        OP_NOT = 7,        //
        OP_ANS = 8,    //
        OP_ORS = 9,    //
        OP_PSHS = 10,    //
        OP_RDS = 11,        //
        OP_POPS = 12,    //
        OP_OUT = 16,        //
        OP_SET = 17,    //
        OP_RESET = 18,    //
        OP_DF = 19,        //
        OP_DF_ = 20,    //
        OP_ST_EQ,    //
        OP_ST_LT,    //
        OP_ST_GT,    //
        OP_ST_LE,    //
        OP_ST_GE,        //
        OP_ST_NE,        //
        OP_AN_EQ,        //
        OP_AN_LT,        //
        OP_AN_GT,
        OP_AN_LE,
        OP_AN_GE,
        OP_AN_NE,
        OP_OR_EQ,
        OP_OR_LT,
        OP_OR_GT,
        OP_OR_LE,
        OP_OR_GE,
        OP_OR_NE,
        OP_MV = 51,
        OP_INC = 52,
        OP_ADD2 = 53,
        OP_ADD3 = 54,
        OP_DEC = 55,
        OP_SUB2 = 56,
        OP_SUB3 = 57,
        OP_MUL = 58,
        OP_DIV = 59,
        OP_BKMV = 60,
        OP_COPY = 61,
        OP_CLR = 62,
        OP_BRK,
        OP_PAUSE,
        OP_JP,
        OP_CALL,
        OP_TML = 0xC8,    //
        OP_TMR = 0xDC,    //
        OP_TMX = 0xDD,    //
        OP_TMY = 0xFA,    //
};
/*
typedef struct tagPLCPROG
{
    unsigned char OP;
    unsigned char AddrType;
    unsigned short Addr;
}stPLCPROG;
*/
    typedef struct stBinProg1
    {
        unsigned char nOp;
        unsigned char nParamType;
        unsigned short nParamAddr;
    }stBinProg1;
    typedef struct stBinProg15
    {    //???
        //
        unsigned char nOp;
        unsigned char nOpNum;
        unsigned short nParamAddr1;
        unsigned char nParamType1;
        unsigned char resvr1;
        unsigned short resvr2;
    }stBinProg15;
    typedef struct stBinProg2
    {    //????
        //
        unsigned char nOp;
        unsigned char nOpNum;
        unsigned short nParamAddr1;
        unsigned char nParamType1;
        unsigned char nParamType2;
        unsigned short nParamAddr2;
    }stBinProg2;
    typedef struct stBinProg3
    {    //???????
        unsigned char nOp;
        unsigned char nOpNum;
        unsigned short nParamAddr1;
        unsigned char nParamType1;
        unsigned char nParamType2;
        unsigned short nParamAddr2;
        unsigned char resvr1;
        unsigned char nParamType3;
        unsigned short nParamAddr3;
    }stBinProg3;
extern stPLCPROG const prog1[];
extern stBinProg1 const prog1[];
extern int nSizeProg1;
//extern unsigned char CurVAL;
//extern unsigned char CurVALs[TOTAL_CurVAL];
//extern unsigned short DFs[TOTAL_WDFS];
@@ -78,23 +158,16 @@
//extern unsigned short WR[64];
//extern unsigned short DT[256];
//extern unsigned short SDT[256];
extern const unsigned short bitMasks[16];
//extern const unsigned short bitMasks[16];
//extern stTimer Timers[TOTALTIMERS];
///*
typedef struct tagPLCMem
{
    unsigned short WDFs[TOTAL_WDFS];
    unsigned char CurVALs[TOTAL_CurVAL];
    unsigned char CurVAL;
    stTimer Timers[TOTALTIMERS];
}stPLCMem;
extern stPLCMem PLCMem;
//*/
int InitTimer(int nIndex, int nType);
int StartTimer(int nIndex , int SV);
int RunTimer(int nIndex , int SV);
int StopTimer(int nIndex);
int ResetTimer(int nIndex);
int SetTimerValue(int nIndex, int bSet, int SV);
@@ -106,51 +179,8 @@
int PushInVal(void);
int PopOutVal(void);
enum enPLCOPs
{
    OP_None =0,
    OP_ST=1,
    OP_ST_=2,
    OP_AN=3,
    OP_AN_=4,
    OP_OR=5,
    OP_OR_=6,
    OP_NOT=7,
    OP_PSHS =8,
    OP_RDS = 9,
    OP_POPS =10,
    OP_ANS=11,
    OP_ORS=12,
    OP_OUT=16,
    OP_SET=17,
    OP_RESET=18,
    OP_DF=19,
    OP_DF_=20,
    OP_TML=0xC8,
    OP_TMR=0xDC,
    OP_TMX=0xDD,
    OP_TMY=0xFA,
};
enum enAddrTypes
{
    Addr_None =0,
    Addr_X =1,
    Addr_Y =2,
    Addr_R =3,
    Addr_T =4,
    Addr_L =5,
    Addr_ =6,
};
int ProcessPLCPROG(const stPLCPROG * prog,int nSize);
int ProcessPLCBinProg(const stBinProg1 * pBinprog, int nSize);
//int ProcessPLCPROG(const stBinProg1 * prog,int nSize);
Inc/functions.h
@@ -43,6 +43,9 @@
int Uart3RecvDMA(void * pBuf, int nSize);
int Uart3TriggerRecvDMA(void );
int Uart3TriggerSendDMA(void );
void TriggerPendSV(void);
void PendSvCallBack(void);
void Uart1SendDone(void);
void Uart1RecvDone(void);
void Uart2SendDone(void);
@@ -66,9 +69,10 @@
unsigned short crc_check(const unsigned char * data, unsigned int  length);
unsigned short crc16bitbybit(const unsigned char *ptr, unsigned int len);
uint16_t crc16table(const uint8_t *ptr, uint16_t len);
uint16_t crc16tablefast(const uint8_t *ptr, uint16_t len) ;
//uint16_t crc16tablefast(const uint8_t *ptr, uint16_t len) ;
void EnableDisIn(uchar bEnable);
void displayInput(unsigned int cc);
void PutOutputSPI1(unsigned int Y);
#endif  /* __MYFUNCTIONS_H__ */
MDK-ARM/F030C8T6_Test2.uvguix.QuakeGod
@@ -18,23 +18,35 @@
      <UserString></UserString>
      <PropColWidth>80</PropColWidth>
    </View>
    <View>
      <ViewName>System Viewer\RCC</ViewName>
      <WinId>35903</WinId>
      <UserString></UserString>
      <PropColWidth>78</PropColWidth>
    </View>
    <View>
      <ViewName>System Viewer\USART2</ViewName>
      <WinId>35902</WinId>
      <UserString></UserString>
      <PropColWidth>78</PropColWidth>
    </View>
  </ViewPool>
  <SECTreeCtrl>
    <View>
      <WinId>38003</WinId>
      <ViewName>Registers</ViewName>
      <TableColWidths>115 179</TableColWidths>
      <TableColWidths>115 79</TableColWidths>
    </View>
    <View>
      <WinId>346</WinId>
      <ViewName>Code Coverage</ViewName>
      <TableColWidths>1010 348</TableColWidths>
      <TableColWidths>1010 160</TableColWidths>
    </View>
    <View>
      <WinId>204</WinId>
      <ViewName>Performance Analyzer</ViewName>
      <TableColWidths>1170 175 175 188</TableColWidths>
      <TableColWidths>1170</TableColWidths>
    </View>
  </SECTreeCtrl>
@@ -66,7 +78,7 @@
    <View>
      <WinId>2506</WinId>
      <ViewName>Trace Data</ViewName>
      <UserString></UserString>
      <UserString>FiltIdx=0;DescrEn=0;DescrHeight=4;FuncTrc=1;FindType=8;ColWidths=004B00870082005F004600E600C80096</UserString>
      <TableColWidths>75 135 130 95 70 230 200 150</TableColWidths>
    </View>
  </TreeListPane>
@@ -87,8 +99,8 @@
    <sActiveDebugView></sActiveDebugView>
    <WindowPosition>
      <length>44</length>
      <flags>2</flags>
      <showCmd>3</showCmd>
      <flags>0</flags>
      <showCmd>1</showCmd>
      <MinPosition>
        <xPos>-32000</xPos>
        <yPos>-32000</yPos>
@@ -98,17 +110,17 @@
        <yPos>-1</yPos>
      </MaxPosition>
      <NormalPosition>
        <Top>116</Top>
        <Left>205</Left>
        <Right>1659</Right>
        <Bottom>991</Bottom>
        <Top>26</Top>
        <Left>-7</Left>
        <Right>1927</Right>
        <Bottom>1040</Bottom>
      </NormalPosition>
    </WindowPosition>
    <MDIClientArea>
      <RegID>0</RegID>
      <MDITabState>
        <Len>2359</Len>
        <Data>0100000004000000010000000100000001000000010000000000000002000000000000000100000001000000010000002800000028000000020000000B000000060000000000000042443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C496E635C504C4366756E6374696F6E732E68000000000E504C4366756E6374696F6E732E6801000000FFDC7800FFFFFFFF3F443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C496E635C66756E6374696F6E732E68000000000B66756E6374696F6E732E6801000000BECEA100FFFFFFFF3F443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C496E635C476C6F62616C6465662E68000000000B476C6F62616C6465662E6801000000F0A0A100FFFFFFFF3A443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C496E635C6D61696E2E6800000000066D61696E2E6801000000BCA8E100FFFFFFFF39443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C496E635C4253502E6800000000054253502E68010000009CC1B600FFFFFFFF3E443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C496E635C4B4D616368696E652E68000000000A4B4D616368696E652E6801000000F7B88600FFFFFFFF3A443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C5372635C6D61696E2E6300000000066D61696E2E6301000000D9ADC200FFFFFFFF3B443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C496E635C4B4C696E6B2E6800000000074B4C696E6B2E6801000000A5C2D700FFFFFFFF63443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C447269766572735C53544D3332463078785F48414C5F4472697665725C496E635C73746D3332663078785F6C6C5F6164632E68000000001273746D3332663078785F6C6C5F6164632E6801000000B3A6BE00FFFFFFFF67443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C447269766572735C434D5349535C4465766963655C53545C53544D3332463078785C496E636C7564655C73746D33326630333078382E68000000000D73746D33326630333078382E6801000000EAD6A300FFFFFFFF64443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C447269766572735C53544D3332463078785F48414C5F4472697665725C5372635C73746D3332663078785F68616C5F7263632E63000000001373746D3332663078785F68616C5F7263632E6301000000B5E99D00FFFFFFFF0100000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD500010000000000000002000000F4000000660000005B040000690300000A00000000000000010000003F443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C5372635C66756E6374696F6E732E63000000000B66756E6374696F6E732E6300000000C5D4F200FFFFFFFF3F443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C5372635C476C6F62616C4465662E63000000000B476C6F62616C4465662E6300000000FFDC7800FFFFFFFF3E443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C5372635C4B4D616368696E652E63000000000A4B4D616368696E652E6300000000BECEA100FFFFFFFF42443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C5372635C504C4366756E6374696F6E732E63000000000E504C4366756E6374696F6E732E6300000000F0A0A100FFFFFFFF39443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C5372635C4253502E6300000000054253502E6300000000BCA8E100FFFFFFFF3B443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C5372635C4B4C696E6B2E6300000000074B4C696E6B2E63000000009CC1B600FFFFFFFF3A443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C5372635C4B4275732E6300000000064B4275732E6300000000F7B88600FFFFFFFF64443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C447269766572735C53544D3332463078785F48414C5F4472697665725C496E635C73746D3332663078785F6C6C5F6770696F2E68000000001373746D3332663078785F6C6C5F6770696F2E6800000000D9ADC200FFFFFFFF42443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C5372635C73746D3332663078785F69742E63000000000E73746D3332663078785F69742E6300000000A5C2D700FFFFFFFF4D443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C4D444B2D41524D5C737461727475705F73746D33326630333078382E730000000015737461727475705F73746D33326630333078382E7300000000B3A6BE00FFFFFFFF0100000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD5000100000000000000020000005B040000660000008007000069030000</Data>
        <Len>1855</Len>
        <Data>0100000004000000010000000100000001000000010000000000000002000000000000000100000001000000010000002800000028000000020000000F0000000E0000000000000042443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C496E635C504C4366756E6374696F6E732E68000000000E504C4366756E6374696F6E732E6801000000C5D4F200FFFFFFFF3F443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C496E635C66756E6374696F6E732E68000000000B66756E6374696F6E732E6801000000FFDC7800FFFFFFFF3A443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C496E635C6D61696E2E6800000000066D61696E2E6801000000BECEA100FFFFFFFF39443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C496E635C4253502E6800000000054253502E6801000000F0A0A100FFFFFFFF3E443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C496E635C4B4D616368696E652E68000000000A4B4D616368696E652E6801000000BCA8E100FFFFFFFF3A443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C5372635C6D61696E2E6300000000066D61696E2E63010000009CC1B600FFFFFFFF3B443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C496E635C4B4C696E6B2E6800000000074B4C696E6B2E6801000000F7B88600FFFFFFFF63443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C447269766572735C53544D3332463078785F48414C5F4472697665725C496E635C73746D3332663078785F6C6C5F6164632E68000000001273746D3332663078785F6C6C5F6164632E6801000000D9ADC200FFFFFFFF67443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C447269766572735C434D5349535C4465766963655C53545C53544D3332463078785C496E636C7564655C73746D33326630333078382E68000000000D73746D33326630333078382E6801000000A5C2D700FFFFFFFF64443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C447269766572735C53544D3332463078785F48414C5F4472697665725C5372635C73746D3332663078785F68616C5F7263632E63000000001373746D3332663078785F68616C5F7263632E6301000000B3A6BE00FFFFFFFF3F443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C5372635C4D6F646275735254552E68000000000B4D6F646275735254552E6801000000EAD6A300FFFFFFFF3A443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C5372635C4B4275732E6300000000064B4275732E6301000000F6FA7D00FFFFFFFF3A443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C496E635C4B4275732E6800000000064B4275732E6801000000B5E99D00FFFFFFFF3F443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C496E635C476C6F62616C6465662E68000000000B476C6F62616C6465662E68010000005FC3CF00FFFFFFFF60443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C447269766572735C53544D3332463078785F48414C5F4472697665725C5372635C73746D3332663078785F68616C2E63000000000F73746D3332663078785F68616C2E6301000000C1838300FFFFFFFF0100000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD500010000000000000002000000D100000088000000490300002F03000001000000000000000100000039443A5C574F524B5C4D4355265043425C444953545F494F5C46303330433854365F4B4C696E6B5F32303231303632305C5372635C4253502E6300000000054253502E6300000000FFDC7800FFFFFFFF0100000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD50001000000000000000200000049030000880000007F0700002F030000</Data>
      </MDITabState>
    </MDIClientArea>
    <ViewEx>
@@ -131,7 +143,7 @@
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
          <Data>F40000006600000090050000F6000000</Data>
          <Data>F5000000880000009105000018010000</Data>
        </RectRecentFloat>
      </Window>
      <Window>
@@ -147,7 +159,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>0300000066000000ED00000039030000</Data>
          <Data>0300000066000000C9000000DD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -167,7 +179,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>0300000066000000ED00000039030000</Data>
          <Data>0300000066000000C9000000DD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -447,7 +459,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>0300000066000000ED00000039030000</Data>
          <Data>0300000066000000C9000000DD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -467,7 +479,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>0300000066000000ED00000039030000</Data>
          <Data>0300000066000000C9000000DD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -487,7 +499,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>000000006A03000080070000E6030000</Data>
          <Data>03000000110300007B070000A3030000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -527,7 +539,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>030000006D0300007D070000CD030000</Data>
          <Data>03000000110300007B070000A3030000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -1127,7 +1139,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>0300000066000000ED00000039030000</Data>
          <Data>0300000066000000C9000000DD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -1137,7 +1149,7 @@
      <Window>
        <RegID>38007</RegID>
        <PaneID>38007</PaneID>
        <IsVisible>0</IsVisible>
        <IsVisible>1</IsVisible>
        <IsFloating>0</IsFloating>
        <IsTabbed>0</IsTabbed>
        <IsActivated>0</IsActivated>
@@ -1147,7 +1159,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>030000006D0300007D070000CD030000</Data>
          <Data>03000000110300007B070000A3030000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -1167,7 +1179,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>030000006D0300007D070000CD030000</Data>
          <Data>03000000110300007B070000A3030000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -1647,7 +1659,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>00000000E603000080070000F9030000</Data>
          <Data>00000000BC0300007E070000CF030000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -1696,14 +1708,14 @@
      </Window>
      <DockMan>
        <Len>3119</Len>
        <Data>000000000B000000000000000020000000000000FFFFFFFFFFFFFFFFF4000000DF00000090050000E3000000000000000100000004000000010000000000000000000000FFFFFFFF06000000CB00000057010000CC000000F08B00005A01000079070000FFFF02000B004354616262656450616E650020000000000000F40000006600000090050000F6000000F40000004F00000090050000DF0000000000000040280046060000000B446973617373656D626C7900000000CB00000001000000FFFFFFFFFFFFFFFF14506572666F726D616E636520416E616C797A6572000000005701000001000000FFFFFFFFFFFFFFFF14506572666F726D616E636520416E616C797A657200000000CC00000001000000FFFFFFFFFFFFFFFF0E4C6F67696320416E616C797A657200000000F08B000001000000FFFFFFFFFFFFFFFF0D436F646520436F766572616765000000005A01000001000000FFFFFFFFFFFFFFFF11496E737472756374696F6E205472616365000000007907000001000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000001000000FFFFFFFFCB00000001000000FFFFFFFFCB000000000000000040000000000000FFFFFFFFFFFFFFFF9C0400004F000000A004000029020000000000000200000004000000010000000000000000000000FFFFFFFF2B000000E2050000CA0900002D8C00002E8C00002F8C0000308C0000318C0000328C0000338C0000348C0000358C0000368C0000378C0000388C0000398C00003A8C00003B8C00003C8C00003D8C00003E8C00003F8C0000408C0000418C000050C3000051C3000052C3000053C3000054C3000055C3000056C3000057C3000058C3000059C300005AC300005BC300005CC300005DC300005EC300005FC3000060C3000061C3000062C3000063C3000001800040000000000000A0040000660000009005000040020000A00400004F000000900500002902000000000000404100462B0000000753796D626F6C7300000000E205000001000000FFFFFFFFFFFFFFFF0A5472616365204461746100000000CA09000001000000FFFFFFFFFFFFFFFF00000000002D8C000001000000FFFFFFFFFFFFFFFF00000000002E8C000001000000FFFFFFFFFFFFFFFF00000000002F8C000001000000FFFFFFFFFFFFFFFF0000000000308C000001000000FFFFFFFFFFFFFFFF0000000000318C000001000000FFFFFFFFFFFFFFFF0000000000328C000001000000FFFFFFFFFFFFFFFF0000000000338C000001000000FFFFFFFFFFFFFFFF0000000000348C000001000000FFFFFFFFFFFFFFFF0000000000358C000001000000FFFFFFFFFFFFFFFF0000000000368C000001000000FFFFFFFFFFFFFFFF0000000000378C000001000000FFFFFFFFFFFFFFFF0000000000388C000001000000FFFFFFFFFFFFFFFF0000000000398C000001000000FFFFFFFFFFFFFFFF00000000003A8C000001000000FFFFFFFFFFFFFFFF00000000003B8C000001000000FFFFFFFFFFFFFFFF00000000003C8C000001000000FFFFFFFFFFFFFFFF00000000003D8C000001000000FFFFFFFFFFFFFFFF00000000003E8C000001000000FFFFFFFFFFFFFFFF00000000003F8C000001000000FFFFFFFFFFFFFFFF0000000000408C000001000000FFFFFFFFFFFFFFFF0000000000418C000001000000FFFFFFFFFFFFFFFF000000000050C3000001000000FFFFFFFFFFFFFFFF000000000051C3000001000000FFFFFFFFFFFFFFFF000000000052C3000001000000FFFFFFFFFFFFFFFF000000000053C3000001000000FFFFFFFFFFFFFFFF000000000054C3000001000000FFFFFFFFFFFFFFFF000000000055C3000001000000FFFFFFFFFFFFFFFF000000000056C3000001000000FFFFFFFFFFFFFFFF000000000057C3000001000000FFFFFFFFFFFFFFFF000000000058C3000001000000FFFFFFFFFFFFFFFF000000000059C3000001000000FFFFFFFFFFFFFFFF00000000005AC3000001000000FFFFFFFFFFFFFFFF00000000005BC3000001000000FFFFFFFFFFFFFFFF00000000005CC3000001000000FFFFFFFFFFFFFFFF00000000005DC3000001000000FFFFFFFFFFFFFFFF00000000005EC3000001000000FFFFFFFFFFFFFFFF00000000005FC3000001000000FFFFFFFFFFFFFFFF000000000060C3000001000000FFFFFFFFFFFFFFFF000000000061C3000001000000FFFFFFFFFFFFFFFF000000000062C3000001000000FFFFFFFFFFFFFFFF000000000063C3000001000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000001000000FFFFFFFFE205000001000000FFFFFFFFE2050000000000000010000001000000FFFFFFFFFFFFFFFFF00000004F000000F400000052030000010000000200001004000000010000000000000000000000FFFFFFFF05000000ED0300006D000000C3000000C400000073940000018000100000010000000000000066000000F000000069030000000000004F000000F0000000520300000000000040410056050000000750726F6A65637401000000ED03000001000000FFFFFFFFFFFFFFFF05426F6F6B73010000006D00000001000000FFFFFFFFFFFFFFFF0946756E6374696F6E7301000000C300000001000000FFFFFFFFFFFFFFFF0954656D706C6174657301000000C400000001000000FFFFFFFFFFFFFFFF09526567697374657273000000007394000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFFED03000001000000FFFFFFFFED030000000000000080000000000000FFFFFFFFFFFFFFFF0000000015020000900500001902000000000000010000000400000001000000000000000000000000000000000000000000000001000000C6000000FFFFFFFF0E0000008F070000930700009407000095070000960700009007000091070000B5010000B8010000B9050000BA050000BB050000BC050000CB09000001800080000000000000000000003002000090050000D4020000000000001902000090050000BD02000000000000404100460E0000001343616C6C20537461636B202B204C6F63616C73000000008F07000001000000FFFFFFFFFFFFFFFF0755415254202331000000009307000001000000FFFFFFFFFFFFFFFF0755415254202332000000009407000001000000FFFFFFFFFFFFFFFF0755415254202333000000009507000001000000FFFFFFFFFFFFFFFF15446562756720287072696E74662920566965776572000000009607000001000000FFFFFFFFFFFFFFFF0757617463682031000000009007000001000000FFFFFFFFFFFFFFFF0757617463682032000000009107000001000000FFFFFFFFFFFFFFFF10547261636520457863657074696F6E7300000000B501000001000000FFFFFFFFFFFFFFFF0E4576656E7420436F756E7465727300000000B801000001000000FFFFFFFFFFFFFFFF084D656D6F7279203100000000B905000001000000FFFFFFFFFFFFFFFF084D656D6F7279203200000000BA05000001000000FFFFFFFFFFFFFFFF084D656D6F7279203300000000BB05000001000000FFFFFFFFFFFFFFFF084D656D6F7279203400000000BC05000001000000FFFFFFFFFFFFFFFF105472616365204E617669676174696F6E00000000CB09000001000000FFFFFFFFFFFFFFFFFFFFFFFF0000000001000000000000000000000001000000FFFFFFFFC802000019020000CC020000BD02000000000000020000000400000000000000000000000000000000000000000000000000000002000000C6000000FFFFFFFF8F07000001000000FFFFFFFF8F07000001000000C6000000000000000080000001000000FFFFFFFFFFFFFFFF00000000520300008007000056030000010000000100001004000000010000000000000000000000FFFFFFFF04000000C5000000C7000000B40100007794000001800080000001000000000000006D03000080070000FD030000000000005603000080070000E60300000000000040820056040000000C4275696C64204F757470757401000000C500000001000000FFFFFFFFFFFFFFFF0D46696E6420496E2046696C657300000000C700000001000000FFFFFFFFFFFFFFFF0A4572726F72204C69737400000000B401000001000000FFFFFFFFFFFFFFFF0742726F77736572000000007794000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFFC500000001000000FFFFFFFFC5000000000000000000000000000000</Data>
        <Data>000000000B000000000000000020000000000000FFFFFFFFFFFFFFFFF4000000DF00000090050000E3000000000000000100000004000000010000000000000000000000FFFFFFFF06000000CB00000057010000CC000000F08B00005A01000079070000FFFF02000B004354616262656450616E650020000000000000F5000000880000009105000018010000F40000004F00000090050000DF0000000000000040280046060000000B446973617373656D626C7900000000CB00000001000000FFFFFFFFFFFFFFFF14506572666F726D616E636520416E616C797A6572000000005701000001000000FFFFFFFFFFFFFFFF14506572666F726D616E636520416E616C797A657200000000CC00000001000000FFFFFFFFFFFFFFFF0E4C6F67696320416E616C797A657200000000F08B000001000000FFFFFFFFFFFFFFFF0D436F646520436F766572616765000000005A01000001000000FFFFFFFFFFFFFFFF11496E737472756374696F6E205472616365000000007907000001000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000001000000FFFFFFFFCB00000001000000FFFFFFFFCB000000000000000040000000000000FFFFFFFFFFFFFFFF9C0400004F000000A004000029020000000000000200000004000000010000000000000000000000FFFFFFFF2B000000E2050000CA0900002D8C00002E8C00002F8C0000308C0000318C0000328C0000338C0000348C0000358C0000368C0000378C0000388C0000398C00003A8C00003B8C00003C8C00003D8C00003E8C00003F8C0000408C0000418C000050C3000051C3000052C3000053C3000054C3000055C3000056C3000057C3000058C3000059C300005AC300005BC300005CC300005DC300005EC300005FC3000060C3000061C3000062C3000063C3000001800040000000000000A1040000880000009105000062020000A00400004F000000900500002902000000000000404100462B0000000753796D626F6C7300000000E205000001000000FFFFFFFFFFFFFFFF0A5472616365204461746100000000CA09000001000000FFFFFFFFFFFFFFFF00000000002D8C000001000000FFFFFFFFFFFFFFFF00000000002E8C000001000000FFFFFFFFFFFFFFFF00000000002F8C000001000000FFFFFFFFFFFFFFFF0000000000308C000001000000FFFFFFFFFFFFFFFF0000000000318C000001000000FFFFFFFFFFFFFFFF0000000000328C000001000000FFFFFFFFFFFFFFFF0000000000338C000001000000FFFFFFFFFFFFFFFF0000000000348C000001000000FFFFFFFFFFFFFFFF0000000000358C000001000000FFFFFFFFFFFFFFFF0000000000368C000001000000FFFFFFFFFFFFFFFF0000000000378C000001000000FFFFFFFFFFFFFFFF0000000000388C000001000000FFFFFFFFFFFFFFFF0000000000398C000001000000FFFFFFFFFFFFFFFF00000000003A8C000001000000FFFFFFFFFFFFFFFF00000000003B8C000001000000FFFFFFFFFFFFFFFF00000000003C8C000001000000FFFFFFFFFFFFFFFF00000000003D8C000001000000FFFFFFFFFFFFFFFF00000000003E8C000001000000FFFFFFFFFFFFFFFF00000000003F8C000001000000FFFFFFFFFFFFFFFF0000000000408C000001000000FFFFFFFFFFFFFFFF0000000000418C000001000000FFFFFFFFFFFFFFFF000000000050C3000001000000FFFFFFFFFFFFFFFF000000000051C3000001000000FFFFFFFFFFFFFFFF000000000052C3000001000000FFFFFFFFFFFFFFFF000000000053C3000001000000FFFFFFFFFFFFFFFF000000000054C3000001000000FFFFFFFFFFFFFFFF000000000055C3000001000000FFFFFFFFFFFFFFFF000000000056C3000001000000FFFFFFFFFFFFFFFF000000000057C3000001000000FFFFFFFFFFFFFFFF000000000058C3000001000000FFFFFFFFFFFFFFFF000000000059C3000001000000FFFFFFFFFFFFFFFF00000000005AC3000001000000FFFFFFFFFFFFFFFF00000000005BC3000001000000FFFFFFFFFFFFFFFF00000000005CC3000001000000FFFFFFFFFFFFFFFF00000000005DC3000001000000FFFFFFFFFFFFFFFF00000000005EC3000001000000FFFFFFFFFFFFFFFF00000000005FC3000001000000FFFFFFFFFFFFFFFF000000000060C3000001000000FFFFFFFFFFFFFFFF000000000061C3000001000000FFFFFFFFFFFFFFFF000000000062C3000001000000FFFFFFFFFFFFFFFF000000000063C3000001000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000001000000FFFFFFFFE205000001000000FFFFFFFFE2050000000000000010000001000000FFFFFFFFFFFFFFFFCC0000004F000000D0000000F602000001000000020000100400000001000000D3FEFFFFC6030000FFFFFFFF05000000ED0300006D000000C3000000C400000073940000018000100000010000000100000088000000CD0000002F030000000000004F000000CC000000F60200000000000040410056050000000750726F6A65637401000000ED03000001000000FFFFFFFFFFFFFFFF05426F6F6B73010000006D00000001000000FFFFFFFFFFFFFFFF0946756E6374696F6E7301000000C300000001000000FFFFFFFFFFFFFFFF0954656D706C6174657301000000C400000001000000FFFFFFFFFFFFFFFF09526567697374657273000000007394000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFFED03000001000000FFFFFFFFED030000000000000080000000000000FFFFFFFFFFFFFFFF0000000015020000900500001902000000000000010000000400000001000000000000000000000000000000000000000000000001000000C6000000FFFFFFFF0E0000008F070000930700009407000095070000960700009007000091070000B5010000B8010000B9050000BA050000BB050000BC050000CB09000001800080000000000000010000005202000091050000F6020000000000001902000090050000BD02000000000000404100460E0000001343616C6C20537461636B202B204C6F63616C73000000008F07000001000000FFFFFFFFFFFFFFFF0755415254202331000000009307000001000000FFFFFFFFFFFFFFFF0755415254202332000000009407000001000000FFFFFFFFFFFFFFFF0755415254202333000000009507000001000000FFFFFFFFFFFFFFFF15446562756720287072696E74662920566965776572000000009607000001000000FFFFFFFFFFFFFFFF0757617463682031000000009007000001000000FFFFFFFFFFFFFFFF0757617463682032000000009107000001000000FFFFFFFFFFFFFFFF10547261636520457863657074696F6E7300000000B501000001000000FFFFFFFFFFFFFFFF0E4576656E7420436F756E7465727300000000B801000001000000FFFFFFFFFFFFFFFF084D656D6F7279203100000000B905000001000000FFFFFFFFFFFFFFFF084D656D6F7279203200000000BA05000001000000FFFFFFFFFFFFFFFF084D656D6F7279203300000000BB05000001000000FFFFFFFFFFFFFFFF084D656D6F7279203400000000BC05000001000000FFFFFFFFFFFFFFFF105472616365204E617669676174696F6E00000000CB09000001000000FFFFFFFFFFFFFFFFFFFFFFFF0000000001000000000000000000000001000000FFFFFFFFC802000019020000CC020000BD02000000000000020000000400000000000000000000000000000000000000000000000000000002000000C6000000FFFFFFFF8F07000001000000FFFFFFFF8F07000001000000C6000000000000000080000001000000FFFFFFFFFFFFFFFF00000000F60200007E070000FA02000001000000010000100400000001000000B9FCFFFF45000000FFFFFFFF04000000C5000000C7000000B4010000779400000180008000000100000001000000330300007F070000F503000000000000FA0200007E070000BC0300000000000040820056040000000C4275696C64204F757470757401000000C500000001000000FFFFFFFFFFFFFFFF0D46696E6420496E2046696C657300000000C700000001000000FFFFFFFFFFFFFFFF0A4572726F72204C69737400000000B401000001000000FFFFFFFFFFFFFFFF0742726F77736572010000007794000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFFC500000001000000FFFFFFFFC5000000000000000000000000000000</Data>
      </DockMan>
      <ToolBar>
        <RegID>59392</RegID>
        <Name>File</Name>
        <Buttons>
          <Len>2024</Len>
          <Data>00200000010000002800FFFF01001100434D4643546F6F6C426172427574746F6E00E100000000000000000000000000000000000000000000000100000001000000018001E100000000000001000000000000000000000000000000000100000001000000018003E1000000000000020000000000000000000000000000000001000000010000000180CD7F0000000000000300000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018023E100000000000004000000000000000000000000000000000100000001000000018022E100000000000005000000000000000000000000000000000100000001000000018025E10000000000000600000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001802BE10000000000000700000000000000000000000000000000010000000100000001802CE10000000004000800000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001807A8A0000000000000900000000000000000000000000000000010000000100000001807B8A0000000004000A00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180D3B00000000000000B000000000000000000000000000000000100000001000000018015B10000000004000C0000000000000000000000000000000001000000010000000180F4B00000000004000D000000000000000000000000000000000100000001000000018036B10000000004000E00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180FF88000000000000460000000000000000000000000000000001000000010000000180FE880000000000004500000000000000000000000000000000010000000100000001800B810000000000001300000000000000000000000000000000010000000100000001800C810000000000001400000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180F0880000020000000F000000000000000000000000000000000100000001000000FFFF0100120043555646696E64436F6D626F427574746F6EE80300000000000000000000000000000000000000000000000100000001000000960000000200205000000000045344445B96000000000000000200045344445B04535049310000000000000000018024E10000000000001100000000000000000000000000000000010000000100000001800A810000000000001200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018022800000020000001500000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180C488000000000000160000000000000000000000000000000001000000010000000180C988000000000400180000000000000000000000000000000001000000010000000180C788000000000000190000000000000000000000000000000001000000010000000180C8880000000000001700000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000FFFF01001500434D4643546F6F6C4261724D656E75427574746F6E4C010000020001001A0000000F2650726F6A6563742057696E646F77000000000000000000000000010000000100000000000000000000000100000008002880DD880000000000001A0000000750726F6A656374000000000000000000000000010000000100000000000000000000000100000000002880DC8B0000000000003A00000005426F6F6B73000000000000000000000000010000000100000000000000000000000100000000002880E18B0000000000003B0000000946756E6374696F6E73000000000000000000000000010000000100000000000000000000000100000000002880E28B000000000000400000000954656D706C6174657300000000000000000000000001000000010000000000000000000000010000000000288018890000000000003D0000000E536F757263652042726F777365720000000000000000000000000100000001000000000000000000000001000000000028800000000000000400FFFFFFFF00000000000000000001000000000000000100000000000000000000000100000000002880D988000000000000390000000C4275696C64204F7574707574000000000000000000000000010000000100000000000000000000000100000000002880E38B000000000000410000000B46696E64204F75747075740000000000000000000000000100000001000000000000000000000001000000000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180FB7F0000000000001B000000000000000000000000000000000100000001000000000000000446696C65AC030000</Data>
          <Len>2025</Len>
          <Data>00200000010000002800FFFF01001100434D4643546F6F6C426172427574746F6E00E100000000000000000000000000000000000000000000000100000001000000018001E100000000000001000000000000000000000000000000000100000001000000018003E1000000000000020000000000000000000000000000000001000000010000000180CD7F0000000000000300000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018023E100000000040004000000000000000000000000000000000100000001000000018022E100000000040005000000000000000000000000000000000100000001000000018025E10000000000000600000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001802BE10000000004000700000000000000000000000000000000010000000100000001802CE10000000004000800000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001807A8A0000000004000900000000000000000000000000000000010000000100000001807B8A0000000004000A00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180D3B00000000000000B000000000000000000000000000000000100000001000000018015B10000000004000C0000000000000000000000000000000001000000010000000180F4B00000000004000D000000000000000000000000000000000100000001000000018036B10000000004000E00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180FF88000000000400460000000000000000000000000000000001000000010000000180FE880000000004004500000000000000000000000000000000010000000100000001800B810000000004001300000000000000000000000000000000010000000100000001800C810000000004001400000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180F0880000020000000F000000000000000000000000000000000100000001000000FFFF0100120043555646696E64436F6D626F427574746F6EE8030000000000000000000000000000000000000000000000010000000100000096000000020020500000000009584C41545F465245519600000000000000010009584C41545F4652455100000000018024E10000000000001100000000000000000000000000000000010000000100000001800A810000000000001200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018022800000020000001500000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180C488000000000000160000000000000000000000000000000001000000010000000180C988000000000400180000000000000000000000000000000001000000010000000180C788000000000000190000000000000000000000000000000001000000010000000180C8880000000000001700000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000FFFF01001500434D4643546F6F6C4261724D656E75427574746F6E4C010000020001001A0000000F2650726F6A6563742057696E646F77000000000000000000000000010000000100000000000000000000000100000008002880DD880000000000001A0000000750726F6A656374000000000000000000000000010000000100000000000000000000000100000000002880DC8B0000000000003A00000005426F6F6B73000000000000000000000000010000000100000000000000000000000100000000002880E18B0000000000003B0000000946756E6374696F6E73000000000000000000000000010000000100000000000000000000000100000000002880E28B000000000000400000000954656D706C6174657300000000000000000000000001000000010000000000000000000000010000000000288018890000000000003D0000000E536F757263652042726F777365720000000000000000000000000100000001000000000000000000000001000000000028800000000000000400FFFFFFFF00000000000000000001000000000000000100000000000000000000000100000000002880D988000000000000390000000C4275696C64204F7574707574000000000000000000000000010000000100000000000000000000000100000000002880E38B000000000000410000000B46696E64204F75747075740000000000000000000000000100000001000000000000000000000001000000000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180FB7F0000000000001B000000000000000000000000000000000100000001000000000000000446696C65AC030000</Data>
        </Buttons>
        <OriginalItems>
          <Len>1423</Len>
@@ -1808,7 +1820,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>03000000660000002D010000F8010000</Data>
          <Data>03000000660000002D010000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -1848,7 +1860,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>C7030000E10200007D07000082040000</Data>
          <Data>C7030000E10200007D070000CD030000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -1868,7 +1880,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>C7030000E10200007D07000082040000</Data>
          <Data>C7030000E10200007D070000CD030000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -1888,7 +1900,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>C7030000E10200007D07000082040000</Data>
          <Data>C7030000E10200007D070000CD030000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -1908,7 +1920,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -1958,7 +1970,7 @@
      <Window>
        <RegID>1936</RegID>
        <PaneID>1936</PaneID>
        <IsVisible>0</IsVisible>
        <IsVisible>1</IsVisible>
        <IsFloating>0</IsFloating>
        <IsTabbed>0</IsTabbed>
        <IsActivated>0</IsActivated>
@@ -1968,7 +1980,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>C7030000E10200007D07000082040000</Data>
          <Data>C7030000E10200007D070000CD030000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -1988,7 +2000,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>C7030000E10200007D07000082040000</Data>
          <Data>C7030000E10200007D070000CD030000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2008,7 +2020,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>C7030000E10200007D07000082040000</Data>
          <Data>C7030000E10200007D070000CD030000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2028,7 +2040,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>C7030000E10200007D07000082040000</Data>
          <Data>C7030000E10200007D070000CD030000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2048,7 +2060,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>C7030000E10200007D07000082040000</Data>
          <Data>C7030000E10200007D070000CD030000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2068,7 +2080,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>C7030000E10200007D07000082040000</Data>
          <Data>C7030000E10200007D070000CD030000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2088,7 +2100,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>03000000660000002D010000F8010000</Data>
          <Data>03000000660000002D010000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2108,7 +2120,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>03000000660000002D010000F8010000</Data>
          <Data>03000000660000002D010000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2248,7 +2260,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2268,7 +2280,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>C7030000E10200007D07000082040000</Data>
          <Data>C7030000E10200007D070000CD030000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2348,7 +2360,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2368,7 +2380,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2388,7 +2400,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2408,7 +2420,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2428,7 +2440,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2448,7 +2460,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2468,7 +2480,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2488,7 +2500,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2508,7 +2520,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2528,7 +2540,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2548,7 +2560,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2568,7 +2580,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2588,7 +2600,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2608,7 +2620,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2628,7 +2640,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2648,7 +2660,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2668,7 +2680,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2678,7 +2690,7 @@
      <Window>
        <RegID>35902</RegID>
        <PaneID>35902</PaneID>
        <IsVisible>0</IsVisible>
        <IsVisible>1</IsVisible>
        <IsFloating>0</IsFloating>
        <IsTabbed>0</IsTabbed>
        <IsActivated>0</IsActivated>
@@ -2688,7 +2700,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2698,7 +2710,7 @@
      <Window>
        <RegID>35903</RegID>
        <PaneID>35903</PaneID>
        <IsVisible>0</IsVisible>
        <IsVisible>1</IsVisible>
        <IsFloating>0</IsFloating>
        <IsTabbed>0</IsTabbed>
        <IsActivated>0</IsActivated>
@@ -2708,7 +2720,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2828,7 +2840,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>C7030000E10200007D07000082040000</Data>
          <Data>C7030000E10200007D070000CD030000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2848,7 +2860,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>C7030000E10200007D07000082040000</Data>
          <Data>C7030000E10200007D070000CD030000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2868,7 +2880,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2888,7 +2900,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2908,7 +2920,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2928,7 +2940,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2948,7 +2960,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2968,7 +2980,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -2988,7 +3000,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -3008,7 +3020,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -3028,7 +3040,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -3048,7 +3060,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -3068,7 +3080,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -3088,7 +3100,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -3108,7 +3120,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -3128,7 +3140,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -3148,7 +3160,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -3168,7 +3180,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -3188,7 +3200,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -3208,7 +3220,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -3228,7 +3240,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -3248,7 +3260,7 @@
        <RecentRowIndex>0</RecentRowIndex>
        <RectRecentDocked>
          <Len>16</Len>
          <Data>93060000660000007D070000F8010000</Data>
          <Data>93060000660000007D070000AD020000</Data>
        </RectRecentDocked>
        <RectRecentFloat>
          <Len>16</Len>
@@ -3336,15 +3348,15 @@
        </RectRecentFloat>
      </Window>
      <DockMan>
        <Len>3119</Len>
        <Data>000000000B000000000000000020000001000000FFFFFFFFFFFFFFFF340100003E0100008C060000420100000100000001000010040000000100000076FEFFFF6E000000FFFFFFFF06000000CB00000057010000CC000000F08B00005A01000079070000FFFF02000B004354616262656450616E65002000000100000034010000660000008C06000055010000340100004F0000008C0600003E0100000000000040280056060000000B446973617373656D626C7901000000CB00000001000000FFFFFFFFFFFFFFFF14506572666F726D616E636520416E616C797A6572000000005701000001000000FFFFFFFFFFFFFFFF14506572666F726D616E636520416E616C797A657200000000CC00000001000000FFFFFFFFFFFFFFFF0E4C6F67696320416E616C797A657200000000F08B000001000000FFFFFFFFFFFFFFFF0D436F646520436F766572616765000000005A01000001000000FFFFFFFFFFFFFFFF11496E737472756374696F6E205472616365000000007907000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFFCB00000001000000FFFFFFFFCB000000000000000040000001000000FFFFFFFFFFFFFFFF8C0600004F00000090060000C6020000010000000200001004000000010000000000000000000000FFFFFFFF2B000000E2050000CA0900002D8C00002E8C00002F8C0000308C0000318C0000328C0000338C0000348C0000358C0000368C0000378C0000388C0000398C00003A8C00003B8C00003C8C00003D8C00003E8C00003F8C0000408C0000418C000050C3000051C3000052C3000053C3000054C3000055C3000056C3000057C3000058C3000059C300005AC300005BC300005CC300005DC300005EC300005FC3000060C3000061C3000062C3000063C300000180004000000100000090060000660000008007000028020000900600004F00000080070000C602000000000000404100562B0000000753796D626F6C7300000000E205000001000000FFFFFFFFFFFFFFFF0A5472616365204461746100000000CA09000001000000FFFFFFFFFFFFFFFF00000000002D8C000001000000FFFFFFFFFFFFFFFF00000000002E8C000001000000FFFFFFFFFFFFFFFF00000000002F8C000001000000FFFFFFFFFFFFFFFF0000000000308C000001000000FFFFFFFFFFFFFFFF0000000000318C000001000000FFFFFFFFFFFFFFFF0000000000328C000001000000FFFFFFFFFFFFFFFF0000000000338C000001000000FFFFFFFFFFFFFFFF0000000000348C000001000000FFFFFFFFFFFFFFFF0000000000358C000001000000FFFFFFFFFFFFFFFF0000000000368C000001000000FFFFFFFFFFFFFFFF0000000000378C000001000000FFFFFFFFFFFFFFFF0000000000388C000001000000FFFFFFFFFFFFFFFF0000000000398C000001000000FFFFFFFFFFFFFFFF00000000003A8C000001000000FFFFFFFFFFFFFFFF00000000003B8C000001000000FFFFFFFFFFFFFFFF00000000003C8C000001000000FFFFFFFFFFFFFFFF00000000003D8C000001000000FFFFFFFFFFFFFFFF00000000003E8C000001000000FFFFFFFFFFFFFFFF00000000003F8C000001000000FFFFFFFFFFFFFFFF0001000000408C000001000000FFFFFFFFFFFFFFFF0001000000418C000001000000FFFFFFFFFFFFFFFF000000000050C3000001000000FFFFFFFFFFFFFFFF000000000051C3000001000000FFFFFFFFFFFFFFFF000000000052C3000001000000FFFFFFFFFFFFFFFF000000000053C3000001000000FFFFFFFFFFFFFFFF000000000054C3000001000000FFFFFFFFFFFFFFFF000000000055C3000001000000FFFFFFFFFFFFFFFF000000000056C3000001000000FFFFFFFFFFFFFFFF000000000057C3000001000000FFFFFFFFFFFFFFFF000000000058C3000001000000FFFFFFFFFFFFFFFF000000000059C3000001000000FFFFFFFFFFFFFFFF00000000005AC3000001000000FFFFFFFFFFFFFFFF00000000005BC3000001000000FFFFFFFFFFFFFFFF00000000005CC3000001000000FFFFFFFFFFFFFFFF00000000005DC3000001000000FFFFFFFFFFFFFFFF00000000005EC3000001000000FFFFFFFFFFFFFFFF00000000005FC3000001000000FFFFFFFFFFFFFFFF000000000060C3000001000000FFFFFFFFFFFFFFFF000000000061C3000001000000FFFFFFFFFFFFFFFF000000000062C3000001000000FFFFFFFFFFFFFFFF000000000063C3000001000000FFFFFFFFFFFFFFFF15000000000000000000000000000000000000000000000001000000FFFFFFFFE205000001000000FFFFFFFFE2050000000000000010000001000000FFFFFFFFFFFFFFFF300100004F00000034010000C6020000010000000200001004000000010000005CFFFFFFDD050000FFFFFFFF05000000ED0300006D000000C3000000C4000000739400000180001000000100000000000000660000003001000028020000000000004F00000030010000C60200000000000040410056050000000750726F6A65637401000000ED03000001000000FFFFFFFFFFFFFFFF05426F6F6B73000000006D00000001000000FFFFFFFFFFFFFFFF0946756E6374696F6E7300000000C300000001000000FFFFFFFFFFFFFFFF0954656D706C6174657300000000C400000001000000FFFFFFFFFFFFFFFF09526567697374657273010000007394000001000000FFFFFFFFFFFFFFFF04000000000000000000000000000000000000000000000001000000FFFFFFFFED03000001000000FFFFFFFFED030000000000000080000001000000FFFFFFFFFFFFFFFF00000000C602000080070000CA0200000100000001000010040000000100000036FFFFFF6C01000000000000000000000000000001000000C6000000FFFFFFFF0E0000008F070000930700009407000095070000960700009007000091070000B5010000B8010000B9050000BA050000BB050000BC050000CB09000001800080000001000000C40300002C02000080070000FD030000C4030000CA02000080070000E603000000000000404100560E0000001343616C6C20537461636B202B204C6F63616C73010000008F07000001000000FFFFFFFFFFFFFFFF0755415254202331000000009307000001000000FFFFFFFFFFFFFFFF0755415254202332000000009407000001000000FFFFFFFFFFFFFFFF0755415254202333000000009507000001000000FFFFFFFFFFFFFFFF15446562756720287072696E74662920566965776572000000009607000001000000FFFFFFFFFFFFFFFF0757617463682031000000009007000001000000FFFFFFFFFFFFFFFF0757617463682032000000009107000001000000FFFFFFFFFFFFFFFF10547261636520457863657074696F6E7300000000B501000001000000FFFFFFFFFFFFFFFF0E4576656E7420436F756E7465727300000000B801000001000000FFFFFFFFFFFFFFFF084D656D6F7279203101000000B905000001000000FFFFFFFFFFFFFFFF084D656D6F7279203200000000BA05000001000000FFFFFFFFFFFFFFFF084D656D6F7279203300000000BB05000001000000FFFFFFFFFFFFFFFF084D656D6F7279203400000000BC05000001000000FFFFFFFFFFFFFFFF105472616365204E617669676174696F6E00000000CB09000001000000FFFFFFFFFFFFFFFF090000000000000001000000000000000100000001000000FFFFFFFFC0030000CA020000C4030000E603000001000000020000100400000000000000000000000000000000000000000000000000000002000000C6000000FFFFFFFF8F07000001000000FFFFFFFF8F07000001000000C6000000000000000080000000000000FFFFFFFFFFFFFFFF00000000520300008007000056030000000000000100000004000000010000000000000000000000FFFFFFFF04000000C5000000C7000000B40100007794000001800080000000000000000000006D03000080070000FD030000000000005603000080070000E60300000000000040820046040000000C4275696C64204F757470757400000000C500000001000000FFFFFFFFFFFFFFFF0D46696E6420496E2046696C657300000000C700000001000000FFFFFFFFFFFFFFFF0A4572726F72204C69737400000000B401000001000000FFFFFFFFFFFFFFFF0742726F77736572000000007794000001000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000001000000FFFFFFFFC500000001000000FFFFFFFFC5000000000000000000000000000000</Data>
        <Len>3128</Len>
        <Data>000000000B000000000000000020000001000000FFFFFFFFFFFFFFFF340100003E0100008C060000420100000100000001000010040000000100000076FEFFFF6E000000FFFFFFFF06000000CB00000057010000CC000000F08B00005A01000079070000FFFF02000B004354616262656450616E65002000000100000034010000660000008C06000055010000340100004F0000008C0600003E0100000000000040280056060000000B446973617373656D626C7901000000CB00000001000000FFFFFFFFFFFFFFFF14506572666F726D616E636520416E616C797A6572000000005701000001000000FFFFFFFFFFFFFFFF14506572666F726D616E636520416E616C797A657200000000CC00000001000000FFFFFFFFFFFFFFFF0E4C6F67696320416E616C797A657200000000F08B000001000000FFFFFFFFFFFFFFFF0D436F646520436F766572616765000000005A01000001000000FFFFFFFFFFFFFFFF11496E737472756374696F6E205472616365000000007907000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFFCB00000001000000FFFFFFFFCB000000000000000040000001000000FFFFFFFFFFFFFFFF8C0600004F00000090060000C6020000010000000200001004000000010000000000000000000000FFFFFFFF2B000000E2050000CA0900002D8C00002E8C00002F8C0000308C0000318C0000328C0000338C0000348C0000358C0000368C0000378C0000388C0000398C00003A8C00003B8C00003C8C00003D8C00003E8C00003F8C0000408C0000418C000050C3000051C3000052C3000053C3000054C3000055C3000056C3000057C3000058C3000059C300005AC300005BC300005CC300005DC300005EC300005FC3000060C3000061C3000062C3000063C3000001800040000001000000900600006600000080070000DD020000900600004F00000080070000C602000000000000404100562B0000000753796D626F6C7300000000E205000001000000FFFFFFFFFFFFFFFF0A5472616365204461746100000000CA09000001000000FFFFFFFFFFFFFFFF00000000002D8C000001000000FFFFFFFFFFFFFFFF00000000002E8C000001000000FFFFFFFFFFFFFFFF00000000002F8C000001000000FFFFFFFFFFFFFFFF0000000000308C000001000000FFFFFFFFFFFFFFFF0000000000318C000001000000FFFFFFFFFFFFFFFF0000000000328C000001000000FFFFFFFFFFFFFFFF0000000000338C000001000000FFFFFFFFFFFFFFFF0000000000348C000001000000FFFFFFFFFFFFFFFF0000000000358C000001000000FFFFFFFFFFFFFFFF0000000000368C000001000000FFFFFFFFFFFFFFFF0000000000378C000001000000FFFFFFFFFFFFFFFF0000000000388C000001000000FFFFFFFFFFFFFFFF0000000000398C000001000000FFFFFFFFFFFFFFFF00000000003A8C000001000000FFFFFFFFFFFFFFFF00000000003B8C000001000000FFFFFFFFFFFFFFFF00000000003C8C000001000000FFFFFFFFFFFFFFFF00000000003D8C000001000000FFFFFFFFFFFFFFFF06555341525432010000003E8C000001000000FFFFFFFFFFFFFFFF03524343010000003F8C000001000000FFFFFFFFFFFFFFFF0001000000408C000001000000FFFFFFFFFFFFFFFF0001000000418C000001000000FFFFFFFFFFFFFFFF000000000050C3000001000000FFFFFFFFFFFFFFFF000000000051C3000001000000FFFFFFFFFFFFFFFF000000000052C3000001000000FFFFFFFFFFFFFFFF000000000053C3000001000000FFFFFFFFFFFFFFFF000000000054C3000001000000FFFFFFFFFFFFFFFF000000000055C3000001000000FFFFFFFFFFFFFFFF000000000056C3000001000000FFFFFFFFFFFFFFFF000000000057C3000001000000FFFFFFFFFFFFFFFF000000000058C3000001000000FFFFFFFFFFFFFFFF000000000059C3000001000000FFFFFFFFFFFFFFFF00000000005AC3000001000000FFFFFFFFFFFFFFFF00000000005BC3000001000000FFFFFFFFFFFFFFFF00000000005CC3000001000000FFFFFFFFFFFFFFFF00000000005DC3000001000000FFFFFFFFFFFFFFFF00000000005EC3000001000000FFFFFFFFFFFFFFFF00000000005FC3000001000000FFFFFFFFFFFFFFFF000000000060C3000001000000FFFFFFFFFFFFFFFF000000000061C3000001000000FFFFFFFFFFFFFFFF000000000062C3000001000000FFFFFFFFFFFFFFFF000000000063C3000001000000FFFFFFFFFFFFFFFF13000000000000000000000000000000000000000000000001000000FFFFFFFFE205000001000000FFFFFFFFE2050000000000000010000001000000FFFFFFFFFFFFFFFF300100004F00000034010000C6020000010000000200001004000000010000005CFFFFFFDD050000FFFFFFFF05000000ED0300006D000000C3000000C40000007394000001800010000001000000000000006600000030010000DD020000000000004F00000030010000C60200000000000040410056050000000750726F6A65637401000000ED03000001000000FFFFFFFFFFFFFFFF05426F6F6B73000000006D00000001000000FFFFFFFFFFFFFFFF0946756E6374696F6E7300000000C300000001000000FFFFFFFFFFFFFFFF0954656D706C6174657300000000C400000001000000FFFFFFFFFFFFFFFF09526567697374657273010000007394000001000000FFFFFFFFFFFFFFFF04000000000000000000000000000000000000000000000001000000FFFFFFFFED03000001000000FFFFFFFFED030000000000000080000001000000FFFFFFFFFFFFFFFF00000000C602000080070000CA0200000100000001000010040000000100000036FFFFFF6C01000000000000000000000000000001000000C6000000FFFFFFFF0E0000008F070000930700009407000095070000960700009007000091070000B5010000B8010000B9050000BA050000BB050000BC050000CB09000001800080000001000000C4030000E102000080070000FD030000C4030000CA02000080070000E603000000000000404100560E0000001343616C6C20537461636B202B204C6F63616C73010000008F07000001000000FFFFFFFFFFFFFFFF0755415254202331000000009307000001000000FFFFFFFFFFFFFFFF0755415254202332000000009407000001000000FFFFFFFFFFFFFFFF0755415254202333000000009507000001000000FFFFFFFFFFFFFFFF15446562756720287072696E74662920566965776572000000009607000001000000FFFFFFFFFFFFFFFF0757617463682031010000009007000001000000FFFFFFFFFFFFFFFF0757617463682032000000009107000001000000FFFFFFFFFFFFFFFF10547261636520457863657074696F6E7300000000B501000001000000FFFFFFFFFFFFFFFF0E4576656E7420436F756E7465727300000000B801000001000000FFFFFFFFFFFFFFFF084D656D6F7279203101000000B905000001000000FFFFFFFFFFFFFFFF084D656D6F7279203200000000BA05000001000000FFFFFFFFFFFFFFFF084D656D6F7279203300000000BB05000001000000FFFFFFFFFFFFFFFF084D656D6F7279203400000000BC05000001000000FFFFFFFFFFFFFFFF105472616365204E617669676174696F6E00000000CB09000001000000FFFFFFFFFFFFFFFF050000000000000001000000000000000100000001000000FFFFFFFFC0030000CA020000C4030000E603000001000000020000100400000000000000000000000000000000000000000000000000000002000000C6000000FFFFFFFF8F07000001000000FFFFFFFF8F07000001000000C6000000000000000080000000000000FFFFFFFFFFFFFFFF00000000520300008007000056030000000000000100000004000000010000000000000000000000FFFFFFFF04000000C5000000C7000000B40100007794000001800080000000000000000000006D03000080070000FD030000000000005603000080070000E60300000000000040820046040000000C4275696C64204F757470757400000000C500000001000000FFFFFFFFFFFFFFFF0D46696E6420496E2046696C657300000000C700000001000000FFFFFFFFFFFFFFFF0A4572726F72204C69737400000000B401000001000000FFFFFFFFFFFFFFFF0742726F77736572000000007794000001000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000001000000FFFFFFFFC500000001000000FFFFFFFFC5000000000000000000000000000000</Data>
      </DockMan>
      <ToolBar>
        <RegID>59392</RegID>
        <Name>File</Name>
        <Buttons>
          <Len>2024</Len>
          <Data>00200000010000002800FFFF01001100434D4643546F6F6C426172427574746F6E00E100000000000000000000000000000000000000000000000100000001000000018001E100000000000001000000000000000000000000000000000100000001000000018003E1000000000000020000000000000000000000000000000001000000010000000180CD7F0000000000000300000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018023E100000000040004000000000000000000000000000000000100000001000000018022E100000000040005000000000000000000000000000000000100000001000000018025E10000000000000600000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001802BE10000000000000700000000000000000000000000000000010000000100000001802CE10000000004000800000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001807A8A0000000000000900000000000000000000000000000000010000000100000001807B8A0000000004000A00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180D3B00000000000000B000000000000000000000000000000000100000001000000018015B10000000004000C0000000000000000000000000000000001000000010000000180F4B00000000004000D000000000000000000000000000000000100000001000000018036B10000000004000E00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180FF88000000000400460000000000000000000000000000000001000000010000000180FE880000000004004500000000000000000000000000000000010000000100000001800B810000000004001300000000000000000000000000000000010000000100000001800C810000000004001400000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180F0880000020000000F000000000000000000000000000000000100000001000000FFFF0100120043555646696E64436F6D626F427574746F6EE80300000000000000000000000000000000000000000000000100000001000000960000000200205000000000045344445B96000000000000000200045344445B04535049310000000000000000018024E10000000000001100000000000000000000000000000000010000000100000001800A810000000000001200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018022800000020001001500000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180C488000000000000160000000000000000000000000000000001000000010000000180C988000000000400180000000000000000000000000000000001000000010000000180C788000000000000190000000000000000000000000000000001000000010000000180C8880000000000001700000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000FFFF01001500434D4643546F6F6C4261724D656E75427574746F6E4C010000020001001A0000000F2650726F6A6563742057696E646F77000000000000000000000000010000000100000000000000000000000100000008002880DD880000000000001A0000000750726F6A656374000000000000000000000000010000000100000000000000000000000100000000002880DC8B0000000000003A00000005426F6F6B73000000000000000000000000010000000100000000000000000000000100000000002880E18B0000000000003B0000000946756E6374696F6E73000000000000000000000000010000000100000000000000000000000100000000002880E28B000000000000400000000954656D706C6174657300000000000000000000000001000000010000000000000000000000010000000000288018890000000000003D0000000E536F757263652042726F777365720000000000000000000000000100000001000000000000000000000001000000000028800000000000000400FFFFFFFF00000000000000000001000000000000000100000000000000000000000100000000002880D988000000000000390000000C4275696C64204F7574707574000000000000000000000000010000000100000000000000000000000100000000002880E38B000000000000410000000B46696E64204F75747075740000000000000000000000000100000001000000000000000000000001000000000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180FB7F0000000000001B000000000000000000000000000000000100000001000000000000000446696C65AC030000</Data>
          <Len>2290</Len>
          <Data>00200000010000002800FFFF01001100434D4643546F6F6C426172427574746F6E00E100000000000000000000000000000000000000000000000100000001000000018001E100000000000001000000000000000000000000000000000100000001000000018003E1000000000000020000000000000000000000000000000001000000010000000180CD7F0000000000000300000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018023E100000000040004000000000000000000000000000000000100000001000000018022E100000000040005000000000000000000000000000000000100000001000000018025E10000000000000600000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001802BE10000000000000700000000000000000000000000000000010000000100000001802CE10000000004000800000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001807A8A0000000000000900000000000000000000000000000000010000000100000001807B8A0000000004000A00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180D3B00000000000000B000000000000000000000000000000000100000001000000018015B10000000004000C0000000000000000000000000000000001000000010000000180F4B00000000004000D000000000000000000000000000000000100000001000000018036B10000000004000E00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180FF88000000000400460000000000000000000000000000000001000000010000000180FE880000000004004500000000000000000000000000000000010000000100000001800B810000000004001300000000000000000000000000000000010000000100000001800C810000000004001400000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180F0880000020000000F000000000000000000000000000000000100000001000000FFFF0100120043555646696E64436F6D626F427574746F6EE80300000000000000000000000000000000000000000000000100000001000000960000000200205000000000094853455F56414C554596000000000000001300094853455F56414C55450F53797374656D436F7265436C6F636B1248414C5F5359535449434B5F436F6E6669670873686F77696E6974155265616C5F74696D655F74656D70657261747572650C5243435F504C4C5F4D554C3609584C41545F46524551066E496E6465780955617274324261756401630E50656E6453565F48616E646C65720F5379735469636B5F48616E646C65720650656E645376075344445B31365D08427566666572496E0A5265637654696D65755305536C617665056E416464720654686973755300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018024E10000000000001100000000000000000000000000000000010000000100000001800A810000000000001200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018022800000020001001500000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180C488000000000000160000000000000000000000000000000001000000010000000180C988000000000400180000000000000000000000000000000001000000010000000180C788000000000000190000000000000000000000000000000001000000010000000180C8880000000000001700000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000FFFF01001500434D4643546F6F6C4261724D656E75427574746F6E4C010000020001001A0000000F2650726F6A6563742057696E646F77000000000000000000000000010000000100000000000000000000000100000008002880DD880000000000001A0000000750726F6A656374000000000000000000000000010000000100000000000000000000000100000000002880DC8B0000000000003A00000005426F6F6B73000000000000000000000000010000000100000000000000000000000100000000002880E18B0000000000003B0000000946756E6374696F6E73000000000000000000000000010000000100000000000000000000000100000000002880E28B000000000000400000000954656D706C6174657300000000000000000000000001000000010000000000000000000000010000000000288018890000000000003D0000000E536F757263652042726F777365720000000000000000000000000100000001000000000000000000000001000000000028800000000000000400FFFFFFFF00000000000000000001000000000000000100000000000000000000000100000000002880D988000000000000390000000C4275696C64204F7574707574000000000000000000000000010000000100000000000000000000000100000000002880E38B000000000000410000000B46696E64204F75747075740000000000000000000000000100000001000000000000000000000001000000000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180FB7F0000000000001B000000000000000000000000000000000100000001000000000000000446696C65AC030000</Data>
        </Buttons>
        <OriginalItems>
          <Len>1423</Len>
@@ -3376,7 +3388,7 @@
        <Name>Debug</Name>
        <Buttons>
          <Len>2362</Len>
          <Data>00200000010000001900FFFF01001100434D4643546F6F6C426172427574746F6ECC880000000000002500000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018017800000000000002600000000000000000000000000000000010000000100000001801D800000000004002700000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001801A800000000000002800000000000000000000000000000000010000000100000001801B80000000000000290000000000000000000000000000000001000000010000000180E57F0000000000002A00000000000000000000000000000000010000000100000001801C800000000000002B00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018000890000000000002C00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180E48B0000020001002D0000000000000000000000000000000001000000010000000180F07F0000020001002E0000000000000000000000000000000001000000010000000180E8880000020000003700000000000000000000000000000000010000000100000001803B010000020001002F0000000000000000000000000000000001000000010000000180BB8A00000200010030000000000000000000000000000000000100000001000000FFFF01001500434D4643546F6F6C4261724D656E75427574746F6E0E01000002000000310000000D57617463682057696E646F7773000000000000000000000000010000000100000000000000000000000100000003001380D88B00000000000031000000085761746368202631000000000000000000000000010000000100000000000000000000000100000000001380D98B00000000000031000000085761746368202632000000000000000000000000010000000100000000000000000000000100000000001380CE01000000000000FFFFFFFF0C576174636820416E63686F720100000000000000010000000000000001000000000000000000000001000000000013800F0100000200010032000000094D656D6F7279202631000000000000000000000000010000000100000000000000000000000100000004001380D28B00000000000032000000094D656D6F7279202631000000000000000000000000010000000100000000000000000000000100000000001380D38B00000000000032000000094D656D6F7279202632000000000000000000000000010000000100000000000000000000000100000000001380D48B00000000000032000000094D656D6F7279202633000000000000000000000000010000000100000000000000000000000100000000001380D58B00000000000032000000094D656D6F72792026340000000000000000000000000100000001000000000000000000000001000000000013801001000002000000330000000855415254202326310000000000000000000000000100000001000000000000000000000001000000040013809307000000000000330000000855415254202326310000000000000000000000000100000001000000000000000000000001000000000013809407000000000000330000000855415254202326320000000000000000000000000100000001000000000000000000000001000000000013809507000000000000330000000855415254202326330000000000000000000000000100000001000000000000000000000001000000000013809607000000000000330000001626446562756720287072696E746629205669657765720000000000000000000000000100000001000000000000000000000001000000000013803C010000020000003400000010416E616C797369732057696E646F7773000000000000000000000000010000000100000000000000000000000100000004001380658A000000000000340000000F264C6F67696320416E616C797A6572000000000000000000000000010000000100000000000000000000000100000000001380DC7F0000000000003E0000001526506572666F726D616E636520416E616C797A6572000000000000000000000000010000000100000000000000000000000100000000001380E788000000000000380000000E26436F646520436F766572616765000000000000000000000000010000000100000000000000000000000100000000001380CD01000000000000FFFFFFFF0F416E616C7973697320416E63686F7201000000000000000100000000000000010000000000000000000000010000000000138053010000000000003F0000000D54726163652057696E646F77730000000000000000000000000100000001000000000000000000000001000000010013805401000000000000FFFFFFFF115472616365204D656E7520416E63686F720100000000000000010000000000000001000000000000000000000001000000000013802901000000000000350000001553797374656D205669657765722057696E646F77730000000000000000000000000100000001000000000000000000000001000000010013804B01000000000000FFFFFFFF1453797374656D2056696577657220416E63686F720100000000000000010000000000000001000000000000000000000001000000000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000013800189000002000000360000000F26546F6F6C626F782057696E646F7700000000000000000000000001000000010000000000000000000000010000000300138044C5000000000000FFFFFFFF0E5570646174652057696E646F77730100000000000000010000000000000001000000000000000000000001000000000013800000000000000400FFFFFFFF000000000000000000010000000000000001000000000000000000000001000000000013805B01000000000000FFFFFFFF12546F6F6C626F78204D656E75416E63686F72010000000000000001000000000000000100000000000000000000000100000000000000000005446562756764020000</Data>
          <Data>00200000010000001900FFFF01001100434D4643546F6F6C426172427574746F6ECC880000000000002500000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018017800000000000002600000000000000000000000000000000010000000100000001801D800000000004002700000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001801A800000000000002800000000000000000000000000000000010000000100000001801B80000000000000290000000000000000000000000000000001000000010000000180E57F0000000000002A00000000000000000000000000000000010000000100000001801C800000000000002B00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018000890000000000002C00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180E48B0000020001002D0000000000000000000000000000000001000000010000000180F07F0000020001002E0000000000000000000000000000000001000000010000000180E8880000020000003700000000000000000000000000000000010000000100000001803B010000020001002F0000000000000000000000000000000001000000010000000180BB8A00000200010030000000000000000000000000000000000100000001000000FFFF01001500434D4643546F6F6C4261724D656E75427574746F6E0E01000002000100310000000D57617463682057696E646F7773000000000000000000000000010000000100000000000000000000000100000003001380D88B00000000000031000000085761746368202631000000000000000000000000010000000100000000000000000000000100000000001380D98B00000000000031000000085761746368202632000000000000000000000000010000000100000000000000000000000100000000001380CE01000000000000FFFFFFFF0C576174636820416E63686F720000000000000000010000000000000001000000000000000000000001000000000013800F0100000200010032000000094D656D6F7279202631000000000000000000000000010000000100000000000000000000000100000004001380D28B00000000000032000000094D656D6F7279202631000000000000000000000000010000000100000000000000000000000100000000001380D38B00000000000032000000094D656D6F7279202632000000000000000000000000010000000100000000000000000000000100000000001380D48B00000000000032000000094D656D6F7279202633000000000000000000000000010000000100000000000000000000000100000000001380D58B00000000000032000000094D656D6F72792026340000000000000000000000000100000001000000000000000000000001000000000013801001000002000000330000000855415254202326310000000000000000000000000100000001000000000000000000000001000000040013809307000000000000330000000855415254202326310000000000000000000000000100000001000000000000000000000001000000000013809407000000000000330000000855415254202326320000000000000000000000000100000001000000000000000000000001000000000013809507000000000000330000000855415254202326330000000000000000000000000100000001000000000000000000000001000000000013809607000000000000330000001626446562756720287072696E746629205669657765720000000000000000000000000100000001000000000000000000000001000000000013803C010000020000003400000010416E616C797369732057696E646F7773000000000000000000000000010000000100000000000000000000000100000004001380658A000000000000340000000F264C6F67696320416E616C797A6572000000000000000000000000010000000100000000000000000000000100000000001380DC7F0000000000003E0000001526506572666F726D616E636520416E616C797A6572000000000000000000000000010000000100000000000000000000000100000000001380E788000000000000380000000E26436F646520436F766572616765000000000000000000000000010000000100000000000000000000000100000000001380CD01000000000000FFFFFFFF0F416E616C7973697320416E63686F7200000000000000000100000000000000010000000000000000000000010000000000138053010000000000003F0000000D54726163652057696E646F77730000000000000000000000000100000001000000000000000000000001000000010013805401000000000000FFFFFFFF115472616365204D656E7520416E63686F720000000000000000010000000000000001000000000000000000000001000000000013802901000000000000350000001553797374656D205669657765722057696E646F77730000000000000000000000000100000001000000000000000000000001000000010013804B01000000000000FFFFFFFF1453797374656D2056696577657220416E63686F720000000000000000010000000000000001000000000000000000000001000000000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000013800189000002000000360000000F26546F6F6C626F782057696E646F7700000000000000000000000001000000010000000000000000000000010000000300138044C5000000000000FFFFFFFF0E5570646174652057696E646F77730000000000000000010000000000000001000000000000000000000001000000000013800000000000000400FFFFFFFF000000000000000000010000000000000001000000000000000000000001000000000013805B01000000000000FFFFFFFF12546F6F6C626F78204D656E75416E63686F72000000000000000001000000000000000100000000000000000000000100000000000000000005446562756764020000</Data>
        </Buttons>
        <OriginalItems>
          <Len>898</Len>
@@ -3399,31 +3411,22 @@
    <Orientation>3</Orientation>
    <ActiveMDIGroup>1</ActiveMDIGroup>
    <MDIGroup>
      <Size>52</Size>
      <ActiveTab>6</ActiveTab>
      <Size>37</Size>
      <ActiveTab>14</ActiveTab>
      <Doc>
        <Name>../Inc/PLCfunctions.h</Name>
        <ColumnNumber>2</ColumnNumber>
        <TopLine>1</TopLine>
        <CurrentLine>91</CurrentLine>
        <ColumnNumber>26</ColumnNumber>
        <TopLine>120</TopLine>
        <CurrentLine>157</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
      </Doc>
      <Doc>
        <Name>../Inc/functions.h</Name>
        <ColumnNumber>0</ColumnNumber>
        <TopLine>1</TopLine>
        <CurrentLine>12</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
      </Doc>
      <Doc>
        <Name>../Inc/Globaldef.h</Name>
        <ColumnNumber>17</ColumnNumber>
        <TopLine>7</TopLine>
        <CurrentLine>19</CurrentLine>
        <ColumnNumber>35</ColumnNumber>
        <TopLine>39</TopLine>
        <CurrentLine>76</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
@@ -3431,7 +3434,7 @@
      <Doc>
        <Name>../Inc/main.h</Name>
        <ColumnNumber>0</ColumnNumber>
        <TopLine>31</TopLine>
        <TopLine>27</TopLine>
        <CurrentLine>45</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
@@ -3448,36 +3451,36 @@
      </Doc>
      <Doc>
        <Name>../Inc/KMachine.h</Name>
        <ColumnNumber>25</ColumnNumber>
        <TopLine>226</TopLine>
        <CurrentLine>265</CurrentLine>
        <ColumnNumber>18</ColumnNumber>
        <TopLine>170</TopLine>
        <CurrentLine>207</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
      </Doc>
      <Doc>
        <Name>../Src/main.c</Name>
        <ColumnNumber>26</ColumnNumber>
        <TopLine>543</TopLine>
        <CurrentLine>558</CurrentLine>
        <ColumnNumber>2</ColumnNumber>
        <TopLine>537</TopLine>
        <CurrentLine>574</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
      </Doc>
      <Doc>
        <Name>../Inc/KLink.h</Name>
        <ColumnNumber>19</ColumnNumber>
        <TopLine>130</TopLine>
        <CurrentLine>156</CurrentLine>
        <ColumnNumber>12</ColumnNumber>
        <TopLine>107</TopLine>
        <CurrentLine>108</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
      </Doc>
      <Doc>
        <Name>../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_adc.h</Name>
        <ColumnNumber>24</ColumnNumber>
        <TopLine>417</TopLine>
        <CurrentLine>448</CurrentLine>
        <ColumnNumber>0</ColumnNumber>
        <TopLine>439</TopLine>
        <CurrentLine>466</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
@@ -3485,111 +3488,75 @@
      <Doc>
        <Name>../Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f030x8.h</Name>
        <ColumnNumber>0</ColumnNumber>
        <TopLine>1856</TopLine>
        <CurrentLine>1867</CurrentLine>
        <TopLine>483</TopLine>
        <CurrentLine>496</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
      </Doc>
      <Doc>
        <Name>../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc.c</Name>
        <ColumnNumber>15</ColumnNumber>
        <TopLine>1104</TopLine>
        <CurrentLine>1141</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
      </Doc>
      <Doc>
        <Name>../Src/ModbusRTU.h</Name>
        <ColumnNumber>0</ColumnNumber>
        <TopLine>837</TopLine>
        <CurrentLine>851</CurrentLine>
        <TopLine>24</TopLine>
        <CurrentLine>54</CurrentLine>
        <Folding>0</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
      </Doc>
      <Doc>
        <Name>..\Src\KBus.c</Name>
        <ColumnNumber>0</ColumnNumber>
        <TopLine>271</TopLine>
        <CurrentLine>276</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
      </Doc>
      <Doc>
        <Name>../Inc/KBus.h</Name>
        <ColumnNumber>23</ColumnNumber>
        <TopLine>165</TopLine>
        <CurrentLine>172</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
      </Doc>
      <Doc>
        <Name>../Inc/Globaldef.h</Name>
        <ColumnNumber>20</ColumnNumber>
        <TopLine>13</TopLine>
        <CurrentLine>41</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
      </Doc>
      <Doc>
        <Name>../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal.c</Name>
        <ColumnNumber>39</ColumnNumber>
        <TopLine>378</TopLine>
        <CurrentLine>393</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
      </Doc>
    </MDIGroup>
    <MDIGroup>
      <Size>48</Size>
      <Size>63</Size>
      <ActiveTab>0</ActiveTab>
      <Doc>
        <Name>..\Src\functions.c</Name>
        <ColumnNumber>20</ColumnNumber>
        <TopLine>546</TopLine>
        <CurrentLine>567</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
      </Doc>
      <Doc>
        <Name>..\Src\GlobalDef.c</Name>
        <ColumnNumber>0</ColumnNumber>
        <TopLine>9</TopLine>
        <CurrentLine>16</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
      </Doc>
      <Doc>
        <Name>..\Src\KMachine.c</Name>
        <ColumnNumber>0</ColumnNumber>
        <TopLine>466</TopLine>
        <CurrentLine>482</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
      </Doc>
      <Doc>
        <Name>..\Src\PLCfunctions.c</Name>
        <ColumnNumber>45</ColumnNumber>
        <TopLine>271</TopLine>
        <CurrentLine>278</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
      </Doc>
      <Doc>
        <Name>..\Src\BSP.c</Name>
        <ColumnNumber>50</ColumnNumber>
        <TopLine>633</TopLine>
        <CurrentLine>667</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
      </Doc>
      <Doc>
        <Name>..\Src\KLink.c</Name>
        <ColumnNumber>8</ColumnNumber>
        <TopLine>157</TopLine>
        <CurrentLine>158</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
      </Doc>
      <Doc>
        <Name>..\Src\KBus.c</Name>
        <ColumnNumber>26</ColumnNumber>
        <TopLine>28</TopLine>
        <CurrentLine>29</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
      </Doc>
      <Doc>
        <Name>../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_gpio.h</Name>
        <ColumnNumber>23</ColumnNumber>
        <TopLine>176</TopLine>
        <CurrentLine>186</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
      </Doc>
      <Doc>
        <Name>../Src/stm32f0xx_it.c</Name>
        <ColumnNumber>0</ColumnNumber>
        <TopLine>244</TopLine>
        <CurrentLine>284</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
      </Doc>
      <Doc>
        <Name>.\startup_stm32f030x8.s</Name>
        <ColumnNumber>0</ColumnNumber>
        <TopLine>131</TopLine>
        <CurrentLine>133</CurrentLine>
        <TopLine>115</TopLine>
        <CurrentLine>140</CurrentLine>
        <Folding>1</Folding>
        <ContractedFolders></ContractedFolders>
        <PaneID>0</PaneID>
MDK-ARM/F030C8T6_Test2.uvoptx
@@ -117,7 +117,8 @@
      <TargetDriverDllRegistry>
        <SetRegEntry>
          <Number>0</Number>
          <Key>DLGUARM</Key>
          <Key>DLGDARM</Key>
          <Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)</Name>
        </SetRegEntry>
        <SetRegEntry>
          <Number>0</Number>
@@ -127,12 +128,12 @@
        <SetRegEntry>
          <Number>0</Number>
          <Key>DLGTARM</Key>
          <Name>(1010=856,0,1273,429,0)(1007=0,0,187,216,0)(1008=-1,-1,-1,-1,0)</Name>
          <Name>(1010=856,0,1273,429,0)(1007=0,0,187,216,0)(1008=90,121,466,357,1)</Name>
        </SetRegEntry>
        <SetRegEntry>
          <Number>0</Number>
          <Key>ARMDBGFLAGS</Key>
          <Name></Name>
          <Name>-T0</Name>
        </SetRegEntry>
        <SetRegEntry>
          <Number>0</Number>
@@ -145,29 +146,17 @@
          <Name>UL2CM3(-S0 -C0 -P0 )  -FN1 -FC1000 -FD20000000 -FF0STM32F0xx_64 -FL010000 -FS08000000 -FP0($$Device:STM32F030C8Tx$CMSIS\Flash\STM32F0xx_64.FLM)</Name>
        </SetRegEntry>
      </TargetDriverDllRegistry>
      <Breakpoint>
        <Bp>
          <Number>0</Number>
          <Type>0</Type>
          <LineNumber>118</LineNumber>
          <EnabledFlag>1</EnabledFlag>
          <Address>134229098</Address>
          <ByteObject>0</ByteObject>
          <HtxType>0</HtxType>
          <ManyObjects>0</ManyObjects>
          <SizeOfObject>0</SizeOfObject>
          <BreakByAccess>0</BreakByAccess>
          <BreakIfRCount>1</BreakIfRCount>
          <Filename>..\Src\BSP.c</Filename>
          <ExecCommand></ExecCommand>
          <Expression>\\F030C8T6_Test2\../Src/BSP.c\118</Expression>
        </Bp>
      </Breakpoint>
      <Breakpoint/>
      <WatchWindow1>
        <Ww>
          <count>0</count>
          <WinNumber>1</WinNumber>
          <ItemText>ADCValues</ItemText>
        </Ww>
        <Ww>
          <count>1</count>
          <WinNumber>1</WinNumber>
          <ItemText>str1</ItemText>
        </Ww>
      </WatchWindow1>
      <MemoryWindow1>
@@ -233,6 +222,14 @@
          <Name>System Viewer\NVIC</Name>
          <WinId>35905</WinId>
        </Entry>
        <Entry>
          <Name>System Viewer\RCC</Name>
          <WinId>35903</WinId>
        </Entry>
        <Entry>
          <Name>System Viewer\USART2</Name>
          <WinId>35902</WinId>
        </Entry>
      </SystemViewers>
      <DebugDescription>
        <Enable>1</Enable>
@@ -285,7 +282,7 @@
      <GroupNumber>2</GroupNumber>
      <FileNumber>3</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExp>1</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
      <bDave2>0</bDave2>
      <PathWithFileName>..\Src\GlobalDef.c</PathWithFileName>
@@ -413,6 +410,18 @@
      <RteFlg>0</RteFlg>
      <bShared>0</bShared>
    </File>
    <File>
      <GroupNumber>2</GroupNumber>
      <FileNumber>14</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
      <bDave2>0</bDave2>
      <PathWithFileName>..\Src\ModbusRTU.c</PathWithFileName>
      <FilenameWithoutPath>ModbusRTU.c</FilenameWithoutPath>
      <RteFlg>0</RteFlg>
      <bShared>0</bShared>
    </File>
  </Group>
  <Group>
@@ -423,7 +432,7 @@
    <RteFlg>0</RteFlg>
    <File>
      <GroupNumber>3</GroupNumber>
      <FileNumber>14</FileNumber>
      <FileNumber>15</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -443,7 +452,7 @@
    <RteFlg>0</RteFlg>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>15</FileNumber>
      <FileNumber>16</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -455,7 +464,7 @@
    </File>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>16</FileNumber>
      <FileNumber>17</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -467,7 +476,7 @@
    </File>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>17</FileNumber>
      <FileNumber>18</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -479,7 +488,7 @@
    </File>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>18</FileNumber>
      <FileNumber>19</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -491,7 +500,7 @@
    </File>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>19</FileNumber>
      <FileNumber>20</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -503,7 +512,7 @@
    </File>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>20</FileNumber>
      <FileNumber>21</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -515,7 +524,7 @@
    </File>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>21</FileNumber>
      <FileNumber>22</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -527,7 +536,7 @@
    </File>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>22</FileNumber>
      <FileNumber>23</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -539,7 +548,7 @@
    </File>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>23</FileNumber>
      <FileNumber>24</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -551,7 +560,7 @@
    </File>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>24</FileNumber>
      <FileNumber>25</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -563,7 +572,7 @@
    </File>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>25</FileNumber>
      <FileNumber>26</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -575,7 +584,7 @@
    </File>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>26</FileNumber>
      <FileNumber>27</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -587,7 +596,7 @@
    </File>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>27</FileNumber>
      <FileNumber>28</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -599,7 +608,7 @@
    </File>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>28</FileNumber>
      <FileNumber>29</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -611,7 +620,7 @@
    </File>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>29</FileNumber>
      <FileNumber>30</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -623,7 +632,7 @@
    </File>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>30</FileNumber>
      <FileNumber>31</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -635,7 +644,7 @@
    </File>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>31</FileNumber>
      <FileNumber>32</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -647,7 +656,7 @@
    </File>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>32</FileNumber>
      <FileNumber>33</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -659,7 +668,7 @@
    </File>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>33</FileNumber>
      <FileNumber>34</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -671,7 +680,7 @@
    </File>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>34</FileNumber>
      <FileNumber>35</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -683,7 +692,7 @@
    </File>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>35</FileNumber>
      <FileNumber>36</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
@@ -695,7 +704,7 @@
    </File>
    <File>
      <GroupNumber>4</GroupNumber>
      <FileNumber>36</FileNumber>
      <FileNumber>37</FileNumber>
      <FileType>1</FileType>
      <tvExp>0</tvExp>
      <tvExpOptDlg>0</tvExpOptDlg>
MDK-ARM/F030C8T6_Test2.uvprojx
@@ -449,6 +449,11 @@
              <FileType>1</FileType>
              <FilePath>..\Src\KLink.c</FilePath>
            </File>
            <File>
              <FileName>ModbusRTU.c</FileName>
              <FileType>1</FileType>
              <FilePath>..\Src\ModbusRTU.c</FilePath>
            </File>
          </Files>
        </Group>
        <Group>
MDK-ARM/JLinkLog.txt
Diff too large
Src/BSP.c
@@ -105,6 +105,7 @@
  * @brief System Clock Configuration
  * @retval None
  */
void SystemClock_Config(void)
{
    RCC_OscInitTypeDef RCC_OscInitStruct = {0};
@@ -115,15 +116,16 @@
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
//  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
    
#if (XLAT_FREQ == 12)
    RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL4;
#else
  RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
#endif
//#if (XLAT_FREQ == 12)
//  RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL8;
//#else
    RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL12;
//#endif
    
  RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1;
  RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV2;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
@@ -158,7 +160,8 @@
    /**Configure the Systick interrupt time 
    */
  HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/10000);
//  HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/10000);
  HAL_SYSTICK_Config(48000000/10000);
    /**Configure the Systick 
    */
@@ -263,9 +266,9 @@
void MX_SPI1_Init(void)
{
  LL_SPI_InitTypeDef SPI_InitStruct;
  LL_SPI_InitTypeDef SPI_InitStruct = {0};
  LL_GPIO_InitTypeDef GPIO_InitStruct;
  LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
  /* Peripheral clock enable */
  LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_SPI1);
@@ -560,7 +563,7 @@
//  LL_USART_SetDESignalPolarity(USART2, LL_USART_DE_POLARITY_HIGH);
  LL_USART_SetDEAssertionTime(USART2, 3);
  LL_USART_SetDEDeassertionTime(USART2, 3);
  LL_USART_EnableOneBitSamp(USART2);
//  LL_USART_EnableOneBitSamp(USART2);
//  LL_USART_EnableAutoBaudRate(USART2);
//  LL_USART_SetAutoBaudRateMode(USART2, LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE);
  LL_USART_DisableOverrunDetect(USART2);
Src/GlobalDef.c
@@ -12,9 +12,10 @@
stUartStat Uart1Stat={0};
stUartStat Uart2Stat={0};
const unsigned int DefaultUart1Baud = 230400;
unsigned int Uart1Baud = 230400;
unsigned int Uart2Baud = 2000000;
//const unsigned int DefaultUart1Baud = 230400;
unsigned int Uart1Baud = DefaultUart1Baud;
unsigned int Uart2Baud = DefaultUart2Baud;
unsigned char Uart1RecvBuf1[128];
int Uart1RecvBuf1DataLen=0;
Src/KBus.c
@@ -17,13 +17,15 @@
unsigned char BufferOut[16]={0};
stChnStat ChnStats[8];
int nAddr=0;
int nChilds;
unsigned char nAddr=0;
unsigned char nChilds;
int ChildStat[16];
int nCurPollId=0;
int nSeq=0;
unsigned char nCurPollId=0;
unsigned char nSeq=0;
int MasterRecved=1;
volatile int MasterRecved=1;
volatile int MasterRecvOK=1;
volatile int SlaveRecved=1;
unsigned int SendTimeuS=0;
volatile int RecvTimeuS=0;
@@ -47,7 +49,7 @@
int MakePacket(pPacket p1,unsigned char src, uchar dst, uchar nType,unsigned char nSEQ, unsigned char DataLen,void * pData )
{
    p1->Sign=StartSign;
    p1->DstAddr=dst;
    p1->DstHost=dst;
    p1->SrcAddr=src;
    p1->nCMD=nType;
    p1->nSEQ=nSEQ;
@@ -183,6 +185,7 @@
    if (thisBCC != p1->data[DataLen]) 
    {//BCC Error;
        Uart2Stat.BCCerr++;
        ChnStats[nCurPollId].BCCErr++;
        return -4;
    }         
    return 0;
@@ -193,21 +196,21 @@
    if (p1->Sign != StartSign)
    {
        Uart2Stat.NotPacketErr++;
        ChnStats[0].NotPkgErr++;
        ChnStats[0].ClientNotPktErr++;
        return -1;
    }
    int DataLen=p1->PacketLen;
    if (DataLen>MaxPacketLength) 
    {
        Uart2Stat.LengthErr++;
        ChnStats[0].PkgLenErr++;
        ChnStats[0].ClientPkgLenErr++;
        return -1;
    }
    if (nLen1<DataLen+sizeof(stPacket)+1)
    {
        //len4=sprintf(str3,"%d < %d + %d \r\n",len2,DataLen,sizeof(stPacket));
        //PutStr(str3,len4);
        ChnStats[0].PkgLenErr++;
        ChnStats[0].ClientPkgLenErr++;
        Uart2Stat.LengthErr++;
        return -3;    //not long enough                    
    }
@@ -221,7 +224,7 @@
    if (thisBCC != p1->data[DataLen]) 
    {//BCC Error;
        Uart2Stat.BCCerr++;
        ChnStats[0].BCCErr++;
        ChnStats[0].ClientBccErr++;
        return -4;
    }         
    return 0;
@@ -259,7 +262,7 @@
            if (DelayuS > ChnStats[nCurPollId].MaxDelay) 
                ChnStats[nCurPollId].MaxDelay=DelayuS;
                //PutOutput(outputvalue);
                MasterRecved=1;
                MasterRecvOK=1;
                break;
            case cmdRead:
                break;
@@ -287,7 +290,11 @@
                if (DelayuS > MaxDelayuS) MaxDelayuS = DelayuS;
                
                BufferIn[ChildId]=p1->data[0];
                KMem.WX[ChildId]=BufferIn[ChildId];
                if (KMRunStat.WorkMode==0) {
                    KMem.WY[0]= KMem.WX[1]+(KMem.WX[2]<<8)    ;
                    PutOutput (KMem.WY[0]);
                }
                //RunStat=100;
                ChnStats[nCurPollId].CtnLstPkts=0;
                ChnStats[nCurPollId].Delay=DelayuS;
@@ -299,7 +306,7 @@
                nIndex=p1->data[3];
                ChnStats[nCurPollId].ClientDatas[nIndex]=p1->data[4]|(p1->data[5]<<8)|(p1->data[6]<<16)|(p1->data[7]<<24);
            
                MasterRecved=1;
                MasterRecvOK=1;
                
                break;
                    
@@ -313,12 +320,13 @@
    //    }    
    return 0;
}
unsigned char nClientDataIndex=0;
int SlaveParsePacket(pPacket p1,int Len1)
{
    Uart2Stat.OKPacket++;                
    int DataLen=p1->PacketLen;    
//int nSrcAddr=p1->SrcAddr;
    int nDstAddr=p1->DstAddr;
    int nDstHost=p1->DstHost;
        
//    RecvTimeuS=ThisuS;
//    SlaveRecved=1;
@@ -326,12 +334,12 @@
    pPacket p2=(pPacket)PacketBuf2;
    int PacketLen=0;
    unsigned char nIndex = p1->nSEQ & 0x07;
    if (nDstAddr!=nAddr && nDstAddr != 0xff)
    if (nDstHost!=nAddr && nDstHost != 0xff)
    {
        ChnStats[0].ClientMisIdPkts++;
        return -1;
    }
    if (nDstAddr==nAddr || nDstAddr==0xff)
    if (nDstHost==nAddr || nDstHost==0xff)
    {
        RecvTimeuS=ThisuS;
        SlaveRecved=1;
@@ -369,17 +377,29 @@
                break;
            case cmdExChgData:
                BufferIn[0]=p1->data[0];
                PutOutput(BufferIn[0]);
                PutOutput(BufferIn[0]);
                nSlaveTick=p1->data[4]+(p1->data[5]<<8);//+(p1->data[6]<<16)+(p1->data[7]<<24);
                //PutOutput(outputvalue);
                //memcpy(DispBuf,p1->data+2,8);
                nIndex=nClientDataIndex;
        //        ChnStats[0].ClientDatas[7]++;
//                BufferOut[0]=GetInput();
//                BufferOut[0]=GetInput();
//                BufferOut[0]=GetInput();
//                BufferOut[0]=GetInput();
//                BufferOut[0]=GetInput();
                BufferOut[0]=GetInput();
                p1->data[0]=BufferOut[0];
                p1->data[3]=nIndex;
                p1->data[4]=ChnStats[0].ClientDatas[nIndex];
                p1->data[5]=ChnStats[0].ClientDatas[nIndex]>>8;
                p1->data[6]=ChnStats[0].ClientDatas[nIndex]>>16;
                p1->data[7]=ChnStats[0].ClientDatas[nIndex]>>24;
                nIndex++;
                nClientDataIndex++;
                if (nClientDataIndex >= 10) { nClientDataIndex=0;}
                PacketLen=MakePacket(p2,nAddr,0,cmdExChgDataReply,p1->nSEQ,DataLen,p1->data);
                ChnStats[0].ClientSendPkts++;
                SendPacket2(p2,PacketLen);
@@ -409,27 +429,30 @@
    int Result=0;
    if (bMaster)
    {
            MasterRecved=1;
            Result=CheckPacket(p1,Len1);
            if (Result != S_OK)
            {
                return Result;
            }
            MasterRecvOK=1;
            Result=MasterParsePacket(p1,Len1);            
            return Result;
    }
    if (bSlave)
    {
            ChnStats[0].ClientRecvPkts++;
            Result=CheckPacket(p1,Len1);
            Result=SlaveCheckPacket(p1,Len1);
            if (Result != S_OK)
            {
                return Result;
            }
            ChnStats[0].ClientTimeOutErr=KMem.RunStat;
            Result=SlaveParsePacket(p1,Len1);
            return Result;
    }
    //int len1=p1->PacketLen;
//    if (p1->DstAddr!=255&&p1->DstAddr!=2) return -3;
//    if (p1->DstHost!=255&&p1->DstHost!=2) return -3;
//    pPacket p2=(pPacket)PacketBuf2;
//            Uart2Stat.OKPacket++;
Src/KLink.c
@@ -24,7 +24,7 @@
int KLThisuS=0;
int KLRecvTimeuS=0;
unsigned char KLBCC(void * pData, int nSize)
unsigned char KLBCC(void const * pData, int nSize)
{
    unsigned char k;
    k=0;
@@ -34,12 +34,12 @@
    }
    return k;    
}
int KLMakeRplyPacket(void * pBuf, uchar dst, uchar Status, uchar nCmd, uchar DataLen,void * pData )
int KLMakeRplyPacket(void * pBuf, uchar dst, uchar Status, uchar nCmd, uchar DataLen,const void * pData )
{
    pKLRplyPktHdr p1 = (pKLRplyPktHdr)pBuf;
    int PacketLenth=0;
    p1->RplyStSgn=KLSignReply;
    p1->DstAddr=dst;
    p1->DstHost=dst;
    p1->nStatus=Status;
    p1->nRplyCMD=nCmd;
    p1->nSize1=DataLen;
@@ -111,12 +111,12 @@
inline void SetAddrBit(unsigned short * pW, unsigned char bitAddr)
{
    (*pW)|=bitMasks[bitAddr&0xf];
    (*pW)|=1<<(bitAddr&0xf);
}
inline void ResetBit(unsigned short * pW, unsigned char bitAddr)
{
    (*pW)&=~bitMasks[bitAddr&0xf];
    (*pW)&=~(1<<(bitAddr&0xf));
}
static inline void SetBitValue(unsigned short * pW, unsigned char bitAddr, unsigned char Value)
@@ -124,11 +124,12 @@
    if (Value)    {    SetAddrBit(pW, bitAddr);}
    else {ResetBit(pW, bitAddr);}
}
int KLParseReqPacket(void * pBuf,int Len1)
{
    pKLReqPktHdr p1 = (pKLReqPktHdr)pBuf;
    int nDstAddr=p1->DstAddr;
    int nDstHost=p1->DstHost;
    KLRecvTimeuS=KLThisuS;
    int nDataType=p1->nType1;
    int nAddr=0;
@@ -143,7 +144,7 @@
    int PacketLen=0;
    KLRecvTimeuS=KLThisuS;
    if (nDstAddr==nKLAddr || nDstAddr==0xff)
    if (nDstHost==nKLAddr || nDstHost==0xff)
    {
        switch (p1->nCMD)
        {
@@ -153,43 +154,73 @@
                DataLen=nDataType;
//                KLBufferIn[0]=p1->Params[0];
//                p1->Params[0]=KLBufferOut[0];
                PacketLen=KLMakeRplyPacket(p2,nDstAddr,nKLStatus.StatByte,KLCmdPing,DataLen,p1->Params);
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,KLCmdPing,DataLen,p1->Params);
                SendPacket1(p2,PacketLen);
                break;
//            case KLCmdPingReply:
//                break;
            case KLCmdInfo:
                //if (nDataType == KLDataTypeDT)
                DataLen= 4;
                pData=&KMem.nEventCount;
                PacketLen=KLMakeRplyPacket(p2,nDstAddr,nKLStatus.StatByte,p1->nCMD,DataLen,pData);
                DataLen= sizeof(KMInfoBlock);
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,p1->nCMD,DataLen,&KMInfoBlock);
                SendPacket1(p2,PacketLen);                
                break;
                break;
            case KLCmdGetUid:
                //if (nDataType == KLDataTypeDT)
                DataLen= 12;
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,p1->nCMD,DataLen,(uint32_t *)UID_BASE);
                SendPacket1(p2,PacketLen);
                break;
            case KLCmdGetSN:
                //if (nDataType == KLDataTypeDT)
                DataLen= 4;
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,p1->nCMD,DataLen,&((pFactoryData)FACTORY_DATA_BASE)->SN1);
                SendPacket1(p2,PacketLen);
                break;
            case KLCmdGetFactoryData:
                DataLen= sizeof(stFactoryData);
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,p1->nCMD,DataLen,(pFactoryData)FACTORY_DATA_BASE);
                SendPacket1(p2,PacketLen);
                break;
            case KLCmdWriteFactoryData:
                nAddr=p1->Params[0]+ (p1->Params[1]<<8);
                DataLen= p1->Params[2];
                //DataLen=16;
                for (int i=0;i<DataLen;i++)
                {KLPacketBuf2[i]=p1->Params[4+i];}
                WriteFactoryData(KLPacketBuf2, DataLen);
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,p1->nCMD,0,0);
                SendPacket1(p2,PacketLen);
                break;
            case KLCmdRead:
            case KLCmdReadDataWord:
            case KLCmdReadDataByte:                
                nAddr=p1->Params[0]+ (p1->Params[1]<<8);
                DataLen= p1->Params[2];
                if (nDataType ==KLDataTypeDT)                {            pData=KMem.DT+nAddr;        }
                else if (nDataType == KLDataTypeSDT)    {        pData=KMem.SDT+nAddr;    }
                else if (nDataType == KLDataTypeWSR)    {        pData=KMem.WSR+nAddr;    }
                else if (nDataType == KLDataTypeWX)        {        pData=KMem.WX+nAddr;        }
                else if (nDataType == KLDataTypeWY)        {        pData=KMem.WY+nAddr;        }
                else if (nDataType == KLDataTypeWR)        {        pData=KMem.WR+nAddr;        }
                else if (nDataType == KLDataTypeWLX)        {        pData=KMem.WLX+nAddr;        }
                else if (nDataType == KLDataTypeWLY)        {        pData=KMem.WLY+nAddr;        }
                else if (nDataType == KLDataTypeSV)        {        pData=KMem.SDT+nAddr;    }
                else if (nDataType == KLDataTypeEV)        {        pData=KMem.SDT+nAddr;    }
                else if (nDataType == KLDataTypeSV)        {        pData=KMem.SV+nAddr;    }
                else if (nDataType == KLDataTypeEV)        {        pData=KMem.EV+nAddr;    }
                else if (nDataType == KLDataTypeTest)    {        pData=KMem.SDT+nAddr;    }
                else if (nDataType == KLDataSysCfg) { pData = (unsigned short *)&KMSysCfg + nAddr;}
                else if (nDataType == KLDataTypeFlash) { pData = (unsigned short *)FLASH_BASE + nAddr;}
                else                {                    pData=KLBufferOut+nAddr;                }
                
                PacketLen=KLMakeRplyPacket(p2,nDstAddr,nKLStatus.StatByte,p1->nCMD,DataLen,pData);
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,p1->nCMD,DataLen,pData);
                SendPacket1(p2,PacketLen);
                
                break;
//            case KLCmdReadReply:
//                break;
            case KLCmdWrite:
            case KLCmdWriteDataWord:
            case KLCmdWriteDataByte:
                
                //memcpy(DispBuf,p1->data,DataLen);
@@ -197,20 +228,21 @@
                DataLen= p1->Params[2];
                    if (nDataType ==KLDataTypeDT)                {        pData=KMem.DT+nAddr;        }
                else if (nDataType == KLDataTypeSDT)    {        pData=KMem.SDT+nAddr;    }
                else if (nDataType == KLDataTypeWSR)    {        pData=KMem.WSR+nAddr;    }
                else if (nDataType == KLDataTypeWX)        {        pData=KMem.WX+nAddr;        }
                else if (nDataType == KLDataTypeWY)        {        pData=KMem.WY+nAddr;        }
                else if (nDataType == KLDataTypeWR)        {        pData=KMem.WR+nAddr;        }
                else if (nDataType == KLDataTypeWLX)        {        pData=KMem.WLX+nAddr;        }
                else if (nDataType == KLDataTypeWLY)        {        pData=KMem.WLY+nAddr;        }
                else if (nDataType == KLDataTypeSV)        {        pData=KMem.SDT+nAddr;    DataLen=0;}
                else if (nDataType == KLDataTypeEV)        {        pData=KMem.SDT+nAddr;    DataLen=0;}
                else if (nDataType == KLDataTypeSV)        {        pData=KMem.SV+nAddr;    DataLen=0;}
                else if (nDataType == KLDataTypeEV)        {        pData=KMem.EV+nAddr;    DataLen=0;}
                else if (nDataType == KLDataTypeTest)    {        pData=KMem.SDT+nAddr;    DataLen=0;}
                else if (nDataType == KLDataSysCfg) { pData = (unsigned short *)&KMSysCfg + nAddr;}
                else if (nDataType == KLDataTypeFlash) { pData = (unsigned short *)FLASH_BASE + nAddr;}
                else                {                    pData=KLBufferOut+nAddr;    DataLen=0;            }
                        
                memcpy(pData,p1->Params+4,DataLen);                    
                PacketLen=KLMakeRplyPacket(p2,nDstAddr,nKLStatus.StatByte,p1->nCMD,0,0);
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,p1->nCMD,0,0);
                SendPacket1(p2,PacketLen);                    
                break;
//            case KLCmdWriteReply:
@@ -219,16 +251,18 @@
            case KLCmdRead1Bit:
                nAddr=p1->Params[0]+ (p1->Params[1]<<8);
                DataLen = 1;
                if (nDataType == KLCoilTypeX)             { rData[0] = ((KMem.WX[nAddr>>4]&bitMasks[nAddr&0x0f])>0);}
                else if (nDataType == KLCoilTypeY) { rData[0] = ((KMem.WY[nAddr>>4]&bitMasks[nAddr&0x0f])>0);}
                else if (nDataType == KLCoilTypeR) { rData[0] = ((KMem.WR[nAddr>>4]&bitMasks[nAddr&0x0f])>0);}
                else if (nDataType == KLCoilTypeLX) { rData[0] = ((KMem.WLX[nAddr>>4]&bitMasks[nAddr&0x0f])>0);}
                else if (nDataType == KLCoilTypeLY) { rData[0] = ((KMem.WLY[nAddr>>4]&bitMasks[nAddr&0x0f])>0);}
                else if (nDataType == KLCoilTypeT) { rData[0] = PLCMem.Timers[nAddr].bTon;}
                else if (nDataType == KLCoilTypeC) { rData[0] = PLCMem.Timers[nAddr].bTon;}
                if (nDataType == KLCoilTypeX)             { rData[0] = ((KMem.WX[nAddr>>4]&(1<<(nAddr&0x0f)))>0);}
                else if (nDataType == KLCoilTypeY) { rData[0] = ((KMem.WY[nAddr>>4]&(1<<(nAddr&0x0f)))>0);}
                else if (nDataType == KLCoilTypeR) { rData[0] = ((KMem.WR[nAddr>>4]&(1<<(nAddr&0x0f)))>0);}
                else if (nDataType == KLCoilTypeLX) { rData[0] = ((KMem.WLX[nAddr>>4]&(1<<(nAddr&0x0f)))>0);}
                else if (nDataType == KLCoilTypeLY) { rData[0] = ((KMem.WLY[nAddr>>4]&(1<<(nAddr&0x0f)))>0);}
                else if (nDataType == KLCoilTypeT) { rData[0] = KMem.Timers[nAddr].bTon;}
                else if (nDataType == KLCoilTypeC) { rData[0] = KMem.Timers[nAddr].bTon;}
                else if (nDataType == KLCoilTypeSR) {rData[0] = ((KMem.WSR[nAddr>>4]&(1<<(nAddr&0x0f)))>0);}
                else if (nDataType == KLCoilTypeLR) { rData[0] = 0;}
                else {rData[0]=0;}
                PacketLen=KLMakeRplyPacket(p2,nDstAddr,nKLStatus.StatByte,KLCmdRead1Bit,DataLen,rData);
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,KLCmdRead1Bit,DataLen,rData);
                SendPacket1(p2,PacketLen);
                break;
            case KLCmdWrite1Bit:
@@ -238,44 +272,107 @@
                else if (nDataType == KLCoilTypeR) { SetBitValue( &KMem.WR[nAddr>>4],nAddr&0x0f,p1->Params[2]);}
                else if (nDataType == KLCoilTypeLX) {SetBitValue( &KMem.WLX[nAddr>>4],nAddr&0x0f,p1->Params[2]);}
                else if (nDataType == KLCoilTypeLY) {SetBitValue( &KMem.WLY[nAddr>>4],nAddr&0x0f,p1->Params[2]);}
                else if (nDataType == KLCoilTypeT) { PLCMem.Timers[nAddr].bTon = p1->Params[2];}
                else if (nDataType == KLCoilTypeC) { PLCMem.Timers[nAddr].bTon = p1->Params[2];}
                else if (nDataType == KLCoilTypeLR) { ;}
                else if (nDataType == KLCoilTypeT) { KMem.Timers[nAddr].bTon = p1->Params[2];}
                else if (nDataType == KLCoilTypeC) { KMem.Timers[nAddr].bTon = p1->Params[2];}
                else if (nDataType == KLCoilTypeC) { KMem.Timers[nAddr].bTon = p1->Params[2];}
                else if (nDataType == KLCoilTypeLR) { SetBitValue( &KMem.WSR[nAddr>>4],nAddr&0x0f,p1->Params[2]);;}
                else {rData[0]=0;}
                DataLen=0;
                PacketLen=KLMakeRplyPacket(p2,nDstAddr,nKLStatus.StatByte,KLCmdWrite1Bit,DataLen,rData);
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,KLCmdWrite1Bit,DataLen,rData);
                SendPacket1(p2,PacketLen);
                break;
            case KLCmdReadBits:
                break;
            case KLCmdWriteBits:
                break;
            case KLCmdChgMode:
                break;
            case KLCmdReadProgram:
                nAddr=p1->Params[0]+ (p1->Params[1]<<8);
                DataLen= p1->Params[2];
                 if (nDataType==0){
                        pData = (unsigned short *)STORE_PRG_BASE + nAddr;
                 } else if (nDataType==1){
                        pData = (unsigned short *)ALT_PRG_BASE + nAddr;
                 } else if (KMRunStat.nBinProgBank == 0) {
                        pData = (unsigned short *)STORE_PRG_BASE + nAddr;
                 }else {
                        pData = (unsigned short *)ALT_PRG_BASE + nAddr;
                 }
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,p1->nCMD,DataLen,pData);
                SendPacket1(p2,PacketLen);
                break;
            case KLCmdStartProgram:
                DataLen=nDataType;
//                KLBufferIn[0]=p1->Params[0];
//                p1->Params[0]=KLBufferOut[0];
                if (PLCMem.bPLCRunning) PLCMem.bPLCRunning=0;
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,KLCmdStartProgram,0,0);
                SendPacket1(p2,PacketLen);
                break;
            case KLCmdWriteProgram:
                if (PLCMem.bPLCRunning) PLCMem.bPLCRunning=0;
                nAddr=p1->Params[0]+ (p1->Params[1]<<8);
                DataLen= p1->Params[2];
                //DataLen=16;
                for (int i=0;i<DataLen;i++)
                {KLPacketBuf2[i]=p1->Params[4+i];}
                WriteProgram(nAddr, KLPacketBuf2, DataLen,nDataType);
                DataLen=4;
                *((int *)(&rData[0]))=(long)(p1->Params+4);
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,KLCmdWriteProgram,0,0);
                SendPacket1(p2,PacketLen);
                break;
            case KLCmdFinishProgram:
                nAddr=p1->Params[0]+ (p1->Params[1]<<8);        //Program Size;
                DataLen=nDataType;
                KMRunStat.nBinProgSize=nAddr;
                if (KMRunStat.nBinProgBank ==0) {KMRunStat.nBinProgBank=1;}
                else {KMRunStat.nBinProgBank=0;}
                SaveRunStat(&KMRunStat);
                PLCMem.bPLCRunning=1;
//                KLBufferIn[0]=p1->Params[0];
//                p1->Params[0]=KLBufferOut[0];
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,KLCmdFinishProgram,0,0);
                SendPacket1(p2,PacketLen);
                break;
            case KLCmdReadRunStat:
                DataLen= sizeof(stRunStat);
                pData=&KMRunStat;
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,p1->nCMD,DataLen,pData);
                SendPacket1(p2,PacketLen);
                break;
            case KLCmdSaveSysCfg:
                WriteSysCfgToFlash(&KMSysCfg);
                PacketLen=KLMakeRplyPacket(p2,nDstAddr,nKLStatus.StatByte,KLCmdSaveSysCfg,0,0);
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,KLCmdSaveSysCfg,0,0);
                SendPacket1(p2,PacketLen);
                break;
            case     KLCmdSaveRunStat:
                SaveRunStat(&KMRunStat);
                PacketLen=KLMakeRplyPacket(p2,nDstAddr,nKLStatus.StatByte,KLCmdSaveRunStat,0,0);
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,KLCmdSaveRunStat,0,0);
                SendPacket1(p2,PacketLen);
                break;
            case KLCmdGetEventLogCount:
                DataLen= 4;
                pData=&KMem.nEventCount;
                PacketLen=KLMakeRplyPacket(p2,nDstAddr,nKLStatus.StatByte,p1->nCMD,DataLen,pData);
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,p1->nCMD,DataLen,pData);
                SendPacket1(p2,PacketLen);
                break;
            case KLCmdGetEventLog:
                nAddr=p1->Params[0]+ (p1->Params[1]<<8);
                DataLen= p1->Params[2] * sizeof(stEventLog);
                pData=GetEventLogAddr(nAddr);
                PacketLen=KLMakeRplyPacket(p2,nDstAddr,nKLStatus.StatByte,p1->nCMD,DataLen,pData);
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,p1->nCMD,DataLen,pData);
                SendPacket1(p2,PacketLen);
                break;
            case KLCmdClearEventLog:
                ClearEventLog();
                PacketLen=KLMakeRplyPacket(p2,nDstAddr,nKLStatus.StatByte,KLCmdClearEventLog,0,0);
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,KLCmdClearEventLog,0,0);
                SendPacket1(p2,PacketLen);
                break;            
            default:
@@ -313,7 +410,7 @@
    Result=KLParseReqPacket(p1,Len1);
    
    //int len1=p1->PacketLen;
//    if (p1->DstAddr!=255&&p1->DstAddr!=2) return -3;
//    if (p1->DstHost!=255&&p1->DstHost!=2) return -3;
//    pPacket p2=(pPacket)PacketBuf2;
//            Uart2Stat.OKPacket++;
Src/KMachine.c
@@ -26,8 +26,22 @@
//uint16_t FlashDatas[16];
//uint32_t * pUID = (uint32_t *)(UID_BASE);
const char VersionStr[] __attribute__((at(0X8001000)))
const stKMInfoBlock KMInfoBlock =
{
    0x0008,
    0x0100,
    0x0100,
    0x0100,
    16,
    16,
    0,
    0,
    0,
    0,
    0,
    0,
};
const char VersionStr[] __attribute__((at(FLASH_BASE + 0X1000))) //__attribute__((at(0X8001000)))
    = "3.00";
const stKMSysCfg KMStoreSysCfg /*__attribute__((at(STORECFGBASE)))*/ =
@@ -78,18 +92,18 @@
const stKMSysCfg KMStoreSysCfg2[7] /*__attribute__((at(STORECFGBASE+sizeof(stKMSysCfg))))*/;
    
int ReadFlashMem(void * pBuf, void * pAddrFlash, int nSize)
int ReadFlashMem(void * pBuf, void * pAddrFlash, int nByteSize)
{
//    memcpy(pBuf,pAddrFlash,nSize);
    for (int i=0;i<nSize/4;i++)
    for (int i=0;i<nByteSize/4;i++)
    {
        ((uint32_t *)pBuf)[i] = ((uint32_t *)pAddrFlash)[i];
    }
    for (int i=nSize/4*2;i<nSize/2;i++)
    for (int i=nByteSize/4*2;i<nByteSize/2;i++)
    {
        ((uint16_t *)pBuf)[i] = ((uint16_t *)pAddrFlash)[i];
    }
    return nSize;
    return nByteSize;
}
int EraseFlashMem(void * pAddrFlash, unsigned int Pages)
{
@@ -104,7 +118,7 @@
    res = HAL_FLASH_Lock();
    return res;
}
int WriteToFlashMemNoErase(void * pBuf, void * pAddrFlash, unsigned int nSize)
int WriteToFlashMemNoErase(void * pBuf, void * pAddrFlash, unsigned int nByteSize)
{
        HAL_StatusTypeDef res;
    res = HAL_FLASH_Unlock();
@@ -115,12 +129,12 @@
    }
*/    
///*    
    for (int i=0;i<nSize/4;i++)
    for (int i=0;i<nByteSize/4;i++)
    {
        res = HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, (uint32_t)pAddrFlash + i*4, ((uint32_t *)pBuf)[i]);
    }
    
    for (int i = nSize/4 * 2 ; i < nSize/2 ; i++)
    for (int i = nByteSize/4 * 2 ; i < nByteSize/2 ; i++)
    {
        res = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, (uint32_t)pAddrFlash + i*2, ((uint16_t *)pBuf)[i]);
    }
@@ -129,7 +143,7 @@
    
    return res;
}
int EraseAndWriteToFlashMem(void * pBuf, void * pAddrFlash, unsigned int nSize)
int EraseAndWriteToFlashMem(void * pBuf, void * pAddrFlash, unsigned int nByteSize)
{
    
    HAL_StatusTypeDef res;
@@ -141,7 +155,7 @@
    erase1.TypeErase=FLASH_TYPEERASE_PAGES;
    res = HAL_FLASHEx_Erase(&erase1,&ErrNo);
    
    for (int i=0;i<nSize/2;i++)
    for (int i=0;i<nByteSize/2;i++)
    {
        res = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, (uint32_t)pAddrFlash + i*2, ((uint16_t *)pBuf)[i]);
    }
@@ -159,6 +173,52 @@
    res = HAL_FLASH_Lock();
    
    return res;
}
int ReadFactoryData(void * pDatabuf, int nByteCount)
{
    memcpy(pDatabuf,(stFactoryData *)FACTORY_DATA_BASE,nByteCount);
    return 0;
}
int WriteFactoryData(void * pDataBuf, int nByteCount)
{
    EraseAndWriteToFlashMem(pDataBuf, (stFactoryData *)FACTORY_DATA_BASE,nByteCount);
    return 0;
}
int ReadProgram(int nProgByteAddr, void *pBuf, int nByteSize, int nBank)
{
    if (nBank==0)    {
        ReadFlashMem(pBuf, (void *)(STORE_PRG_BASE+nProgByteAddr), nByteSize);
    }else if (nBank ==1) {
        ReadFlashMem(pBuf, (void *)(ALT_PRG_BASE+nProgByteAddr), nByteSize);
    }else if (KMRunStat.nBinProgBank==0) {
        ReadFlashMem(pBuf, (void *)(STORE_PRG_BASE+nProgByteAddr), nByteSize);
    } else {
        ReadFlashMem(pBuf, (void *)(ALT_PRG_BASE+nProgByteAddr), nByteSize);
    }
    return 0;
}
int WriteProgram(int nProgAddress, void * pBuf, int nByteSize, int nBank)
{
            // Program Save Address;//
          // Program 2 Save Address; //
    void * progByteAddr;
    if (nBank == 0) {
        progByteAddr=(void *)(STORE_PRG_BASE+nProgAddress);
    }else if (nBank==1) {
        progByteAddr=(void *)(ALT_PRG_BASE+nProgAddress);
    } else if (KMRunStat.nBinProgBank==0) {
        progByteAddr=(void *)(ALT_PRG_BASE+nProgAddress);
    }else{
        progByteAddr=(void *)(STORE_PRG_BASE+nProgAddress);
    }
    if (nProgAddress ==0)    {
        EraseAndWriteToFlashMem(pBuf, progByteAddr, nByteSize);
    }else{
        WriteToFlashMemNoErase(pBuf, progByteAddr, nByteSize);
    }
    return 0;
}
int LoadDefaultSysCfg(pKMSysCfg theKMSysCfg)
@@ -526,3 +586,264 @@
    
    return 0;
}
inline void SetAddrBit(unsigned short * pW, unsigned char bitAddr)
{
    (*pW)|=1<<(bitAddr&0xf);
}
inline void ResetBit(unsigned short * pW, unsigned char bitAddr)
{
    (*pW)&=~(1<<(bitAddr&0xf));
}
static inline void SetBitValue(unsigned short * pW, unsigned char bitAddr, unsigned char Value)
{
    if (Value)    {    SetAddrBit(pW, bitAddr);}
    else {ResetBit(pW, bitAddr);}
}
static inline unsigned char GetBitValue(unsigned short W, unsigned char bitAddr)
{
    if (W&(1<<(bitAddr&0xf))) return 1;
    else return 0;
}
unsigned char GetCoilValue(unsigned char nCoilType, unsigned short nCoilAddr)
{
        unsigned char thisValue=0;
        unsigned short nWordAddr=(nCoilAddr&0xff0)>>4;
        unsigned char nBitAddr=nCoilAddr&0xf;
        switch(nCoilType)
        {
        case KLCoilTypeX:
            if (nCoilAddr >= KLCoilXCount) return 0;
            thisValue = GetBitValue(KMem.WX[nWordAddr], nBitAddr);
            break;
        case KLCoilTypeY:
            if (nCoilAddr >= KLCoilYCount) return 0;
            thisValue = GetBitValue(KMem.WY[nWordAddr], nBitAddr);
            break;
        case KLCoilTypeR:
            if (nCoilAddr >= KLCoilRCount) return 0;
            thisValue = GetBitValue(KMem.WR[nWordAddr], nBitAddr);
            break;
        case KLCoilTypeLX:
            if (nCoilAddr >= KLCoilLXCount) return 0;
             thisValue = GetBitValue(KMem.WLX[nWordAddr], nBitAddr);
            break;
        case KLCoilTypeLY:
            if (nCoilAddr >= KLCoilLYCount) return 0;
            thisValue = GetBitValue(KMem.WLY[nWordAddr], nBitAddr);
            break;
        case KLCoilTypeT:
            if (nCoilAddr >= KLCoilTCount) return 0;
            thisValue = GetBitValue(KMem.WT[nWordAddr], nBitAddr);
            break;
        case KLCoilTypeC:
            if (nCoilAddr >= KLCoilCCount) return 0;
            thisValue = GetBitValue(KMem.WC[nWordAddr], nBitAddr);
            break;
        case KLCoilTypeLR:
            if (nCoilAddr >= KLCoilLRCount) return 0;
            thisValue = GetBitValue(KMem.WLR[nWordAddr], nBitAddr);
            break;
        case KLCoilTypeSR:
            if (nCoilAddr >= KLCoilSRCount) return 0;
            thisValue = GetBitValue(KMem.WSR[nWordAddr], nBitAddr);
            break;
            default:
                break;
        }
        return thisValue;
}
int SetCoilValue(unsigned char nCoilType, unsigned short nCoilAddr, unsigned char nCoilValue)
{
        unsigned short nWordAddr=(nCoilAddr&0xff0)>>4;
        unsigned char nBitAddr=nCoilAddr&0xf;
        switch(nCoilType)
        {
        case KLCoilTypeX:
            if (nCoilAddr >= KLCoilXCount) return 0;
            SetBitValue(&KMem.WX[nWordAddr], nBitAddr, nCoilValue);
            break;
        case KLCoilTypeY:
            if (nCoilAddr >= KLCoilYCount) return 0;
            SetBitValue(&KMem.WY[nWordAddr], nBitAddr, nCoilValue);
            break;
        case KLCoilTypeR:
            if (nCoilAddr >= KLCoilRCount) return 0;
            SetBitValue(&KMem.WR[nWordAddr], nBitAddr, nCoilValue);
            break;
        case KLCoilTypeLX:
            if (nCoilAddr >= KLCoilLXCount) return 0;
            SetBitValue(&KMem.WLX[nWordAddr], nBitAddr, nCoilValue);
            break;
        case KLCoilTypeLY:
            if (nCoilAddr >= KLCoilLYCount) return 0;
            SetBitValue(&KMem.WLY[nWordAddr], nBitAddr, nCoilValue);
            break;
        case KLCoilTypeT:
            if (nCoilAddr >= KLCoilTCount) return 0;
            SetBitValue(&KMem.WT[nWordAddr], nBitAddr, nCoilValue);
            break;
        case KLCoilTypeC:
            if (nCoilAddr >= KLCoilCCount) return 0;
            SetBitValue(&KMem.WC[nWordAddr], nBitAddr, nCoilValue);
            break;
        case KLCoilTypeLR:
            if (nCoilAddr >= KLCoilLRCount) return 0;
            SetBitValue(&KMem.WLR[nWordAddr], nBitAddr, nCoilValue);
            break;
        case KLCoilTypeSR:
            if (nCoilAddr >= KLCoilSRCount) return 0;
            SetBitValue(&KMem.WSR[nWordAddr], nBitAddr, nCoilValue);
            break;
            default:
                break;
        }
        return 0;
}
int GetVarData(int nDataType, int nDataAddr)
{
    // TODO: ?????????.
    int thisValue = 0;
    switch (nDataType)
    {
    case KLDataTypeDEC:
    case KLDataTypeHEX:
        thisValue = nDataAddr;
        break;
    case KLDataTypeWX:
        if (nDataAddr >= KLDataWXCount) return 0;
        thisValue = KMem.WX[nDataAddr];
        break;
    case KLDataTypeWY:
        if (nDataAddr >= KLDataWYCount) return 0;
        thisValue = KMem.WY[nDataAddr];
        break;
    case KLDataTypeWR:
        if (nDataAddr >= KLDataWRCount) return 0;
        thisValue = KMem.WR[nDataAddr];
        break;
    case KLDataTypeWLX:
        if (nDataAddr >= KLDataWLCount) return 0;
        thisValue = KMem.WLX[nDataAddr];
        break;
    case KLDataTypeWLY:
        if (nDataAddr >= KLDataWLCount) return 0;
        thisValue = KMem.WLY[nDataAddr];
        break;
    case KLDataTypeDT:
        if (nDataAddr >= KLDataDTCount) return 0;
        thisValue = (signed short)KMem.DT[nDataAddr];
        break;
    case KLDataTypeSDT:
        if (nDataAddr >= KLDataSDTCount) return 0;
        thisValue = KMem.SDT[nDataAddr];
        break;
    case KLDataTypeWSR:
        if (nDataAddr >= KLCoilLRCount) return 0;
        thisValue = KMem.WSR[nDataAddr];
        break;
    case KLDataTypeSV:
        if (nDataAddr >= KLDataSVCount) return 0;
        thisValue = KMem.SV[nDataAddr];
        break;
    case KLDataTypeEV:
        if (nDataAddr >= KLDataEVCount) return 0;
        thisValue = KMem.EV[nDataAddr];
        break;
    case KLDataTypeLD:
        if (nDataAddr >= KLDataLDCount) return 0;
        thisValue = KMem.DT[nDataAddr];
        break;
    case KLDataSysCfg:
        if (nDataAddr >= KLCoilSRCount) return 0;
        thisValue = KMem.SDT[nDataAddr];
        break;
    case KLDataTypeFlash:
        if (nDataAddr >= KLCoilSRCount) return 0;
        thisValue = KMem.SDT[nDataAddr];
        break;
    case KLDataTypeTest:
        if (nDataAddr >= KLCoilSRCount) return 0;
        thisValue = KMem.SDT[nDataAddr];
        break;
    }
    return thisValue;
}
int SetVarData(int nDataType, int nDataAddr, int nDataValue)
{
    // TODO: ?????????.
    switch (nDataType)
    {
//    case KLDataTypeDEC:
//    case KLDataTypeHEX:
//        break;
    case KLDataTypeWX:
        if (nDataAddr >= KLDataWXCount) return 0;
        KMem.WX[nDataAddr] = nDataValue;
        break;
    case KLDataTypeWY:
        if (nDataAddr >= KLDataWYCount) return 0;
        KMem.WY[nDataAddr] = nDataValue;
        break;
    case KLDataTypeWR:
        if (nDataAddr >= KLDataWRCount) return 0;
        KMem.WR[nDataAddr] = nDataValue;
        break;
    case KLDataTypeWLX:
        if (nDataAddr >= KLDataWLCount) return 0;
        KMem.WLX[nDataAddr] = nDataValue;
        break;
    case KLDataTypeWLY:
        if (nDataAddr >= KLDataWLCount) return 0;
        KMem.WLY[nDataAddr] = nDataValue;
        break;
    case KLDataTypeDT:
        if (nDataAddr >= KLDataDTCount) return 0;
        KMem.DT[nDataAddr] = nDataValue;
        break;
    case KLDataTypeSDT:
        if (nDataAddr >= KLDataSDTCount) return 0;
        KMem.SDT[nDataAddr] = nDataValue;
        break;
    case KLDataTypeWSR:
        if (nDataAddr >= KLCoilLRCount) return 0;
        KMem.WSR[nDataAddr] = nDataValue;
        break;
    case KLDataTypeSV:
        if (nDataAddr >= KLDataSVCount) return 0;
        KMem.SV[nDataAddr] = nDataValue;
        break;
    case KLDataTypeEV:
        if (nDataAddr >= KLDataEVCount) return 0;
        KMem.EV[nDataAddr] = nDataValue;
        break;
    case KLDataTypeLD:
        if (nDataAddr >= KLDataLDCount) return 0;
        KMem.DT[nDataAddr] = nDataValue;
        break;
    case KLDataSysCfg:
        if (nDataAddr >= KLCoilSRCount) return 0;
        KMem.SDT[nDataAddr] = nDataValue;
        break;
    case KLDataTypeFlash:
        if (nDataAddr >= KLCoilSRCount) return 0;
        KMem.SDT[nDataAddr] = nDataValue;
        break;
    case KLDataTypeTest:
        if (nDataAddr >= KLCoilSRCount) return 0;
        KMem.SDT[nDataAddr] = nDataValue;
        break;
    }
    return 0;
}
Src/ModbusRTU.c
New file
@@ -0,0 +1,312 @@
/**
  ******************************************************************************
  * @file           : ModbusRTU.c
  * @brief          : Modbus RTU Protocol program body
  ******************************************************************************
    */
#include "ModbusRTU.h"
#include "functions.h"
#include "string.h"
#include "Kmachine.h"
static inline unsigned char HiByte(uint16_t in)
{
    return (in>>8)&0xff;
}
static inline unsigned char LoByte(uint16_t in)
{
    return (in&0xff);
}
static inline uint16_t swaphilo(uint16_t in)
{
    return ((in&0xff)<<8)|((in>>8)&0xff);
}
static inline uint16_t mkshort(uint8_t hi, uint8_t lo)
{
    return ((uint16_t)hi<<8)|lo;
}
uint8_t MyAddr = 1;
int ModBusCRC16(void * pBuf, int len1)
{
    return 0;
}
//const uint16_t polynom = 0xA001;
/*
uint16_t crc16bitbybit(uint8_t *ptr, uint16_t len)
{
    uint8_t i;
    uint16_t crc = 0xffff;
    if (len == 0) {
        len = 1;
    }
    while (len--) {
        crc ^= *ptr;
        for (i = 0; i<8; i++)
        {
            if (crc & 1) {
                crc >>= 1;
                crc ^= polynom;
            }
            else {
                crc >>= 1;
            }
        }
        ptr++;
    }
    return(crc);
}
*/
const uint16_t crctalbeabs[] = {
    0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401,
    0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400
};
uint16_t crc16tablefast(uint8_t *ptr, uint16_t len)
{
    uint16_t crc = 0xffff;
    uint16_t i;
    uint8_t ch;
    for (i = 0; i < len; i++) {
        ch = *ptr++;
        crc = crctalbeabs[(ch ^ crc) & 15] ^ (crc >> 4);
        crc = crctalbeabs[((ch >> 4) ^ crc) & 15] ^ (crc >> 4);
    }
    return crc;
}
//**********************************************************************
//******************  Modbus slave  ************************************
int ModBusSlaveCheckPkg(void *ptr, uint16_t len1)
{
    if (len1 <=4) return -1;        //包长
    pModBusRTUReqPkg pPkg = (pModBusRTUReqPkg) ptr;
    if (pPkg->Dst >127) return -2;   //地址码
    if ((pPkg->Cmd&0x7f) > 0x1f) return -3;  //功能码
    uint16_t crc = crc16tablefast(ptr,len1);   //CRC 校验
    if (crc != 0 ) return 4;        //CRC 校验错误
    return S_OK;
}
int mkReqPkg(uint8_t *ptr, uint8_t opcode, uint8_t nsize, uint8_t *buf)
{
    int len1=0;
    return len1;
}
/*
static const unsigned short bitMasks[16]=
{
    0x1<<0,    0x1<<1,    0x1<<2,    0x1<<3,    0x1<<4,    0x1<<5,    0x1<<6,    0x1<<7,
    0x1<<8,    0x1<<9,    0x1<<10,    0x1<<11,    0x1<<12,    0x1<<13,    0x1<<14,    0x1<<15,
};
*/
static inline void SetAddrBit(unsigned short * pW, unsigned char bitAddr)
{
    (*pW)|=1<<(bitAddr&0xf);
}
static inline void ResetBit(unsigned short * pW, unsigned char bitAddr)
{
    (*pW)&=~(1<<(bitAddr&0xf));
}
static inline void SetBitValue(unsigned short * pW, unsigned char bitAddr, unsigned char Value)
{
    if (Value)    {    SetAddrBit(pW, bitAddr);}
    else {ResetBit(pW, bitAddr);}
}
static inline unsigned char GetBitValue(unsigned short W, unsigned char bitAddr)
{
    if (W&(1<<(bitAddr&0xf))) return 1;
    else return 0;
}
uint8_t Pkgbuf[128];
int ModBusSlaveParsePkg( void *ptr, uint16_t len)
{
    uchar * bptr = (uchar *) ptr;
    int err=ModBusSlaveCheckPkg(ptr,len);
    if (err) return -1;
    pModBusRTUReqPkg pPkg = (pModBusRTUReqPkg) ptr;
    uint8_t DstHost=pPkg->Dst;
    if (DstHost != MyAddr) return 0;
    uint8_t opcode = pPkg->Cmd;
    ushort Addr=mkshort(pPkg->AddrH,pPkg->AddrL);
    ushort nCount=swaphilo(pPkg->nCount);
    Pkgbuf[0]=MyAddr;
    Pkgbuf[1]=opcode;
    int len2=2;
    int needcrc=1;
    uint16_t crc;
    int nByteCount;
    unsigned short Addr1=(Addr&0xff0)>>4;
    unsigned char bitAddr=Addr&0xf;
    unsigned char thisValue;
    unsigned char bitmask=1;
    switch (opcode)
    {
        case None:        //0
            break;
        case ReadCoils:    //1  bits
        //    Fetch Datas;
            nByteCount=(nCount+7)/8;
            Pkgbuf[2]=nByteCount;
            for (int i=0;i<nByteCount;i++)
            {
                thisValue=0;
                bitmask=1;
                for (int j=0;j<8&&i*8+j<nCount;j++)
                {
                    Addr1=(Addr&0xff0)>>4;
                    bitAddr=Addr&0xf;
                    if (GetBitValue( KMem.WR[Addr1],bitAddr))
                    {
                        thisValue|=bitmask;
                    }
                    bitmask<<=1;
                    Addr++;
                }
                Pkgbuf[3+i]=thisValue;
            }
            len2+=1+nByteCount;
            break;
        case ReadInputs:    //2  bits
        // Fetch Datas;
            nByteCount=(nCount+7)/8;
            Pkgbuf[2]=nByteCount;
            for (int i=0;i<nByteCount;i++)
            {
                thisValue=0;
                bitmask=1;
                for (int j=0;j<8&&i*8+j<nCount;j++)
                {
                    Addr1=(Addr&0xff0)>>4;
                    bitAddr=Addr&0xf;
                    if (GetBitValue( KMem.WX[Addr1],bitAddr))
                    {
                        thisValue|=bitmask;
                    }
                    bitmask<<=1;
                    Addr++;
                }
                Pkgbuf[3+i]=thisValue;
            }
            len2+=1+nByteCount;
            break;
        case ReadKeepRegs:    //3  words
        // Fetch Datas;
            nByteCount=nCount*2;
            Pkgbuf[2]=nByteCount;
            for (int i=0;i<nCount;i++)
            {
            Pkgbuf[3+i*2]=(KMem.DT[Addr+i]>>8)&0xff;
            Pkgbuf[4+i*2]=(KMem.DT[Addr+i])&0xff;
            }
            len2+=1+nByteCount;
            break;
        case ReadInputRegs:    //4  words
        // Fetch Datas;
            nByteCount=nCount*2;
            Pkgbuf[2]=nByteCount;
            for (int i=0;i<nCount;i++)
            {
                Pkgbuf[3+i*2]=HiByte(KMem.WX[Addr+i]);
                Pkgbuf[4+i*2]=LoByte(KMem.WX[Addr+i]);
            }
            len2+=1+nByteCount;
            break;
        case WriteCoil:    //5  bit
        //Store Datas;
            //SetBitValue(&KMem.WR[Addr1],bitAddr,pPkg->nCount);
            if (nCount == 0)
            {
                ResetBit(&KMem.WR[Addr1],bitAddr);
            }else if (nCount == 0xFF00)
            {
                SetAddrBit(&KMem.WR[Addr1],bitAddr);
            }else
            {
                //error
            }
            memcpy(Pkgbuf,ptr,len);
            needcrc=0;
            len2=len;
            break;
        case WriteReg:    //6 word
        //Store Datas;
            KMem.DT[Addr]=mkshort(bptr[4],bptr[5]);
            memcpy(Pkgbuf,ptr,len);
            needcrc=0;
            len2=len;
            break;
        case WriteCoils:    //0x0f, 15  bits
        //Store Datas;
            nByteCount=(nCount+7)/8;
            Pkgbuf[2]=nByteCount;
            for (int i=0;i<nByteCount;i++)
            {
                thisValue=bptr[7+i];
                bitmask=1;
                for (int j=0;j<8&&i*8+j<nCount;j++)
                {
                    Addr1=(Addr&0xff0)>>4;
                    bitAddr=Addr&0xf;
                    SetBitValue( &KMem.WR[Addr1],bitAddr,bitmask&thisValue);
                    bitmask<<=1;
                    Addr++;
                }
            }
        //makeReply
            Pkgbuf[2]=bptr[2];    //HiByte(Addr);
            Pkgbuf[3]=bptr[3];    //LoByte(Addr);
            Pkgbuf[4]=bptr[4];    //HiByte(nCount);
            Pkgbuf[5]=bptr[5];    //LoByte(nCount);
            len2+=4;
            break;
        case WriteRegs:    //0x10, 16  words
        //Store Datas;
        for (int i=0;i<nCount;i++)
        {
            KMem.DT[Addr+i]=mkshort(bptr[7+i*2],bptr[8+i*2]);
        }
        //Make Reply
            Pkgbuf[2]=bptr[2];    //HiByte(Addr);
            Pkgbuf[3]=bptr[3];    //LoByte(Addr);
            Pkgbuf[4]=bptr[4];    //HiByte(nCount);
            Pkgbuf[5]=bptr[5];    //LoByte(nCount);
            len2+=4;
            break;
        default:            //others
            break;
    }
if (err==0)
{
    if (needcrc)
    {
            crc=crc16tablefast(Pkgbuf,len2);
            Pkgbuf[len2]=LoByte(crc);
          Pkgbuf[len2+1]=HiByte(crc);
            len2+=2;
    }
            //SendPkg(Pkgbuf,len2);
            SendPacket1(Pkgbuf,len2);
}
    return 0;
}
Src/ModbusRTU.h
New file
@@ -0,0 +1,86 @@
/**
  ******************************************************************************
  * @file           : ModbusRTU.h
  * @brief          : Header for ModbusRTU.c file.
  *                   This file contains the common defines of the ModbusRTU protocol.
  ******************************************************************************
    */
#ifndef __MODBUSRTU_H__
#define __MODBUSRTU_H__
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef int int32_t;
/*
enum enResult
{
    S_OK = 0,
    S_ERR = 1,
};
*/
enum enModbusRTUCmd
{
    None =0,
    ReadCoils =1, //读线圈
    ReadInputs =2,  //读离散量输入
    ReadKeepRegs =3,    //读保持寄存器
    ReadInputRegs =4,    //读输入寄存器
    WriteCoil = 5,        //写单个线圈
    WriteReg =6,        //写单个寄存器
    ReadExptStat = 7,  //读取异常状态
    FetchCommEventCtr =11,   //Fetch Comm Event Ctr
                                                     // 12 Fetch Comm Event Log
    WriteCoils =15,                //写多个线圈
    WriteRegs = 16,        //写多个寄存器
                                        //17 Report Slave ID
                                        //20 Read General Reference
                                        //21 Write General Reference
                                        //22 Mask Write 4X Register
                                        // 23 Read/Write 4X Registers
                                        //24 Read FIFO Queue
};
#pragma anon_unions
typedef struct tagModBusRTUReqPkg
{
    uchar Dst;
    uchar Cmd;
    union    {
        ushort Addr;
        struct        {
            uchar AddrH;
            uchar AddrL;
        };
    };
    union
    {
        ushort nCount;
        struct
        {
            uchar CountH;
            uchar CountL;
        };
    };
}stModBusRTUReqPkg, *pModBusRTUReqPkg;
typedef struct tagModBusRTUReplyPkg
{
    uchar Dst;
    uchar Cmd;
    uchar nByteCount;
    uchar Datas[1];
}stModBusRTUReplyPkg, *pModBusRTUReplyPkg;
int ModBusCRC16(void * pBuf, int len1);
int ModBusSlaveCheckPkg(void * pPkg, uint16_t len1);
int ModBusSlaveParsePkg(void * pPkg, uint16_t len1);
#endif    /* __MODBUSRTU_H__ */
Src/PLCfunctions.c
@@ -36,23 +36,23 @@
int InitTimer(int nIndex, int nType)
{
    if (nIndex >= TOTALTIMERS) return -1;
    PLCMem.Timers[nIndex].StatByte = 0x0010 | nType;
    KMem.Timers[nIndex].StatByte = 0x0010 | nType;
//    Timers[nIndex].nType = 0;
    PLCMem.Timers[nIndex].SV = 0;
    PLCMem.Timers[nIndex].EV = 0;
    PLCMem.Timers[nIndex].LastActTime = GetTick();
    KMem.SV[nIndex] = 0;
    KMem.EV[nIndex] = 0;
    KMem.Timers[nIndex].LastActTime = GetTick();
    return 0;
}
int StartTimer(int nIndex , int SV)
int RunTimer(int nIndex , int SV)
{
    if (nIndex >= TOTALTIMERS) return -1;    
    if (!PLCMem.Timers[nIndex].bSet)
    if (!KMem.Timers[nIndex].bSet)
    {
        PLCMem.Timers[nIndex].SV = SV;
        PLCMem.Timers[nIndex].EV = 0;
        PLCMem.Timers[nIndex].LastActTime = GetTick();
        PLCMem.Timers[nIndex].bSet = 1;
        KMem.SV[nIndex] = SV;
        KMem.EV[nIndex]= 0;
        KMem.Timers[nIndex].LastActTime = GetTick();
        KMem.Timers[nIndex].bSet = 1;
    }
    return 0;
}
@@ -60,48 +60,48 @@
int StopTimer(int nIndex)
{
    if (nIndex >= TOTALTIMERS) return -1;    
    if (PLCMem.Timers[nIndex].bSet)
    if (KMem.Timers[nIndex].bSet)
    {
        PLCMem.Timers[nIndex].EV = 0;
        PLCMem.Timers[nIndex].LastActTime = GetTick();
        PLCMem.Timers[nIndex].bSet = 0;
        KMem.EV[nIndex] = 0;
        KMem.Timers[nIndex].LastActTime = GetTick();
        KMem.Timers[nIndex].bSet = 0;
    }
    return 0;
}
int ResetTimer(int nIndex)
{
    if (nIndex >= TOTALTIMERS) return -1;
    PLCMem.Timers[nIndex].EV = 0;
    PLCMem.Timers[nIndex].bTon = 0;
    PLCMem.Timers[nIndex].LastActTime=GetTick();
    KMem.EV[nIndex] = 0;
    KMem.Timers[nIndex].bTon = 0;
    KMem.Timers[nIndex].LastActTime=GetTick();
    return 0;
}
int SetTimerValue(int nIndex, int bSet, int SV)
{
    if (nIndex >= TOTALTIMERS) return -1;    
    if (bSet) {StartTimer(nIndex, SV);}
    if (bSet) {RunTimer(nIndex, SV);}
    else {StopTimer(nIndex);}
    return PLCMem.Timers[nIndex].bTon;
    return KMem.Timers[nIndex].bTon;
}
int ProcessTimer(int nIndex)
{
    if (nIndex >= TOTALTIMERS) return -1;
    if (!PLCMem.Timers[nIndex].nInited) return 0;
    if (PLCMem.Timers[nIndex].bSet)        // bSet =1;
    if (!KMem.Timers[nIndex].nInited) return 0;
    if (KMem.Timers[nIndex].bSet)        // bSet =1;
    {
        if (!PLCMem.Timers[nIndex].bTon)
        if (!KMem.Timers[nIndex].bTon)
        {
            int TimeDiff = GetTick() - PLCMem.Timers[nIndex].LastActTime;
            int TimeDiff = GetTick() - KMem.Timers[nIndex].LastActTime;
            int nScale = TICK_OF_MS;
            if (PLCMem.Timers[nIndex].nScale == 0)
            if (KMem.Timers[nIndex].nScale == 0)
            {nScale = TICK_OF_MS;
            }else if (PLCMem.Timers[nIndex].nScale == 1)
            }else if (KMem.Timers[nIndex].nScale == 1)
            {nScale = TICK_OF_RS;
            }else if (PLCMem.Timers[nIndex].nScale == 2)
            }else if (KMem.Timers[nIndex].nScale == 2)
            {nScale = TICK_OF_XS;
            }else if (PLCMem.Timers[nIndex].nScale == 3)
            }else if (KMem.Timers[nIndex].nScale == 3)
            {nScale = TICK_OF_YS;
            }else {}
            
@@ -109,32 +109,33 @@
            if (TimeDiff >= nScale)
            {
                int TimeDiffmS = TimeDiff / nScale;
                unsigned short NextEV = PLCMem.Timers[nIndex].EV + TimeDiffmS;
                PLCMem.Timers[nIndex].LastActTime += TimeDiffmS*nScale;
                unsigned short NextEV = KMem.EV[nIndex] + TimeDiffmS;
                KMem.Timers[nIndex].LastActTime += TimeDiffmS*nScale;
                
                if (NextEV >= PLCMem.Timers[nIndex].SV)
                if (NextEV >= KMem.SV[nIndex])
                {
                    NextEV = PLCMem.Timers[nIndex].SV;
                    PLCMem.Timers[nIndex].bTon =1;
                    NextEV = KMem.SV[nIndex];
                    KMem.Timers[nIndex].bTon =1;
                }
                PLCMem.Timers[nIndex].EV = NextEV;
                KMem.EV[nIndex] = NextEV;
            }
        }
    }else         //bSet=0;
    {
        if(PLCMem.Timers[nIndex].bTon)
        if(KMem.Timers[nIndex].bTon)
        {
            PLCMem.Timers[nIndex].bTon =    0;
            KMem.Timers[nIndex].bTon =    0;
        }
    }
    return PLCMem.Timers[nIndex].bTon;
    SetCoilValue(KLCoilTypeT, nIndex, KMem.Timers[nIndex].bTon);
    return KMem.Timers[nIndex].bTon;
}
int IsTimerOn(int nIndex)
{
    if (nIndex >= TOTALTIMERS) return 0;
    ProcessTimer(nIndex);
    return PLCMem.Timers[nIndex].bTon;
    return KMem.Timers[nIndex].bTon;
}
@@ -142,164 +143,185 @@
{
    if (nIndex >= TOTALTIMERS) return 0;
//    ProcessTimer(nIndex);    
    return PLCMem.Timers[nIndex].SV;
    return KMem.SV[nIndex];
//    return 0;    
}
int GetTimerEV(int nIndex)
{
    if (nIndex >= TOTALTIMERS) return 0;
//    ProcessTimer(nIndex);    
    return PLCMem.Timers[nIndex].EV;
    return KMem.EV[nIndex];
//    return 0;
}
const unsigned short bitMasks[16]=
{
    0x1<<0,
    0x1<<1,
    0x1<<2,
    0x1<<3,
    0x1<<4,
    0x1<<5,
    0x1<<6,
    0x1<<7,
    0x1<<8,
    0x1<<9,
    0x1<<10,
    0x1<<11,
    0x1<<12,
    0x1<<13,
    0x1<<14,
    0x1<<15,
};
inline void SetAddrBit(unsigned short * pW, unsigned char bitAddr)
{
    (*pW)|=bitMasks[bitAddr&0xf];
}
inline void ResetBit(unsigned short * pW, unsigned char bitAddr)
{
    (*pW)&=~bitMasks[bitAddr&0xf];
}
static inline void SetBitValue(unsigned short * pW, unsigned char bitAddr, unsigned char Value)
{
    if (Value)    {    SetAddrBit(pW, bitAddr);}
    else {ResetBit(pW, bitAddr);}
}
static inline unsigned char GetBitValue(unsigned short W, unsigned char bitAddr)
{
    if (W&bitMasks[bitAddr&0xf]) return 1;
    else return 0;
}
int InitAllDFs()
{
    for (int i=0;i<TOTAL_WDFS;i++)
    {
        PLCMem.WDFs[i]=0;
    }
    return TOTAL_WDFS;
}
int IsDF(int nIndex, int bSet)
{
    unsigned short addr1 = (nIndex&0xff0)>>4;
    unsigned char bitAddr=nIndex&0xf;
    if (addr1 >= TOTAL_WDFS) return 0;
    if (!GetBitValue( PLCMem.WDFs[addr1],bitAddr) && bSet)
    {
        SetBitValue(&PLCMem.WDFs[addr1],bitAddr,1);
        return 1;
    }else
    {
        SetBitValue(&PLCMem.WDFs[addr1],bitAddr,bSet);
    }
    return 0;
}
int PushInVal(void)
{
    for (int i=TOTAL_CurVAL;i>0;i--)
    for (int i=TOTAL_CurVAL -1 ;i>0;i--)
    {
        PLCMem.CurVALs[i]=PLCMem.CurVALs[i-1];
        KMem.CurVALs[i]=KMem.CurVALs[i-1];
    }
    PLCMem.CurVALs[0]=PLCMem.CurVAL;
    return PLCMem.CurVAL;
    KMem.CurVALs[0]=KMem.CurVAL;
    return KMem.CurVAL;
}
int PopOutVal(void)
{
    unsigned char theVAL=PLCMem.CurVALs[0];
    unsigned char theVAL=KMem.CurVALs[0];
    for (int i=0;i<TOTAL_CurVAL-1;i++)
    {
        PLCMem.CurVALs[i]=PLCMem.CurVALs[i+1];
        KMem.CurVALs[i]=KMem.CurVALs[i+1];
    }
    return theVAL;
}
int ANS(int bValue)
stBinProg1 const  prog1[]= //__attribute__((at(0X8008000)))
{
    return PLCMem.CurVAL;
}
int ORS(int bValue)
{
    return PLCMem.CurVAL;
}
int ST(int nAddr)
{
    return 0;
}
int AN(int nAddr)
{
    return 0;
}
int OR(int nAddr)
{
    return 0;
}
int AN_(int nAddr)
{
    return 0;
}
int OR_(int nAddr)
{
    return 0;
}
stPLCPROG const  prog1[]= //__attribute__((at(0X8008000)))
{
    {OP_ST,Addr_X,0},
    {OP_OR,Addr_Y,0},
    {OP_AN_,Addr_X,1},
    {OP_OUT,Addr_Y,0},
    {OP_ST,KLCoilTypeSR,13},
    {OP_MV,0,50},    {KLDataTypeDEC,KLDataTypeDT,1},
    {OP_MV,0,20},    {KLDataTypeDEC,KLDataTypeDT,2},
    {OP_MV,0,30},    {KLDataTypeDEC,KLDataTypeDT,3},
    {OP_MV,0,40},    {KLDataTypeDEC,KLDataTypeDT,4},
    {OP_SET,KLCoilTypeR,0},
//    {OP_SET,KLCoilTypeY,0},
    
    {OP_ST,Addr_X,2},
    {OP_SET,Addr_R,1},
    {OP_ST,Addr_X,3},
    {OP_RESET,Addr_R,1},
    {OP_ST,Addr_R,1},
    {OP_PSHS,0,0},
    {OP_AN_,Addr_Y,1},
    {OP_TML,5,25},
    {OP_SET,Addr_Y,1},
    {OP_RESET,Addr_Y,2},
    {OP_ST,KLCoilTypeR,0},
        {OP_TMX,1,1},    {KLDataTypeDT,0,0},
        {OP_DF},
        {OP_SET,KLCoilTypeR,10},
    {OP_ST,KLCoilTypeX,0},
    {OP_DF},
    {OP_SET,KLCoilTypeR,10},
    {OP_POPS,0,0},
    {OP_AN,Addr_Y,1},
    {OP_TML,6,25},
    {OP_RESET,Addr_Y,1},
    {OP_SET,Addr_Y,2},
    {OP_ST,KLCoilTypeX,1},
    {OP_DF},
    {OP_RESET,KLCoilTypeR,10},
/*
    {OP_ST,KLCoilTypeR,10},
    {OP_AN,KLCoilTypeR,51},
    {OP_AN,KLCoilTypeR,52},
    {OP_AN,KLCoilTypeR,53},
    {OP_ADD3,0,21},        {KLDataTypeDT,KLDataTypeDT,31},        {0,KLDataTypeDT,32},
    {OP_ST,KLCoilTypeR,10},
    {OP_AN,KLCoilTypeR,54},
    {OP_AN,KLCoilTypeR,55},
    {OP_AN,KLCoilTypeR,56},
    {OP_ADD3,0,23},        {KLDataTypeDT,KLDataTypeDT,33},        {0,KLDataTypeDT,34},
*/
    {OP_ST,KLCoilTypeSR,1},
    {OP_PSHS},
    {OP_AN,KLCoilTypeR,51},
    {OP_OUT,KLCoilTypeY,1},
    {OP_RDS},
    {OP_AN,KLCoilTypeR,52},
    {OP_OUT,KLCoilTypeY,2},
    {OP_RDS},
    {OP_AN,KLCoilTypeR,53},
    {OP_OUT,KLCoilTypeY,3},
    {OP_RDS},
    {OP_AN,KLCoilTypeR,54},
    {OP_OUT,KLCoilTypeY,4},
    {OP_RDS},
    {OP_AN,KLCoilTypeR,55},
    {OP_OUT,KLCoilTypeY,5},
    {OP_POPS},
    {OP_AN,KLCoilTypeR,56},
    {OP_OUT,KLCoilTypeY,6},
    {OP_ST,KLCoilTypeR,10},
    {OP_DF},
    {OP_PSHS},
    {OP_MV,0,150},    {KLDataTypeDEC,KLDataTypeDT,11},
    {OP_MV,0,30},    {KLDataTypeDEC,KLDataTypeDT,12},
    {OP_RDS},
    {OP_MV,0,150},    {KLDataTypeDEC,KLDataTypeDT,13},
    {OP_MV,0,30},    {KLDataTypeDEC,KLDataTypeDT,14},
    {OP_POPS},
    {OP_AN_,KLCoilTypeR,11},
    {OP_AN_,KLCoilTypeR,12},
    {OP_AN_,KLCoilTypeR,13},
    {OP_AN_,KLCoilTypeR,14},
    {OP_SET,KLCoilTypeR,14},
    {OP_ST,KLCoilTypeR,10},
    {OP_PSHS},
    {OP_AN,KLCoilTypeR,11},
    {OP_DF},
    {OP_SET,KLCoilTypeR,51},
    {OP_RESET,KLCoilTypeR,52},
    {OP_RESET,KLCoilTypeR,53},
    {OP_RESET,KLCoilTypeR,54},
    {OP_RESET,KLCoilTypeR,55},
    {OP_SET,KLCoilTypeR,56},
    {OP_RDS},
    {OP_AN,KLCoilTypeR,11},
        {OP_PSHS},
        {OP_TMX,11,11},    {KLDataTypeDT,0,0},
            {OP_RESET,KLCoilTypeR,11},
            {OP_SET,KLCoilTypeR,12},
        {OP_POPS},
            {OP_SUB3,0,11},        {KLDataTypeSV,KLDataTypeEV,11},        {0,KLDataTypeDT,21},
            {OP_AN_LE,0,21},{KLDataTypeDT,KLDataTypeDEC,30},
            {OP_PSHS},
                {OP_DIV,0,21},        {KLDataTypeDT,KLDataTypeDEC,10},        {0,KLDataTypeDT,31},
            {OP_RDS},
                {OP_AN_GE,0,32},{KLDataTypeDT,KLDataTypeDEC,5},
                {OP_SET,KLCoilTypeR,51},
            {OP_POPS},
                {OP_AN_LT,0,32},{KLDataTypeDT,KLDataTypeDEC,5},
                {OP_RESET,KLCoilTypeR,51},
    {OP_RDS},
    {OP_AN,KLCoilTypeR,12},
    {OP_DF},
    {OP_RESET,KLCoilTypeR,51},
    {OP_SET,KLCoilTypeR,52},
    {OP_RDS},
    {OP_AN,KLCoilTypeR,12},
        {OP_TMX,12,12},    {KLDataTypeDT,0,0},
            {OP_RESET,KLCoilTypeR,12},
            {OP_SET,KLCoilTypeR,13},
    {OP_POPS},
    {OP_AN,KLCoilTypeR,12},
    {OP_OUT,KLCoilTypeR,52},
    
    {OP_ST,KLCoilTypeR,10},
    {OP_PSHS},
    {OP_AN,KLCoilTypeR,13},
    {OP_DF},
    {OP_RESET,KLCoilTypeR,52},
    {OP_SET,KLCoilTypeR,53},
    {OP_SET,KLCoilTypeR,54},
    {OP_RESET,KLCoilTypeR,56},
    {OP_RDS},
    {OP_AN,KLCoilTypeR,13},
        {OP_TMX,13,13},    {KLDataTypeDT,0,0},
            {OP_RESET,KLCoilTypeR,13},
            {OP_SET,KLCoilTypeR,14},
    {OP_RDS},
    {OP_AN,KLCoilTypeR,13},
            {OP_SUB3,0,13},        {KLDataTypeSV,KLDataTypeEV,13},        {0,KLDataTypeDT,23},
            {OP_AN_LE,0,23},{KLDataTypeDT,KLDataTypeDEC,30},
            {OP_PSHS},
                {OP_DIV,0,23},        {KLDataTypeDT,KLDataTypeDEC,10},        {0,KLDataTypeDT,33},
            {OP_RDS},
                {OP_AN_GE,0,34},{KLDataTypeDT,KLDataTypeDEC,5},
                {OP_SET,KLCoilTypeR,54},
            {OP_POPS},
                {OP_AN_LT,0,34},{KLDataTypeDT,KLDataTypeDEC,5},
                {OP_RESET,KLCoilTypeR,54},
    {OP_RDS},
    {OP_AN,KLCoilTypeR,14},
    {OP_DF},
    {OP_RESET,KLCoilTypeR,54},
    {OP_SET,KLCoilTypeR,55},
    {OP_POPS},
    {OP_AN,KLCoilTypeR,14},
        {OP_TMX,14,14},    {KLDataTypeDT,0,0},
            {OP_RESET,KLCoilTypeR,14},
            {OP_SET,KLCoilTypeR,11},
};
/*
@@ -315,159 +337,416 @@
    {OP_RESET,Addr_Y,1},
*/
int nSizeProg1=sizeof(prog1)/sizeof(stPLCPROG);
int nSizeProg1=sizeof(prog1)/sizeof(stBinProg1);
char * PLCPRG=
int InitPLC()
{
    "ST X0\n\
    AN X1\n\
    ST Y0\n\
    AN Y1\n\
    ORS\n\
    AN/ X2\n\
    AN/ X3\n\
    OT Y0\n\
    OT Y1\n\
    "
};
int InitPLCPROGStat()
{
    PLCMem.nScanCount=0;
    for (int i=0;i<1024;i++){PLCMem.ProgTrace[i]=0;}
    for (int i=0;i<16;i++)    {
        KMem.WR[i]=0;
    }
    for (int i=0;i<256;i++)    {
        KMem.DT[i]=0;
    }
    return 0;
}
unsigned char GetAddrValue(unsigned char AddrType, unsigned short Addr)
int StartPLC()
{
        unsigned char thisValue;
        unsigned short Addr1=(Addr&0xff0)>>4;
        unsigned char bitAddr=Addr&0xf;
        switch(AddrType)
        {
            case Addr_None:
                break;
            case Addr_X:
                thisValue=GetBitValue( KMem.WX[Addr1],bitAddr);
                break;
            case Addr_Y:
                thisValue=GetBitValue( KMem.WY[Addr1],bitAddr);
                break;
            case Addr_R:
                thisValue=GetBitValue( KMem.WR[Addr1],bitAddr);
                break;
            case Addr_T:
                thisValue=PLCMem.Timers[Addr].bTon;
                break;
            case Addr_L:
                break;
            default:
                break;
        }
        return thisValue;
    for (int i=0;i<1024;i++){PLCMem.ProgTrace[i]=0;}
    for (int i=0;i<16;i++)    {
        KMem.WR[i]=0;
    }
    for (int i=0;i<256;i++)    {
        KMem.DT[i]=0;
    }
    PLCMem.bPLCRunning=1;
    return 0;
}
int SetAddrValue(unsigned char AddrType, unsigned short Addr, unsigned char Value)
int StopPLC()
{
        unsigned short Addr1=(Addr&0xff0)>>4;
        unsigned char bitAddr=Addr&0xf;
        switch(AddrType)
        {
            case Addr_None:
                break;
            case Addr_X:
                SetBitValue(&KMem.WX[Addr1],bitAddr,Value);
                break;
            case Addr_Y:
                SetBitValue(&KMem.WY[Addr1],bitAddr,Value);
            break;
            case Addr_R:
                SetBitValue(&KMem.WR[Addr1],bitAddr,Value);
            break;
            case Addr_T:
                PLCMem.Timers[Addr].bTon=Value;
                break;
            case Addr_L:
                break;
            default:
                break;
        }
        return Value;
    PLCMem.bPLCRunning=0;
    return 0;
}
int ProcessPLCPROG(const stPLCPROG * prog,int nSize)
int ProcessPLCBinProg(const stBinProg1 * pBinprog, int nStepSize)
{
    for (int i=0;i<nSize;i++)
    if (!PLCMem.bPLCRunning) return 0;
    if (PLCMem.nScanCount == 0) {
        SetCoilValue(KLCoilTypeSR, 13, 1);
        SetCoilValue(KLCoilTypeSR, 0, 0);
        SetCoilValue(KLCoilTypeSR, 1, 1);
    }
    else
    {
        unsigned char thisOP=prog[i].OP;
        unsigned char thisAddrType=prog[i].AddrType;
        unsigned short thisAddr=prog[i].Addr;
        SetCoilValue(KLCoilTypeSR, 13, 0);
        SetCoilValue(KLCoilTypeSR, 0, 0);
        SetCoilValue(KLCoilTypeSR, 1, 1);
    }
    for (int i = 0; i < TOTAL_CurVAL; i++) {
        KMem.CurVALs[i] = 0;
    }
    int CurPos = 0;
//    stBinProg1 * pBinProg1;
    stBinProg15 * pBinProg15;
    stBinProg2 * pBinProg2;
    stBinProg3 * pBinProg3;
    int lastScanInputVal = 1;//??????,????????,? ?? ???
    while (CurPos < nStepSize)
    {
        unsigned int nNextPos = 1;
        unsigned int thisOP = pBinprog[CurPos].nOp;
//        unsigned int nParamCount = 0
        unsigned char thisAddrType = pBinprog[CurPos].nParamType;
        unsigned short thisAddr = pBinprog[CurPos].nParamAddr;
        switch (thisOP)
        {
            case OP_None:
                break;
            case OP_ST:
                PushInVal();
                PLCMem.CurVAL=GetAddrValue(thisAddrType, thisAddr);
                break;
            case OP_ST_:
                PushInVal();
                PLCMem.CurVAL=!GetAddrValue(thisAddrType, thisAddr);
                break;
            case OP_AN:
              PLCMem.CurVAL = PLCMem.CurVAL&&GetAddrValue(thisAddrType, thisAddr);
                break;
            case OP_AN_:
                PLCMem.CurVAL = PLCMem.CurVAL && (!GetAddrValue(thisAddrType, thisAddr));
                break;
            case OP_OR:
                PLCMem.CurVAL = PLCMem.CurVAL || GetAddrValue(thisAddrType, thisAddr);
                break;
            case OP_OR_:
                PLCMem.CurVAL = PLCMem.CurVAL || (!GetAddrValue(thisAddrType, thisAddr));
                break;
//        case OP_NONE:
//            break;
        case OP_NOP:
            break;
            //??? ??
        case OP_NOT:
        case OP_ANS:
        case OP_ORS:
        case OP_PSHS:
        case OP_RDS:
        case OP_POPS:
        case OP_DF:
        case OP_DF_:
            switch (thisOP)
            {
            case OP_NOT:
                PLCMem.CurVAL = ! PLCMem.CurVAL;
                KMem.CurVAL = !KMem.CurVAL;
                break;
            case OP_ANS:
                KMem.CurVAL = PopOutVal() && KMem.CurVAL;
                break;
            case OP_ORS:
                KMem.CurVAL = PopOutVal() || KMem.CurVAL;
                break;
            case OP_PSHS:
                PushInVal();
                break;
            case OP_RDS:
                KMem.CurVAL = KMem.CurVALs[0] != 0;
                break;
            case OP_POPS:
                PLCMem.CurVAL = PopOutVal();
                KMem.CurVAL = PopOutVal();
                break;
            case OP_ANS:
                PLCMem.CurVAL = PLCMem.CurVAL && PopOutVal();
            case OP_DF:
                KMem.CurVAL = KMem.CurVAL && !lastScanInputVal;
                break;
            case OP_ORS:
                PLCMem.CurVAL = PLCMem.CurVAL || PopOutVal();
            case OP_DF_:
                KMem.CurVAL = !KMem.CurVAL && lastScanInputVal;
                break;
            case OP_OUT:
                SetAddrValue(thisAddrType,thisAddr,PLCMem.CurVAL);
                break;
            case OP_SET:
                if (PLCMem.CurVAL) SetAddrValue(thisAddrType,thisAddr,1);
                break;
            case OP_RESET:
                if (PLCMem.CurVAL) SetAddrValue(thisAddrType,thisAddr,0);
                break;
            case OP_DF:
                break;
            case OP_TML:
                if (!PLCMem.Timers[thisAddrType].nInited) InitTimer(thisAddrType,0);
                if (PLCMem.CurVAL) StartTimer(thisAddrType,thisAddr);
                else StopTimer(thisAddrType);
                PLCMem.CurVAL = ProcessTimer(thisAddrType);
                break;
            case OP_TMR:
                if (!PLCMem.Timers[thisAddrType].nInited) InitTimer(thisAddrType,1);
                if (PLCMem.CurVAL) StartTimer(thisAddrType,thisAddr);
                else StopTimer(thisAddrType);
                PLCMem.CurVAL = ProcessTimer(thisAddrType);
                break;
            default:
                break;
            }
            break;
            // 1????
        case OP_ST:
        case OP_ST_:
        case OP_AN:
        case OP_AN_:
        case OP_OR:
        case OP_OR_:
            switch (thisOP)
            {
            case OP_ST:
                PushInVal();
                KMem.CurVAL = GetCoilValue(thisAddrType, thisAddr);
                break;
            case OP_ST_:
                PushInVal();
                KMem.CurVAL = !GetCoilValue(thisAddrType, thisAddr);
                break;
            case OP_AN:
                KMem.CurVAL = KMem.CurVAL&&GetCoilValue(thisAddrType, thisAddr);
                break;
            case OP_AN_:
                KMem.CurVAL = KMem.CurVAL && (!GetCoilValue(thisAddrType, thisAddr));
                break;
            case OP_OR:
                KMem.CurVAL = KMem.CurVAL || GetCoilValue(thisAddrType, thisAddr);
                break;
            case OP_OR_:
                KMem.CurVAL = KMem.CurVAL || (!GetCoilValue(thisAddrType, thisAddr));
                break;
            default:
                break;
            }
            break;
            // 1 ?? ??
        case OP_OUT:
        case OP_SET:
        case OP_RESET:
            switch (thisOP)
            {
            case OP_OUT:
                SetCoilValue(thisAddrType, thisAddr, KMem.CurVAL);
                break;
            case OP_SET:
                if (KMem.CurVAL) SetCoilValue(thisAddrType, thisAddr, 1);
                break;
            case OP_RESET:
                if (KMem.CurVAL) SetCoilValue(thisAddrType, thisAddr, 0);
                break;
            default:
                break;
            }
            break;
            // ????
        case OP_ST_EQ:
        case OP_ST_NE:
        case OP_ST_LT:
        case OP_ST_GT:
        case OP_ST_LE:
        case OP_ST_GE:
        case OP_AN_EQ:
        case OP_AN_NE:
        case OP_AN_LT:
        case OP_AN_GT:
        case OP_AN_LE:
        case OP_AN_GE:
        case OP_OR_EQ:
        case OP_OR_NE:
        case OP_OR_LT:
        case OP_OR_GT:
        case OP_OR_LE:
        case OP_OR_GE:
            pBinProg2 = (stBinProg2 *)&pBinprog[CurPos];
            thisAddrType = pBinProg2->nParamType1;
            switch (thisOP)
            {
            case OP_ST_EQ:
                PushInVal();
                KMem.CurVAL = (GetVarData(thisAddrType, thisAddr) == GetVarData(pBinProg2->nParamType2, pBinProg2->nParamAddr2));
                break;
            case OP_ST_NE:
                PushInVal();
                KMem.CurVAL = (GetVarData(thisAddrType, thisAddr) != GetVarData(pBinProg2->nParamType2, pBinProg2->nParamAddr2));
                break;
            case OP_ST_LT:
                PushInVal();
                KMem.CurVAL = (GetVarData(thisAddrType, thisAddr) < GetVarData(pBinProg2->nParamType2, pBinProg2->nParamAddr2));
                break;
            case OP_ST_GT:
                PushInVal();
                KMem.CurVAL = (GetVarData(thisAddrType, thisAddr) > GetVarData(pBinProg2->nParamType2, pBinProg2->nParamAddr2));
                break;
            case OP_ST_LE:
                PushInVal();
                KMem.CurVAL = (GetVarData(thisAddrType, thisAddr) <= GetVarData(pBinProg2->nParamType2, pBinProg2->nParamAddr2));
                break;
            case OP_ST_GE:
                PushInVal();
                KMem.CurVAL = (GetVarData(thisAddrType, thisAddr) >= GetVarData(pBinProg2->nParamType2, pBinProg2->nParamAddr2));
                break;
            case OP_AN_EQ:
                KMem.CurVAL = KMem.CurVAL && (GetVarData(thisAddrType, thisAddr) == GetVarData(pBinProg2->nParamType2, pBinProg2->nParamAddr2));
                break;
            case OP_AN_NE:
                KMem.CurVAL = KMem.CurVAL && (GetVarData(thisAddrType, thisAddr) != GetVarData(pBinProg2->nParamType2, pBinProg2->nParamAddr2));
                break;
            case OP_AN_LT:
                KMem.CurVAL = KMem.CurVAL && (GetVarData(thisAddrType, thisAddr) < GetVarData(pBinProg2->nParamType2, pBinProg2->nParamAddr2));
                break;
            case OP_AN_GT:
                KMem.CurVAL = KMem.CurVAL && (GetVarData(thisAddrType, thisAddr) > GetVarData(pBinProg2->nParamType2, pBinProg2->nParamAddr2));
                break;
            case OP_AN_LE:
                KMem.CurVAL = KMem.CurVAL && (GetVarData(thisAddrType, thisAddr) <= GetVarData(pBinProg2->nParamType2, pBinProg2->nParamAddr2));
                break;
            case OP_AN_GE:
                KMem.CurVAL = KMem.CurVAL && (GetVarData(thisAddrType, thisAddr) >= GetVarData(pBinProg2->nParamType2, pBinProg2->nParamAddr2));
                break;
            case OP_OR_EQ:
                KMem.CurVAL = KMem.CurVAL || (GetVarData(thisAddrType, thisAddr) == GetVarData(pBinProg2->nParamType2, pBinProg2->nParamAddr2));
                break;
            case OP_OR_NE:
                KMem.CurVAL = KMem.CurVAL || (GetVarData(thisAddrType, thisAddr) != GetVarData(pBinProg2->nParamType2, pBinProg2->nParamAddr2));
                break;
            case OP_OR_LT:
                KMem.CurVAL = KMem.CurVAL || (GetVarData(thisAddrType, thisAddr) < GetVarData(pBinProg2->nParamType2, pBinProg2->nParamAddr2));
                break;
            case OP_OR_GT:
                KMem.CurVAL = KMem.CurVAL || (GetVarData(thisAddrType, thisAddr) > GetVarData(pBinProg2->nParamType2, pBinProg2->nParamAddr2));
                break;
            case OP_OR_LE:
                KMem.CurVAL = KMem.CurVAL || (GetVarData(thisAddrType, thisAddr) <= GetVarData(pBinProg2->nParamType2, pBinProg2->nParamAddr2));
                break;
            case OP_OR_GE:
                KMem.CurVAL = KMem.CurVAL || (GetVarData(thisAddrType, thisAddr) >= GetVarData(pBinProg2->nParamType2, pBinProg2->nParamAddr2));
                break;
            default:
                break;
            }
            nNextPos = 2;
            break;
            // ???
        case OP_TML:
        case OP_TMR:
        case OP_TMX:
        case OP_TMY:
            pBinProg15 = (stBinProg15 *)(&pBinprog[CurPos]);
            {
                unsigned char thisNum= pBinProg15->nOpNum;
                thisAddrType = pBinProg15->nParamType1;
                thisAddr = pBinProg15->nParamAddr1;
                switch (thisOP)
                {
                case OP_TML:
                    if (!KMem.Timers[thisNum].nInited) InitTimer(thisNum, 0);
                    if (KMem.CurVAL) RunTimer(thisNum, GetVarData(thisAddrType, thisAddr));
                    else StopTimer(thisNum);
                    KMem.CurVAL = ProcessTimer(thisNum);
                    break;
                case OP_TMR:
                    if (!KMem.Timers[thisNum].nInited) InitTimer(thisNum, 1);
                    if (KMem.CurVAL) RunTimer(thisNum, GetVarData(thisAddrType, thisAddr));
                    else StopTimer(thisNum);
                    KMem.CurVAL = ProcessTimer(thisNum);
                    break;
                case OP_TMX:
                    if (!KMem.Timers[thisNum].nInited) InitTimer(thisNum, 2);
                    if (KMem.CurVAL) RunTimer(thisNum, GetVarData(thisAddrType, thisAddr));
                    else StopTimer(thisNum);
                    KMem.CurVAL = ProcessTimer(thisNum);
                    break;
                case OP_TMY:
                    if (!KMem.Timers[thisNum].nInited) InitTimer(thisNum, 3);
                    if (KMem.CurVAL) RunTimer(thisNum, GetVarData(thisAddrType, thisAddr));
                    else StopTimer(thisNum);
                    KMem.CurVAL = ProcessTimer(thisNum);
                    break;
                default:
                    break;
                }
            }
            nNextPos = 2;
            break;
            // 1 ??????
        case OP_INC:
        case OP_DEC:
            pBinProg15 = (stBinProg15 *)(&pBinprog[CurPos]);
            thisAddrType = pBinProg15->nParamType1;
            thisAddr = pBinProg15->nParamAddr1;
            nNextPos = 2;
            switch (thisOP)
            {
            case OP_INC:
                if (KMem.CurVAL) SetVarData(thisAddrType, thisAddr, GetVarData(thisAddrType, thisAddr) + 1);
                break;
            case OP_DEC:
                if (KMem.CurVAL) SetVarData(thisAddrType, thisAddr, GetVarData(thisAddrType, thisAddr) - 1);
                break;
            default:
                break;
            }
            break;
            // 2??????
        case OP_MV:
        case OP_ADD2:
        case OP_SUB2:
            pBinProg2 = (stBinProg2 *)(&pBinprog[CurPos]);
            {
                int nParamType2, nParamAddr2;
                thisAddrType = pBinProg2->nParamType1;
                thisAddr = pBinProg2->nParamAddr1;
                nParamType2 = pBinProg2->nParamType2;
                nParamAddr2 = pBinProg2->nParamAddr2;
                switch (thisOP)
                {
                case OP_MV:
                    if (KMem.CurVAL) SetVarData(nParamType2, nParamAddr2, GetVarData(thisAddrType, thisAddr));
                    break;
                case OP_ADD2:
                    if (KMem.CurVAL) SetVarData(nParamType2, nParamAddr2, GetVarData(thisAddrType, thisAddr) + GetVarData(nParamType2, nParamAddr2));
                    break;
                case OP_SUB2:
                    if (KMem.CurVAL) SetVarData(nParamType2, nParamAddr2, GetVarData(nParamType2, nParamAddr2) - GetVarData(thisAddrType, thisAddr));
                    break;
                default:
                    break;
                }
            }
            nNextPos = 2;
            break;
            // 3 ??????
        case OP_ADD3:
        case OP_SUB3:
        case OP_MUL:
        case OP_DIV:
            pBinProg3 = (stBinProg3 *)(&pBinprog[CurPos]);
            int nParamType2, nParamAddr2;
            int nParamType3, nParamAddr3;
            thisAddrType = pBinProg3->nParamType1;
            thisAddr = pBinProg3->nParamAddr1;
            nParamType2 = pBinProg3->nParamType2;
            nParamAddr2 = pBinProg3->nParamAddr2;
            nParamType3 = pBinProg3->nParamType3;
            nParamAddr3 = pBinProg3->nParamAddr3;
            switch (thisOP)
            {
            case OP_ADD3:
                if (KMem.CurVAL) SetVarData(nParamType3, nParamAddr3, GetVarData(thisAddrType, thisAddr) + GetVarData(nParamType2, nParamAddr2));
                break;
            case OP_SUB3:
                if (KMem.CurVAL) SetVarData(nParamType3, nParamAddr3, GetVarData(thisAddrType, thisAddr) - GetVarData(nParamType2, nParamAddr2));
                break;
            case OP_MUL:
                if (KMem.CurVAL) {
                    short multiplicand = GetVarData(thisAddrType, thisAddr);
                    short multiplier = GetVarData(nParamType2, nParamAddr2);
                    int product = multiplicand * multiplier;
                    SetVarData(nParamType3, nParamAddr3, product);
                    SetVarData(nParamType3, nParamAddr3 + 1, product >> 16);
                }
                break;
            case OP_DIV:
                if (KMem.CurVAL) {
                    short dividend = GetVarData(thisAddrType, thisAddr);
                    short divisor = GetVarData(nParamType2, nParamAddr2);
                    short quotient = dividend / divisor;
                    short remainder = dividend % divisor;
                    SetVarData(nParamType3, nParamAddr3, quotient);
                    SetVarData(nParamType3, nParamAddr3 + 1, remainder);
                }
                break;
            default:
                break;
            }
            nNextPos = 3;
            break;
        default:
            break;
        }
        lastScanInputVal = PLCMem.ProgTrace[CurPos];
        PLCMem.ProgTrace[CurPos] = KMem.CurVAL;
        CurPos += nNextPos;
    }
    PLCMem.nScanCount++;
    return 0;
}
Src/functions.c
@@ -123,7 +123,7 @@
    return(crc);
}
 
/* Table of CRC values for high杘rder byte */
/* Table of CRC values for high-order byte */
const uint8_t crctablehi[] = {
    0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81,
    0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
@@ -144,7 +144,7 @@
    0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81,
    0x40
};
/* Table of CRC values for low杘rder byte */
/* Table of CRC values for low-order byte */
const uint8_t crctablelo[] = {
    0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x07, 0xC7, 0x05, 0xC5, 0xC4,
    0x04, 0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09,
@@ -180,26 +180,6 @@
    return (crchi << 8 | crclo);
}
 
const uint16_t crctalbeabs[] = {
    0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401,
    0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400
};
uint16_t crc16tablefast(const uint8_t *ptr, uint16_t len)
{
    uint16_t crc = 0xffff;
    uint16_t i;
    uint8_t ch;
    for (i = 0; i < len; i++) {
        ch = *ptr++;
        crc = crctalbeabs[(ch ^ crc) & 15] ^ (crc >> 4);
        crc = crctalbeabs[((ch >> 4) ^ crc) & 15] ^ (crc >> 4);
    }
    return crc;
}
void modbuscrc16test()
{
    printf("\n");
@@ -207,7 +187,7 @@
    printf("-----------------------------------------------------------------------\n");
    uint8_t crc16_data[] = { 0x01, 0x04, 0x04, 0x43, 0x6b, 0x58, 0x0e };    // expected crc value 0xD825.
    printf(" modbus crc16table test, expected value : 0xd825, calculate value : 0x%x\n", crc16table(crc16_data, sizeof(crc16_data)));
    printf(" modbus crc16tablefast test, expected value : 0xd825, calculate value : 0x%x\n", crc16tablefast(crc16_data, sizeof(crc16_data)));
//    printf(" modbus crc16tablefast test, expected value : 0xd825, calculate value : 0x%x\n", crc16tablefast(crc16_data, sizeof(crc16_data)));
    printf(" modbus crc16bitbybit test, expected value : 0xd825, calculate value : 0x%x\n", crc16bitbybit(crc16_data, sizeof(crc16_data)));
}
@@ -243,6 +223,19 @@
        return 0;
}
int Uart2RecvDMA(void * pBuf, int nSize)
{
    LL_DMA_DisableChannel(DMA1,LL_DMA_CHANNEL_5);
    LL_DMA_ConfigAddresses(DMA1,LL_DMA_CHANNEL_5, (uint32_t)&USART2->RDR,
         (uint32_t)pBuf, LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
    LL_DMA_SetDataLength(DMA1,LL_DMA_CHANNEL_5,nSize);
    LL_DMA_EnableChannel(DMA1,LL_DMA_CHANNEL_5);
    Uart2Stat.DMARecvLen=nSize;
    Uart2Stat.Recving=1;
    LL_DMA_EnableIT_TC(DMA1,LL_DMA_CHANNEL_5);
    LL_USART_EnableDMAReq_RX(USART2);
    return 0;
}
int Uart2SendDMA(void * pData, int nSize)
{
    LL_DMA_DisableChannel(DMA1,LL_DMA_CHANNEL_4);
@@ -265,6 +258,22 @@
        }
        return 0;
}
void TriggerPendSV()
{
      SCB->ICSR=SCB_ICSR_PENDSVSET_Msk; //1<<SCB_ICSR_PENDSVSET_Pos;
}
void PendSvCallBack()
{
    if (Uart2Stat.bPacketRecved)
    {
        ParsePacket((pPacket)Uart2RecvBuf1,Uart2RecvBuf1DataLen);
        Uart2RecvBuf1DataLen=0;
        Uart2Stat.bPacketRecved=0;
        Uart2RecvDMA(Uart2RecvBuf1,sizeof(Uart2RecvBuf1));
    }
}
void Uart1SendDone()
{
    Uart1Stat.TcCount++;
@@ -275,9 +284,12 @@
{
        Uart1Stat.IdelCount++;
//        NVIC_SetPendingIRQ(PendSV_IRQn);
//      SCB->ICSR=SCB_ICSR_PENDSVSET_Msk; //1<<SCB_ICSR_PENDSVSET_Pos;
    if (Uart1RecvBuf1DataLen >0)
    {
        Uart1Stat.bPacketRecved=1;
//      SCB->ICSR=SCB_ICSR_PENDSVSET_Msk; //1<<SCB_ICSR_PENDSVSET_Pos;
//        KLParsePacket(Uart1RecvBuf1,Uart1RecvBuf1DataLen);
//        Uart1RecvBuf1DataLen=0;
    }
@@ -289,10 +301,12 @@
}
void Uart2RecvDone()
{
    Uart2RecvBuf1DataLen=sizeof(Uart2RecvBuf1) - LL_DMA_GetDataLength(DMA1,LL_DMA_CHANNEL_5);
    Uart2Stat.bPacketRecved=1;
    Uart2Stat.IdelCount++;
    ParsePacket((pPacket)Uart2RecvBuf1,Uart2RecvBuf1DataLen);
    Uart2RecvBuf1DataLen=0;
    if (Uart2RecvBuf1DataLen>0)
        TriggerPendSV();
    //    ParsePacket((pPacket)Uart2RecvBuf1,Uart2RecvBuf1DataLen);
}
int PutStr(char * str1, int len1)
@@ -315,11 +329,11 @@
}
int PutStr2(char * str1, int len1)
{
//    Uart1SendDMA(str1,len1);
    PushIn(&Uart2Stat.QTx,str1,len1);
    Uart2SendDMA(str1,len1);
//    PushIn(&Uart2Stat.QTx,str1,len1);
//    LL_USART_EnableIT_TXE(USART1);   
//    LL_USART_EnableIT_TC(USART1);     
    Uart2TriggerSendDMA();
//    Uart2TriggerSendDMA();
    return len1;
}
@@ -390,6 +404,7 @@
unsigned int Input165_8()
{
    int x1=0;
    __disable_irq();
    set165SL_0();    set165SL_1();
    unsigned int mask1=0x0080;
    volatile uint32_t * p1=&GPIOA->IDR;
@@ -405,12 +420,14 @@
        mask1>>=1;
        set165CLK_1();
    }
    __enable_irq();
    return x1;
}
unsigned int Input165(int nBit)
{
    int x1=0;
    __disable_irq();
    set165SL_0();    set165SL_1();
    unsigned int mask1=1<<(nBit-1);
    volatile uint32_t * p1=&GPIOA->IDR;
@@ -426,11 +443,12 @@
        mask1>>=1;
        set165CLK_1();
    }
    __enable_irq();
    return x1;
}
unsigned int Input165_R(int nBit)
{
    __disable_irq();
    set165SL_0();    set165SL_1();
    int nBytes = nBit /8;
    volatile uint32_t * p1=&GPIOA->IDR;
@@ -458,13 +476,14 @@
        }
        rdata.Bytes[i]=x1;
    }
    __enable_irq();
    return rdata.intvalue;
}
unsigned int Input165Cfg(int nBit)
{
    int x1=0;
    __disable_irq();
    set165SL_0();    set165SL_1();
    unsigned int mask1=1<<(nBit-1);
    volatile uint32_t * p1=&GPIOA->IDR;
@@ -480,6 +499,7 @@
        mask1>>=1;
        set165CLK_1();
    }
    __enable_irq();
    return x1;
}
@@ -601,12 +621,12 @@
    }
}
#define SRCLK_0() //LL_GPIO_ResetOutputPin(GPIOB,LL_GPIO_PIN_13)
#define SRCLK_1() //LL_GPIO_SetOutputPin(GPIOB,LL_GPIO_PIN_13)
#define STRCLK_0() LL_GPIO_ResetOutputPin(GPIOB,LL_GPIO_PIN_12)
#define STRCLK_1() LL_GPIO_SetOutputPin(GPIOB,LL_GPIO_PIN_12)
#define SER_0() //LL_GPIO_ResetOutputPin(GPIOB,LL_GPIO_PIN_15)
#define SER_1() //LL_GPIO_SetOutputPin(GPIOB,LL_GPIO_PIN_15)
#define SRCLK2_0() LL_GPIO_ResetOutputPin(GPIOB,LL_GPIO_PIN_13)
#define SRCLK2_1() LL_GPIO_SetOutputPin(GPIOB,LL_GPIO_PIN_13)
#define STRCLK2_0() LL_GPIO_ResetOutputPin(GPIOB,LL_GPIO_PIN_12)
#define STRCLK2_1() LL_GPIO_SetOutputPin(GPIOB,LL_GPIO_PIN_12)
#define SER2_0() LL_GPIO_ResetOutputPin(GPIOB,LL_GPIO_PIN_15)
#define SER2_1() LL_GPIO_SetOutputPin(GPIOB,LL_GPIO_PIN_15)
void Enable595(uchar bEnable)
{
@@ -619,52 +639,92 @@
//unsigned char i;
;//        74HC595输出程序,输出8位
//    cc=~0x3f;
    STRCLK_1();
    __disable_irq();
    STRCLK2_1();
    unsigned int mask1=0x0080;
    //volatile uint32_t * p1 = &GPIOB->BRR;
    //volatile uint32_t * p2 = &GPIOB->BSRR;
    for (;mask1;)
    {
        SRCLK_0();
        SRCLK2_0();
        //*p1=LL_GPIO_PIN_13;
        if (cc&mask1) {SER_1();}
        else {SER_0();}
        if (cc&mask1) {SER2_1();}
        else {SER2_0();}
        mask1>>=1;
        SRCLK_1();
        SRCLK2_1();
//        __nop();
        //*p2=LL_GPIO_PIN_13;
    }
    STRCLK_0();
    STRCLK_1();
    STRCLK2_0();
    STRCLK2_1();
    __enable_irq();
}
void Output595_16(unsigned int cc)
{
//unsigned char i;
;//        74HC595输出程序,输出8位
//    cc=~0x3f;
    STRCLK_1();
    __disable_irq();
    STRCLK2_1();
    unsigned int mask1=0x8000;
    //volatile uint32_t * p1 = &GPIOB->BRR;
    //volatile uint32_t * p2 = &GPIOB->BSRR;
    for (;mask1;)
    {
        SRCLK_0();
        SRCLK2_0();
        //*p1=LL_GPIO_PIN_13;
        if (cc&mask1) {SER_1();}
        else {SER_0();}
        if (cc&mask1) {SER2_1();}
        else {SER2_0();}
        mask1>>=1;
        SRCLK_1();
        SRCLK2_1();
//        __nop();
        //*p2=LL_GPIO_PIN_13;
    }
    STRCLK_0();
    STRCLK_1();
    STRCLK2_0();
    STRCLK2_1();
    __enable_irq();
}
void PutOutput(unsigned int Y)
{
//    Output595_16(Y);
    STRCLK_1();
    LL_SPI_TransmitData8(SPI2,Y);
#define STRCLK12_0() LL_GPIO_ResetOutputPin(GPIOB,LL_GPIO_PIN_7)
#define STRCLK12_1() LL_GPIO_SetOutputPin(GPIOB,LL_GPIO_PIN_7)
void PutOutputSPI1(unsigned int Y)
{
    __disable_irq();
    STRCLK12_1();
    LL_SPI_TransmitData8(SPI1,Y>>8);
    int i=0;
    while (LL_SPI_IsActiveFlag_TXE(SPI1) == RESET)
    {
    }
    KMem.SDD[28]=i;
    i=0;
    while (LL_SPI_IsActiveFlag_BSY(SPI1) == SET)
    {
        i++;
    }
    LL_SPI_TransmitData8(SPI1,Y);
    while (LL_SPI_IsActiveFlag_TXE(SPI1) == RESET)
    {
    }
    KMem.SDD[28]=i;
    i=0;
    while (LL_SPI_IsActiveFlag_BSY(SPI1) == SET)
    {
        i++;
    }
    KMem.SDD[30]=i;
        STRCLK12_0();
        STRCLK12_1();
    __enable_irq();
}
void PutOutputSPI2(unsigned int Y)
{
    __disable_irq();
    STRCLK2_1();
    LL_SPI_TransmitData8(SPI2,Y>>8);
    int i=0;
    while (LL_SPI_IsActiveFlag_TXE(SPI2) == RESET)
    {
@@ -675,14 +735,31 @@
    {
        i++;
    }    
    LL_SPI_TransmitData8(SPI2,Y);
    while (LL_SPI_IsActiveFlag_TXE(SPI2) == RESET)
    {
    }
    KMem.SDD[28]=i;
    i=0;
    while (LL_SPI_IsActiveFlag_BSY(SPI2) == SET)
    {
        i++;
    }
    KMem.SDD[30]=i;
        STRCLK_0();
        STRCLK_1();
        STRCLK2_0();
        STRCLK2_1();
    __enable_irq();
}
void PutOutput(unsigned int Y)
{
    PutOutputSPI2(Y);
    //Output595_16(Y);
}
#if (BOARD_TYPE == 9 || BOARD_TYPE == 10 )
//#pragma message("9,10")
    // V4.2 管脚排列向右移动了一位。
#define SRCLK1_0() LL_GPIO_ResetOutputPin(GPIOB,LL_GPIO_PIN_1)
#define SRCLK1_1() LL_GPIO_SetOutputPin(GPIOB,LL_GPIO_PIN_1)
#define STRCLK1_0() LL_GPIO_ResetOutputPin(GPIOB,LL_GPIO_PIN_2)
@@ -691,7 +768,7 @@
#define OE1_1() LL_GPIO_SetOutputPin(GPIOB,LL_GPIO_PIN_10)
#define SER1_0() LL_GPIO_ResetOutputPin(GPIOB,LL_GPIO_PIN_11)
#define SER1_1() LL_GPIO_SetOutputPin(GPIOB,LL_GPIO_PIN_11)
#else
#else        //按照原来的管脚排列
#define SRCLK1_0() LL_GPIO_ResetOutputPin(GPIOB,LL_GPIO_PIN_0)
#define SRCLK1_1() LL_GPIO_SetOutputPin(GPIOB,LL_GPIO_PIN_0)
#define STRCLK1_0() LL_GPIO_ResetOutputPin(GPIOB,LL_GPIO_PIN_1)
@@ -713,6 +790,7 @@
//unsigned char i;
;//        74HC595输出程序,输出8位
//    cc=~0x3f;
    __disable_irq();
    STRCLK1_1();
    unsigned int mask1=0x8000;
    //volatile uint32_t * p1 = &GPIOB->BRR;
@@ -729,5 +807,6 @@
        //*p2=LL_GPIO_PIN_13;
    }
    STRCLK1_0();
    STRCLK1_1();
    STRCLK1_1();
    __enable_irq();
}
Src/main.c
@@ -49,22 +49,23 @@
#include "KLink.h"
#include "string.h"
#include "BSP.h"
#include "ModbusRTU.h"
/* USER CODE END Includes */
/* Private variables ---------------------------------------------------------*/
#define ADCrefAddr 0x1FFFF7BA
/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/
#define RXBUFSIZE 128
#define TXBUFSIZE 128
#define RX2BUFSIZE 128
#define TX2BUFSIZE 128
unsigned char Uart1RxBuf[256];
unsigned char Uart1TxBuf[512];
unsigned char Uart2RxBuf[RXBUFSIZE];
unsigned char Uart2TxBuf[TXBUFSIZE];
unsigned char Uart2RxBuf[RX2BUFSIZE];
unsigned char Uart2TxBuf[TX2BUFSIZE];
//unsigned char buf1[128];    
@@ -92,6 +93,7 @@
int LastCircleStartTime=0;
int CircleTime=0;
stBinProg1 * pProgs = (stBinProg1 *)STORE_PRG_BASE;
//volatile unsigned int nRunCount=0;
volatile int nCount2=0;
@@ -109,6 +111,12 @@
/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/
const unsigned char LEDSEGTAB[]={
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,    //0-F
0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef,0xf7,0xfc,0xb9,0xde,0xf9,0xf1,  //0.-F.
0x00,0x40,            //  ,-,_,~,o,n,N,<,>,J,r,
};
/* USER CODE END PFP */
@@ -254,12 +262,12 @@
        
        PutStr(str1,len1);
    InitTimer(0,0);
    InitTimer(1,1);
    InitTimer(2,2);
    InitTimer(3,3);
//    InitTimer(0,0);
//    InitTimer(1,1);
//    InitTimer(2,2);
//    InitTimer(3,3);
    
    StartTimer(0,1000);
//    RunTimer(0,1000);
//    StartTimer(2,1000);
    Locate(13,1);LineCount=3;
    return 0;
@@ -269,9 +277,24 @@
int ADCProcess()
{
                    uint16_t ADC_ConvertedValue=0;
    // ADC channels
    //  0 -- 24V  --> 0
    //  1 -- 5V   --> 2
    //    2 --
    //  3 --
    //  4 --
    //  5 --
    //  6 --
    //  7 --
    //  8 --
    //                         --> 5
    // 16 -- Temp  --> 6
    // 17 -- Vref  --> 7
    uint16_t ADC_ConvertedValue=0;
static int CurChannel=LL_ADC_CHANNEL_0;
//static int waitcount = 0;
                if (!LL_ADC_REG_IsConversionOngoing(ADC1))
                {
                    //waitcount++;
@@ -285,8 +308,8 @@
                    if ((channels & LL_ADC_CHANNEL_0) == LL_ADC_CHANNEL_0)
                    {
                        KMem.ADCValues[0] = ADC_ConvertedValue;
                        nextchannel = LL_ADC_CHANNEL_7;
                    }else if ((channels & LL_ADC_CHANNEL_7) == LL_ADC_CHANNEL_7)
                        nextchannel = LL_ADC_CHANNEL_8;
                    }else if ((channels & LL_ADC_CHANNEL_8) == LL_ADC_CHANNEL_8)
                    {
                        KMem.ADCValues[2] = ADC_ConvertedValue;                        
                        nextchannel = LL_ADC_CHANNEL_TEMPSENSOR;
@@ -304,6 +327,8 @@
                    }else if ((channels & LL_ADC_CHANNEL_17) == LL_ADC_CHANNEL_17)
                    {
                        KMem.ADCValues[7] = ADC_ConvertedValue;                        
                        KMem.ADCValues[5] = *((unsigned short *)ADCrefAddr);
                        nextchannel = LL_ADC_CHANNEL_0;
                    }else
                    {
@@ -372,10 +397,10 @@
                timeus2=GetuS();
                sprintftime = timeus1 - theUs;
                putstrtime = timeus2 - timeus1;
                if (IsTimerOn(0)) {StartTimer(1,1000);StopTimer(3);}
                if (IsTimerOn(1)) {StartTimer(2,100);StopTimer(0);}
                if (IsTimerOn(2)) {StartTimer(3,10);StopTimer(1);}
                if (IsTimerOn(3)) {StartTimer(0,10000);StopTimer(2);}
                if (IsTimerOn(0)) {RunTimer(1,1000);StopTimer(3);}
                if (IsTimerOn(1)) {RunTimer(2,100);StopTimer(0);}
                if (IsTimerOn(2)) {RunTimer(3,10);StopTimer(1);}
                if (IsTimerOn(3)) {RunTimer(0,10000);StopTimer(2);}
          }
            if ((nRunCount2 & 0xff) == 0x2f && 0)
            {
@@ -395,21 +420,22 @@
    
            int len1=0;
            if ((MasterRecved && thisuS-SendTimeuS>50) || thisuS-SendTimeuS>1500u)
            if ((MasterRecved && MasterRecvOK && thisuS-SendTimeuS>50) || thisuS-SendTimeuS>1000u)
            {
                if (!MasterRecved)
                if (!MasterRecvOK)
                {
                    TimeOutCount++;
                    Uart2Stat.TimeOutErr++; 
                    ChnStats[nCurPollId].LostPackets++;
                    ChnStats[nCurPollId].CtnLstPkts++;
                    if (!MasterRecved) {ChnStats[nCurPollId].TimeOutErr++;}
                    if (ChnStats[nCurPollId].CtnLstPkts>ChnStats[nCurPollId].MaxCtnLstPkts)
                    {ChnStats[nCurPollId].MaxCtnLstPkts=ChnStats[nCurPollId].CtnLstPkts;}
                    if (ChnStats[nCurPollId].CtnLstPkts>3)
                    {
                        ChnStats[nCurPollId].Stat=0;
                        KMem.ErrStat=200;
                        {BufferIn[nCurPollId]=0;}
                    }
                //    LL_GPIO_SetOutputPin(GPIOA,LL_GPIO_PIN_7);
@@ -426,7 +452,16 @@
                    LastCircleStartTime=thisuS;
                    nSeq++;
                    nCurPollId=1;
                }
                }
                if (KMRunStat.WorkMode==0)
                {
                    KMem.WX[0]= GetInput();
                    KMem.WY[1]=KMem.WX[0]&0xff;
                    KMem.WY[2]=(KMem.WX[0]>>8)&0xff;
                }
                BufferOut[1]=KMem.WY[1];
                BufferOut[2]=KMem.WY[2];
                Datas[0]=BufferOut[nCurPollId];
                Datas[1]=BufferOut[nCurPollId+1];;
                Datas[2]=ChnStats[nCurPollId].Stat;
@@ -446,6 +481,7 @@
                SendTime=tick1;
                MasterRecved=0;
                MasterRecvOK=0;
            //    LL_GPIO_TogglePin(GPIOA,LL_GPIO_PIN_5);        
                //ToggleErrLed();
//                ToggleOut8();
@@ -464,17 +500,17 @@
        int thisRecvTime=RecvTimeuS;
        if (SlaveRecved)
        {
            KMem.RunStat=100;
            KMem.RunStat=8000;
            SlaveRecved=0;
        }else if ((ThisuS - thisRecvTime) >12000u)
        {
            KMem.ErrStat=200;
            KMem.ErrStat=8000;
            KMem.SDD[17]=1;
            KMem.SDD[18]=ThisuS;
            KMem.SDD[19]=RecvTimeuS;
        }else if ( ThisuS > (thisRecvTime + 12000u))
        {
            KMem.ErrStat=200;
            KMem.ErrStat=8000;
            KMem.SDD[17]=2;
            KMem.SDD[18]=ThisuS;
            KMem.SDD[19]=RecvTimeuS;
@@ -544,7 +580,7 @@
  /* USER CODE BEGIN SysInit */
    TickFreq=10000;        //Tick频率
    InituS(TickFreq);    
  HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/TickFreq);    //ÖØж¨ÒåSysTickµÄƵÂÊÎ
 // HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/TickFreq);    //ÖØж¨ÒåSysTickµÄƵÂÊÎ
  /* USER CODE END SysInit */
@@ -565,7 +601,8 @@
    if (KMem.EffJumperSW == 0x00) Uart1Baud = DefaultUart1Baud;
  MX_USART1_UART_Init();
  MX_USART2_UART_Init();
//    MX_SPI1_Init();
    MX_SPI1_Init();
    MX_SPI2_Init();
  MX_ADC_Init();
    MX_IWDG_Init();
@@ -575,7 +612,8 @@
    LL_USART_EnableIT_IDLE(USART1);
    LL_USART_EnableIT_TC(USART1);
    LL_USART_EnableIT_RXNE(USART2);
//    LL_USART_EnableIT_RXNE(USART2);
    Uart2RecvDMA(Uart2RecvBuf1,sizeof(Uart2RecvBuf1));
    LL_USART_EnableIT_IDLE(USART2);
    LL_USART_EnableIT_TC(USART2);
    
@@ -605,8 +643,34 @@
            EnableDisIn(1);                //Input Diaplay Enable 595 
        }
    SetOutStat(0);            //OK Good, signal
//    ShowInitInfo();
    ShowInitInfo();
    KMem.LastScanTime = GetuS();
/*
    int time1=GetuS();
    PutOutput(0x01);
    int x;
    while (1)
    {
        x = GetInput();
        if (x&0x1) break;
    }
    int time2=GetuS();
    KMem.SDD[17]=time2-time1;
    PutOutput(0x00);
    while (1)
    {
        x = GetInput();
        if ((x&0x1) == 0) break;
    }
    int time3=GetuS();
    KMem.SDD[18]=time3-time2;
*/
    InitPLC();
    StartPLC();
    KMRunStat.WorkMode=1;
    KMem.WX[5]=0x5a;
  while (1)
  {
        //int MyKeyStat1,MyKeyStat2;
@@ -620,15 +684,17 @@
        us1=GetuS();
        int haltick=HAL_GetTick();
        
        int CurJumperSW=ReadJumperSW();
        KMem.CurJumperSW=CurJumperSW;
//        int CurJumperSW=ReadJumperSW();
//        KMem.CurJumperSW=CurJumperSW;
        KMem.haltick=haltick;
//        KMem.TotalRunTime=TotalRunTime;
//        KMem.ThisRunTime=ThisRunTime;        
        
//        *((unsigned int *)&(PLCMem.SDT[2]))=nChilds;
        KMem.WX[0]= GetInput();
//        KMem.SDD[13]=PendSvCount;
//        KMem.SDD[14]=RCC->CSR;
        KMem.WX[0]= GetInput();
        
        if (GetBoardType() == 7 || GetBoardType() ==8 
            || GetBoardType() == 9 || GetBoardType() ==10 ) 
@@ -636,13 +702,27 @@
            displayInput(KMem.WX[0]);
        }
        us2=GetuS();
//        ProcessPLCPROG(prog1, nSizeProg1);
//        ScanTimeuS=us2-LastScanTime;
//        LastScanTime = us2;
//        pProgs = (stBinProg1 *) STORE_PRG_BASE;
        if (    KMRunStat.WorkMode==1)
        {
        if (KMRunStat.nBinProgBank == 0){
            pProgs=(stBinProg1 *)STORE_PRG_BASE;
        }else {
            pProgs=(stBinProg1 *)ALT_PRG_BASE;
        }
        nSizeProg1=KMRunStat.nBinProgSize;
        ProcessPLCBinProg(pProgs, nSizeProg1);
        }
        KMem.ScanTimeuS=us2-KMem.LastScanTime;
        KMem.LastScanTime = us2;
        if (KMem.ScanTimeuS < KMem.MinScanTimeuS) {KMem.MinScanTimeuS = KMem.ScanTimeuS;}
        if (KMem.ScanTimeuS > KMem.MaxScanTimeuS) {KMem.MaxScanTimeuS = KMem.ScanTimeuS;}
        if (repeater)        {    RepeaterFunc();    }
//        if (repeater)        {    RepeaterFunc();    }
        us3=GetuS();
        if ((KMem.nRunCount &0x1f) == 0x02)
        {
@@ -667,11 +747,11 @@
        }
        if (bMaster)        
        {
            BufferOut[1]=KMem.WX[0]&0xff;
            BufferOut[2]=(KMem.WX[0]>>8)&0xff;
//            BufferOut[1]=KMem.WX[0]&0xff;
//            BufferOut[2]=(KMem.WX[0]>>8)&0xff;
            MasterFunc();
            
            KMem.WY[0]=BufferIn[1]+(BufferIn[2]<<8);
//            KMem.WY[0]=BufferIn[1]+(BufferIn[2]<<8);
            if (haltick&0x00002000) SlowFlicker=1;
            else SlowFlicker=0;
@@ -681,7 +761,7 @@
        }
        if (bSlave)        
        {
            BufferOut[0]=KMem.WX[0];
//            BufferOut[0]=KMem.WX[0];
            SlaveFunc();    
            if (! KMem.RunStat) {BufferIn[0]=0;}
            KMem.WY[0]=BufferIn[0];
@@ -738,7 +818,12 @@
//        SDT[48]=55;
        if (Uart1RecvBuf1DataLen >0 && Uart1Stat.bPacketRecved)
        {
            KLParsePacket(Uart1RecvBuf1,Uart1RecvBuf1DataLen);
            int res1 = -1;
            res1 = ModBusSlaveParsePkg(Uart1RecvBuf1,Uart1RecvBuf1DataLen);
            if (res1 !=0)
            {
                KLParsePacket(Uart1RecvBuf1,Uart1RecvBuf1DataLen);
            }
            Uart1RecvBuf1DataLen=0;
            Uart1Stat.bPacketRecved=0;
        }
@@ -752,7 +837,23 @@
                clearscreen();
            }
        }
*/
*/
        unsigned char pos,seg;
        unsigned short val;
        pos=((KMem.nRunCount)&0x3);
        //val=(KMem.nRunCount)&0xfff;
        val=KMem.ErrStat;
        char buf5[20];
        sprintf(buf5,"%4d",val);
        val=buf5[3-pos];
        if (val <'0' || val >'9') {seg=0;}
        else {seg=LEDSEGTAB[val-'0'];}
        pos=1<<pos;
        //pos=1;
        //seg=2;
        seg=~seg;
        PutOutputSPI1(pos|(seg<<8));
     LL_IWDG_ReloadCounter(IWDG);
        
  }    //while (1) ;
Src/stm32f0xx_it.c
@@ -95,9 +95,11 @@
void PendSV_Handler(void)
{
  /* USER CODE BEGIN PendSV_IRQn 0 */
    NVIC_ClearPendingIRQ(PendSV_IRQn);
  SCB->ICSR=SCB_ICSR_PENDSVCLR_Msk; //1<<SCB_ICSR_PENDSVCLR_Pos;
//    NVIC_ClearPendingIRQ(PendSV_IRQn);
    PendSvCount++;
    NVIC_DisableIRQ(PendSV_IRQn);
//    NVIC_DisableIRQ(PendSV_IRQn);
    PendSvCallBack();
  /* USER CODE END PendSV_IRQn 0 */
  /* USER CODE BEGIN PendSV_IRQn 1 */
@@ -174,10 +176,11 @@
    Uart2DmaInts++;
    if (LL_DMA_IsActiveFlag_TC4(DMA1))
    {
        LL_DMA_ClearFlag_TC4(DMA1);
/*
        Uart2Stat.SendBytes+=Uart2Stat.DMASendLen;
        DelData(&Uart2Stat.QTx,Uart2Stat.DMASendLen);
        LL_DMA_ClearFlag_TC4(DMA1);
        
        if (!IsEmpty(&Uart2Stat.QTx))
        {
@@ -191,6 +194,7 @@
            LL_USART_EnableDMAReq_TX(USART2);
        }
        else
*/
        {
            Uart2Stat.DMASendLen=0;
            Uart2Stat.Sending=0;
@@ -202,6 +206,7 @@
    if (LL_DMA_IsActiveFlag_TC5(DMA1))
    {
        LL_DMA_ClearFlag_TC5(DMA1);
    }
  /* USER CODE END DMA1_Channel4_5_IRQn 1 */
@@ -220,7 +225,7 @@
        Uart1BaudFirstGot=1;
        Uart1Stat.RXNECount++;
        unsigned char ch=LL_USART_ReceiveData8(USART1);
        PushOne(&Uart1Stat.QRx,ch);
        // PushOne(&Uart1Stat.QRx,ch);
        Uart1Stat.RecvBytes++;
        Uart1RecvBuf1[Uart1RecvBuf1DataLen++]=ch;
        //LL_USART_TransmitData8(USART1,ch);
@@ -252,13 +257,11 @@
    if (LL_USART_IsActiveFlag_RXNE(USART2))
    {
        Uart2BaudGot=1;
        Uart2BaudFirstGot=1;
        Uart2Stat.RXNECount++;
        unsigned char ch=LL_USART_ReceiveData8(USART2);
        PushOne(&Uart2Stat.QRx,ch);
        Uart2Stat.RecvBytes++;
        Uart2RecvBuf1[Uart2RecvBuf1DataLen++]=ch;
    //    unsigned char ch=LL_USART_ReceiveData8(USART2);
    //    Uart2Stat.RXNECount++;
        // PushOne(&Uart2Stat.QRx,ch);
    //    Uart2Stat.RecvBytes++;
    //    Uart2RecvBuf1[Uart2RecvBuf1DataLen++]=ch;
        //LL_USART_TransmitData8(USART2,ch);
    }
Src/system_stm32f0xx.c
@@ -97,7 +97,7 @@
  * @{
  */
#if !defined  (HSE_VALUE) 
  #define HSE_VALUE    ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz.
  #define HSE_VALUE    ((uint32_t)12000000) /*!< Default value of the External oscillator in Hz.
                                                This value can be provided and adapted by the user application. */
#endif /* HSE_VALUE */
@@ -133,7 +133,7 @@
               call the 2 first functions listed above, since SystemCoreClock variable is 
               updated automatically.
  */
uint32_t SystemCoreClock = 8000000;
uint32_t SystemCoreClock = 12000000;
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
const uint8_t APBPrescTable[8]  = {0, 0, 0, 0, 1, 2, 3, 4};