📄 halanticol.c
字号:
/* ============================================================================ Project Name : jayaCard Module Name : proto/hal/simu/halanticol.c Version : $Id: halanticol.c,v 1.15 2004/01/11 09:56:33 dgil Exp $ Description: Type A Anticollision and Selection The Original Code is jayaCard code. The Initial Developer of the Original Code is Gilles Dumortier. Portions created by the Initial Developer are Copyright (C) 2002-2004 the Initial Developer. All Rights Reserved. Contributor(s): This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see http://www.gnu.org/licenses/gpl.html History Rev Description 032303 dgil wrote it from scratch 053103 dgil wrote simplified but realistic behavior ! 072203 dgil remove specific message for Type A protocol ============================================================================*/#include "precomp.h"#ifdef JAYACFG_CONTACTLESS_TYPEA/* ========================================================================= hal_tcl_anticol_and_selectA() anticollision and selection for Type A ========================================================================= */void hal_tcl_anticol_and_selectA(jbyte xdata* buf){IDLE: if (tcl_halt_state) { LOG1("TCL","hal_tcl_anticol_and_selectA(0x%p) - wait WAKEUPA",buf); } else { LOG1("TCL","hal_tcl_anticol_and_selectA(0x%p) - wait REQA",buf); } /* wait for REQA or WKUPA */ do { LOG("TCL","wait for REQA ..."); tcl_cnt = HAL_TCL_RECEIVE(buf,sizeof(gInBuffer),jtrue); } while (tcl_cnt==0); if ( (buf[0]!=0x26) && (buf[0]!=0x52)) { /* unknown command here ! */ LOG1("TCL","waiting for REQA: unknown command 0x%.2X !",buf[0]); goto IDLE; } if ( (buf[0]==0x26) && tcl_halt_state) { /* REQA received but card is in halt state ! */ LOG("TCL","ignore REQA ... card is halted !"); goto IDLE; } /* then send ATQA */ HAL_TCL_INITSEND(0x00); HAL_TCL_SEND(0x01); /* single UUID */ HAL_TCL_SENDGO(jtrue); /* wait for ANTICOL */ do { LOG("TCL","wait for ANTICOL ..."); tcl_cnt = HAL_TCL_RECEIVE(buf,sizeof(gInBuffer),jtrue); } while (tcl_cnt==0); if (buf[0]==0x50) { /* note: ignore other bytes */ LOG("TCL","HALT"); /* halt state is true -> next time, accept wakeupA */ tcl_halt_state = true; goto IDLE; } if ((buf[0]!=0x93) && (buf[1]!=0x20)) { LOG2("TCL","waiting for ANTICOL: unknown command 0x%.2X%.2X !",buf[0],buf[1]); goto IDLE; } /* then send single UUID */ HAL_TCL_INITSEND(chipUUID[0]); /* single UUID byte 0 */ HAL_TCL_SEND(chipUUID[1]); /* single UUID byte 1 */ HAL_TCL_SEND(chipUUID[2]); /* single UUID byte 2 */ HAL_TCL_SEND(chipUUID[3]); /* single UUID byte 3 */ HAL_TCL_SENDGO(jtrue); /* then wait for SELECT */ do { LOG("TCL","wait for SELECT ..."); tcl_cnt = HAL_TCL_RECEIVE(buf,sizeof(gInBuffer),jtrue); } while (tcl_cnt==0); if ((buf[0]!=0x93) && (buf[1]!=0x70)) { if (buf[0]==0x50) { LOG("TCL","HALT"); tcl_halt_state = jtrue; } else { LOG1("TCL","waiting for SELECT: unknown command 0x%.2X !",buf[0]); } goto IDLE; } /* check chipUUID */ if ( (buf[2]!=chipUUID[0]) || (buf[3]!=chipUUID[1]) ||(buf[4]!=chipUUID[2]) ||(buf[5]!=chipUUID[3]) ) { LOG4("TCL","waiting for SELECT: unknown chipUUID 0x%.2X%.2X%.2X%.2X !",buf[0],buf[1],buf[2],buf[3]); goto IDLE; } /* then transmit SAK */ HAL_TCL_INITSEND(0x20); /* send SAK */ HAL_TCL_SENDGO(jtrue); /* wait */ /* then finish with Activation */ BIOS_TCL_ACTIVATIONA(); goto IDLE;}/* ========================================================================= That's all folks ! ========================================================================= */#endif/* JAYACFG_CONTACTLESS_TYPEA */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -