📄 prd_config.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 : M210_3G
// Project Name : INSIDE Coupler
// Module Name : ConfigReader.c
// Platform dev : WINDOWS (CCS Compiler)
// Target : PIC18FXX2 (MICROCHIP)
// Language : C + ASM
// Revision : 1.0
// Description : Reader configuration functions.
//=============================================================================
// When Who Ver What
// 06-05-12 FPK 1.2 restructuration
//=============================================================================
// Defines standard
#include <stdio.h> // Standard C Libray file containing basic functions to use serial host
// Defines for common C writting
#include "Defines_C.h" // TRUE, FALSE, etc
// Defines for the current target
#include "Target.h" // Definition of processor registers
// Defines for PicoRead
#include "PRD_PicoReadRF_Pages_Parameters.h" // Definition of PicoRead chip registers
#include "PRD_Config.h" // Reader Configuration functions
StructReader g_sPicoReadStructReader;
#include "PRD_RF_Comm.h" //
#include "PRD_Protocols_Defines.h" //Protocols defines
#include "PRD_COMMON_Anticollision_Parameters.h" //Common Anticollision parameters defines
// For Default Settings (For Anticollision)
#include "PRD_ISO14443A_Anticollision_Parameters.h" //Anticollision parameters defines for ISO14443A
#include "PRD_ISO14443A_Anticollision_Default_Parameters.h"
#include "PRD_ISO14443B_Anticollision_Parameters.h" //Anticollision parameters defines for ISO14443B
#include "PRD_ISO14443B_Anticollision_Default_Parameters.h"
#include "PRD_ISO15693_Anticollision_Parameters.h" //Anticollision parameters defines for ISO14443B
#include "PRD_ISO15693_Anticollision_Default_Parameters.h"
#include "PRD_PicoPass_Anticollision_Parameters.h" //Anticollision parameters defines for PicoPass
#include "PRD_PicoPass_Anticollision_Default_Parameters.h"
#include "PRD_TypeC_18092_Anticollision_Parameters.h" //Anticollision parameters defines for Type C(18092)
#include "PRD_TypeC_18092_Anticollision_Default_Parameters.h"
//-----------------------------------------------------------------------------
// Function : v_fnGetConfigAnalog(BYTE* p_abPage6)
//-----------------------------------------------------------------------------
// Description : Get PicoRead RF Page 6
//
// IN : *p_abPage6 : Bytes of Page 6
//
// OUT : - none -
//
// RETURN : - none -
//
// Notes : - none -
//-----------------------------------------------------------------------------
void v_fnGetConfigAnalog(unsigned char* p_abPage6)
{
// Configure page 6
v_fnCS_reset();
v_fnSPI_SendByte(P0_REG_NO_RST | P0_PAGE_SELECT_6 | P0_RFON);
v_fnSPI_SendByte(p_abPage6[0]);
v_fnSPI_SendByte(p_abPage6[1]);
v_fnSPI_SendByte(p_abPage6[2]);
v_fnSPI_SendByte(p_abPage6[3]);
v_fnSPI_SendByte(p_abPage6[4]);
v_fnSPI_SendByte(p_abPage6[5]);
v_fnSPI_SendByte(p_abPage6[6]);
v_fnSPI_SendByte(p_abPage6[7]);
}
//-----------------------------------------------------------------------------
// Function : v_fnConfigAnalog(BYTE* p_abPage6)
//-----------------------------------------------------------------------------
// Description : Configure PicoRead RF Page 6
//
// IN : *p_abPage6 : Bytes used to configure Page 6
//
// OUT : - none -
//
// RETURN : - none -
//
// Notes : - none -
//-----------------------------------------------------------------------------
void v_fnConfigAnalog(unsigned char* p_abPage6)
{
// Configure page 6
v_fnCS_reset();
v_fnSPI_SendByte(P0_REG_NO_RST | P0_PAGE_SELECT_6 | P0_RFON);
v_fnSPI_SendByte(p_abPage6[0]);
v_fnSPI_SendByte(p_abPage6[1]);
v_fnSPI_SendByte(p_abPage6[2]);
v_fnSPI_SendByte(p_abPage6[3]);
v_fnSPI_SendByte(p_abPage6[4]);
v_fnSPI_SendByte(p_abPage6[5]);
v_fnSPI_SendByte(p_abPage6[6]);
v_fnSPI_SendByte(p_abPage6[7]);
}
//-----------------------------------------------------------------------------
// Function : v_fnConfigTimeout(BYTE p_bTimeout)
//-----------------------------------------------------------------------------
// Description : Configure reader timeout parameters
//
// IN : p_bTimeout : Timeout value
// p_pStructReader : Pointer to the used StructReader structure.
//
// OUT : p_pStructReader->s_bRTimeoutDefault
// p_pStructReader->s_bRTimeoutUsed
//
// RETURN : - none -
//
// Notes : - none -
//-----------------------------------------------------------------------------
void v_fnConfigTimeout(unsigned long p_bTimeout,StructReader* p_pStructReader)
{
p_pStructReader->s_bRTimeoutDefault = p_bTimeout;
p_pStructReader->s_bRTimeoutUsed = p_bTimeout;
if(p_bTimeout<=0x0E)
{
p_pStructReader->s_bRTimeoutUsed = p_bTimeout & 0xEF;
}
}
//-----------------------------------------------------------------------------
// Function : v_fnConfigBitRate(BYTE p_bSpeed)
//-----------------------------------------------------------------------------
// Description : Modify PicoRead Protocol Page to change communication bit rate
//
// IN : p_bSpeed : Emission and reception speed
// p_pbRFReceiveEOF = Pointer to a value equals to 0, that defines (for ISO B) that EOF need to be taken into account or not.
// For ISOB : p_pbRFReceiveEOF=1
// Other Protocols : p_pbRFReceiveEOF=0
// p_pStructReader : Pointer to the used StructReader structure.
//
// OUT : p_pStructReader->s_bCommunicationSupportedSpeed
// p_pStructReader->s_bRSpeedConfig
//
// RETURN : - none -
//
// Notes : - none -
//-----------------------------------------------------------------------------
void v_fnConfigBitRate(unsigned char p_bSpeed,unsigned char* p_pbRFReceiveEOF,StructReader* p_pStructReader)
{
p_pStructReader->s_bCommunicationSupportedSpeed=p_bSpeed;
if(bit_testChar(&p_pStructReader->s_bCommunicationSupportedSpeed,2))
{
p_pStructReader->s_bRSpeedConfig = CODING_BIT_RATE_848K;
}
else if (bit_testChar(&p_pStructReader->s_bCommunicationSupportedSpeed,1))
{
p_pStructReader->s_bRSpeedConfig = CODING_BIT_RATE_424K;
}
else if (bit_testChar(&p_pStructReader->s_bCommunicationSupportedSpeed,0))
{
p_pStructReader->s_bRSpeedConfig = CODING_BIT_RATE_212K;
}
else p_pStructReader->s_bRSpeedConfig = CODING_BIT_RATE_106K;
if(bit_testChar(&p_pStructReader->s_bCommunicationSupportedSpeed,6))
{
p_pStructReader->s_bRSpeedConfig |= DECODING_BIT_RATE_848K;
}
else if (bit_testChar(&p_pStructReader->s_bCommunicationSupportedSpeed,5))
{
p_pStructReader->s_bRSpeedConfig |= DECODING_BIT_RATE_424K;
}
else if (bit_testChar(&p_pStructReader->s_bCommunicationSupportedSpeed,4))
{
p_pStructReader->s_bRSpeedConfig |= DECODING_BIT_RATE_212K;
}
else
{
p_pStructReader->s_bRSpeedConfig |= DECODING_BIT_RATE_106K;
}
// Configure protocol page according to speed transmission
v_fnCS_reset();
switch(p_pStructReader->s_bRProtocol)
{
case ISOA_PROTOCOL :
if((p_pStructReader->s_bRSpeedConfig & DECODING_BIT_RATE_106K)==DECODING_BIT_RATE_106K)
{
v_fnSPI_SendByte(P0_REG_NO_RST | P0_PAGE_SELECT_3 | P0_RFON);
v_fnSPI_SendByte(SEND_EOF | SEND_SOF | PARITY_EN);
v_fnSPI_SendByte(RCV_SOF| RCV_EOF | PARITY_ODD);
v_fnSPI_SendByte(CODING_ISO_14443A | DECODING_ISO_14443A);
v_fnSPI_SendByte(p_pStructReader->s_bRSpeedConfig | SOF_TYPE_0);
v_fnSPI_SendByte(CRC_INV_DISABLE | CRC_SKIP_0 | CRC_INIT_6363);
*p_pbRFReceiveEOF=0;
}
else
{
v_fnSPI_SendByte(P0_REG_NO_RST | P0_PAGE_SELECT_3 | P0_RFON);
v_fnSPI_SendByte(SEND_EOF | SEND_SOF | PARITY_EN);
v_fnSPI_SendByte(RCV_SOF | PARITY_ODD);
v_fnSPI_SendByte(CODING_ISO_14443A | DECODING_ISO_14443B);
v_fnSPI_SendByte(p_pStructReader->s_bRSpeedConfig | SOF_TYPE_0);
v_fnSPI_SendByte(CRC_INV_DISABLE | CRC_SKIP_0 | CRC_INIT_6363);
*p_pbRFReceiveEOF=1;
}
break;
case INNOVATRON_PROTOCOL:
case ISOB_PROTOCOL :
v_fnSPI_SendByte(P0_REG_NO_RST | P0_PAGE_SELECT_1 | P0_RFON);
v_fnSPI_SendByte(SEND_EOF | SEND_STOP_BIT_1 | SEND_START_BIT | SEND_SOF);
v_fnSPI_SendByte(RCV_EOF | RCV_STOP | RCV_START_BIT | RCV_SOF);
v_fnSPI_SendByte(CODING_ISO_14443B | DECODING_ISO_14443B);
v_fnSPI_SendByte(p_pStructReader->s_bRSpeedConfig | SOF_TYPE_10 | HEADER_LEN_10ETU);
v_fnSPI_SendByte(CRC_INV_ENABLE | CRC_SKIP_0 | CRC_INIT_FFFF);
break;
}
}
//-----------------------------------------------------------------------------
// Function : v_fnConfigProtocol(BYTE p_bProtocol)
//-----------------------------------------------------------------------------
// Description : Configure PicoRead RF in chosen protocol
//
// IN : p_bProtocol : protocol used
// p_pbRFReceiveEOF = Pointer to value, that define (for ISO B) that EOF need to be taken into account or not.
// For ISOB : p_pbRFReceiveEOF=1
// Other Protocols : p_pbRFReceiveEOF=0
// p_pStructReader : Pointer to the used StructReader structure.
//
// OUT : p_pStructReader->s_bRProtocol
// p_pStructReader->s_bRSpeedConfig
//
// RETURN : - none -
//
// Notes : - none -
//-----------------------------------------------------------------------------
void v_fnConfigProtocol(unsigned char p_bProtocol,unsigned char* p_pbRFReceiveEOF,StructReader* p_pStructReader)
{
p_pStructReader->s_bRProtocol = p_bProtocol;
p_pStructReader->s_bRSpeedConfig = CODING_BIT_RATE_106K | DECODING_BIT_RATE_106K;
if (((p_pStructReader->s_bRProtocol & 0xF0) == ISOB_PROTOCOL) || ((p_pStructReader->s_bRProtocol & 0xF0) == INNOVATRON_PROTOCOL))
{
*p_pbRFReceiveEOF=1;
// Configure protocol page 1 as ISO14443B or PicoPass 14443B
v_fnCS_reset();
v_fnSPI_SendByte(P0_REG_NO_RST | P0_PAGE_SELECT_1 | P0_RFON);
v_fnSPI_SendByte(SEND_EOF | SEND_STOP_BIT_1 | SEND_START_BIT | SEND_SOF);
if(p_bProtocol==INNOVATRON_PROTOCOL)
{
v_fnSPI_SendByte(RCV_EOF | RCV_STOP | RCV_START_BIT );
}
else
{
v_fnSPI_SendByte(RCV_EOF | RCV_STOP | RCV_START_BIT | RCV_SOF);
}
v_fnSPI_SendByte(CODING_ISO_14443B | DECODING_ISO_14443B);
if (p_bProtocol == PICOPASS_ISOB424) p_pStructReader->s_bRSpeedConfig = (CODING_BIT_RATE_106K | DECODING_BIT_RATE_424K);
v_fnSPI_SendByte(p_pStructReader->s_bRSpeedConfig | SOF_TYPE_10 | HEADER_LEN_10ETU);
if (p_bProtocol == ISOB_PROTOCOL) v_fnSPI_SendByte(CRC_INV_ENABLE | CRC_SKIP_0 | CRC_INIT_FFFF);
if (p_bProtocol == PICOPASS_ISOB106 || p_bProtocol == PICOPASS_ISOB424) v_fnSPI_SendByte(CRC_INV_DISABLE | CRC_SKIP_1 | CRC_INIT_E012);
}
else if ((p_pStructReader->s_bRProtocol & 0xF0) == ISO15693_PROTOCOL)
{
*p_pbRFReceiveEOF = 0;
// Configure protocol page 2 as ISO15693 or PicoPass 15693
v_fnCS_reset();
v_fnSPI_SendByte(P0_REG_NO_RST | P0_PAGE_SELECT_2 | P0_RFON);
v_fnSPI_SendByte(SEND_EOF | SEND_SOF);
v_fnSPI_SendByte(RCV_EOF | RCV_SOF);
v_fnSPI_SendByte(CODING_ISO_15693 | DECODING_ISO_15693);
v_fnSPI_SendByte(0x00);
if (p_bProtocol == ISO15693_PROTOCOL)
{
v_fnSPI_SendByte(CRC_INV_ENABLE | CRC_SKIP_0 | CRC_INIT_FFFF);
}
if (p_bProtocol == PICOPASS_ISO15693)
{
v_fnSPI_SendByte(CRC_INV_DISABLE | CRC_SKIP_1 | CRC_INIT_E012);
}
}
else if (p_pStructReader->s_bRProtocol == ISOA_PROTOCOL)
{
*p_pbRFReceiveEOF = 0;
// Configure protocol page 3 as ISO14443A 106kbps protocol
v_fnCS_reset();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -