QuakeGod
2023-05-26 db25c9f050a690bbec032ef3f93e244c7ec2dbee
PLCFunction fix2
10个文件已修改
167 ■■■■■ 已修改文件
Inc/GlobalDef.h 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Inc/KMachine.h 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Inc/KWireLess.h 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Inc/PLCfunctions.h 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Src/KBus.c 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Src/KLink.c 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Src/KMachine.c 89 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Src/KWireLess.c 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Src/PLCfunctions.c 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Src/main.c 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Inc/GlobalDef.h
@@ -43,9 +43,7 @@
    
};
#define BOARD_TYPE 16
#define BOARD_VER 1
#define XLAT_FREQ 8
#define BOARD_TYPE 9
#define BOARD_VER 1
#if (BOARD_TYPE == 11)
Inc/KMachine.h
@@ -20,16 +20,16 @@
#define ALT_PRG_PAGESIZE (0x00000400)                            //Page Size = 1K
#define ALT_PRG_PAGES 4                                                    //use 4 pages
#define STORE_SYSREG_BASE (FLASH_BASE + 0x0000A000)        //40k //and
#define STORE_SYSREG_BASE (FLASH_BASE + 0x0000C000)        //40k //and
#define STORE_SYSREG_PAGESIZE (0x00000400)                            //Page Size = 1K
#define STORE_SYSREG_PAGES 1                                                        //use 1 pages
#define STORE_RUNSTAT_BASE (FLASH_BASE + 0x0000A800)        //44k K //and
#define STORE_RUNSTAT_BASE (FLASH_BASE + 0x0000C800)        //44k K //and
#define STORE_RUNSTAT_PAGESIZE (0x00000400)                            //Page Size = 1K
#define STORE_RUNSTAT_PAGES 1                                                        //use 1 pages
#define STORE_LOG_BASE (FLASH_BASE + 0x0000C000)        //48k and FLASH_BANK1_END
#define STORE_LOG_BASE (FLASH_BASE + 0x0000D000)        //48k and FLASH_BANK1_END
#define STORE_LOG_PAGESIZE (0x00000400)                            //Page Size = 1K
#define STORE_LOG_PAGES 4                                                        //use 4 pages
Inc/KWireLess.h
@@ -37,7 +37,7 @@
void LedToggle(void);
typedef enum tag_KWStates
typedef enum tagenKWStates
{
    KW_PON,
    KW_UNINIT,
@@ -51,7 +51,7 @@
    KW_ERROR1,
    KW_ERROR2,
    KW_ERROR3,
}KWStates;
}enKWStates;
int KWMasterProc(void);
@@ -60,5 +60,13 @@
int KWSendPkg(void* pPkg, int len);
int KWProcPkg(void);
/*
typedef struct KWStates
{
}stKWStat,*pstKWstat;
*/
#endif ///*  __KBUS_H__  */
Inc/PLCfunctions.h
@@ -21,7 +21,7 @@
{
    int bPLCRunning;
    int nScanCount;
    char ProgTrace[512];
    unsigned short ProgTrace[256];
    
}stPLCMem;
extern stPLCMem PLCMem;
Src/KBus.c
@@ -310,9 +310,9 @@
                }
#else
                BufferIn[ChildId]=p1->data[0];
                KMem.WX[ChildId]=BufferIn[ChildId];
                KMem.WLX[ChildId]=BufferIn[ChildId];
                if (KMRunStat.WorkMode==0) {    
                    KMem.WY[0]= KMem.WX[1]+(KMem.WX[2]<<8)    ;
                    KMem.WY[0]= KMem.WLX[1]+(KMem.WLX[2]<<8)    ;
                    PutOutput (KMem.WY[0]);
                }
#endif
@@ -590,11 +590,11 @@
            if (KMRunStat.WorkMode==0)
            {
                KMem.WX[0]= GetInput();
                KMem.WY[1]=KMem.WX[0]&0xff;
                KMem.WY[2]=(KMem.WX[0]>>8)&0xff;
                KMem.WLY[1]=KMem.WX[0]&0xff;
                KMem.WLY[2]=(KMem.WX[0]>>8)&0xff;
            }
            BufferOut[1]=KMem.WY[1];
            BufferOut[2]=KMem.WY[2];
            BufferOut[1]=KMem.WLY[1];
            BufferOut[2]=KMem.WLY[2];
