User manual
NXP Semiconductors
UM10663
NXP Reader Library User Manual
UM10663
All information provided in this document is subject to legal disclaimers.
© NXP B.V. 2013. All rights reserved.
User Manual
COMPANY PUBLIC
Rev. 1.2 — 24 July 2013
257412
38 of 47
3. Sample code
In this chapter we introduce a sample code performing basic handling with MIFARE
Classic card. There are only fragments of the complete original source code presented
with focus on most important parts. Main purpose of example code is to clarify functions
and their aim in context of application, what are particular functions responsible for,
prerequisites for some functions necessary to do or call.
104
int main (void)
105
{
110
phStatus_t status;
111
uint8_t bHalBufferReader[0x40];
112
uint8_t bBufferReader[0x60];
113
uint8_t bSak[1];
114
uint8_t bUid[10];
115
uint8_t bMoreCardsAvailable;
116
uint8_t bLength;
117
void *pHal;
Before any operations with card and hardware configuration either, declare data
parameter structures for all the layers. When particular data parameter structure will be
initiated later, underlaying structure must already exist. Particular layers and their mutual
relationships and hierarchy are described in section 1.1.1.
122
phbalReg_Stub_DataParams_t balReader;
123
phhalHw_Rc663_DataParams_t halReader;
124
phpalI14443p3a_Sw_DataParams_t I14443p3a;
125
phpalI14443p4_Sw_DataParams_t I14443p4;
126
phpalMifare_Sw_DataParams_t palMifare;
127
128
phKeyStore_Rc663_DataParams_t Rc663keyStore;
129
phalMfc_Sw_DataParams_t alMfc;
Set interface between the MCU and the reader chip for correct communication. This
includes bus type selection and MCU’s PIN configuration for that purpose.
142
Set_Interface_Link();
Perform reset of reader chip. One of the MCU GPIO pin is connected to the CLRC663
reader chip. MCU sets reset signal on this pin.
145
Reset_RC663_device();
Initialize data parameter structure for the BAL layer.
150
phbalReg_Stub_Init(&balReader, sizeof(phbalReg_Stub_DataParams_t));