コード例 #1
0
ファイル: lib_iso18092pcd.c プロジェクト: ngohaibac/ST95HF
/**
 * @brief  Initializes the xx95HF for the FELICA protocol
 * @param  void
 * @return TRUE (if well configured) / FALSE (Communication issue)
 */
static int8_t FELICA_Init( uint8_t *pDataRead )
{
	int8_t  status;
	u8     ProtocolSelectParameters [4]  = {0x51, 0x13, 0x01,0x0D};
	u8     WriteAmpliGain [2]  = {PCD_TYPEF_ARConfigA, PCD_TYPEF_ARConfigB};
	u8     AutoFDet [2]  = {0x02,0xA1};

	
	/* sends a protocol Select command to the pcd to configure it */
	errchk(PCD_ProtocolSelect(0x05,PCD_PROTOCOL_FELICA,ProtocolSelectParameters,pDataRead));
	TechnoSelected = PCDPROTOCOL_18092;
	
	/* in order to adjust the demodulation gain of the PCD*/
  errchk(PCD_WriteRegister    ( 0x04,AFE_ANALOG_CONF_REG_SELECTION,0x01,WriteAmpliGain,pDataRead)); 

	/* in order to adjust the auto detect of the PCD*/
	errchk(PCD_WriteRegister    ( 0x04,0x0A,0x01,AutoFDet,pDataRead)); 
	
	/* GT min time to respect before sending REQ_C */
	delay_us(20400);

	return ISO18092_SUCCESSCODE;
Error:
 return ISO18092_ERRORCODE_DEFAULT;
	
}
コード例 #2
0
ファイル: lib_iso14443Bpcd.c プロジェクト: ngohaibac/ST95HF
/**
 * @brief  Initializes the the PCD device for the IS014443B protocol
 * @retval ISO14443B_SUCCESSCODE  : the PCD device is well configured.
 * @retval ISO14443B_ERRORCODE_DEFAULT : Communication issue.
 */
int8_t ISO14443B_Init( void )
{
	uint8_t		*pDataRead = u95HFBuffer;
	int8_t		status;
	uint8_t * ProtocolSelectParameters;
	uc8 ProtocolSelectParametersQJC[] 	= { 
																		/* Parameters */		
																		PCD_ISO14443B_TRANSMISSION_SPEED_106K     |
																		PCD_ISO14443B_RECEPTION_SPEED_106K        |
																		PCD_ISO14443B_APPEND_CRC,
																		/* Set FDT */
																		0x02                         ,
																		0x00    																	
														};
	uc8 ProtocolSelectParametersQJE[] 	= { 
																		/* Parameters */		
																		PCD_ISO14443B_TRANSMISSION_SPEED_106K     |
																		PCD_ISO14443B_RECEPTION_SPEED_106K        |
																		PCD_ISO14443B_APPEND_CRC,
																		/* PP MM bytes */
																		0x00,
																		0x1A
																		
														};
    uc8	Length = 0x04;
														
	if( IcVers < QJE)
	{
		ProtocolSelectParameters 	= (uint8_t*)(ProtocolSelectParametersQJC);
	}
	else
	{
	  ProtocolSelectParameters 	= (uint8_t*)(ProtocolSelectParametersQJE);
  }

	ISO14443B_InitStructure( );

	/* sends a protocol Select command to the pcd to configure it */
	errchk(PCD_ProtocolSelect(Length,PCD_PROTOCOL_ISO14443B,ProtocolSelectParameters,pDataRead));
	TechnoSelected = PCDPROTOCOL_14443B;
	/* update the AR register */
	errchk(ISO14443B_WriteAndCheckARConfigB ());
														
	/* GT min time to respect before sending REQ_B */
	delay_us(5100);																											

	return ISO14443B_SUCCESSCODE;
Error:
	return ISO14443B_ERRORCODE_DEFAULT;
}
コード例 #3
0
ファイル: lib_iso14443Bpcd.c プロジェクト: ngohaibac/ST95HF
/**
 * @brief Anticolision state machine for ISO14443B cards
 * @param void
 * @retval ISO14443B_SUCCESSCODE  : the function is successful.
 * @retval ISO14443B_ERRORCODE_DEFAULT  : an error occured
 */
int8_t ISO14443B_Anticollision(void)
{
	int8_t	status;
	uint8_t *pDataRead = u95HFBuffer;
	uc8 ProtocolSelectParameters[] 	= {PCD_ISO14443B_TRANSMISSION_SPEED_106K|PCD_ISO14443B_RECEPTION_SPEED_106K|PCD_ISO14443B_APPEND_CRC,0x04,0x3E};
	
	/* ATTRIB attempt */
	errchk(ISO14443B_AttriB(pDataRead));
	
	/* Change the PP:MM parameter to accept longer APDU timeout (2^PP)*(MM+1)*(DD+128)*32/13.56 ~= 304ms*/
	errchk(PCD_ProtocolSelect(0x04,PCD_PROTOCOL_ISO14443B,ProtocolSelectParameters,pDataRead));
	
	devicemode = PCD;
	nfc_tagtype = TT4B;
	
	return ISO14443B_SUCCESSCODE;
Error:
	return ISO14443B_ERRORCODE_DEFAULT; 
}
コード例 #4
0
ファイル: lib_iso14443Apcd.c プロジェクト: LuYan129130/tes1
/**
 * @brief  this command initializes the PCD device for the IS014443A protocol
 * @param  none
 * @return ISO14443A_SUCCESSCODE the function is succesful
 * @return ISO14443A_ERRORCODE_DEFAULT : an error occured
 */
int8_t ISO14443A_Init ( void )
{
	u8  ProtocolSelectParameters []  = {0x00, 0x01, 0xA0},
			WriteRegisterParameters []  = {0x5A, 0x04},
			DemoGainParameters []  = {0x01, 0xDF};
	uint8_t  *pDataRead = u95HFBuffer;
	int8_t  status;

	ISO14443A_InitStructure( );

	/* sends a protocol Select command to the pcd to configure it */
	errchk(PCD_ProtocolSelect(0x04,PCD_PROTOCOL_ISO14443A,ProtocolSelectParameters,pDataRead)); 

	errchk(PCD_WriteRegister    ( 0x04,0x3A,0x00,WriteRegisterParameters,pDataRead));

	/* in order to adjust the demoduation gain of the PCD*/
	errchk(PCD_WriteRegister (0x04,0x68,0x01,DemoGainParameters,u95HFBuffer));

#if 0
  errchk(PCD_WriteRegister  ( 0x03,0x68,0x00,&StartIndex,pDataRead)); 

	for(i=0; i<=1; i++)
	{
		errchk(PCD_WriteRegister  ( 0x03,0x69,0x00,&DemoGainParameters[i],pDataRead)); 
	} 

 
	errchk(PCD_WriteRegister  ( 0x03,0x68,0x00,&StartIndex,pDataRead)); 
	for(i=0; i<=5; i++)
	{
		errchk(PCD_ReadRegister ( 0x03,0x69,0x01,0x00,pDataRead));
		DemoGainParameters[i] = pDataRead[2];
	}
#endif
 
 return ISO14443A_SUCCESSCODE;
Error:
 return ISO14443A_ERRORCODE_DEFAULT;
	
}