/////////////////////////////////////////////////////////////////////////////////////// // OutCmd1: Write command and wait for acknowledge of IK 220 with user defined time out /////////////////////////////////////////////////////////////////////////////////////// BOOL OutCmd1 (USHORT Axis, USHORT IK220Cmd) { USHORT RegW; // Register value word DLLInfo = DLLInfo & 0x00FFFFFF; DLLInfo=DLLInfo+0x01000000; // -- 1 -- if (!OutputW (Axis, CmdPort, IK220Cmd)) return FALSE; // Write command to IK 220 DLLInfo=DLLInfo+0x01000000; // -- 2 -- InitTimeOut (TimOutCmd1); // Init timer for time out do { if (!InputW (Axis, Flag1Reg, &RegW)) return FALSE; // Wait until finished } // or time out while ( !(RegW & G28Sem0) && !TimeOut (TimOutCmd1, UserTimeOut1) ); DLLInfo=DLLInfo+0x01000000; // -- 3 -- if (!InputW (Axis, Flag1Reg, &RegW)) return FALSE; // Finished ? if ( !(RegW & G28Sem0) ) { DLLStatus = DLLStatus | DLLStatus_TimeOut; return FALSE; // No, time out } DLLInfo=DLLInfo+0x01000000; // -- 4 -- if (!InputW (Axis, DatPort0, &RegW)) return FALSE; // Verify acknowledge if (RegW!=IK220Cmd) { DLLStatus = DLLStatus | DLLStatus_WrongAck; return FALSE; // Wrong command acknowledge } return TRUE; }
BOOL IKFind (ULONG* pBuffer256) { USHORT RegW; // Register value word USHORT Ax; if (!pBuffer256) // Check buffer address { DLLStatus = DLLStatus | DLLStatus_BufferAddressInvalid; return FALSE; // Buffer address invalid! } for (Ax=0; Ax<MAX_CARDS; Ax++) { if (PortBase[Ax]) { if (!InputW (Ax, CodeReg, &RegW)) return FALSE; // Read hardware code G28 if (RegW == 0x0007) *(pBuffer256+Ax)=(ULONG)PortBase[Ax]; // Return address of IK 220 else *(pBuffer256+Ax)=0; // Clear address entry } else *(pBuffer256+Ax)=0; // Clear address entry } return TRUE; }
int Input(short Inport, char Value){ int Data; if(Value == 0x01) InputB(Inport); else if(Value == 0x02) InputW(Inport); else if(Value == 0x03) InputD(Inport); else{ ; } return Data; }