📄 prd_iso14443a_commands.c
字号:
//=============================================================================
// Copyright (C) INSIDE Contactless 1998-2005
//
// INSIDE Contactless reserves the right to make changes, without notice,
// to any product (including application note) herein to improve
// reliability, functionality, or design. INSIDE Contactless advises its
// customers to obtain the latest version of device data sheets to verify,
// before placing orders, that the information being relied upon by the
// customer is current.
//
// INSIDE Contactless makes no warranty that the use will not infringe any
// third party patent, copyright or trademark.
//
// Information furnished by INSIDE Contactless is believed to be accurate
// and reliable. However, INSIDE Contactless does not assume any liability
// resulting from the application or use of any product described within.
//
// All rights are reserved. Reproduction in whole or in part is prohibited
// without the written consent of the copyright owner.
//
// Bat 11a,
// Parc Club du Golf,
// Z.A.C. du Pichaury Tel : +33 (0)4.42.39.33.00
// 13856 Aix-en-Provence Cedex 3 Fax : +33 (0)4.42.39.63.19
// FRANCE Email : info@insidefr.com
//
//-----------------------------------------------------------------------------
// Project Code : PICOREAD LIBRARY
// Project Name : PICOREAD LIBRARY
// Module Name : PRD_ISO14443A_COMMANDS.C
// Platform dev : Keil 礦ision 3 (IDE ) + Keil ARM Compiler
// Target : LPC2103 (ARM7TDMI Core)
// Language : C ANSI
// Revision : 1.0
// Description : ISO14443A commands
//=============================================================================
// When Who Ver What
// 06-05-12 FPK 1.2 creation
//=============================================================================
// Defines for PicoRead
#include "PRD_PicoReadRF_Pages_Parameters.h" // Definition of PicoRead chip registers
#include "PRD_Config.h" // Reader Configuration functions
#include "PRD_RF_Comm.h"
#include "PRD_BufferExchange.h"
// Defines for LPC2129
#include "Target.H" // Definition of processor registers & Low level functions to be modified according to the target, and the user needs
// ISO A Commands
#include "PRD_ISO14443A_Commands.h"
#include "PRD_COMMON_Anticollision_Parameters.h" //Common Anticollision parameters defines
//-----------------------------------------------------------------------------
// Function name : b_fnSendReceiveREQAWUPA(unsigned char p_pcmd,unsigned char* p_pabBuffer,StructReader* p_pStructReader, unsigned short* p_bATQALength)
//-----------------------------------------------------------------------------
// Description : Send the REQA/WUPA Command
//
// IN : p_pStructReader : Pointer to the used StructReader structure.
// p_pcmd : choice between REQA and WUPA
//
// OUT : p_bATQALength : size of the ATQA
// p_pabBuffer : ATQA
//
// RETURN : l_bStatus : Error code
//
// Notes : - none -
//-----------------------------------------------------------------------------
unsigned char b_fnSendReceiveREQAWUPA(unsigned char p_pcmd,unsigned char* p_pabBuffer,StructReader* p_pStructReader, unsigned short* p_bATQALength )
{
unsigned char l_abBuffer[1];
unsigned char l_bStatus;
// _ISOA_REQA (0x26) or _ISOA_WUPA (0x52)
l_abBuffer[0]= p_pcmd;
v_fnSendBuffer(0,0,7,&l_abBuffer[0],p_pStructReader);
l_bStatus=b_fnReceiveBuffer(0,&p_pabBuffer[0],p_pStructReader,p_bATQALength,&g_bDataBitsReceived,&g_bPicoReadStatus,&g_bRFReceiveEOFA,&g_bBitsToReceive);
delay_us(300);
return l_bStatus;
}
//-----------------------------------------------------------------------------
// Function name : b_fnSendReceiveHALTA(StructReader* p_pStructReader)
//-----------------------------------------------------------------------------
// Description : Send the HALT A Command, no response is waiting
//
// IN : p_pStructReader : Pointer to the used StructReader structure.
//
// OUT : - none -
//
// RETURN : - none -
//
// Notes : - none -
//-----------------------------------------------------------------------------
void v_fnSendHALTA(StructReader* p_pStructReader)
{
unsigned char l_abBuffer[2];
l_abBuffer[0] = _ISOA_HALT_0; // 0x50
l_abBuffer[1] = _ISOA_HALT_1; // 0x52
v_fnSendBuffer(_SENDCRC,2,0,&l_abBuffer[0],p_pStructReader);
}
//-----------------------------------------------------------------------------
// Function name : b_fnSendReceiveSELECT_ISOA(unsigned char p_pSEL,unsigned char* p_pabBuffer,StructReader* p_pStructReader)
//-----------------------------------------------------------------------------
// Description : Send the SELECT Command
//
// IN : p_pStructReader : Pointer to the used StructReader structure.
// p_pSEL : determinate the cascade level (93/95/97)
// p_pabBuffer : a part of the UID coming from ANTICOLLISION command
//
// OUT : - none -
//
// RETURN : l_bStatus : Error code
//
// Notes : - none -
//-----------------------------------------------------------------------------
unsigned char b_fnSendReceiveSELECT_ISOA(unsigned char p_pSEL,unsigned char* p_pabBuffer,StructReader* p_pStructReader)
{
unsigned char l_bStatus;
// CASCADE LEVEL: SEL= 93/95/97
p_pabBuffer[0] = p_pSEL;
p_pabBuffer[1] = 0x70;
// LRC (BCC calculate)
p_pabBuffer[6] = p_pabBuffer[2] ^ p_pabBuffer[3] ^ p_pabBuffer[4] ^ p_pabBuffer[5]; // LRC (BCC calculate)
v_fnSendBuffer(_SENDCRC,7,0,&p_pabBuffer[0],p_pStructReader);
l_bStatus=b_fnReceiveBuffer(_CHECKCRC,&p_pabBuffer[0],p_pStructReader,&g_lDataBytesReceived,&g_bDataBitsReceived,&g_bPicoReadStatus,&g_bRFReceiveEOFA,&g_bBitsToReceive);
return l_bStatus;
}
//-----------------------------------------------------------------------------
// Function name : b_fnSendReceiveANTICOLLISION_ISOA(unsigned char p_pSEL,unsigned char* p_pabBuffer,StructReader* p_pStructReader)
//-----------------------------------------------------------------------------
// Description : Send the ANTICOLLISION Command
//
// IN : p_pStructReader : Pointer to the used StructReader structure.
// p_pSEL : determinate the cascade level (93/95/97)
//
// OUT : p_pabBuffer : a part of UID, used with SELECT command
//
// RETURN : l_bStatus : Error code
//
// Notes : - none -
//-----------------------------------------------------------------------------
unsigned char b_fnSendReceiveANTICOLLISION_ISOA(unsigned char p_pSEL,unsigned char* p_pabBuffer,StructReader* p_pStructReader)
{
unsigned char l_abBuffer[2];
unsigned char l_bStatus;
// CASCADE LEVEL : SEL= 93/95/97
l_abBuffer[0]=p_pSEL;
l_abBuffer[1]=0x20;
v_fnSendBuffer(0,2,0,&l_abBuffer[0],p_pStructReader);
l_bStatus=b_fnReceiveBuffer(0,&p_pabBuffer[0],p_pStructReader,&g_lDataBytesReceived,&g_bDataBitsReceived,&g_bPicoReadStatus,&g_bRFReceiveEOFA,&g_bBitsToReceive);
return l_bStatus;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -