[Add] First commit
This commit is contained in:
@ -0,0 +1,238 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright 2016-2022 NXP */
|
||||
/* */
|
||||
/* NXP Confidential. This software is owned or controlled by NXP and may only */
|
||||
/* be used strictly in accordance with the applicable license terms. */
|
||||
/* By expressly accepting such terms or by downloading, installing, */
|
||||
/* activating and/or otherwise using the software, you are agreeing that you */
|
||||
/* have read, and that you agree to comply with and are bound by, such */
|
||||
/* license terms. If you do not agree to be bound by the applicable license */
|
||||
/* terms, then you may not retain, install, activate or otherwise use the */
|
||||
/* software. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \file
|
||||
* Reference application file for ISO15693 interface of Simplified API
|
||||
* $Author: NXP $
|
||||
* $Revision: $ (v07.10.00)
|
||||
* $Date: $
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Nfcrdlib_SimplifiedApi_ISO.h>
|
||||
extern phNfcLib_Transmit_t phNfcLib_TransmitInput;
|
||||
extern phNfcLib_PeerInfo_t PeerInfo;
|
||||
|
||||
extern uint8_t bMoreDataAvailable;
|
||||
extern uint16_t wNumberofBytes;
|
||||
extern uint8_t bDataBuffer[256];
|
||||
|
||||
/*
|
||||
* This application is to demonstrate the usage of simplified API related to ISO15693
|
||||
* The application reaches to this point only after the activation of a card with ISO 15693
|
||||
* interface is done. Transmit api is used to perform any command exchange with the card and
|
||||
* receive api is used to get back the out data.
|
||||
* In case the user already knows the UID of the card he wants to talk to he can directly call these api
|
||||
*/
|
||||
uint32_t NfcLib_ISO15693_Reference_app()
|
||||
{
|
||||
uint32_t dwStatus;
|
||||
uint8_t bData[16] = {0xA0, 0xA0, 0xA0, 0xA0,
|
||||
0xA0, 0xA0, 0xA0, 0xA0,
|
||||
0xA0, 0xA0, 0xA0, 0xA0,
|
||||
0xA0, 0xA0, 0xA0, 0xA0};
|
||||
|
||||
/*
|
||||
* Copying the UID of the card on which the user wish to perform the operation.
|
||||
* For the reference purpose we will be talking to the card at index value 0
|
||||
*/
|
||||
memcpy(phNfcLib_TransmitInput.phNfcLib_ISO15693.bUid, PeerInfo.uTi.uInitiator.tIso15693.TagIndex[0].pUid, 8);
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
/*************************************************************************************************************************
|
||||
****************************************READ SINGLE BLOCK ***************************************************************
|
||||
*************************************************************************************************************************/
|
||||
|
||||
/* The parameters for Read Single Block are the option and the Block number user wants to read */
|
||||
/* Option is kept #PH_OFF for refer purpose and the block number to Read is Block - 5 */
|
||||
READ_SINGLEBLOCK(PH_OFF, 5)
|
||||
|
||||
/* Finally the command has to be sent, the command for 15693 will be send in addressed mode */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x0 /* This length paramter is used only when apart from the command, there is some data to be send*/
|
||||
);
|
||||
|
||||
/* The status should be success, if not break from the application */
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF (" \n Card does not support Read single block... \n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* wNumberofBytes has to be reset before every receive */
|
||||
wNumberofBytes = 256;
|
||||
|
||||
/*The data received over the above command can be retrieved by calling the receive */
|
||||
/* wNumberofBytes first as input tells the max supported recieve size and then as out tells the actual number of data bytes received */
|
||||
/* wNumberofBytes will vary depending upon the card layout*/
|
||||
dwStatus = phNfcLib_Receive(&bDataBuffer[0],
|
||||
&wNumberofBytes,
|
||||
&bMoreDataAvailable
|
||||
);
|
||||
|
||||
/* The status should be success and the number of bytes received should be 4 for Most NXP cards
|
||||
* The expectation of the number of bytes can be modified for different cards
|
||||
*/
|
||||
if((dwStatus != PH_NFCLIB_STATUS_SUCCESS) ||(wNumberofBytes != 4))
|
||||
{
|
||||
break;
|
||||
}
|
||||
DEBUG_PRINTF("\nRead Data from Block 5 is");
|
||||
phApp_Print_Buff(&bDataBuffer[0], wNumberofBytes);
|
||||
|
||||
/*************************************************************************************************************************
|
||||
****************************************WRITE SINGLE BLOCK **************************************************************
|
||||
*************************************************************************************************************************/
|
||||
|
||||
/* The parameters for Write Single Block are the option, the Block number user wants to write and the data */
|
||||
/* Option is kept #PH_OFF for refer purpose and the block number to write is Block - 5 */
|
||||
|
||||
WRITE_SINGLEBLOCK(PH_OFF, 5, &bData[0])
|
||||
|
||||
/* Finally the command has to be sent, the command for 15693 will be send in addressed mode */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x04 /* While writing a block we will be writing 4 bytes of data*/
|
||||
);
|
||||
|
||||
/* The status should be success, if not break from the application */
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF (" \n Card does not support Write single block... \n");
|
||||
break;
|
||||
}
|
||||
|
||||
/*************************************************************************************************************************
|
||||
****************************************READ MULTIPLE BLOCK **************************************************************
|
||||
*************************************************************************************************************************/
|
||||
|
||||
/* The parameters for Read Multiple Block are the option, the starting Block number and the no of blocks to read*/
|
||||
/* Option is kept #PH_OFF for refer purpose, the starting block number is 5 and the no of blocks is 4*/
|
||||
READ_MULTIPLEBLOCK(PH_OFF, 5, 4)
|
||||
|
||||
/* Finally the command has to be sent, the command for 15693 will be send in addressed mode */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x0 /* This length paramter is used only when apart from the command, there is some data to be send*/
|
||||
);
|
||||
|
||||
/* The status should be success, if not break from the application */
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF (" \n Card does not support Read Multiple block... \n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* This parameter has to be reset before every receive */
|
||||
wNumberofBytes = 256;
|
||||
|
||||
/*The data received over the above command can be retrieved by calling the receive */
|
||||
/* wNumberofBytes first as input tells the max supported recieve size and then as out tells the actual number of data bytes received */
|
||||
/* wNumberofBytes will vary depending upon the card layout*/
|
||||
dwStatus = phNfcLib_Receive(&bDataBuffer[0],
|
||||
&wNumberofBytes,
|
||||
&bMoreDataAvailable
|
||||
);
|
||||
|
||||
/* The status should be success and the number of bytes received should be 4 * numofblocks for Most NXP cards
|
||||
* The expectation of the number of bytes can be modified for different cards
|
||||
*/
|
||||
if((dwStatus != PH_NFCLIB_STATUS_SUCCESS) ||(wNumberofBytes != 16))
|
||||
{
|
||||
break;
|
||||
}
|
||||
DEBUG_PRINTF("\nRead Data from Block 5 to 8 is");
|
||||
phApp_Print_Buff(&bDataBuffer[0], wNumberofBytes);
|
||||
|
||||
/*************************************************************************************************************************
|
||||
*****************************************GET SYSTEM INFORMATION *********************************************************
|
||||
*************************************************************************************************************************/
|
||||
|
||||
/* Get System Information takes no parameter and returns back the System Information */
|
||||
GET_SYSTEMINFORMATION()
|
||||
|
||||
/* Finally the command has to be sent, the command for 15693 will be send in addressed mode */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x0 /* This length parameter is used only when apart from the command, there is some data to be send*/
|
||||
);
|
||||
|
||||
/* The status should be success, if not break from the application */
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF (" \n Card does not support GET SYSTEM INFORMATION... \n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* This parameter has to be reset before every receive */
|
||||
wNumberofBytes = 256;
|
||||
|
||||
/*The System Information received over the above command can be retrieved by calling the receive */
|
||||
/* wNumberofBytes first as input tells the max supported recieve size and then as out tells the actual number of data bytes received */
|
||||
dwStatus = phNfcLib_Receive(&bDataBuffer[0],
|
||||
&wNumberofBytes,
|
||||
&bMoreDataAvailable
|
||||
);
|
||||
|
||||
/* The status should be success */
|
||||
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
break;
|
||||
}
|
||||
DEBUG_PRINTF("\nSystem Information is ");
|
||||
phApp_Print_Buff(&bDataBuffer[0], wNumberofBytes);
|
||||
|
||||
/*************************************************************************************************************************
|
||||
************************************GET MULTIPLE BLOCK SECURITY STATUS **************************************************
|
||||
*************************************************************************************************************************/
|
||||
|
||||
/* The parameters for Get Multiple Block security Status are the starting block nad the no of blocks whose status to read*/
|
||||
/* Starting block is 9 which is already locked and no of blocks is 4 */
|
||||
|
||||
GET_MULTIPLEBLOCKSECURITYSTATUS(9, 4)
|
||||
|
||||
/* Finally the command has to be sent, the command for 15693 will be send in addressed mode */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x0 /* This length parameter is used only when apart from the command, there is some data to be send*/
|
||||
);
|
||||
|
||||
/* The status should be success, if not break from the application */
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF (" \n Card does not support GET MULTIPLE BLOCK SECURITY STATUS... \n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* This parameter has to be reset before every receive */
|
||||
wNumberofBytes = 256;
|
||||
|
||||
/*The System Information received over the above command can be retrieved by calling the receive */
|
||||
/* wNumberofBytes first as input tells the max supported recieve size and then as out tells the actual number of data bytes received */
|
||||
dwStatus = phNfcLib_Receive(&bDataBuffer[0],
|
||||
&wNumberofBytes,
|
||||
&bMoreDataAvailable
|
||||
);
|
||||
|
||||
/* The status should be success */
|
||||
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
break;
|
||||
}
|
||||
DEBUG_PRINTF("\nSecurity status for block 9 to 12 is ");
|
||||
phApp_Print_Buff(&bDataBuffer[0], wNumberofBytes);
|
||||
|
||||
}while(0);
|
||||
|
||||
return dwStatus;
|
||||
}
|
||||
@ -0,0 +1,189 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright 2016-2022 NXP */
|
||||
/* */
|
||||
/* NXP Confidential. This software is owned or controlled by NXP and may only */
|
||||
/* be used strictly in accordance with the applicable license terms. */
|
||||
/* By expressly accepting such terms or by downloading, installing, */
|
||||
/* activating and/or otherwise using the software, you are agreeing that you */
|
||||
/* have read, and that you agree to comply with and are bound by, such */
|
||||
/* license terms. If you do not agree to be bound by the applicable license */
|
||||
/* terms, then you may not retain, install, activate or otherwise use the */
|
||||
/* software. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \file
|
||||
* Reference application file for ISO18000 interface of Simplified API
|
||||
* $Author: NXP $
|
||||
* $Revision: $ (v07.10.00)
|
||||
* $Date: $
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Nfcrdlib_SimplifiedApi_ISO.h>
|
||||
|
||||
extern phNfcLib_Transmit_t phNfcLib_TransmitInput;
|
||||
extern phNfcLib_PeerInfo_t PeerInfo;
|
||||
|
||||
extern uint8_t bMoreDataAvailable;
|
||||
extern uint16_t wNumberofBytes;
|
||||
extern uint8_t bDataBuffer[256];
|
||||
|
||||
#define NFCLIB_I18000P3M3_REQRN_USE_HANDLE 0x01U /**< Use given Handle for ReqRn command. */
|
||||
|
||||
#define NFCLIB_I18000P3M3_AC_NO_COVER_CODING 0x00U /**< Do not use cover coding, send plain passwords. */
|
||||
#define NFCLIB_I18000P3M3_AC_USE_COVER_CODING 0x01U /**< Use cover coding to diversify passwords. */
|
||||
|
||||
uint32_t NfcLib_ISO18000p3m3_Reference_app()
|
||||
{
|
||||
uint32_t dwStatus;
|
||||
uint8_t bWordPtr = 0x00;
|
||||
uint8_t bData[8] = {0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A};
|
||||
uint8_t bPassword[4] = {0x00, 0x00, 0x00, 0x00}; /* Default Paasword */
|
||||
uint8_t bHandle[2] = {0x00, 0x00}; /* Invalid Handle */
|
||||
|
||||
phNfcLib_TransmitInput.phNfcLib_ISO18000.wUiiMaskLength = PeerInfo.uTi.uInitiator.tIso18000_3_3.TagIndex[0].wUiiLength;
|
||||
phNfcLib_TransmitInput.phNfcLib_ISO18000.pUii = PeerInfo.uTi.uInitiator.tIso18000_3_3.TagIndex[0].pUii;
|
||||
|
||||
do
|
||||
{
|
||||
/*************************************************************************************************************************
|
||||
********************************************************WRITE************************************************************
|
||||
*************************************************************************************************************************/
|
||||
/* Write is performed with Using cover coding on user membank(0x03) from the start of membank */
|
||||
I18000_WRITE(NFCLIB_I18000P3M3_AC_USE_COVER_CODING, 0x03, &bWordPtr, 0x00, &bData[0])
|
||||
|
||||
/* Finally the command has to be sent */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x2 /* A word is of 2 bytes*/
|
||||
);
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF (" \n Performing Write Operation to user Membank failed, Membank may be locked.. \n");
|
||||
break;
|
||||
}
|
||||
/*************************************************************************************************************************
|
||||
*******************************************************READ**************************************************************
|
||||
*************************************************************************************************************************/
|
||||
|
||||
/* READ wants to perform Read on Membank 0x03 which is a user memory, from the start of the user memory thus ptr and ptr length
|
||||
* as 0x00 and total no of words as 1
|
||||
*/
|
||||
I18000_READ(0x03, &bWordPtr, 0x00, 0x01)
|
||||
|
||||
/* Finally the command has to be sent */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x0 /* This length paramter is used only when apart from the command, there is some data to be send*/
|
||||
);
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF (" \n Read Operation of User Membank failed, Membank may be locked... \n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* This parameter has to be reset before every receive */
|
||||
wNumberofBytes = 256;
|
||||
|
||||
/*The data received over the above command can be retrieved by calling the receive will be same as above write */
|
||||
/* wNumberofBytes first as input tells the max supported recieve size and then as out tells the actual number of data bytes received */
|
||||
dwStatus = phNfcLib_Receive(&bDataBuffer[0],
|
||||
&wNumberofBytes,
|
||||
&bMoreDataAvailable
|
||||
);
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
break;
|
||||
}
|
||||
DEBUG_PRINTF("\nData Read from the ISO File is");
|
||||
phApp_Print_Buff(&bDataBuffer[0], wNumberofBytes);
|
||||
/*************************************************************************************************************************
|
||||
******************************************************BLOCK WRITE*********************************************************
|
||||
*************************************************************************************************************************/
|
||||
/* Block write is a optional command please check the card's spec regarding support */
|
||||
/* BLOCK_WRITE is being performed on User Membank(0x03), from the start of the Mmebank and for ICode ILT-M one block is 2 words */
|
||||
I18000_BLOCKWRITE(0x03, &bWordPtr, 0x00, 2, &bData[0])
|
||||
|
||||
/* Finally the command has to be sent */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x4 /* Since ICode ILT-M supports maximum 2 word block write*/
|
||||
);
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF("\nCard Does not support Block Write");
|
||||
break;
|
||||
}
|
||||
|
||||
/*************************************************************************************************************************
|
||||
********************************************************ACCESS************************************************************
|
||||
*************************************************************************************************************************/
|
||||
/* Access is performed with cover coding and default password */
|
||||
I18000_ACCESS(PH_NFCLIB_18000P3M3_AC_USE_COVER_CODING, &bPassword[0])
|
||||
|
||||
/* Finally the command has to be sent */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x0 /* No data to be send apart from command*/
|
||||
);
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF("\nAccess Operation Failed, use factory default card");
|
||||
break;
|
||||
}
|
||||
|
||||
/*************************************************************************************************************************
|
||||
******************************************************REQ RN*************************************************************
|
||||
*************************************************************************************************************************/
|
||||
|
||||
/* REQRN can here be performed only with handle option */
|
||||
I18000_REQRN(NFCLIB_I18000P3M3_REQRN_USE_HANDLE)
|
||||
|
||||
/* Finally the command has to be sent */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x0 /* No data to be send apart from command*/
|
||||
);
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF("\nReqRN failed");
|
||||
break;
|
||||
}
|
||||
/*************************************************************************************************************************
|
||||
**********************************************************ACK************************************************************
|
||||
*************************************************************************************************************************/
|
||||
/* ACK takes no parameter and sends the ack with the Handle */
|
||||
I18000_ACK()
|
||||
/* Finally the command has to be sent */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x0 /* No data to be send */
|
||||
);
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF (" \n Performing Ack Operation failed... \n");
|
||||
break;
|
||||
}
|
||||
/* This parameter has to be reset before every receive */
|
||||
wNumberofBytes = 256;
|
||||
|
||||
/*The data received over the above command can be retrieved by calling the receive */
|
||||
/* wNumberofBytes first as input tells the max supported recieve size and then as out tells the actual number of data bytes received */
|
||||
dwStatus = phNfcLib_Receive(&bDataBuffer[0],
|
||||
&wNumberofBytes,
|
||||
&bMoreDataAvailable
|
||||
);
|
||||
DEBUG_PRINTF("\nUII Data Received is");
|
||||
phApp_Print_Buff(&bDataBuffer[0], wNumberofBytes);
|
||||
|
||||
/*************************************************************************************************************************
|
||||
******************************************************SET HANDLE**********************************************************
|
||||
*************************************************************************************************************************/
|
||||
/* Set Handle is to provide the handle to the data params */
|
||||
I18000_SETHANDLE(&bHandle[0])
|
||||
|
||||
/* Finally the command has to be sent */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x0 /* No data to be send apart from command*/
|
||||
);
|
||||
|
||||
/**************************************************************************************************************************/
|
||||
|
||||
}while(0);
|
||||
|
||||
return dwStatus;
|
||||
}
|
||||
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c), NXP Semiconductors Bangalore / India
|
||||
*
|
||||
* (C)NXP Semiconductors
|
||||
* All rights are reserved. Reproduction in whole or in part is
|
||||
* prohibited without the written consent of the copyright owner.
|
||||
* NXP reserves the right to make changes without notice at any time.
|
||||
* NXP makes no warranty, expressed, implied or statutory, including but
|
||||
* not limited to any implied warranty of merchantability or fitness for any
|
||||
* particular purpose, or that the use will not infringe any third party patent,
|
||||
* copyright or trademark. NXP must not be liable for any loss or damage
|
||||
* arising from its use.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Reference application file for Type A Layer 4 interface of Simplified API
|
||||
* $Author: Ashish Pal (nxp79566) $
|
||||
* $Revision: 5458 $ (v07.10.00)
|
||||
* $Date: 2016-09-01 19:11:09 +0530 (Thu, 01 Sept 2016) $
|
||||
*
|
||||
* History:
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Nfcrdlib_SimplifiedApi_ISO.h>
|
||||
|
||||
extern phNfcLib_Transmit_t phNfcLib_TransmitInput;
|
||||
extern phNfcLib_PeerInfo_t PeerInfo;
|
||||
|
||||
extern uint8_t bMoreDataAvailable;
|
||||
extern uint16_t wNumberofBytes;
|
||||
extern uint8_t bDataBuffer[256];
|
||||
|
||||
/*
|
||||
* This application is to demonstrate the usage of simplified API related to Layer 4 Type A
|
||||
* The application reaches to this point only after the activation of a card of Type B technology with
|
||||
* or without ISO 14443-4 compatibilty is done. Transmit api is used to perform any command exchange with the card and
|
||||
* receive api is used to get back the out data.
|
||||
*/
|
||||
uint32_t NfcLib_Layer4TypeA_Reference_app()
|
||||
{
|
||||
uint32_t dwStatus;
|
||||
uint8_t bData[6] = {0};
|
||||
do
|
||||
{
|
||||
|
||||
/*************************************************************************************************************************
|
||||
****************************************ISO 14443-4 EXCHANGE ************************************************************
|
||||
*************************************************************************************************************************/
|
||||
|
||||
/*
|
||||
* To perform ISO14443-4 layer exchange first form the command in bData
|
||||
* this is get challenge command of ISO7816-4
|
||||
*/
|
||||
bData[0] = 0x00; /* INF1 */
|
||||
bData[1] = 0x84; /* INF2 */
|
||||
bData[2] = 0x00; /* INF3 */
|
||||
bData[3] = 0x00; /* INF4 */
|
||||
bData[4] = 0x08; /* INF4 */
|
||||
|
||||
phNfcLib_TransmitInput.phNfcLib_RawTransmit.pBuffer = &bData[0];
|
||||
|
||||
/* Finally the command has to be sent, the command for Type a with layer 4 compatibility will be send with ISO 7816 - 4*/
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x05 /* Length of this exchange is 5 bytes*/
|
||||
);
|
||||
|
||||
/* The status should be success, if not break from the application */
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
/* This parameter has to be reset before every receive */
|
||||
wNumberofBytes = 256;
|
||||
|
||||
/*The data received over the above command can be retrieved by calling the receive */
|
||||
/* wNumberofBytes first as input tells the max supported recieve size and then as out tells the actual number of data bytes received */
|
||||
/* wNumberofBytes will vary depending upon the card layout*/
|
||||
dwStatus = phNfcLib_Receive(&bDataBuffer[0],
|
||||
&wNumberofBytes,
|
||||
&bMoreDataAvailable
|
||||
);
|
||||
DEBUG_PRINTF("\nReply to get challenge is");
|
||||
phApp_Print_Buff(&bDataBuffer[0], wNumberofBytes);
|
||||
/*************************************************************************************************************************/
|
||||
|
||||
}while(0);
|
||||
|
||||
return dwStatus;
|
||||
|
||||
}
|
||||
@ -0,0 +1,267 @@
|
||||
/*
|
||||
* Copyright (c), NXP Semiconductors Bangalore / India
|
||||
*
|
||||
* (C)NXP Semiconductors
|
||||
* All rights are reserved. Reproduction in whole or in part is
|
||||
* prohibited without the written consent of the copyright owner.
|
||||
* NXP reserves the right to make changes without notice at any time.
|
||||
* NXP makes no warranty, expressed, implied or statutory, including but
|
||||
* not limited to any implied warranty of merchantability or fitness for any
|
||||
* particular purpose, or that the use will not infringe any third party patent,
|
||||
* copyright or trademark. NXP must not be liable for any loss or damage
|
||||
* arising from its use.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Reference application file for MFC interface of Simplified API
|
||||
* $Author: Ashish Pal (nxp79566) $
|
||||
* $Revision: 5458 $ (v07.10.00)
|
||||
* $Date: 2016-09-01 19:11:09 +0530 (Thu, 01 Sept 2016) $
|
||||
*
|
||||
* History:
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Nfcrdlib_SimplifiedApi_ISO.h>
|
||||
|
||||
static uint8_t Message[16] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
|
||||
extern phNfcLib_Transmit_t phNfcLib_TransmitInput;
|
||||
extern phNfcLib_PeerInfo_t PeerInfo;
|
||||
|
||||
extern uint8_t bMoreDataAvailable;
|
||||
extern uint16_t wNumberofBytes;
|
||||
extern uint8_t bDataBuffer[256];
|
||||
|
||||
#define MFC_KEYA 0x0AU /**< MIFARE(R) Key A. */
|
||||
#define MFC_KEYB 0x0BU /**< MIFARE(R) Key B. */
|
||||
|
||||
void framevalueblock(uint8_t* pValue, uint8_t bAddrData, uint8_t* pBlock);
|
||||
|
||||
/*
|
||||
* This application is to demonstrate the usage of simplified API related to MIFARE Classic contactless IC 1K
|
||||
* The application reaches to this point only after the activation of a Mifare Classic 1k card
|
||||
* with Type A technology is done. Transmit api is used to perform any command exchange with the card and
|
||||
* receive api is used to get back the out data.
|
||||
*/
|
||||
uint32_t NfcLib_MifareClassic_1k_Reference_app()
|
||||
{
|
||||
uint32_t dwStatus;
|
||||
uint8_t pValue[4] = {0x10, 0x10, 0x10, 0x10};
|
||||
uint8_t pBlock[16] = {0};
|
||||
|
||||
do
|
||||
{
|
||||
/*************************************************************************************************************************
|
||||
*********************************************AUTHENTICATE ***************************************************************
|
||||
*************************************************************************************************************************/
|
||||
/* Authenticate takes the block number to authenticate which is 6 alng with the Key type as MFC_KEYA and key number as 1
|
||||
* and key version as 0X00, Key no and Key version depends upon the keystore settings, authenticate is valid for one sector
|
||||
*/
|
||||
MFC_AUTHENTICATE(6, MFC_KEYA, 0x01, 0x00)
|
||||
/* To Perform the Authentication of Block 6 */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x0
|
||||
);
|
||||
/* The status should be success, if not break from the application */
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF (" \n Authenticate Failed Please use the factory default card... \n");
|
||||
break;
|
||||
}
|
||||
|
||||
/*************************************************************************************************************************
|
||||
***********************************************WRITE*********************************************************************
|
||||
*************************************************************************************************************************/
|
||||
|
||||
/* Write takes the block number and data to write, the block number is 6 */
|
||||
MFC_WRITE(6, &Message[0])
|
||||
|
||||
/* To perform the write operation of Block 6 */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x10
|
||||
);
|
||||
/* The status should be success, if not break from the application */
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF (" \n Write to the Mifare Classic Card Failed... \n");
|
||||
break;
|
||||
}
|
||||
|
||||
/*************************************************************************************************************************
|
||||
***********************************************READ**********************************************************************
|
||||
*************************************************************************************************************************/
|
||||
/* Read takes the block number to Read */
|
||||
MFC_READ(6)
|
||||
|
||||
/* To perform the read operation of Block 6 that was written above*/
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x0
|
||||
);
|
||||
/* The status should be success, if not break from the application */
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF (" \n Read from the Mifare Classic Card Failed... \n");
|
||||
break;
|
||||
}
|
||||
/* Has to be reset before every receive */
|
||||
wNumberofBytes = 256;
|
||||
|
||||
/* To perform receive operation to get back the read data */
|
||||
dwStatus = phNfcLib_Receive(&bDataBuffer[0],
|
||||
&wNumberofBytes,
|
||||
&bMoreDataAvailable
|
||||
);
|
||||
/* The status should be success, if not break from the application */
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
break;
|
||||
}
|
||||
DEBUG_PRINTF("\nRead Data from block 6 is");
|
||||
phApp_Print_Buff(&bDataBuffer[0], wNumberofBytes);
|
||||
/*************************************************************************************************************************
|
||||
*****************************************Creating Value Block************************************************************
|
||||
*************************************************************************************************************************/
|
||||
|
||||
/* Api to frame the value block output pBlock is the value block */
|
||||
framevalueblock(&pValue[0], 0x05, &pBlock[0]);
|
||||
|
||||
/* Making the Block 5 as the vALUE block */
|
||||
MFC_WRITE(5, &pBlock[0])
|
||||
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x10 /* 16 bytes of data to be written for value block */
|
||||
);
|
||||
|
||||
/* The status should be success, if not break from the application */
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF (" \n Creating Value block on Mifare Classic Failed... \n");
|
||||
break;
|
||||
}
|
||||
/*************************************************************************************************************************
|
||||
***********************************************INCREMENT*****************************************************************
|
||||
*************************************************************************************************************************/
|
||||
|
||||
/* Now increment can be perfomed over this value block */
|
||||
/* Value block to increment is 5 and then the data to be incremented */
|
||||
MFC_INCREMENT(5, &pValue[0])
|
||||
|
||||
/* To perform the increment operation on block 5 */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x4 /* the value block for increment just takes 4 byte */
|
||||
);
|
||||
/* The status should be success, if not break from the application */
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF (" \n Increment to the value block failed... \n");
|
||||
break;
|
||||
}
|
||||
|
||||
/*************************************************************************************************************************
|
||||
***********************************************TRANSFER******************************************************************
|
||||
*************************************************************************************************************************/
|
||||
/* Transfer takes the block number where the transfer buffer will be transmitted, this case it is 5 */
|
||||
MFC_TRANSFER(5)
|
||||
|
||||
/* To perform the transfer operation to transfer data from transferred block to the block 5 */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x0
|
||||
);
|
||||
/* The status should be success, if not break from the application */
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF (" \n Increment Transfer Operation failed... \n");
|
||||
break;
|
||||
}
|
||||
|
||||
/*************************************************************************************************************************
|
||||
***********************************************DECREMENT*****************************************************************
|
||||
*************************************************************************************************************************/
|
||||
|
||||
/* Value block to decrement is 5 and then the data to be decremented */
|
||||
MFC_DECREMENT(5, &pValue[0])
|
||||
|
||||
/* To perform the decrement operation on block 5 */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x4 /* the value block for decrement just takes 4 byte */
|
||||
);
|
||||
/* The status should be success, if not break from the application */
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF (" \n Decrement Operation failed... \n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Transfer takes the block number where the transfer buffer will be transmitted, this case it is 5 */
|
||||
MFC_TRANSFER(5)
|
||||
|
||||
/* To perform the transfer operation to transfer data from transferred block to the block 5 */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x0
|
||||
);
|
||||
/* The status should be success, if not break from the application */
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF (" \n Decrement Transfer Operation failed... \n");
|
||||
break;
|
||||
}
|
||||
|
||||
/*************************************************************************************************************************
|
||||
***********************************************RESTORE*****************************************************************
|
||||
*************************************************************************************************************************/
|
||||
/* Restore takes the block number from where the transfer buffer shalee be restored and is 5 here */
|
||||
MFC_RESTORE(5)
|
||||
|
||||
/* To perform the restore operation */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x0
|
||||
);
|
||||
|
||||
/* The status should be success, if not break from the application */
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF (" \n Restore Operation failed... \n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Transfer takes the block number where the transfer buffer will be transmitted, this case it is 5 */
|
||||
MFC_TRANSFER(5)
|
||||
|
||||
/* To perform the transfer operation to transfer data from transferred block to the block 5 */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x0
|
||||
);
|
||||
/* The status should be success, if not break from the application */
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF (" \n Restore Transfer Operation failed... \n");
|
||||
break;
|
||||
}
|
||||
}while(0);
|
||||
|
||||
return dwStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* API to generate value block
|
||||
*/
|
||||
void framevalueblock(uint8_t* pValue, uint8_t bAddrData, uint8_t* pBlock)
|
||||
{
|
||||
pBlock[0] = (uint8_t)pValue[0];
|
||||
pBlock[1] = (uint8_t)pValue[1];
|
||||
pBlock[2] = (uint8_t)pValue[2];
|
||||
pBlock[3] = (uint8_t)pValue[3];
|
||||
pBlock[4] = (uint8_t)~(uint8_t)pValue[0];
|
||||
pBlock[5] = (uint8_t)~(uint8_t)pValue[1];
|
||||
pBlock[6] = (uint8_t)~(uint8_t)pValue[2];
|
||||
pBlock[7] = (uint8_t)~(uint8_t)pValue[3];
|
||||
pBlock[8] = (uint8_t)pValue[0];
|
||||
pBlock[9] = (uint8_t)pValue[1];
|
||||
pBlock[10] = (uint8_t)pValue[2];
|
||||
pBlock[11] = (uint8_t)pValue[3];
|
||||
pBlock[12] = (uint8_t)bAddrData;
|
||||
pBlock[13] = (uint8_t)~(uint8_t)bAddrData;
|
||||
pBlock[14] = (uint8_t)bAddrData;
|
||||
pBlock[15] = (uint8_t)~(uint8_t)bAddrData;
|
||||
}
|
||||
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (c), NXP Semiconductors Bangalore / India
|
||||
*
|
||||
* (C)NXP Semiconductors
|
||||
* All rights are reserved. Reproduction in whole or in part is
|
||||
* prohibited without the written consent of the copyright owner.
|
||||
* NXP reserves the right to make changes without notice at any time.
|
||||
* NXP makes no warranty, expressed, implied or statutory, including but
|
||||
* not limited to any implied warranty of merchantability or fitness for any
|
||||
* particular purpose, or that the use will not infringe any third party patent,
|
||||
* copyright or trademark. NXP must not be liable for any loss or damage
|
||||
* arising from its use.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Reference application file for MFUL interface of Simplified API
|
||||
* $Author: Ashish Pal (nxp79566) $
|
||||
* $Revision: 5458 $ (v07.10.00)
|
||||
* $Date: 2016-09-01 19:11:09 +0530 (Thu, 01 Sept 2016) $
|
||||
*
|
||||
* History:
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Nfcrdlib_SimplifiedApi_ISO.h>
|
||||
|
||||
extern phNfcLib_Transmit_t phNfcLib_TransmitInput;
|
||||
extern phNfcLib_PeerInfo_t PeerInfo;
|
||||
|
||||
extern uint8_t bMoreDataAvailable;
|
||||
extern uint16_t wNumberofBytes;
|
||||
extern uint8_t bDataBuffer[256];
|
||||
|
||||
/*
|
||||
* This application is to demonstrate the usage of simplified API related to MIFARE Ultralight contactless IC
|
||||
* The application reaches to this point only after the activation of a Mifare Ultralight card
|
||||
* with Type A technology is done. Transmit api is used to perform any command exchange with the card and
|
||||
* receive api is used to get back the out data.
|
||||
*/
|
||||
|
||||
uint32_t NfcLib_MifareUltralight_Reference_app()
|
||||
{
|
||||
uint32_t dwStatus;
|
||||
uint8_t bData[16] = {0xB0, 0xB0, 0xB0, 0xB0,
|
||||
0xA0, 0xA0, 0xA0, 0xA0,
|
||||
0xA0, 0xA0, 0xA0, 0xA0,
|
||||
0xA0, 0xA0, 0xA0, 0xA0};
|
||||
|
||||
do
|
||||
{
|
||||
/*************************************************************************************************************************
|
||||
*********************************************MFUL READ *****************************************************************
|
||||
*************************************************************************************************************************/
|
||||
/* MFUL read takes the page number to read, for refer purpose the page is page 5 */
|
||||
MFUL_READ(5)
|
||||
|
||||
/* Transmit will execute the command the returned data can be read by Receive command */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x0 /* This length paramter is used only when apart from the command, there is some data to be send*/
|
||||
);
|
||||
|
||||
/* The status should be success, if not break from the application */
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF (" \n Read for Block 5 failed... \n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* This parameter has to be reset before every receive */
|
||||
wNumberofBytes = 256;
|
||||
|
||||
/* To perform receive operation to get back the read data */
|
||||
dwStatus = phNfcLib_Receive(&bDataBuffer[0],
|
||||
&wNumberofBytes,
|
||||
&bMoreDataAvailable
|
||||
);
|
||||
|
||||
/* The status should be success and the number of bytes received should be 16 for MIFARE Ultralight cards */
|
||||
if((dwStatus != PH_NFCLIB_STATUS_SUCCESS) ||(wNumberofBytes != 16))
|
||||
{
|
||||
break;
|
||||
}
|
||||
DEBUG_PRINTF("\nRead Data from block 5 is");
|
||||
phApp_Print_Buff(&bDataBuffer[0], wNumberofBytes);
|
||||
|
||||
/*************************************************************************************************************************
|
||||
*********************************************MFUL WRITE******************************************************************
|
||||
*************************************************************************************************************************/
|
||||
/* MFUL write takes the page number and data to write, for refer purpose the page is page 5 */
|
||||
MFUL_WRITE(5, &bData[0])
|
||||
|
||||
/* Transmit will execute the command */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x04 /* For Mifare Ultralight the size of a page to be written is 4 bytes */
|
||||
);
|
||||
|
||||
/* The status should be success, if not break from the application */
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF (" \n Write to Block 5 failed... \n");
|
||||
break;
|
||||
}
|
||||
|
||||
/*************************************************************************************************************************
|
||||
*********************************************MFUL COMPATIBILITY WRITE ***************************************************
|
||||
*************************************************************************************************************************/
|
||||
|
||||
/* MFUL Compatibilily write takes the page number and data to write, for refer purpose the page is page 6 */
|
||||
/* the command is just to accomodate the Mifare PCD infrastructure */
|
||||
MFUL_WRITE(6, &bData[0])
|
||||
|
||||
/* Transmit will execute the command */
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x10 /* But only 4 LSB will be actuallly written, 16 byte is only for compatibility purpose */
|
||||
);
|
||||
|
||||
/* The status should be success, if not break from the application */
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF (" \n Compatibilty Write to Block 5 failed... \n");
|
||||
break;
|
||||
}
|
||||
|
||||
/*************************************************************************************************************************/
|
||||
}while(0);
|
||||
|
||||
return dwStatus;
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c), NXP Semiconductors Bangalore / India
|
||||
*
|
||||
* (C)NXP Semiconductors
|
||||
* All rights are reserved. Reproduction in whole or in part is
|
||||
* prohibited without the written consent of the copyright owner.
|
||||
* NXP reserves the right to make changes without notice at any time.
|
||||
* NXP makes no warranty, expressed, implied or statutory, including but
|
||||
* not limited to any implied warranty of merchantability or fitness for any
|
||||
* particular purpose, or that the use will not infringe any third party patent,
|
||||
* copyright or trademark. NXP must not be liable for any loss or damage
|
||||
* arising from its use.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Reference application file for Type B interface of Simplified API
|
||||
* $Author: Ashish Pal (nxp79566) $
|
||||
* $Revision: 5458 $ (v07.10.00)
|
||||
* $Date: 2016-09-01 19:11:09 +0530 (Thu, 01 Sept 2016) $
|
||||
*
|
||||
* History:
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Nfcrdlib_SimplifiedApi_ISO.h>
|
||||
|
||||
extern phNfcLib_Transmit_t phNfcLib_TransmitInput;
|
||||
extern phNfcLib_PeerInfo_t PeerInfo;
|
||||
|
||||
extern uint8_t bMoreDataAvailable;
|
||||
extern uint16_t wNumberofBytes;
|
||||
extern uint8_t bDataBuffer[256];
|
||||
|
||||
/*
|
||||
* This application is to demonstrate the usage of simplified API related to Type B
|
||||
* The application reaches to this point only after the activation of a card of Type B technology with
|
||||
* or without ISO 14443-4 compatibilty is done. Transmit api is used to perform any command exchange with the card and
|
||||
* receive api is used to get back the out data.
|
||||
*/
|
||||
uint32_t NfcLib_TypeB_Reference_app()
|
||||
{
|
||||
uint32_t dwStatus;
|
||||
uint8_t bData[6] = {0};
|
||||
do
|
||||
{
|
||||
|
||||
/*************************************************************************************************************************
|
||||
****************************************ISO 14443-4 EXCHANGE ************************************************************
|
||||
*************************************************************************************************************************/
|
||||
|
||||
/*
|
||||
* To perform ISO14443-4 layer exchange first form the command in bData
|
||||
* this is get challenge command of ISO7816-4
|
||||
*/
|
||||
bData[0] = 0x00; /* INF1 */
|
||||
bData[1] = 0x84; /* INF2 */
|
||||
bData[2] = 0x00; /* INF3 */
|
||||
bData[3] = 0x00; /* INF4 */
|
||||
bData[4] = 0x08; /* INF4 */
|
||||
|
||||
phNfcLib_TransmitInput.phNfcLib_RawTransmit.pBuffer = &bData[0];
|
||||
|
||||
/* Finally the command has to be sent, the command for Type B with layer 4 compatibility will be send with ISO 7816 - 4*/
|
||||
dwStatus = phNfcLib_Transmit(&phNfcLib_TransmitInput,
|
||||
0x05 /* Length of this exchange is 5 bytes*/
|
||||
);
|
||||
|
||||
/* The status should be success, if not break from the application */
|
||||
if(dwStatus != PH_NFCLIB_STATUS_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF("\nGet Challenge failed");
|
||||
break;
|
||||
}
|
||||
|
||||
/* This parameter has to be reset before every receive */
|
||||
wNumberofBytes = 256;
|
||||
|
||||
/*The data received over the above command can be retrieved by calling the receive */
|
||||
/* wNumberofBytes first as input tells the max supported recieve size and then as out tells the actual number of data bytes received */
|
||||
/* wNumberofBytes will vary depending upon the card layout*/
|
||||
dwStatus = phNfcLib_Receive(&bDataBuffer[0],
|
||||
&wNumberofBytes,
|
||||
&bMoreDataAvailable
|
||||
);
|
||||
|
||||
DEBUG_PRINTF("\nReply to get challenge is\n");
|
||||
phApp_Print_Buff(&bDataBuffer[0], wNumberofBytes);
|
||||
/*************************************************************************************************************************/
|
||||
|
||||
}while(0);
|
||||
|
||||
return dwStatus;
|
||||
|
||||
}
|
||||
375
Examples/Nfcrdlib_SimplifiedAPI_ISO/src/phApp_Helper.c
Normal file
375
Examples/Nfcrdlib_SimplifiedAPI_ISO/src/phApp_Helper.c
Normal file
@ -0,0 +1,375 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright 2020 NXP */
|
||||
/* */
|
||||
/* NXP Confidential. This software is owned or controlled by NXP and may only */
|
||||
/* be used strictly in accordance with the applicable license terms. */
|
||||
/* By expressly accepting such terms or by downloading, installing, */
|
||||
/* activating and/or otherwise using the software, you are agreeing that you */
|
||||
/* have read, and that you agree to comply with and are bound by, such */
|
||||
/* license terms. If you do not agree to be bound by the applicable license */
|
||||
/* terms, then you may not retain, install, activate or otherwise use the */
|
||||
/* software. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \file
|
||||
* Example Source abstracting component data structure and code initialization and code specific to HW used in the examples
|
||||
* This file shall be present in all examples. A customer does not need to touch/modify this file. This file
|
||||
* purely depends on the phNxpBuild_Lpc.h or phNxpBuild_App.h
|
||||
* The phAppInit.h externs the component data structures initialized here that is in turn included by the core examples.
|
||||
* The core example shall not use any other variable defined here except the RdLib component data structures(as explained above)
|
||||
* The RdLib component initialization requires some user defined data and function pointers.
|
||||
* These are defined in the respective examples and externed here.
|
||||
*
|
||||
* Keystore and Crypto initialization needs to be handled by application.
|
||||
*
|
||||
* $Author$
|
||||
* $Revision$ (v07.10.00)
|
||||
* $Date$
|
||||
*
|
||||
*/
|
||||
|
||||
#include "phApp_Init.h"
|
||||
|
||||
#include <phOsal.h>
|
||||
|
||||
/*******************************************************************************
|
||||
** Function Declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
** Function Definitions
|
||||
*******************************************************************************/
|
||||
/* Print technology being resolved */
|
||||
void phApp_PrintTech(uint8_t TechType)
|
||||
{
|
||||
switch(TechType)
|
||||
{
|
||||
case PHAC_DISCLOOP_POS_BIT_MASK_A:
|
||||
DEBUG_PRINTF ("\tResolving Type A... \n");
|
||||
break;
|
||||
|
||||
case PHAC_DISCLOOP_POS_BIT_MASK_B:
|
||||
DEBUG_PRINTF ("\tResolving Type B... \n");
|
||||
break;
|
||||
|
||||
case PHAC_DISCLOOP_POS_BIT_MASK_F212:
|
||||
DEBUG_PRINTF ("\tResolving Type F with baud rate 212... \n");
|
||||
break;
|
||||
|
||||
case PHAC_DISCLOOP_POS_BIT_MASK_F424:
|
||||
DEBUG_PRINTF ("\tResolving Type F with baud rate 424... \n");
|
||||
break;
|
||||
|
||||
case PHAC_DISCLOOP_POS_BIT_MASK_V:
|
||||
DEBUG_PRINTF ("\tResolving Type V... \n");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will print buffer content
|
||||
* \param *pBuff Buffer Reference
|
||||
* \param num data size to be print
|
||||
*/
|
||||
void phApp_Print_Buff(uint8_t *pBuff, uint8_t num)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
for(i = 0; i < num; i++)
|
||||
{
|
||||
DEBUG_PRINTF(" %02X",pBuff[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will print Tag information
|
||||
* \param pDataParams The discovery loop data parameters
|
||||
* \param wNumberOfTags Total number of tags detected
|
||||
* \param wTagsDetected Technology Detected
|
||||
*/
|
||||
void phApp_PrintTagInfo(phacDiscLoop_Sw_DataParams_t *pDataParams, uint16_t wNumberOfTags, uint16_t wTagsDetected)
|
||||
{
|
||||
#if defined(NXPBUILD__PHAC_DISCLOOP_TYPEA_TAGS) || \
|
||||
defined(NXPBUILD__PHAC_DISCLOOP_TYPEA_P2P_ACTIVE) || \
|
||||
defined(NXPBUILD__PHAC_DISCLOOP_TYPEB_TAGS) || \
|
||||
defined(NXPBUILD__PHAC_DISCLOOP_TYPEF_TAGS) || \
|
||||
defined(NXPBUILD__PHAC_DISCLOOP_TYPEV_TAGS) || \
|
||||
defined(NXPBUILD__PHAC_DISCLOOP_I18000P3M3_TAGS)
|
||||
uint8_t bIndex;
|
||||
#endif
|
||||
#if defined(NXPBUILD__PHAC_DISCLOOP_TYPEA_TAGS) || defined(NXPBUILD__PHAC_DISCLOOP_TYPEA_P2P_ACTIVE)
|
||||
uint8_t bTagType;
|
||||
#endif
|
||||
|
||||
#if defined(NXPBUILD__PHAC_DISCLOOP_TYPEA_TAGS) || defined(NXPBUILD__PHAC_DISCLOOP_TYPEA_P2P_ACTIVE)
|
||||
if (PHAC_DISCLOOP_CHECK_ANDMASK(wTagsDetected, PHAC_DISCLOOP_POS_BIT_MASK_A))
|
||||
{
|
||||
if(pDataParams->sTypeATargetInfo.bT1TFlag)
|
||||
{
|
||||
DEBUG_PRINTF("\tTechnology : Type A");
|
||||
DEBUG_PRINTF ("\n\t\tUID :");
|
||||
phApp_Print_Buff( pDataParams->sTypeATargetInfo.aTypeA_I3P3[0].aUid,
|
||||
pDataParams->sTypeATargetInfo.aTypeA_I3P3[0].bUidSize);
|
||||
DEBUG_PRINTF ("\n\t\tSAK : 0x%02x",pDataParams->sTypeATargetInfo.aTypeA_I3P3[0].aSak);
|
||||
DEBUG_PRINTF ("\n\t\tType: Type 1 Tag\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_PRINTF("\tTechnology : Type A");
|
||||
for(bIndex = 0; bIndex < wNumberOfTags; bIndex++)
|
||||
{
|
||||
DEBUG_PRINTF ("\n\t\tCard: %d",bIndex + 1);
|
||||
DEBUG_PRINTF ("\n\t\tUID :");
|
||||
phApp_Print_Buff( pDataParams->sTypeATargetInfo.aTypeA_I3P3[bIndex].aUid,
|
||||
pDataParams->sTypeATargetInfo.aTypeA_I3P3[bIndex].bUidSize);
|
||||
DEBUG_PRINTF ("\n\t\tSAK : 0x%02x",pDataParams->sTypeATargetInfo.aTypeA_I3P3[bIndex].aSak);
|
||||
|
||||
if ((pDataParams->sTypeATargetInfo.aTypeA_I3P3[bIndex].aSak & (uint8_t) ~0xFB) == 0)
|
||||
{
|
||||
/* Bit b3 is set to zero, [Digital] 4.8.2 */
|
||||
/* Mask out all other bits except for b7 and b6 */
|
||||
bTagType = (pDataParams->sTypeATargetInfo.aTypeA_I3P3[bIndex].aSak & 0x60);
|
||||
bTagType = bTagType >> 5;
|
||||
|
||||
switch(bTagType)
|
||||
{
|
||||
case PHAC_DISCLOOP_TYPEA_TYPE2_TAG_CONFIG_MASK:
|
||||
DEBUG_PRINTF ("\n\t\tType: Type 2 Tag\n");
|
||||
break;
|
||||
case PHAC_DISCLOOP_TYPEA_TYPE4A_TAG_CONFIG_MASK:
|
||||
DEBUG_PRINTF ("\n\t\tType: Type 4A Tag\n");
|
||||
break;
|
||||
case PHAC_DISCLOOP_TYPEA_TYPE_NFC_DEP_TAG_CONFIG_MASK:
|
||||
DEBUG_PRINTF ("\n\t\tType: P2P\n");
|
||||
break;
|
||||
case PHAC_DISCLOOP_TYPEA_TYPE_NFC_DEP_TYPE4A_TAG_CONFIG_MASK:
|
||||
DEBUG_PRINTF ("\n\t\tType: Type NFC_DEP and 4A Tag\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEB_TAGS
|
||||
if (PHAC_DISCLOOP_CHECK_ANDMASK(wTagsDetected, PHAC_DISCLOOP_POS_BIT_MASK_B))
|
||||
{
|
||||
DEBUG_PRINTF("\tTechnology : Type B");
|
||||
/* Loop through all the Type B tags detected and print the Pupi */
|
||||
for (bIndex = 0; bIndex < wNumberOfTags; bIndex++)
|
||||
{
|
||||
DEBUG_PRINTF ("\n\t\tCard: %d",bIndex + 1);
|
||||
DEBUG_PRINTF ("\n\t\tUID :");
|
||||
/* PUPI Length is always 4 bytes */
|
||||
phApp_Print_Buff( pDataParams->sTypeBTargetInfo.aTypeB_I3P3[bIndex].aPupi, 0x04);
|
||||
}
|
||||
DEBUG_PRINTF("\n");
|
||||
}
|
||||
#endif /* NXPBUILD__PHAC_DISCLOOP_TYPEB_TAGS */
|
||||
|
||||
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEF_TAGS
|
||||
if( PHAC_DISCLOOP_CHECK_ANDMASK(wTagsDetected, PHAC_DISCLOOP_POS_BIT_MASK_F212) ||
|
||||
PHAC_DISCLOOP_CHECK_ANDMASK(wTagsDetected, PHAC_DISCLOOP_POS_BIT_MASK_F424))
|
||||
{
|
||||
DEBUG_PRINTF("\tTechnology : Type F");
|
||||
|
||||
/* Loop through all the type F tags and print the IDm */
|
||||
for (bIndex = 0; bIndex < wNumberOfTags; bIndex++)
|
||||
{
|
||||
DEBUG_PRINTF ("\n\t\tCard: %d",bIndex + 1);
|
||||
DEBUG_PRINTF ("\n\t\tUID :");
|
||||
phApp_Print_Buff( pDataParams->sTypeFTargetInfo.aTypeFTag[bIndex].aIDmPMm,
|
||||
PHAC_DISCLOOP_FELICA_IDM_LENGTH );
|
||||
if ((pDataParams->sTypeFTargetInfo.aTypeFTag[bIndex].aIDmPMm[0] == 0x01) &&
|
||||
(pDataParams->sTypeFTargetInfo.aTypeFTag[bIndex].aIDmPMm[1] == 0xFE))
|
||||
{
|
||||
/* This is Type F tag with P2P capabilities */
|
||||
DEBUG_PRINTF ("\n\t\tType: P2P");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is Type F T3T tag */
|
||||
DEBUG_PRINTF ("\n\t\tType: Type 3 Tag");
|
||||
}
|
||||
|
||||
if(pDataParams->sTypeFTargetInfo.aTypeFTag[bIndex].bBaud != PHAC_DISCLOOP_CON_BITR_212)
|
||||
{
|
||||
DEBUG_PRINTF ("\n\t\tBit Rate: 424\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_PRINTF ("\n\t\tBit Rate: 212\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* NXPBUILD__PHAC_DISCLOOP_TYPEF_TAGS */
|
||||
|
||||
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEV_TAGS
|
||||
if (PHAC_DISCLOOP_CHECK_ANDMASK(wTagsDetected, PHAC_DISCLOOP_POS_BIT_MASK_V))
|
||||
{
|
||||
DEBUG_PRINTF("\tTechnology : Type V / ISO 15693 / T5T");
|
||||
/* Loop through all the Type V tags detected and print the UIDs */
|
||||
for (bIndex = 0; bIndex < wNumberOfTags; bIndex++)
|
||||
{
|
||||
DEBUG_PRINTF ("\n\t\tCard: %d",bIndex + 1);
|
||||
DEBUG_PRINTF ("\n\t\tUID :");
|
||||
phApp_Print_Buff( pDataParams->sTypeVTargetInfo.aTypeV[bIndex].aUid, 0x08);
|
||||
}
|
||||
DEBUG_PRINTF("\n");
|
||||
}
|
||||
#endif /* NXPBUILD__PHAC_DISCLOOP_TYPEV_TAGS */
|
||||
|
||||
#ifdef NXPBUILD__PHAC_DISCLOOP_I18000P3M3_TAGS
|
||||
if (PHAC_DISCLOOP_CHECK_ANDMASK(wTagsDetected, PHAC_DISCLOOP_POS_BIT_MASK_18000P3M3))
|
||||
{
|
||||
DEBUG_PRINTF("\tTechnology : ISO 18000p3m3 / EPC Gen2");
|
||||
/* Loop through all the 18000p3m3 tags detected and print the UII */
|
||||
for (bIndex = 0; bIndex < wNumberOfTags; bIndex++)
|
||||
{
|
||||
DEBUG_PRINTF("\n\t\tCard: %d",bIndex + 1);
|
||||
DEBUG_PRINTF("\n\t\tUII :");
|
||||
phApp_Print_Buff(
|
||||
pDataParams->sI18000p3m3TargetInfo.aI18000p3m3[bIndex].aUii,
|
||||
(pDataParams->sI18000p3m3TargetInfo.aI18000p3m3[bIndex].wUiiLength / 8));
|
||||
}
|
||||
DEBUG_PRINTF("\n");
|
||||
}
|
||||
#endif /* NXPBUILD__PHAC_DISCLOOP_I18000P3M3_TAGS */
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will print Error information received from Reader Lib
|
||||
* \param wStatus Error status
|
||||
*/
|
||||
void PrintErrorInfo(phStatus_t wStatus)
|
||||
{
|
||||
DEBUG_PRINTF("\n ErrorInfo Comp:");
|
||||
|
||||
switch(wStatus & 0xFF00)
|
||||
{
|
||||
case PH_COMP_BAL:
|
||||
DEBUG_PRINTF("\t PH_COMP_BAL");
|
||||
break;
|
||||
case PH_COMP_HAL:
|
||||
DEBUG_PRINTF("\t PH_COMP_HAL");
|
||||
break;
|
||||
case PH_COMP_PAL_ISO14443P3A:
|
||||
DEBUG_PRINTF("\t PH_COMP_PAL_ISO14443P3A");
|
||||
break;
|
||||
case PH_COMP_PAL_ISO14443P3B:
|
||||
DEBUG_PRINTF("\t PH_COMP_PAL_ISO14443P3B");
|
||||
break;
|
||||
case PH_COMP_PAL_ISO14443P4A:
|
||||
DEBUG_PRINTF("\t PH_COMP_PAL_ISO14443P4A");
|
||||
break;
|
||||
case PH_COMP_PAL_ISO14443P4:
|
||||
DEBUG_PRINTF("\t PH_COMP_PAL_ISO14443P4");
|
||||
break;
|
||||
case PH_COMP_PAL_FELICA:
|
||||
DEBUG_PRINTF("\t PH_COMP_PAL_FELICA");
|
||||
break;
|
||||
case PH_COMP_PAL_EPCUID:
|
||||
DEBUG_PRINTF("\t PH_COMP_PAL_EPCUID");
|
||||
break;
|
||||
case PH_COMP_PAL_SLI15693:
|
||||
DEBUG_PRINTF("\t PH_COMP_PAL_SLI15693");
|
||||
break;
|
||||
case PH_COMP_PAL_I18000P3M3:
|
||||
DEBUG_PRINTF("\t PH_COMP_PAL_I18000P3M3");
|
||||
break;
|
||||
case PH_COMP_PAL_I18092MPI:
|
||||
DEBUG_PRINTF("\t PH_COMP_PAL_I18092MPI");
|
||||
break;
|
||||
case PH_COMP_PAL_I18092MT:
|
||||
DEBUG_PRINTF("\t PH_COMP_PAL_I18092MT");
|
||||
break;
|
||||
case PH_COMP_PAL_I14443P4MC:
|
||||
DEBUG_PRINTF("\t PH_COMP_PAL_I14443P4MC");
|
||||
break;
|
||||
case PH_COMP_AC_DISCLOOP:
|
||||
DEBUG_PRINTF("\t PH_COMP_AC_DISCLOOP");
|
||||
break;
|
||||
case PH_COMP_OSAL:
|
||||
DEBUG_PRINTF("\t PH_COMP_OSAL");
|
||||
break;
|
||||
default:
|
||||
DEBUG_PRINTF("\t 0x%x",(wStatus & PH_COMPID_MASK));
|
||||
break;
|
||||
}
|
||||
|
||||
DEBUG_PRINTF("\t type:");
|
||||
|
||||
switch(wStatus & PH_ERR_MASK)
|
||||
{
|
||||
case PH_ERR_SUCCESS_INCOMPLETE_BYTE:
|
||||
DEBUG_PRINTF("\t PH_ERR_SUCCESS_INCOMPLETE_BYTE");
|
||||
break;
|
||||
case PH_ERR_IO_TIMEOUT:
|
||||
DEBUG_PRINTF("\t PH_ERR_IO_TIMEOUT");
|
||||
break;
|
||||
case PH_ERR_INTEGRITY_ERROR:
|
||||
DEBUG_PRINTF("\t PH_ERR_INTEGRITY_ERROR");
|
||||
break;
|
||||
case PH_ERR_COLLISION_ERROR:
|
||||
DEBUG_PRINTF("\t PH_ERR_COLLISION_ERROR");
|
||||
break;
|
||||
case PH_ERR_BUFFER_OVERFLOW:
|
||||
DEBUG_PRINTF("\t PH_ERR_BUFFER_OVERFLOW");
|
||||
break;
|
||||
case PH_ERR_FRAMING_ERROR:
|
||||
DEBUG_PRINTF("\t PH_ERR_FRAMING_ERROR");
|
||||
break;
|
||||
case PH_ERR_PROTOCOL_ERROR:
|
||||
DEBUG_PRINTF("\t PH_ERR_PROTOCOL_ERROR");
|
||||
break;
|
||||
case PH_ERR_RF_ERROR:
|
||||
DEBUG_PRINTF("\t PH_ERR_RF_ERROR");
|
||||
break;
|
||||
case PH_ERR_EXT_RF_ERROR:
|
||||
DEBUG_PRINTF("\t PH_ERR_EXT_RF_ERROR");
|
||||
break;
|
||||
case PH_ERR_NOISE_ERROR:
|
||||
DEBUG_PRINTF("\t PH_ERR_NOISE_ERROR");
|
||||
break;
|
||||
case PH_ERR_ABORTED:
|
||||
DEBUG_PRINTF("\t PH_ERR_ABORTED");
|
||||
break;
|
||||
case PH_ERR_INTERNAL_ERROR:
|
||||
DEBUG_PRINTF("\t PH_ERR_INTERNAL_ERROR");
|
||||
break;
|
||||
case PH_ERR_INVALID_DATA_PARAMS:
|
||||
DEBUG_PRINTF("\t PH_ERR_INVALID_DATA_PARAMS");
|
||||
break;
|
||||
case PH_ERR_INVALID_PARAMETER:
|
||||
DEBUG_PRINTF("\t PH_ERR_INVALID_PARAMETER");
|
||||
break;
|
||||
case PH_ERR_PARAMETER_OVERFLOW:
|
||||
DEBUG_PRINTF("\t PH_ERR_PARAMETER_OVERFLOW");
|
||||
break;
|
||||
case PH_ERR_UNSUPPORTED_PARAMETER:
|
||||
DEBUG_PRINTF("\t PH_ERR_UNSUPPORTED_PARAMETER");
|
||||
break;
|
||||
case PH_ERR_OSAL_ERROR:
|
||||
DEBUG_PRINTF("\t PH_ERR_OSAL_ERROR");
|
||||
break;
|
||||
case PHAC_DISCLOOP_LPCD_NO_TECH_DETECTED:
|
||||
DEBUG_PRINTF("\t PHAC_DISCLOOP_LPCD_NO_TECH_DETECTED");
|
||||
break;
|
||||
case PHAC_DISCLOOP_COLLISION_PENDING:
|
||||
DEBUG_PRINTF("\t PHAC_DISCLOOP_COLLISION_PENDING");
|
||||
break;
|
||||
default:
|
||||
DEBUG_PRINTF("\t 0x%x",(wStatus & PH_ERR_MASK));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
** End Of File
|
||||
******************************************************************************/
|
||||
343
Examples/Nfcrdlib_SimplifiedAPI_ISO/src/phApp_Init.c
Normal file
343
Examples/Nfcrdlib_SimplifiedAPI_ISO/src/phApp_Init.c
Normal file
@ -0,0 +1,343 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright 2016-2020,2022 NXP */
|
||||
/* */
|
||||
/* NXP Confidential. This software is owned or controlled by NXP and may only */
|
||||
/* be used strictly in accordance with the applicable license terms. */
|
||||
/* By expressly accepting such terms or by downloading, installing, */
|
||||
/* activating and/or otherwise using the software, you are agreeing that you */
|
||||
/* have read, and that you agree to comply with and are bound by, such */
|
||||
/* license terms. If you do not agree to be bound by the applicable license */
|
||||
/* terms, then you may not retain, install, activate or otherwise use the */
|
||||
/* software. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \file
|
||||
* Example Source abstracting component data structure and code initialization and code specific to HW used in the examples
|
||||
* This file shall be present in all examples. A customer does not need to touch/modify this file. This file
|
||||
* purely depends on the phNxpBuild_Lpc.h or phNxpBuild_App.h
|
||||
* The phAppInit.h externs the component data structures initialized here that is in turn included by the core examples.
|
||||
* The core example shall not use any other variable defined here except the RdLib component data structures(as explained above)
|
||||
* The RdLib component initialization requires some user defined data and function pointers.
|
||||
* These are defined in the respective examples and externed here.
|
||||
*
|
||||
* Keystore and Crypto initialization needs to be handled by application.
|
||||
*
|
||||
* $Author$
|
||||
* $Revision$ (v07.10.00)
|
||||
* $Date$
|
||||
*
|
||||
*/
|
||||
|
||||
#include "phApp_Init.h"
|
||||
|
||||
#ifdef PH_PLATFORM_HAS_ICFRONTEND
|
||||
#include "BoardSelection.h"
|
||||
#endif /* PH_PLATFORM_HAS_ICFRONTEND */
|
||||
|
||||
/* HAL Header */
|
||||
#include <phhalHw.h>
|
||||
|
||||
#ifdef PHDRIVER_KINETIS_K82
|
||||
#include <fsl_port.h>
|
||||
#include <fsl_pit.h>
|
||||
#ifdef DEBUG
|
||||
#include <fsl_clock.h>
|
||||
#endif
|
||||
#endif /* PHDRIVER_KINETIS_K82 */
|
||||
|
||||
#ifdef PHDRIVER_KINETIS_K82
|
||||
#ifdef DEBUG
|
||||
|
||||
#define KINETIS_K82_DEBUG_UART_CLK_FREQ CLOCK_GetOsc0ErClkFreq()
|
||||
#define KINETIS_K82_DEBUG_UART_BASEADDR (uint32_t)(LPUART4)
|
||||
#define KINETIS_K82_DEBUG_UART_INSTANCE 4U
|
||||
#define KINETIS_K82_DEBUG_UART_BAUDRATE 115200
|
||||
#define KINETIS_K82_DEBUG_UART_TYPE DEBUG_CONSOLE_DEVICE_TYPE_LPUART
|
||||
|
||||
#endif /* DEBUG */
|
||||
|
||||
/*! @brief Clock configuration structure. */
|
||||
typedef struct _clock_config
|
||||
{
|
||||
mcg_config_t mcgConfig; /*!< MCG configuration. */
|
||||
sim_clock_config_t simConfig; /*!< SIM configuration. */
|
||||
osc_config_t oscConfig; /*!< OSC configuration. */
|
||||
uint32_t coreClock; /*!< core clock frequency. */
|
||||
} clock_config_t;
|
||||
#endif /* PHDRIVER_KINETIS_K82 */
|
||||
|
||||
#ifdef PH_OSAL_LINUX
|
||||
# define PI_IRQ_POLLING_TASK_PRIO 0
|
||||
# define PI_IRQ_POLLING_TASK_STACK 0x20000
|
||||
phOsal_ThreadObj_t gphPiThreadObj;
|
||||
#endif /* PH_OSAL_LINUX */
|
||||
|
||||
#if defined(PHDRIVER_LPC1769) && defined(__CC_ARM)
|
||||
uint32_t SystemCoreClock;
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
** Global Variable Declaration
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
** Function Declarations
|
||||
*******************************************************************************/
|
||||
#ifdef PHDRIVER_KINETIS_K82
|
||||
static void phApp_K82_Init(void);
|
||||
#endif /* PHDRIVER_KINETIS_K82 */
|
||||
|
||||
#ifdef PH_OSAL_LINUX
|
||||
static void phExample_IrqPolling(void* param);
|
||||
#endif /* PH_OSAL_LINUX */
|
||||
|
||||
/*******************************************************************************
|
||||
** Clock configuration of K82 Platform
|
||||
*******************************************************************************/
|
||||
|
||||
#ifdef PHDRIVER_KINETIS_K82
|
||||
/* Configuration for enter RUN mode. Core clock = 50MHz. */
|
||||
const clock_config_t g_defaultClockConfigRun = {
|
||||
.mcgConfig =
|
||||
{
|
||||
.mcgMode = kMCG_ModePEE, /* Work in PEE mode. */
|
||||
.irclkEnableMode = kMCG_IrclkEnable, /* MCGIRCLK enable. */
|
||||
.ircs = kMCG_IrcSlow, /* Select IRC32k. */
|
||||
.fcrdiv = 0U, /* FCRDIV is 0. */
|
||||
|
||||
.frdiv = 4U,
|
||||
.drs = kMCG_DrsLow, /* Low frequency range. */
|
||||
.dmx32 = kMCG_Dmx32Default, /* DCO has a default range of 25%. */
|
||||
.oscsel = kMCG_OscselOsc, /* Select OSC. */
|
||||
|
||||
.pll0Config =
|
||||
{
|
||||
.enableMode = 0U, .prdiv = 0x00U, .vdiv = 0x04U,
|
||||
},
|
||||
},
|
||||
.simConfig =
|
||||
{
|
||||
.pllFllSel = 1U, /* PLLFLLSEL select PLL. */
|
||||
.pllFllDiv = 0U, /* PLLFLLSEL clock divider divisor. */
|
||||
.pllFllFrac = 0U, /* PLLFLLSEL clock divider fraction. */
|
||||
.er32kSrc = 5U, /* ERCLK32K selection, use RTC. */
|
||||
.clkdiv1 = 0x01140000U, /* SIM_CLKDIV1. */
|
||||
},
|
||||
.oscConfig = {.freq = CPU_XTAL_CLK_HZ,
|
||||
.capLoad = 0,
|
||||
.workMode = kOSC_ModeOscLowPower,
|
||||
.oscerConfig =
|
||||
{
|
||||
.enableMode = kOSC_ErClkEnable,
|
||||
#if (defined(FSL_FEATURE_OSC_HAS_EXT_REF_CLOCK_DIVIDER) && FSL_FEATURE_OSC_HAS_EXT_REF_CLOCK_DIVIDER)
|
||||
.erclkDiv = 0U,
|
||||
#endif
|
||||
}},
|
||||
|
||||
};
|
||||
#endif /* PHDRIVER_KINETIS_K82 */
|
||||
|
||||
/*******************************************************************************
|
||||
** Function Definitions
|
||||
*******************************************************************************/
|
||||
#ifdef PHDRIVER_KINETIS_K82
|
||||
static void phApp_K82_Init(void)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
uint32_t uartClkSrcFreq;
|
||||
#endif /* DEBUG */
|
||||
|
||||
pit_config_t pitConfig; /* Structure of initialize PIT */
|
||||
|
||||
CLOCK_SetSimSafeDivs();
|
||||
|
||||
CLOCK_InitOsc0(&g_defaultClockConfigRun.oscConfig);
|
||||
CLOCK_SetXtal0Freq(CPU_XTAL_CLK_HZ);
|
||||
|
||||
CLOCK_BootToPeeMode(g_defaultClockConfigRun.mcgConfig.oscsel, kMCG_PllClkSelPll0,
|
||||
&g_defaultClockConfigRun.mcgConfig.pll0Config);
|
||||
|
||||
CLOCK_SetInternalRefClkConfig(g_defaultClockConfigRun.mcgConfig.irclkEnableMode,
|
||||
g_defaultClockConfigRun.mcgConfig.ircs, g_defaultClockConfigRun.mcgConfig.fcrdiv);
|
||||
|
||||
CLOCK_SetSimConfig(&g_defaultClockConfigRun.simConfig);
|
||||
|
||||
SystemCoreClockUpdate();
|
||||
|
||||
/*
|
||||
* pitConfig.enableRunInDebug = false;
|
||||
*/
|
||||
PIT_GetDefaultConfig(&pitConfig);
|
||||
|
||||
/* Init pit module */
|
||||
PIT_Init(PIT, &pitConfig);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
/* Initialize LPUART4 pins below used to Print */
|
||||
/* Ungate the port clock */
|
||||
CLOCK_EnableClock(kCLOCK_PortC);
|
||||
/* Affects PORTC_PCR14 register */
|
||||
PORT_SetPinMux(PORTC, 14U, kPORT_MuxAlt3);
|
||||
/* Affects PORTC_PCR15 register */
|
||||
PORT_SetPinMux(PORTC, 15U, kPORT_MuxAlt3);
|
||||
|
||||
/* SIM_SOPT2[27:26]:
|
||||
* 00: Clock Disabled
|
||||
* 01: MCGFLLCLK, or MCGPLLCLK, or IRC48M
|
||||
* 10: OSCERCLK
|
||||
* 11: MCGIRCCLK
|
||||
*/
|
||||
CLOCK_SetLpuartClock(2);
|
||||
|
||||
uartClkSrcFreq = KINETIS_K82_DEBUG_UART_CLK_FREQ;
|
||||
|
||||
DbgConsole_Init(KINETIS_K82_DEBUG_UART_INSTANCE, KINETIS_K82_DEBUG_UART_BAUDRATE, KINETIS_K82_DEBUG_UART_TYPE, uartClkSrcFreq);
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
#endif /* PHDRIVER_KINETIS_K82 */
|
||||
|
||||
#ifdef PH_PLATFORM_HAS_ICFRONTEND
|
||||
/**
|
||||
* This function will initialize Host Controller interfaced with NXP Reader IC's.
|
||||
* Any initialization which is not generic across Platforms, should be done here.
|
||||
* Note: For NXP NFC Controllers HOST initialization is not required.
|
||||
*/
|
||||
void phApp_CPU_Init(void)
|
||||
{
|
||||
#if defined PHDRIVER_KINETIS_K82
|
||||
phApp_K82_Init();
|
||||
#elif defined(PHDRIVER_LPC1769) && defined(__CC_ARM)
|
||||
SystemCoreClock = (( unsigned long ) 96000000);
|
||||
#elif defined(PH_OSAL_LINUX) && defined(NXPBUILD__PHHAL_HW_PN5190)
|
||||
phStatus_t status;
|
||||
status = PiGpio_OpenIrq();
|
||||
if ((status & PH_ERR_MASK) != PH_ERR_SUCCESS)
|
||||
{
|
||||
DEBUG_PRINTF("\n PiGpio_OpenIrq failed \n");
|
||||
DEBUG_PRINTF("\n Couldn't open PN5190 Kernel IRQ Driver.\n Halting here!!FIX IT!!\n");
|
||||
while(1);
|
||||
}
|
||||
#else
|
||||
/* In case of LPC series, startup file takes care of initializing clock and ports.
|
||||
* No initialization is required in Linux environment. */
|
||||
#endif
|
||||
}
|
||||
#endif /* PH_PLATFORM_HAS_ICFRONTEND */
|
||||
|
||||
phStatus_t phApp_Configure_IRQ()
|
||||
{
|
||||
#ifdef PH_PLATFORM_HAS_ICFRONTEND
|
||||
#if !(defined(PH_OSAL_LINUX) && defined(NXPBUILD__PHHAL_HW_PN5190))
|
||||
phDriver_Pin_Config_t pinCfg;
|
||||
|
||||
pinCfg.bOutputLogic = PH_DRIVER_SET_LOW;
|
||||
pinCfg.bPullSelect = PHDRIVER_PIN_IRQ_PULL_CFG;
|
||||
|
||||
pinCfg.eInterruptConfig = PIN_IRQ_TRIGGER_TYPE;
|
||||
phDriver_PinConfig(PHDRIVER_PIN_IRQ, PH_DRIVER_PINFUNC_INTERRUPT, &pinCfg);
|
||||
#endif
|
||||
|
||||
#ifdef PHDRIVER_LPC1769
|
||||
NVIC_SetPriority(EINT_IRQn, EINT_PRIORITY);
|
||||
/* Enable interrupt in the NVIC */
|
||||
NVIC_ClearPendingIRQ(EINT_IRQn);
|
||||
NVIC_EnableIRQ(EINT_IRQn);
|
||||
#endif /* PHDRIVER_LPC1769 */
|
||||
|
||||
#ifdef PH_OSAL_LINUX
|
||||
phStatus_t wStatus;
|
||||
|
||||
gphPiThreadObj.pTaskName = (uint8_t *) "IrqPolling";
|
||||
gphPiThreadObj.pStackBuffer = NULL;
|
||||
gphPiThreadObj.priority = PI_IRQ_POLLING_TASK_PRIO;
|
||||
gphPiThreadObj.stackSizeInNum = PI_IRQ_POLLING_TASK_STACK;
|
||||
PH_CHECK_SUCCESS_FCT(wStatus, phOsal_ThreadCreate(&gphPiThreadObj.ThreadHandle, &gphPiThreadObj,
|
||||
&phExample_IrqPolling, NULL));
|
||||
|
||||
#endif /* PH_OSAL_LINUX */
|
||||
|
||||
#ifdef PHDRIVER_KINETIS_K82
|
||||
NVIC_SetPriority(EINT_IRQn, EINT_PRIORITY);
|
||||
NVIC_ClearPendingIRQ(EINT_IRQn);
|
||||
EnableIRQ(EINT_IRQn);
|
||||
#endif /* PHDRIVER_KINETIS_K82 */
|
||||
|
||||
#endif /* #ifdef PH_PLATFORM_HAS_ICFRONTEND */
|
||||
|
||||
return PH_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
#ifdef PH_OSAL_LINUX
|
||||
/*
|
||||
* \brief: The purpose of this Thread is to detect RF signal from an External Peer .
|
||||
*/
|
||||
static void phExample_IrqPolling(void* param)
|
||||
{
|
||||
uint8_t bgpioVal = 0;
|
||||
uint8_t bhighOrLow = 0;
|
||||
|
||||
#if defined(NXPBUILD__PHHAL_HW_RC663) || defined(NXPBUILD__PHHAL_HW_PN5180)
|
||||
if(PIN_IRQ_TRIGGER_TYPE == PH_DRIVER_INTERRUPT_RISINGEDGE)
|
||||
{
|
||||
bhighOrLow = 1;
|
||||
}
|
||||
|
||||
while(PiGpio_read(PHDRIVER_PIN_IRQ, &bgpioVal) != PH_ERR_SUCCESS)
|
||||
{
|
||||
PiGpio_unexport(PHDRIVER_PIN_IRQ);
|
||||
PiGpio_export(PHDRIVER_PIN_IRQ);
|
||||
PiGpio_set_direction(PHDRIVER_PIN_IRQ, false);
|
||||
|
||||
if(PIN_IRQ_TRIGGER_TYPE == PH_DRIVER_INTERRUPT_RISINGEDGE)
|
||||
{
|
||||
PiGpio_set_edge(PHDRIVER_PIN_IRQ, true, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
PiGpio_set_edge(PHDRIVER_PIN_IRQ, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
/* Initial status: If pin is already Active, post an event. */
|
||||
if(bgpioVal == bhighOrLow)
|
||||
{
|
||||
CLIF_IRQHandler();
|
||||
}
|
||||
#endif
|
||||
|
||||
while(1)
|
||||
{
|
||||
/* Block forever for Raising Edge in PHDRIVER_PIN_IRQ. */
|
||||
#if defined(NXPBUILD__PHHAL_HW_RC663) || defined(NXPBUILD__PHHAL_HW_PN5180)
|
||||
if(PiGpio_poll(PHDRIVER_PIN_IRQ, bhighOrLow, -1) == PH_ERR_SUCCESS)
|
||||
#elif defined(NXPBUILD__PHHAL_HW_PN5190)
|
||||
if(PiGpio_Irq() == PH_ERR_SUCCESS)
|
||||
#endif
|
||||
{
|
||||
CLIF_IRQHandler();
|
||||
}
|
||||
else
|
||||
{
|
||||
PiGpio_unexport(PHDRIVER_PIN_IRQ);
|
||||
|
||||
PiGpio_export(PHDRIVER_PIN_IRQ);
|
||||
|
||||
PiGpio_set_direction(PHDRIVER_PIN_IRQ, false);
|
||||
|
||||
if(PIN_IRQ_TRIGGER_TYPE == PH_DRIVER_INTERRUPT_RISINGEDGE)
|
||||
{
|
||||
PiGpio_set_edge(PHDRIVER_PIN_IRQ, true, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
PiGpio_set_edge(PHDRIVER_PIN_IRQ, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PH_OSAL_LINUX */
|
||||
|
||||
/******************************************************************************
|
||||
** End Of File
|
||||
******************************************************************************/
|
||||
179
Examples/Nfcrdlib_SimplifiedAPI_ISO/src/phApp_PN5180_Init.c
Normal file
179
Examples/Nfcrdlib_SimplifiedAPI_ISO/src/phApp_PN5180_Init.c
Normal file
@ -0,0 +1,179 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright 2020,2023 NXP */
|
||||
/* */
|
||||
/* NXP Confidential. This software is owned or controlled by NXP and may only */
|
||||
/* be used strictly in accordance with the applicable license terms. */
|
||||
/* By expressly accepting such terms or by downloading, installing, */
|
||||
/* activating and/or otherwise using the software, you are agreeing that you */
|
||||
/* have read, and that you agree to comply with and are bound by, such */
|
||||
/* license terms. If you do not agree to be bound by the applicable license */
|
||||
/* terms, then you may not retain, install, activate or otherwise use the */
|
||||
/* software. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \file
|
||||
* Example Source abstracting component data structure and code initialization and code specific to HW used in the examples
|
||||
* This file shall be present in all examples. A customer does not need to touch/modify this file. This file
|
||||
* purely depends on the phNxpBuild_Lpc.h or phNxpBuild_App.h
|
||||
* The phAppInit.h externs the component data structures initialized here that is in turn included by the core examples.
|
||||
* The core example shall not use any other variable defined here except the RdLib component data structures(as explained above)
|
||||
* The RdLib component initialization requires some user defined data and function pointers.
|
||||
* These are defined in the respective examples and externed here.
|
||||
*
|
||||
* Keystore and Crypto initialization needs to be handled by application.
|
||||
*
|
||||
* $Author$
|
||||
* $Revision$ (v07.10.00)
|
||||
* $Date$
|
||||
*
|
||||
*/
|
||||
|
||||
/* Status header */
|
||||
#include <ph_Status.h>
|
||||
|
||||
#include "phApp_Init.h"
|
||||
|
||||
#ifdef NXPBUILD__PHHAL_HW_PN5180
|
||||
|
||||
#include "BoardSelection.h"
|
||||
|
||||
/* HAL specific headers */
|
||||
#include <phhalHw_Pn5180_Instr.h>
|
||||
|
||||
/*******************************************************************************
|
||||
** Function Declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
** Global Variable Declaration
|
||||
*******************************************************************************/
|
||||
phbalReg_Type_t sBalParams;
|
||||
phhalHw_Pn5180_DataParams_t * pHal;
|
||||
|
||||
#ifdef NXPBUILD__PHHAL_HW_TARGET
|
||||
/* Parameters for L3 activation during Autocoll */
|
||||
extern uint8_t sens_res[2] ;
|
||||
extern uint8_t nfc_id1[3] ;
|
||||
extern uint8_t sel_res ;
|
||||
extern uint8_t nfc_id3 ;
|
||||
extern uint8_t poll_res[18] ;
|
||||
#endif /* NXPBUILD__PHHAL_HW_TARGET */
|
||||
|
||||
/*******************************************************************************
|
||||
** Function Definitions
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* This function will initialize Hal Target Config
|
||||
*/
|
||||
phStatus_t phApp_HALConfigAutoColl(void)
|
||||
{
|
||||
#ifdef NXPBUILD__PHHAL_HW_TARGET
|
||||
phStatus_t wStatus;
|
||||
uint8_t baDynamicUidConfig[1U] = { 1U };
|
||||
uint8_t baReadEepromConfig[24U] = { 0U };
|
||||
|
||||
/* Read Set Listen Parameters data from EEPROM */
|
||||
wStatus = phhalHw_Pn5180_Instr_ReadE2Prom(
|
||||
(phhalHw_Pn5180_DataParams_t *) pHal,
|
||||
PHHAL_HW_PN5180_SET_LISTEN_E2PROM_ADDR,
|
||||
baReadEepromConfig,
|
||||
24U
|
||||
);
|
||||
CHECK_SUCCESS(wStatus);
|
||||
|
||||
/* Verify EEPROM data and configure Set Listen Parameters if EEPROM data is not correct. */
|
||||
if ((memcmp(&baReadEepromConfig[0U], sens_res, 2U) != 0x00) ||
|
||||
(memcmp(&baReadEepromConfig[2U], nfc_id1, 3U) != 0x00) ||
|
||||
(memcmp(&baReadEepromConfig[5U], &sel_res, 1U) != 0x00) ||
|
||||
(memcmp(&baReadEepromConfig[6U], poll_res, 18U) != 0x00))
|
||||
{
|
||||
/* Configure Set Listen Parameters. */
|
||||
wStatus = phhalHw_Pn5180_SetListenParameters(
|
||||
pHal,
|
||||
&sens_res[0],
|
||||
&nfc_id1[0],
|
||||
sel_res,
|
||||
&poll_res[0],
|
||||
nfc_id3
|
||||
);
|
||||
CHECK_SUCCESS(wStatus);
|
||||
}
|
||||
|
||||
if (pHal->wFirmwareVer < 0x308U)
|
||||
{
|
||||
/* With Pn5180 FW version < 3.8, only static UID is supported. */
|
||||
baDynamicUidConfig[0] = 0x00;
|
||||
}
|
||||
|
||||
/* Read Dynamic UID configuration from EEPROM */
|
||||
wStatus = phhalHw_Pn5180_Instr_ReadE2Prom(
|
||||
(phhalHw_Pn5180_DataParams_t *) pHal,
|
||||
PHHAL_HW_PN5180_DYN_UID_CFG_E2PROM_ADDR,
|
||||
baReadEepromConfig,
|
||||
1U
|
||||
);
|
||||
CHECK_SUCCESS(wStatus);
|
||||
|
||||
/* Verify EEPROM data and perform Dynamic UID configuration if EEPROM data is not correct. */
|
||||
if (memcmp(baReadEepromConfig, baDynamicUidConfig, 1U) != 0x00)
|
||||
{
|
||||
/* Configure Dynamic UID */
|
||||
wStatus = phhalHw_Pn5180_Instr_WriteE2Prom(
|
||||
(phhalHw_Pn5180_DataParams_t *) pHal,
|
||||
PHHAL_HW_PN5180_DYN_UID_CFG_E2PROM_ADDR,
|
||||
baDynamicUidConfig,
|
||||
1U
|
||||
);
|
||||
CHECK_SUCCESS(wStatus);
|
||||
}
|
||||
#endif /* NXPBUILD__PHHAL_HW_TARGET */
|
||||
return PH_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
/* Configure LPCD (for PN5180) */
|
||||
phStatus_t phApp_ConfigureLPCD(void)
|
||||
{
|
||||
/**
|
||||
* PHHAL_HW_CONFIG_SET_LPCD_WAKEUPTIME_MS 0x0070U //< Used value for wakeup counter in msecs, i.e. after this amount of time IC will wakes up from standby.
|
||||
* PHHAL_HW_CONFIG_LPCD_MODE 0x0071U //< Used to set options PHHAL_HW_PN5180_LPCD_MODE_DEFAULT or PHHAL_HW_PN5180_LPCD_MODE_POWERDOWN_GUARDED
|
||||
* PHHAL_HW_CONFIG_LPCD_REF 0x0072U //< Used to set or get LPCD Ref
|
||||
*/
|
||||
phStatus_t status = PH_ERR_SUCCESS;
|
||||
uint16_t wConfig = PHHAL_HW_CONFIG_LPCD_REF;
|
||||
uint16_t wValue;
|
||||
uint8_t bLPCD_Threshold_EEPROMAddress = 0x37;
|
||||
uint8_t bLPCD_Threshold = 0x10;
|
||||
wValue = PHHAL_HW_PN5180_LPCD_MODE_POWERDOWN;
|
||||
wConfig = PHHAL_HW_CONFIG_LPCD_MODE;
|
||||
|
||||
//status = phhalHw_Pn5180_Int_LPCD_GetConfig(pHal, wConfig, &wValue);
|
||||
status = phhalHw_Pn5180_Instr_WriteE2Prom(pHal,bLPCD_Threshold_EEPROMAddress, &bLPCD_Threshold, 1 );
|
||||
CHECK_SUCCESS(status);
|
||||
status = phhalHw_Pn5180_Int_LPCD_SetConfig(
|
||||
pHal,
|
||||
wConfig,
|
||||
wValue
|
||||
);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void CLIF_IRQHandler(void)
|
||||
{
|
||||
/* Read the interrupt status of external interrupt attached to the reader IC IRQ pin */
|
||||
if (phDriver_PinRead(PHDRIVER_PIN_IRQ, PH_DRIVER_PINFUNC_INTERRUPT))
|
||||
{
|
||||
phDriver_PinClearIntStatus(PHDRIVER_PIN_IRQ);
|
||||
|
||||
/* Call application registered callback. */
|
||||
if (pHal->pRFISRCallback != NULL)
|
||||
{
|
||||
pHal->pRFISRCallback(pHal);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* NXPBUILD__PHHAL_HW_PN5180 */
|
||||
|
||||
/******************************************************************************
|
||||
** End Of File
|
||||
******************************************************************************/
|
||||
Reference in New Issue
Block a user