#endif
            Datas[0]=BufferOut[nCurPollId];
Src/KLink.c
@@ -194,7 +194,7 @@
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,p1->nCMD,0,0);
                SendPacket(nChn, p2, PacketLen);
                break;
            case KLCmdRead:
            case KLCmdReadDataWord:
            case KLCmdReadDataByte:                
@@ -292,7 +292,10 @@
            case KLCmdWriteBits:
                break;
            case KLCmdChgMode:
                if (nDataType ==0) {StopPLC();}
                if (nDataType == 1) {StartPLC();}
                PacketLen=KLMakeRplyPacket(p2,nDstHost,nKLStatus.StatByte,p1->nCMD,0,0);
                SendPacket(nChn, p2, PacketLen);
                break;
            case KLCmdReadProgram:
                nWordAddr=p1->Params[0]+ (p1->Params[1]<<8);
Src/KMachine.c
@@ -60,47 +60,47 @@
{
    START_SIGN,
    0x0000,
    CFG_VER,
    0x0000,
    0x0000,
    0x0000,
    {
        {
            PortType_KLink,    //PorttType
            1,                            //Station
            2304,                        //Buadrate = * 100;
            0,                            //ByteSize
            0,                            //Parity
            0,                            //StopBits
            0,                            //endType
            0,                            //EofChar
            0,                            //SofChar
            0,                            //endtime
            0,                            //recvbuf
            0,                            //bufsize
        CFG_VER,
        0x0000,                //workmode
        0x0000,                //switchfunc
        0x0000,                //pad1;
        {                //comportparam[2]
            {
                PortType_KLink,    //PorttType
                1,                            //Station
                2304,                        //Buadrate = * 100;
                0,                            //ByteSize
                0,                            //Parity
                0,                            //StopBits
                0,                            //endType
                0,                            //EofChar
                0,                            //SofChar
                0,                            //endtime
                0,                            //recvbuf
                0,                            //bufsize
            },
            {
                PortType_KBus,    //PorttType
                0,                            //Station
                2304,                        //Buadrate = * 100;
                0,                            //ByteSize
                0,                            //Parity
                0,                            //StopBits
                0,                            //endType
                0,                            //EofChar
                0,                            //SofChar
                0,                            //endtime
                0,                            //recvbuf
                0,                            //bufsize
            }
        },
        {
            PortType_KBus,    //PorttType
            0,                            //Station
            2304,                        //Buadrate = * 100;
            0,                            //ByteSize
            0,                            //Parity
            0,                            //StopBits
            0,                            //endType
            0,                            //EofChar
            0,                            //SofChar
            0,                            //endtime
            0,                            //recvbuf
            0,                            //bufsize
        }
    },
    {{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}},
    {{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1}},
    {        //default port mapping
            0,0,0,0,0,0
    },
    0x0003,
        {{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}},    //inputfilterparam
        {{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1}},    //outputholdparam
        {        //default port mapping
                0,0,0,0,0,0
        },
        0x0003,            //padding s
        0x0004,
        0x0005,
        0x0006,
@@ -110,8 +110,8 @@
        0x000a,
        0x000b,
        0x000c,
    0x0011,
    },
    0x0011,                //CRC16
    END_SIGN,
};
@@ -426,6 +426,13 @@
int nNextRunStatSpace=0;
int LoadDefaultRunStat(pRunStat theRunStat)
{
    theRunStat->PowerCount=1;
//    theRunStat->UpTime=0;
//    theRunStat->UserData1=0;
//    theRunStat->WorkMode=0;
//    theRunStat->WorkMode2=0;
//    theRunStat->nBinProgBank=0;
//    theRunStat->nBinProgSize=0;
    return 0;
}
int LoadRunStat(pRunStat theRunStat)
Src/KWireLess.c
@@ -129,7 +129,7 @@
int8_t RssiValue = 0;
int8_t SnrValue = 0;
KWStates KW_State=KW_PON;
//KWStates KW_State=KW_PON;
void LedToggle(void)
{
@@ -277,9 +277,9 @@
    memcpy( RX_Buffer, payload, BufferSize );
    RssiValue = rssi;
    SnrValue = snr;
    KMem.DT[40]=rssi; //Radio.Rssi(MODEM_FSK);;
        KMem.DT[41]=snr;
        KMem.DT[42]++;
    KMem.WDT[40]=rssi; //Radio.Rssi(MODEM_FSK);;
        KMem.WDT[41]=snr;
        KMem.WDT[42]++;
        
    Radio.Standby();
    
@@ -314,13 +314,14 @@
void OnTxTimeout( void )
{
   KMem.WDT[43]++;
}
void OnRxTimeout( void )
{
    Radio.Standby();
            KMem.DT[43]++;
            KMem.WDT[44]++;
        KMem.ErrStat=200;
    if(RadioEnableMaster)
    {
@@ -336,7 +337,7 @@
{
    Radio.Standby();
            KMem.DT[44]++;
            KMem.WDT[45]++;
    if(RadioEnableMaster)
    {
            SendPingMsg();
Src/PLCfunctions.c
@@ -342,7 +342,7 @@
int InitPLC()
{
    PLCMem.nScanCount=0;
    for (int i=0;i<1024;i++){PLCMem.ProgTrace[i]=0;}
    for (int i=0;i<256;i++){PLCMem.ProgTrace[i]=0;}
    for (int i=0;i<16;i++)    {
        KMem.WR[i]=0;
    }
@@ -355,7 +355,7 @@
int StartPLC()
{
    PLCMem.nScanCount = 0;
    for (int i=0;i<1024;i++){PLCMem.ProgTrace[i]=0;}
    for (int i=0;i<256;i++){PLCMem.ProgTrace[i]=0;}
    for (int i=0;i<16;i++)    {
        KMem.WR[i]=0;
    }
@@ -369,6 +369,8 @@
int StopPLC()
{
    PLCMem.bPLCRunning=0;
    for (int i=0;i<KLDataWXCount;i++) KMem.WY[i]=0;
    for (int i=0;i<KLDataWLCount;i++) KMem.WLY[i]=0;
    return 0;
}
@@ -765,9 +767,11 @@
        default:
            break;
        }
        lastScanInputVal =  PLCMem.ProgTrace[CurPos]; //GetBitValue(KMem.WDFs);
        PLCMem.ProgTrace[CurPos] = KMem.CurVAL;
        lastScanInputVal =  GetBitValue( PLCMem.ProgTrace[CurPos>>4],CurPos&0xf); //GetBitValue(KMem.WDFs);
        SetBitValue( &PLCMem.ProgTrace[CurPos>>4],CurPos&0xf, KMem.CurVAL);
//        lastScanInputVal =  PLCMem.ProgTrace[CurPos]; //GetBitValue(KMem.WDFs);
//        PLCMem.ProgTrace[CurPos] = KMem.CurVAL;
        CurPos += nNextPos;
    }
    PLCMem.nScanCount++;
Src/main.c
@@ -304,7 +304,7 @@
    ShowInitInfo();
    KMem.LastScanTime = GetuS();
    KMRunStat.WorkMode=0;
    KMRunStat.WorkMode=1;
    if (KMRunStat.WorkMode == 1){
        InitPLC();
        StartPLC();
@@ -378,8 +378,7 @@
#endif
//        pProgs = (stBinProg1 *) STORE_PRG_BASE;
        if (    KMRunStat.WorkMode==1 && bKBusMaster)
        if (    KMRunStat.WorkMode==1 ) //&& bKBusMaster)
        {
            if (KMRunStat.nBinProgBank == 0){
                pProgs=(stBinProg1 *)STORE_PRG_BASE;
@@ -387,6 +386,7 @@
                pProgs=(stBinProg1 *)ALT_PRG_BASE;
            }
            nSizeProg1=KMRunStat.nBinProgSize;
        //    pProgs=(stBinProg1 *)prog1;
            
            ProcessPLCBinProg(pProgs, nSizeProg1);
        }