1 #ifndef DRIVER_NFC_NXP_H 2 #define DRIVER_NFC_NXP_H 15 #include <nfc_t2t_lib.h> 17 #include "ph_NxpBuild_App.h" 18 #include "ph_NxpBuild.h" 20 #include <ph_Status.h> 21 #include <ph_RefDefs.h> 25 #include <ph_Status.h> 29 #include <phpalI14443p3a.h> 30 #include <phpalI14443p4.h> 31 #include <phpalFelica.h> 32 #include <phpalI14443p3b.h> 33 #include <phpalI14443p4a.h> 34 #include <phpalI18092mPI.h> 35 #include <phpalMifare.h> 36 #include <phpalI14443p4mC.h> 37 #include <phpalSli15693.h> 38 #include <phpalI18000p3m3.h> 39 #include <phalI18000p3m3.h> 43 #include <phalFelica.h> 45 #include <phacDiscLoop.h> 60 #ifdef NXPBUILD__PH_DEBUG 62 #define DEBUG_PRINTF(...) printf(__VA_ARGS__) 64 #define DEBUG_PRINTF(...) 68 #define CHECK_STATUS(x) \ 69 if ((x) != PH_ERR_SUCCESS) \ 71 DEBUG_PRINTF("%s: %d Error - (0x%04X) has occurred : 0xCCEE CC-Component ID, EE-Error code. Refer ph_Status.h\n", \ 72 __FILE__, __LINE__, (x)); \ 76 #define CHECK_SUCCESS(x) \ 77 if ((x) != PH_ERR_SUCCESS) \ 79 DEBUG_PRINTF("%s: %d Error - (0x%04X) has occurred : 0xCCEE CC-Component ID, EE-Error code. Refer ph_Status.h\n ", \ 80 __FILE__, __LINE__, (x)); \ 85 #define ASSERT_STATUS(x) \ 86 if ((x) != PH_ERR_SUCCESS) \ 88 DEBUG_PRINTF("%s: %d Error - (0x%04X) has occurred : 0xCCEE CC-Component ID, EE-Error code. Refer ph_Status.h\n ", \ 89 __FILE__, __LINE__, (x)); \ 95 #define ISO_10373_6_PICC_TEST_BENCH 0 98 #define USE_APP_CALLBACK 1 101 #define GET_CCFILE_CONTENT_LEN(x) ((((uint16_t)(x[0]) << 8) & 0xFF00) | (x[1])) 104 #define GET_FILE_CONTENT_LEN(x) ((((((uint16_t)(x[0]) << 8) & 0xFF00) | (x[1])) > 0)? \ 105 (((((uint16_t)(x[0]) << 8) & 0xFF00) | (x[1])) + 2) : 0) 107 #ifdef NXPBUILD__PH_DEBUG 108 #define DEBUG_ERROR_PRINT CHECK_STATUS 109 #define PRINT_INFO(...) DEBUG_PRINTF(__VA_ARGS__) 111 #define DEBUG_ERROR_PRINT(x) 112 #define PRINT_INFO(...) 115 #define SoftReset_reader_device(pHal) phhalHw_Rc523_Cmd_SoftReset(pHal) 156 uint8_t poll_res_def[18];
172 uint8_t bHalBufferTx[256];
173 uint8_t bHalBufferRx[256];
179 phpalI14443p4mC_Sw_DataParams_t sPalI14443p4mC;
185 phceT4T_Sw_DataParams_t sCeT4T;
187 uint8_t aAppBuffer[256];
197 uint8_t poll_res[18];
200 #ifdef NXPBUILD__PHCE_T4T_PROPRIETARY 201 uint8_t aProprietaryFile[100];
202 #endif // NXPBUILD__PHCE_T4T_PROPRIETARY 207 #if ISO_10373_6_PICC_TEST_BENCH 208 phOsal_SemaphoreHandle_t timerwtx;
209 #endif // ISO_10373_6_PICC_TEST_BENCH 212 volatile phOsal_EventSource_t gphOsal_EvtLastSource;
213 volatile phOsal_EventDestination_t gphOsal_EvtLastDest;
214 volatile phOsal_EventDetail_t gphOsal_EvtDetail;
221 extern const struct nfc_nxp_t* NfcNxp_ptr;
286 uint8_t* NdefFile, uint16_t NdefFileSize);
309 #endif // DRIVER_NFC_NXP_H const struct spi_cs_t SpiCs
SPI CS settings.
phpalI14443p3b_Sw_DataParams_t spalI14443p3b
PAL ISO I14443-B component.
uint8_t sel_res_def
SAK (ISO18092mT or ISO14443P4 Card) - needed for anti-collision.
phpalFelica_Sw_DataParams_t spalFelica
PAL Felica component.
void NfcNxpGetUid(const struct nfc_nxp_t *Nfc, uint8_t TagIndex, uint8_t **Uid, uint8_t *UidLen)
Returns UID of one of detected tags.
void NfcNxpInterruptCb(const struct nfc_nxp_t *Nfc)
Driver's HW interrupt callback to be exposed to EVE config.
uint8_t sel_res
SAK (ISO18092mT or ISO14443P4 Card) - needed for anti-collision.
uint8_t NfcNxpDiscovery(const struct nfc_nxp_t *Nfc, bool Continue)
Starts cards detection phase. During execution NFC lib is in the reader mode. NFC lib loops through a...
const struct adc_channel_t * AdcIcc
ADC channel used for ICC measurement.
struct EventGroup_t * EventGroupHandle_t
phhalHw_Nfc_Ic_DataParams_t sHal_Nfc_Ic
HAL component holder for Nfc Ic's.
uint16_t aNdefFileSize
Mandatory NDEF file size.
phpalI14443p3a_Sw_DataParams_t spalI14443p3a
PAL ISO I14443-A component.
phpalI18092mPI_Sw_DataParams_t spalI18092mPI
PAL ISO 18092 Initiator component.
uint8_t aAtsRes_def[5]
ATS Response send for RATS: |TL|T0|TA|TB|TC|.
Header file for the rtos emulation layer.
const struct nfc_ndef_changed_cb_table_t * NdefChangedCbTable
table of interrupt handlers for supported NFC message types
NFC driver descriptor: static structure for configuration of driver instance.
Driver for the MCU's SPI blocks.
phpalI14443p4_Sw_DataParams_t spalI14443p4
PAL ISO I14443-4 component.
nfc_irq_callback_t NfcIrqCb
interrupt handler
bool NfcNxpLibInit(const struct nfc_nxp_t *Nfc)
Initialises NFC instance structure, connects it to SPI. Powers up pn512 if supported.
uint8_t nfc_id3
NFC3 byte - required for anti-collision.
struct nfc_nxp_state_t * State
Pointer to the NFC state.
void NfcNxpSetNdefFile(const struct nfc_nxp_t *Nfc, uint8_t *NdefFile, uint16_t NdefFileSize)
Sets a memory buffer as an NDEF file for subsequent NfcNrfCardEmulation function call.
void NfcNxpResetReader(const struct nfc_nxp_t *Nfc)
Performs pn512 HW reset. pn512 switches to configuration mode after reset. NB! It should be verified ...
phalT1T_Sw_DataParams_t alT1T
AL T1T component.
Table element of interrupt handlers called on NDEF write attempt for supported NFC message types...
uint8_t nfc_id3_def
NFC3 byte - required for anti-collision.
phbalReg_Stub_DataParams_t sBalReader
BAL component holder.
phacDiscLoop_Sw_DataParams_t sDiscLoop
Discovery loop component.
bool NfcNxpSetup(const struct nfc_nxp_t *Nfc)
Sets up pn512 registers according to preconfigured parameters. NB! pn512 should be in configuration m...
uint8_t GI_def[13]
General information bytes to be sent with ATR */.
phpalI14443p4a_Sw_DataParams_t spalI14443p4a
PAL ISO I14443-4A component.
phOsal_SemaphoreHandle_t appstart
Semaphores for synchronization between application thread and reader library thread.
phpalMifare_Sw_DataParams_t spalMifare
PAL Mifare component.
phOsal_SemaphoreHandle_t appexit
Used to synchronize end of one cycle of application processing.
void NfcNxpCardEmulation(const struct nfc_nxp_t *Nfc)
Starts external RF detection phase During execution NFC lib is in the card emulation mode...
uint32_t SpiBaudrate
SPI speed.
uint8_t nfc_id1_def[3]
user defined bytes of the UID (one is hardcoded) - needed for anti-collision
uint8_t * aNdefFile
Mandatory NDEF file. It's set using phceT4T_SetElementaryFile.
bool NfcNxpLibDisable(const struct nfc_nxp_t *Nfc)
Disables interrupts from pn512 and releases SPI. Powers down pn512 if supported by product HW...
bool Enabled
The chip is enabled.
const struct spi_t * Spi
Pointer to the SPI interface instance.
holds current NFC instance state variables.
uint8_t sens_res_def[2]
ATQ bytes - needed for anti-collision.
void(* nfc_irq_callback_t)(const struct nfc_nxp_t *Nfc)
The callback is called on interrupt from pn512.
uint8_t ResetPin
RSTPDn pin.
uint8_t DetectPin
Card detect sense enable pin.