📄 prd_picopass_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 RF ISO15693-3 READER
// Project Name : APPLICATION NOTE
// Module Name : PRD_ISO14443B_COMMANDS.C
// Platform dev : Keil 礦ision 3 (IDE ) + Keil ARM Compiler
// Target : LPC2129 (ARM7TDMI Core)
// Language : C ANSI
// Revision : 1.0
// Description : Anticollision commands management
//=============================================================================
// When Who Ver What
// 06-04-24 MCY 1.1 restructuration
//=============================================================================
// C ANSI Defines
#include <string.h>
// Defines for PicoRead
#include "PRD_PicoReadRF_Pages_Parameters.h" // Definition of PicoRead chip registers
//#include "\DEV\Projects\LIB\PicoRead\u03\Level_1\common\defines\PRD_Parameters.h" // READER configuration parameters
#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 B Commands
#include "PRD_ISO14443B_Commands.h"
//-----------------------------------------------------------------------------
// Function name : b_fnSendReceiveREQBWUPB(unsigned char p_pcmd,unsigned char* p_pabBuffer,StructReader* p_pStructReader, unsigned short* p_bATQBLength)
//-----------------------------------------------------------------------------
// Description : Send the REQB/WUPB Command
//
// IN : p_pStructReader : Pointer to the used StructReader structure.
// p_pcmd : choice between REQB and WUPB
//
// OUT : p_bATQBLength : size of ATQB
// p_pabBuffer : ATQB
//
// RETURN : l_bStatus : Error code
//
// Notes : - none -
//-----------------------------------------------------------------------------
unsigned char b_fnSendReceiveREQBWUPB(unsigned char p_pcmd,unsigned char* p_pabBuffer,StructReader* p_pStructReader, unsigned short* p_bATQBLength)
{
unsigned char l_abBuffer[3];
unsigned char l_bStatus;
l_abBuffer[0] = _ISOB_REQB;
l_abBuffer[1] = _ISOB_AFI_ALL; // all application families
l_abBuffer[2] = p_pcmd; // _ISOB_REQB_NO_SLOT or _ISOB_WUPB_NO_SLOT
v_fnSendBuffer(_SENDCRC,3,0,&l_abBuffer[0],p_pStructReader);
l_bStatus=b_fnReceiveBuffer(_CHECKCRC,&p_pabBuffer[0],p_pStructReader,p_bATQBLength,&g_bDataBitsReceived,&g_bPicoReadStatus,&g_bRFReceiveEOFB,&g_bBitsToReceive);
//if byte2>'8' -->byte2='8' max_frame_size
if ((p_pabBuffer[10] & 0xF0)>0x80)
{
p_pabBuffer[10] &= 0x8F;
}
//if Protocol_Type is RFU --> = 0000 (Requirements 6.10)
if ((p_pabBuffer[10] & 0x0E) != 0x00)
{
p_pabBuffer[10] &= 0xF0;
}
return l_bStatus;
}
//-----------------------------------------------------------------------------
// Function name : v_fnSendPreparATTRIB(unsigned char* p_pabBuffer,StructReader* p_pStructReader)
//-----------------------------------------------------------------------------
// Description : Prepare the data to send for an ATRRIB command
//
// IN : p_pStructReader : Pointer to the used StructReader structure.
//
//
// OUT : p_pabBuffer : buffer ready to be sent
//
// RETURN : - none -
//
// Notes : - none -
//-----------------------------------------------------------------------------
void v_fnSendPreparATTRIB(unsigned char* p_pabBuffer,StructReader* p_pStructReader)
{
p_pabBuffer[0] = _ISOB_ATTRIB ; // 0x1D
//p_pabBuffer[1]..[4] --> PUPI from ATQA (Requirements 6.15)
p_pabBuffer[11] = p_pabBuffer[7] ;
p_pabBuffer[7] = p_pabBuffer[10] & 0x01; //PARAM 3 (Requirements 6.20)
p_pabBuffer[9] = p_pabBuffer[5] ;
p_pabBuffer[10] = p_pabBuffer[6] ;
p_pabBuffer[12] = p_pabBuffer[8] ;
p_pabBuffer[5] = 0 ; //PARAM 1 (Requirements 6.16)
p_pabBuffer[6] = 0x08 ; //PARAM 2 (Requirements 6.17)
p_pabBuffer[8] = 0 ; //PARAM 4 (Requirements 6.21)
if(p_pStructReader->s_bReaderSupportedSpeed & P0_USE_CHIP_BR) //PARAM 2
{
if (bit_testChar(&p_pStructReader->s_bCommunicationSupportedSpeed,2))
{
p_pabBuffer[6]|=0x30; // Emission 847 kbps
}
else if (bit_testChar(&p_pStructReader->s_bCommunicationSupportedSpeed,1))
{
p_pabBuffer[6]|=0x20; // Emission 423 kbps
}
else if (bit_testChar(&p_pStructReader->s_bCommunicationSupportedSpeed,0))
{
p_pabBuffer[6]|=0x10; // Emission 212 kbps
}
if (bit_testChar(&p_pStructReader->s_bCommunicationSupportedSpeed,6))
{
p_pabBuffer[6]|=0xC0; // Reception 847 kbps
}
else if (bit_testChar(&p_pStructReader->s_bCommunicationSupportedSpeed,5))
{
p_pabBuffer[6]|=0x80; // Reception 423 kbps
}
else if (bit_testChar(&p_pStructReader->s_bCommunicationSupportedSpeed,4))
{
p_pabBuffer[6]|=0x40; // Reception 212 kbps
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -