输入条件:SysKind=0--->EasmChip的操作,SysKind=1-->CpuCard的操作,IccCase命令类别,Length命令长度。
void CosCommand(bool SysKind,unsigned char IccCase, unsigned char Length) { unsigned char AckBbuf = 0, i; WDT(); _DINT(); AckBbuf=0x00; SwBuf[0] = 0x00; SwBuf[1] = 0x00; for(i = 0; i < 5; i++) { CosSend(SysKind,CmdBuf); } AckBbuf = CosReceive(SysKind); if(AckBbuf==CmdBuf[1]) { switch(IccCase) { case 1: SwBuf[0] = CosReceive(SysKind); SwBuf[1] = CosReceive(SysKind); _NOP(); break; case 2: for(i = 5; i < Length + 5; i++) { CosSend(SysKind,CmdBuf); } SwBuf[0] = CosReceive(SysKind); SwBuf[1] = CosReceive(SysKind); _NOP(); break; case 3: for(i = 0; i < Length + 2; i++) { CosBuf = CosReceive(SysKind); } i--; SwBuf[1]=CosBuf; i--; SwBuf[0]=CosBuf; _NOP(); break; case 4: for(i = 5; i < Length + 5; i++) { CosSend(SysKind,CmdBuf); } Length = CosBuf; for(i = 0; i < Length + 2; i++) { CosBuf = CosReceive(SysKind); } i--; SwBuf[1]=CosBuf; i--; SwBuf[0]=CosBuf; _NOP(); break; } } _EINT(); }