www.pudn.com > rfid.rar > findtags.c, change:2012-05-14,size:3333b


/******************************************************************************* 
 * 文件名称:findtags.c 
 * 功    能:寻找指定类别的tag 
 * 作    者:Ronnie 
 * 公    司:湘潭斯凯电子科技有限公司 
 *           www.sikai-tech.com 
 * 日    期:2011-06-22 
 ******************************************************************************/ 
 
 
/* 包含头文件 */ 
/********************************************************************/ 
#include "findtags.h" 
/********************************************************************/ 
 
 
/* 变量定义 */ 
/********************************************************************/ 
unsigned char	protocol; 
/********************************************************************/ 
 
 
/********************************************************************* 
 * 函数名称:FindTags 
 * 功    能:寻找指定类别的tag 
 * 入口参数:protocol    RDID协议标准 
 * 出口参数:无 
 * 返 回 值:无 
 ********************************************************************/ 
unsigned char FindTags(unsigned char protocol) 
{ 
  unsigned char	command[10]; 
 
  while(1) 
  { 
    /* ISO15693 */ 
    if((protocol == 0x00) || (protocol == 0x01)) 
    {	 
      command[0] = ChipStateControl; 
      command[1] = 0x21; 
      command[2] = ISOControl;		 
      command[3] = 0x02; 
      WriteSingle(command, 4); 
 
      delay_ms(5); 
      flags = 0x06; 
 
      command[0] = 0x00; 
      InventoryRequest(command, 0); 
 
      command[0] = ChipStateControl;	  //关射频场? 
      command[1] = 0x01; 
      WriteSingle(command, 2); 
      delay_ms(1); 
 
      command[0] = IRQStatus; 
      command[1] = IRQMask;	 
      ReadCont(command, 2); 
    } 
 
    /* ISO14443A */ 
    if((protocol == 0x00) || (protocol == 0x02)) 
    {	 
      command[0] = ChipStateControl; 
      command[1] = 0x21; 
      command[2] = ISOControl; 
      command[3] = 0x08; 
      WriteSingle(command, 4); 
      delay_ms(5); 
 
      AnticollisionSequenceA(0x00); 
       
      command[0] = ChipStateControl;	 
      command[1] = 0x01; 
      WriteSingle(command, 2); 
      delay_ms(1); 
 
      command[0] = IRQStatus; 
      command[1] = IRQMask;	 
      ReadCont(command, 2); 
    } 
 
    /* ISO14443B */	 
    if((protocol == 0x00) || (protocol == 0x03)) 
    { 
      command[0] = ChipStateControl; 
      command[1] = 0x21; 
      WriteSingle(command, 2); 
 
       
      command[0] = ISOControl;	 
      command[1] = 0x0C; 
      WriteSingle(command, 2); 
      delay_ms(5); 
       
      AnticollisionSequenceB(0xB0, 0x04); 
 
      command[0] = ChipStateControl; 
      command[1] = 0x01; 
      WriteSingle(command, 2); 
      delay_ms(1); 
 
      command[0] = IRQStatus; 
      command[1] = IRQMask;	 
      ReadCont(command, 2); 
    } 
 
    /* Tag-it */	 
    if((protocol == 0x00) || (protocol == 0x04)) 
    { 
      command[0] = ChipStateControl; 
      command[1] = 0x21; 
      command[2] = ISOControl;	 
      command[3] = 0x13; 
      WriteSingle(command, 4); 
      delay_ms(5); 
			 
      flags = 0x00; 
      command[0] = 0x00; 
      TIInventoryRequest(command, 0); 
 
 
      command[0] = ChipStateControl; 
      command[1] = 0x01; 
      WriteSingle(command, 2); 
      delay_ms(1); 
 
      command[0] = IRQStatus; 
      command[1] = IRQMask;	 
      ReadCont(command, 2); 
    } 
  }	 
}