aboutsummaryrefslogtreecommitdiff
path: root/pn54x/common
diff options
context:
space:
mode:
Diffstat (limited to 'pn54x/common')
-rw-r--r--pn54x/common/phNfcCommon.h172
-rw-r--r--pn54x/common/phNfcCompId.h68
-rw-r--r--pn54x/common/phNfcStatus.h374
-rw-r--r--pn54x/common/phNfcTypes.h303
4 files changed, 917 insertions, 0 deletions
diff --git a/pn54x/common/phNfcCommon.h b/pn54x/common/phNfcCommon.h
new file mode 100644
index 0000000..638a133
--- /dev/null
+++ b/pn54x/common/phNfcCommon.h
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2010-2014 NXP Semiconductors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * OSAL header files related to memory, debug, random, semaphore and mutex
+ * functions.
+ */
+
+#ifndef PHNFCCOMMON_H
+#define PHNFCCOMMON_H
+
+/*
+************************* Include Files ****************************************
+*/
+
+#include <phDal4Nfc_messageQueueLib.h>
+#include <phNfcCompId.h>
+#include <phNfcStatus.h>
+#include <phOsalNfc_Timer.h>
+#include <pthread.h>
+#include <semaphore.h>
+
+#define FW_DLL_ROOT_DIR "/system/vendor/firmware/"
+#define FW_DLL_EXTENSION ".so"
+
+#if (NFC_NXP_CHIP_TYPE == PN548C2)
+
+/* Actual FW library name*/
+#define FW_LIB_PATH FW_DLL_ROOT_DIR "libpn548ad_fw" FW_DLL_EXTENSION
+/* Restore Corrupted PLL Setttings/etc */
+#define PLATFORM_LIB_PATH \
+ FW_DLL_ROOT_DIR "libpn548ad_fw_platform" FW_DLL_EXTENSION
+/* Upgrade the public Key */
+#define PKU_LIB_PATH FW_DLL_ROOT_DIR "libpn548ad_fw_pku" FW_DLL_EXTENSION
+#elif (NFC_NXP_CHIP_TYPE == PN551)
+/* Actual FW library name*/
+#define FW_LIB_PATH FLASH_CONF_ROOT_DIR "libpn551_fw" FW_DLL_EXTENSION
+/* Restore Corrupted PLL Settings/etc */
+#define PLATFORM_LIB_PATH \
+ FW_DLL_ROOT_DIR "libpn551_fw_platform" FW_DLL_EXTENSION
+/* Upgrade the public Key */
+#define PKU_LIB_PATH FW_DLL_ROOT_DIR "libpn551_fw_pku" FW_DLL_EXTENSION
+#elif (NFC_NXP_CHIP_TYPE == PN553)
+/* Actual FW library name*/
+#define FW_LIB_PATH FLASH_CONF_ROOT_DIR "libpn553_fw" FW_DLL_EXTENSION
+/* Restore Corrupted PLL Settings/etc */
+#define PLATFORM_LIB_PATH \
+ FW_DLL_ROOT_DIR "libpn553_fw_platform" FW_DLL_EXTENSION
+/* Upgrade the public Key */
+#define PKU_LIB_PATH FW_DLL_ROOT_DIR "libpn553_fw_pku" FW_DLL_EXTENSION
+#else
+/* Actual FW library name*/
+#define FW_LIB_PATH FW_DLL_ROOT_DIR "libpn547_fw" FW_DLL_EXTENSION
+/* Restore Corrupted PLL Settings/etc */
+#define PLATFORM_LIB_PATH \
+ FW_DLL_ROOT_DIR "libpn547_fw_platform" FW_DLL_EXTENSION
+/* Upgrade the public Key */
+#define PKU_LIB_PATH FW_DLL_ROOT_DIR "libpn547_fw_pku" FW_DLL_EXTENSION
+#endif
+
+#if (NFC_NXP_CHIP_TYPE == PN548C2)
+#define COMPILATION_MW "PN548C2"
+#elif (NFC_NXP_CHIP_TYPE == PN551)
+#define COMPILATION_MW "PN551"
+#elif (NFC_NXP_CHIP_TYPE == PN553)
+#define COMPILATION_MW "PN553"
+#else
+#define COMPILATION_MW "PN547C2"
+#endif
+
+/* HAL Version number (Updated as per release) */
+#define NXP_MW_VERSION_MAJ (3U)
+#define NXP_MW_VERSION_MIN (5U)
+
+/*
+ *****************************************************************
+ *********** System clock source selection configuration ********
+ *****************************************************************
+ */
+
+#define CLK_SRC_UNDEF 0
+#define CLK_SRC_XTAL 1
+#define CLK_SRC_PLL 2
+#define CLK_SRC_PADDIRECT 3
+
+/*Extern crystal clock source*/
+/* Use one of CLK_SRC_<value> */
+#define NXP_SYS_CLK_SRC_SEL CLK_SRC_PLL
+/*Direct clock*/
+
+/*
+ *****************************************************************
+ *********** System clock frequency selection configuration ****************
+ * If Clk_Src is set to PLL, make sure to set the Clk_Freq also*
+ *****************************************************************
+ */
+#define CLK_FREQ_UNDEF 0
+#define CLK_FREQ_13MHZ 1
+#define CLK_FREQ_19_2MHZ 2
+#define CLK_FREQ_24MHZ 3
+#define CLK_FREQ_26MHZ 4
+#define CLK_FREQ_38_4MHZ 5
+#define CLK_FREQ_52MHZ 6
+
+/* Set to one of CLK_FREQ_<value> */
+#define NXP_SYS_CLK_FREQ_SEL CLK_FREQ_19_2MHZ
+
+#define CLK_TO_CFG_DEF 1
+#define CLK_TO_CFG_MAX 6
+/*
+ * information to configure OSAL
+ */
+typedef struct phOsalNfc_Config {
+ uint8_t* pLogFile; /* Log File Name*/
+ uintptr_t dwCallbackThreadId; /* Client ID to which message is posted */
+} phOsalNfc_Config_t, *pphOsalNfc_Config_t /* Pointer to #phOsalNfc_Config_t */;
+
+/*
+ * Deferred call declaration.
+ * This type of API is called from ClientApplication (main thread) to notify
+ * specific callback.
+ */
+typedef void (*pphOsalNfc_DeferFuncPointer_t)(void*);
+
+/*
+ * Deferred message specific info declaration.
+ */
+typedef struct phOsalNfc_DeferedCallInfo {
+ pphOsalNfc_DeferFuncPointer_t pDeferedCall; /* pointer to Deferred callback */
+ void* pParam; /* contains timer message specific details*/
+} phOsalNfc_DeferedCallInfo_t;
+
+/*
+ * States in which a OSAL timer exist.
+ */
+typedef enum {
+ eTimerIdle = 0, /* Indicates Initial state of timer */
+ eTimerRunning = 1, /* Indicate timer state when started */
+ eTimerStopped = 2 /* Indicates timer state when stopped */
+} phOsalNfc_TimerStates_t; /* Variable representing State of timer */
+
+/*
+ **Timer Handle structure containing details of a timer.
+ */
+typedef struct phOsalNfc_TimerHandle {
+ uint32_t TimerId; /* ID of the timer */
+ timer_t hTimerHandle; /* Handle of the timer */
+ /* Timer callback function to be invoked */
+ pphOsalNfc_TimerCallbck_t Application_callback;
+ void* pContext; /* Parameter to be passed to the callback function */
+ phOsalNfc_TimerStates_t eState; /* Timer states */
+ /* Osal Timer message posted on User Thread */
+ phLibNfc_Message_t tOsalMessage;
+ /* Deferred Call structure to Invoke Callback function */
+ phOsalNfc_DeferedCallInfo_t tDeferedCallInfo;
+ /* Variables for Structure Instance and Structure Ptr */
+} phOsalNfc_TimerHandle_t, *pphOsalNfc_TimerHandle_t;
+
+#endif /* PHOSALNFC_H */
diff --git a/pn54x/common/phNfcCompId.h b/pn54x/common/phNfcCompId.h
new file mode 100644
index 0000000..9930e0c
--- /dev/null
+++ b/pn54x/common/phNfcCompId.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2010-2014 NXP Semiconductors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * NFC Component ID Values - Used for Function Return Codes
+ */
+
+#ifndef PHNFCCOMPID_H
+#define PHNFCCOMPID_H
+
+/*
+ * Component IDs
+ *
+ * IDs for all NFC components. Combined with the Status Code they build the
+ * value (status)
+ * returned by each function.
+ *
+ * ID Number Spaces:
+ * - 01..1F: HAL
+ * - 20..3F: NFC-MW (Local Device)
+ * - 40..5F: NFC-MW (Remote Device)
+ * .
+ *
+ * The value CID_NFC_NONE does not exist for Component IDs. Do not use
+ * this value except
+ * for NFCSTATUS_SUCCESS. The enumeration function uses CID_NFC_NONE
+ * to mark unassigned "References".
+ */
+/* Unassigned or doesn't apply (see #NFCSTATUS_SUCCESS) */
+#define CID_NFC_NONE 0x00
+#define CID_NFC_TML 0x01 /* Transport Mapping Layer */
+#define CID_NFC_LLC 0x07 /* Logical Link Control Layer */
+/* NFC Controller(NFCC) Interface Layer */
+#define CID_NFC_NCI 0x08
+/* Firmware Download Management Layer */
+#define CID_NFC_DNLD 0x09
+#define CID_NFC_HAL 0x10 /* Hardware Abstraction Layer */
+/* Operating System Abstraction Layer*/
+#define CID_NFC_OSAL CID_NFC_NONE
+#define CID_FRI_NFC_OVR_HAL 0x20 /* NFC-Device, HAL-based */
+#define CID_FRI_NFC_NDEF_RECORD 0x22 /* NDEF Record Tools Library. */
+#define CID_FRI_NFC_NDEF_MAP 0x23 /* NDEF Mapping. */
+#define CID_FRI_NFC_NDEF_REGISTRY 0x24 /* NDEF_REGISTRY. */
+/* Automatic Device Discovery. */
+#define CID_FRI_NFC_AUTO_DEV_DIS 0x25
+#define CID_FRI_NFC_NDEF_SMTCRDFMT 0x26 /* Smart Card Formatting */
+#define CID_NFC_LIB 0x30 /* NFC Library Layer*/
+/* The maximum CID value that is defined. */
+#define CID_MAX_VALUE 0xF0
+/* Logical Link Control Protocol */
+#define CID_FRI_NFC_LLCP 0x40
+#define CID_FRI_NFC_LLCP_TRANSPORT 0x50
+#define CID_FRI_NFC_LLCP_MAC 0x60
+
+#endif /* PHNFCCOMPID_H */
diff --git a/pn54x/common/phNfcStatus.h b/pn54x/common/phNfcStatus.h
new file mode 100644
index 0000000..f3aa51a
--- /dev/null
+++ b/pn54x/common/phNfcStatus.h
@@ -0,0 +1,374 @@
+/*
+ * Copyright (C) 2010-2014 NXP Semiconductors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * NFC Status Values - Function Return Codes
+ */
+
+#ifndef PHNFCSTATUS_H
+#define PHNFCSTATUS_H
+
+#include <phNfcTypes.h>
+
+/* Internally required by PHNFCSTVAL. */
+#define PHNFCSTSHL8 (8U)
+/* Required by PHNFCSTVAL. */
+#define PHNFCSTBLOWER ((NFCSTATUS)(0x00FFU))
+
+/*
+ * NFC Status Composition Macro
+ *
+ * This is the macro which must be used to compose status values.
+ *
+ * phNfcCompID Component ID, as defined in phNfcCompId.h .
+ * phNfcStatus Status values, as defined in phNfcStatus.h .
+ *
+ * The macro is not required for the NFCSTATUS_SUCCESS value.
+ * This is the only return value to be used directly.
+ * For all other values it shall be used in assignment and conditional
+ * statements, e.g.:
+ * NFCSTATUS status = PHNFCSTVAL(phNfcCompID, phNfcStatus); ...
+ * if (status == PHNFCSTVAL(phNfcCompID, phNfcStatus)) ...
+ */
+#define PHNFCSTVAL(phNfcCompID, phNfcStatus) \
+ (((phNfcStatus) == (NFCSTATUS_SUCCESS)) \
+ ? (NFCSTATUS_SUCCESS) \
+ : ((((NFCSTATUS)(phNfcStatus)) & (PHNFCSTBLOWER)) | \
+ (((uint16_t)(phNfcCompID)) << (PHNFCSTSHL8))))
+
+/*
+ * PHNFCSTATUS
+ * Get grp_retval from Status Code
+ */
+#define PHNFCSTATUS(phNfcStatus) ((phNfcStatus)&0x00FFU)
+#define PHNFCCID(phNfcStatus) (((phNfcStatus)&0xFF00U) >> 8)
+
+#define PHNFC_I2C_FRAGMENT_SIZE 512
+/*
+ * Status Codes
+ *
+ * Generic Status codes for the NFC components. Combined with the Component ID
+ * they build the value (status) returned by each function.
+ * Example:
+ * grp_comp_id "Component ID" - e.g. 0x10, plus
+ * status code as listed in this file - e.g. 0x03
+ * result in a status value of 0x0003.
+ */
+
+/*
+ * The function indicates successful completion
+ */
+#define NFCSTATUS_SUCCESS (0x0000)
+
+/*
+ * The function indicates successful completion
+ */
+#define NFCSTATUS_OK (NFCSTATUS_SUCCESS)
+
+/*
+ * At least one parameter could not be properly interpreted
+ */
+#define NFCSTATUS_INVALID_PARAMETER (0x0001)
+
+/*
+ * The buffer provided by the caller is too small
+ */
+#define NFCSTATUS_BUFFER_TOO_SMALL (0x0003)
+
+/*
+ * Device specifier/handle value is invalid for the operation
+ */
+#define NFCSTATUS_INVALID_DEVICE (0x0006)
+
+/*
+ * The function executed successfully but could have returned
+ * more information than space provided by the caller
+ */
+#define NFCSTATUS_MORE_INFORMATION (0x0008)
+
+/*
+ * No response from the remote device received: Time-out
+ */
+#define NFCSTATUS_RF_TIMEOUT (0x0009)
+
+/*
+ * RF Error during data transaction with the remote device
+ */
+#define NFCSTATUS_RF_ERROR (0x000A)
+
+/*
+ * Not enough resources Memory, Timer etc(e.g. allocation failed.)
+ */
+#define NFCSTATUS_INSUFFICIENT_RESOURCES (0x000C)
+
+/*
+ * A non-blocking function returns this immediately to indicate
+ * that an internal operation is in progress
+ */
+#define NFCSTATUS_PENDING (0x000D)
+
+/*
+ * A board communication error occurred
+ * (e.g. Configuration went wrong)
+ */
+#define NFCSTATUS_BOARD_COMMUNICATION_ERROR (0x000F)
+
+/*
+ * Invalid State of the particular state machine
+ */
+#define NFCSTATUS_INVALID_STATE (0x0011)
+
+/*
+ * This Layer is Not initialized, hence initialization required.
+ */
+#define NFCSTATUS_NOT_INITIALISED (0x0031)
+
+/*
+ * The Layer is already initialized, hence initialization repeated.
+ */
+#define NFCSTATUS_ALREADY_INITIALISED (0x0032)
+
+/*
+ * Feature not supported
+ */
+#define NFCSTATUS_FEATURE_NOT_SUPPORTED (0x0033)
+
+/* The Unregistration command has failed because the user wants to unregister
+ * on
+ * an element for which he was not registered
+ */
+#define NFCSTATUS_NOT_REGISTERED (0x0034)
+
+/* The Registration command has failed because the user wants to register on
+ * an element for which he is already registered
+ */
+#define NFCSTATUS_ALREADY_REGISTERED (0x0035)
+
+/* Single Tag with Multiple
+ Protocol support detected */
+#define NFCSTATUS_MULTIPLE_PROTOCOLS (0x0036)
+
+/*
+ * Feature not supported
+ */
+#define NFCSTATUS_MULTIPLE_TAGS (0x0037)
+
+/*
+ * A DESELECT event has occurred
+ */
+#define NFCSTATUS_DESELECTED (0x0038)
+
+/*
+ * A RELEASE event has occurred
+ */
+#define NFCSTATUS_RELEASED (0x0039)
+
+/*
+ * The operation is currently not possible or not allowed
+ */
+#define NFCSTATUS_NOT_ALLOWED (0x003A)
+
+/*
+ * FW version error while performing FW download,
+ * FW major version mismatch (cannot downgrade FW major version) or FW version
+ * already upto date
+ * User may be trying to flash Mobile FW on top of Infra FW, which is not
+ * allowed
+ * Download appropriate version of FW
+ */
+#define NFCSTATUS_FW_VERSION_ERROR (0x003C)
+
+/*
+ * The system is busy with the previous operation.
+ */
+#define NFCSTATUS_BUSY (0x006F)
+
+/* NDEF Mapping error codes */
+
+/* The remote device (type) is not valid for this request. */
+#define NFCSTATUS_INVALID_REMOTE_DEVICE (0x001D)
+
+/* Read operation failed */
+#define NFCSTATUS_READ_FAILED (0x0014)
+
+/*
+ * Write operation failed
+ */
+#define NFCSTATUS_WRITE_FAILED (0x0015)
+
+/* Non Ndef Compliant */
+#define NFCSTATUS_NO_NDEF_SUPPORT (0x0016)
+
+/* Could not proceed further with the write operation: reached card EOF*/
+#define NFCSTATUS_EOF_NDEF_CONTAINER_REACHED (0x001A)
+
+/* Incorrect number of bytes received from the card*/
+#define NFCSTATUS_INVALID_RECEIVE_LENGTH (0x001B)
+
+/* The data format/composition is not understood/correct. */
+#define NFCSTATUS_INVALID_FORMAT (0x001C)
+
+/* There is not sufficient storage available. */
+#define NFCSTATUS_INSUFFICIENT_STORAGE (0x001F)
+
+/* The Ndef Format procedure has failed. */
+#define NFCSTATUS_FORMAT_ERROR (0x0023)
+
+/* The NCI Cedit error */
+#define NFCSTATUS_CREDIT_TIMEOUT (0x0024)
+
+/*
+ * Response Time out for the control message(NFCC not responded)
+ */
+#define NFCSTATUS_RESPONSE_TIMEOUT (0x0025)
+
+/*
+ * Device is already connected
+ */
+#define NFCSTATUS_ALREADY_CONNECTED (0x0026)
+
+/*
+ * Device is already connected
+ */
+#define NFCSTATUS_ANOTHER_DEVICE_CONNECTED (0x0027)
+
+/*
+ * Single Target Detected and Activated
+ */
+#define NFCSTATUS_SINGLE_TAG_ACTIVATED (0x0028)
+
+/*
+ * Single Target Detected
+ */
+#define NFCSTATUS_SINGLE_TAG_DISCOVERED (0x0029)
+
+/*
+ * Secure element Detected and Activated
+ */
+#define NFCSTATUS_SECURE_ELEMENT_ACTIVATED (0x0028)
+
+/*
+ * Unknown error Status Codes
+ */
+#define NFCSTATUS_UNKNOWN_ERROR (0x00FE)
+
+/*
+ * Status code for failure
+ */
+#define NFCSTATUS_FAILED (0x00FF)
+
+/*
+ * The function/command has been aborted
+ */
+#define NFCSTATUS_CMD_ABORTED (0x0002)
+
+/*
+ * No target found after poll
+ */
+#define NFCSTATUS_NO_TARGET_FOUND (0x000A)
+
+/* Attempt to disconnect a not connected remote device. */
+#define NFCSTATUS_NO_DEVICE_CONNECTED (0x000B)
+
+/* External RF field detected. */
+#define NFCSTATUS_EXTERNAL_RF_DETECTED (0x000E)
+
+/* Message is not allowed by the state machine
+ * (e.g. configuration went wrong)
+ */
+#define NFCSTATUS_MSG_NOT_ALLOWED_BY_FSM (0x0010)
+
+/*
+ * No access has been granted
+ */
+#define NFCSTATUS_ACCESS_DENIED (0x001E)
+
+/* No registry node matches the specified input data. */
+#define NFCSTATUS_NODE_NOT_FOUND (0x0017)
+
+/* The current module is busy ; one might retry later */
+#define NFCSTATUS_SMX_BAD_STATE (0x00F0)
+
+/* The Abort mechanism has failed for unexpected reason: user can try again*/
+#define NFCSTATUS_ABORT_FAILED (0x00F2)
+
+/* The Registration command has failed because the user wants to register as
+ * target
+ * on a operating mode not supported
+ */
+#define NFCSTATUS_REG_OPMODE_NOT_SUPPORTED (0x00F5)
+
+/*
+ * Shutdown in progress, cannot handle the request at this time.
+ */
+#define NFCSTATUS_SHUTDOWN (0x0091)
+
+/*
+ * Target is no more in RF field
+ */
+#define NFCSTATUS_TARGET_LOST (0x0092)
+
+/*
+ * Request is rejected
+ */
+#define NFCSTATUS_REJECTED (0x0093)
+
+/*
+ * Target is not connected
+ */
+#define NFCSTATUS_TARGET_NOT_CONNECTED (0x0094)
+
+/*
+ * Invalid handle for the operation
+ */
+#define NFCSTATUS_INVALID_HANDLE (0x0095)
+
+/*
+ * Process aborted
+ */
+#define NFCSTATUS_ABORTED (0x0096)
+
+/*
+ * Requested command is not supported
+ */
+#define NFCSTATUS_COMMAND_NOT_SUPPORTED (0x0097)
+
+/*
+ * Tag is not NDEF compilant
+ */
+#define NFCSTATUS_NON_NDEF_COMPLIANT (0x0098)
+
+/*
+ * Not enough memory available to complete the requested operation
+ */
+#define NFCSTATUS_NOT_ENOUGH_MEMORY (0x001F)
+
+/*
+ * Indicates incoming connection
+ */
+#define NFCSTATUS_INCOMING_CONNECTION (0x0045)
+
+/*
+ * Indicates Connection was successful
+ */
+#define NFCSTATUS_CONNECTION_SUCCESS (0x0046)
+
+/*
+ * Indicates Connection failed
+ */
+#define NFCSTATUS_CONNECTION_FAILED (0x0047)
+
+#endif /* PHNFCSTATUS_H */
diff --git a/pn54x/common/phNfcTypes.h b/pn54x/common/phNfcTypes.h
new file mode 100644
index 0000000..d80ad50
--- /dev/null
+++ b/pn54x/common/phNfcTypes.h
@@ -0,0 +1,303 @@
+/*
+ * Copyright (C) 2010-2014 NXP Semiconductors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PHNFCTYPES_H
+#define PHNFCTYPES_H
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifndef TRUE
+#define TRUE (0x01) /* Logical True Value */
+#endif
+#ifndef FALSE
+#define FALSE (0x00) /* Logical False Value */
+#endif
+typedef uint8_t utf8_t; /* UTF8 Character String */
+typedef uint8_t bool_t; /* boolean data type */
+typedef uint16_t NFCSTATUS; /* Return values */
+#define STATIC static
+
+#define PHNFC_MAX_UID_LENGTH 0x0AU /* Maximum UID length expected */
+/* Maximum ATR_RES (General Bytes) length expected */
+#define PHNFC_MAX_ATR_LENGTH 0x30U
+#define PHNFC_NFCID_LENGTH 0x0AU /* Maximum length of NFCID 1.3*/
+#define PHNFC_ATQA_LENGTH 0x02U /* ATQA length */
+
+/*
+ * NFC Data structure
+ */
+typedef struct phNfc_sData {
+ uint8_t* buffer; /* Buffer to store data */
+ uint32_t length; /* Buffer length */
+} phNfc_sData_t;
+
+/*
+ * Possible Hardware Configuration exposed to upper layer.
+ * Typically this should be port name (Ex:"COM1","COM2") to which PN54X is
+ * connected.
+ */
+typedef enum {
+ ENUM_LINK_TYPE_COM1,
+ ENUM_LINK_TYPE_COM2,
+ ENUM_LINK_TYPE_COM3,
+ ENUM_LINK_TYPE_COM4,
+ ENUM_LINK_TYPE_COM5,
+ ENUM_LINK_TYPE_COM6,
+ ENUM_LINK_TYPE_COM7,
+ ENUM_LINK_TYPE_COM8,
+ ENUM_LINK_TYPE_I2C,
+ ENUM_LINK_TYPE_SPI,
+ ENUM_LINK_TYPE_USB,
+ ENUM_LINK_TYPE_TCP,
+ ENUM_LINK_TYPE_NB
+} phLibNfc_eConfigLinkType;
+
+/*
+ * Deferred message. This message type will be posted to the client application
+ * thread
+ * to notify that a deferred call must be invoked.
+ */
+#define PH_LIBNFC_DEFERREDCALL_MSG (0x311)
+
+/*
+ * Deferred call declaration.
+ * This type of API is called from ClientApplication ( main thread) to notify
+ * specific callback.
+ */
+typedef void (*pphLibNfc_DeferredCallback_t)(void*);
+
+/*
+ * Deferred parameter declaration.
+ * This type of data is passed as parameter from ClientApplication (main thread)
+ * to the
+ * callback.
+ */
+typedef void* pphLibNfc_DeferredParameter_t;
+
+/*
+ * Possible Hardware Configuration exposed to upper layer.
+ * Typically this should be at least the communication link (Ex:"COM1","COM2")
+ * the controller is connected to.
+ */
+typedef struct phLibNfc_sConfig {
+ uint8_t* pLogFile; /* Log File Name*/
+ /* Hardware communication link to the controller */
+ phLibNfc_eConfigLinkType nLinkType;
+ /* The client ID (thread ID or message queue ID) */
+ uintptr_t nClientId;
+} phLibNfc_sConfig_t, *pphLibNfc_sConfig_t;
+
+/*
+ * NFC Message structure contains message specific details like
+ * message type, message specific data block details, etc.
+ */
+typedef struct phLibNfc_Message {
+ uint32_t eMsgType; /* Type of the message to be posted*/
+ void* pMsgData; /* Pointer to message specific data block in case any*/
+ uint32_t Size; /* Size of the datablock*/
+} phLibNfc_Message_t, *pphLibNfc_Message_t;
+
+/*
+ * Deferred message specific info declaration.
+ * This type of information is packed as message data when
+ * PH_LIBNFC_DEFERREDCALL_MSG
+ * type message is posted to message handler thread.
+ */
+typedef struct phLibNfc_DeferredCall {
+ pphLibNfc_DeferredCallback_t pCallback; /* pointer to Deferred callback */
+ pphLibNfc_DeferredParameter_t pParameter; /* pointer to Deferred parameter */
+} phLibNfc_DeferredCall_t;
+
+/*
+ * Definitions for supported protocol
+ */
+typedef struct phNfc_sSupProtocol {
+ unsigned int MifareUL : 1; /* Protocol Mifare Ultra Light or any NFC Forum
+ Type-2 tags */
+ unsigned int MifareStd : 1; /* Protocol Mifare Standard. */
+ unsigned int ISO14443_4A : 1; /* Protocol ISO14443-4 Type A. */
+ unsigned int ISO14443_4B : 1; /* Protocol ISO14443-4 Type B. */
+ unsigned int ISO15693 : 1; /* Protocol ISO15693 HiTag. */
+ unsigned int Felica : 1; /* Protocol Felica. */
+ unsigned int NFC : 1; /* Protocol NFC. */
+ unsigned int Jewel : 1; /* Protocol Innovision Jewel Tag. or Any T1T*/
+ unsigned int
+ Desfire : 1; /*TRUE indicates specified feature (mapping
+ or formatting)for DESFire tag supported else not supported.*/
+ unsigned int Kovio : 1; /* Protocol Kovio Tag*/
+ unsigned int HID : 1; /* Protocol HID(Picopass) Tag*/
+ unsigned int Bprime : 1; /* Protocol BPrime Tag*/
+ unsigned int EPCGEN2 : 1; /* Protocol EPCGEN2 Tag*/
+} phNfc_sSupProtocol_t;
+
+/*
+ * Enumerated MIFARE Commands
+ */
+
+typedef enum phNfc_eMifareCmdList {
+ phNfc_eMifareRaw = 0x00U, /* This command performs raw transcations */
+ phNfc_eMifareAuthentA = 0x60U, /* This command performs an authentication with
+ KEY A for a sector. */
+ phNfc_eMifareAuthentB = 0x61U, /* This command performs an authentication with
+ KEY B for a sector. */
+ phNfc_eMifareRead16 = 0x30U, /* Read 16 Bytes from a Mifare Standard block */
+ phNfc_eMifareRead = 0x30U, /* Read Mifare Standard */
+ phNfc_eMifareWrite16 = 0xA0U, /* Write 16 Bytes to a Mifare Standard block */
+ phNfc_eMifareWrite4 = 0xA2U, /* Write 4 bytes. */
+ phNfc_eMifareInc = 0xC1U, /* Increment */
+ phNfc_eMifareDec = 0xC0U, /* Decrement */
+ phNfc_eMifareTransfer = 0xB0U, /* Transfer */
+ phNfc_eMifareRestore = 0xC2U, /* Restore. */
+ phNfc_eMifareReadSector = 0x38U, /* Read Sector. */
+ phNfc_eMifareWriteSector = 0xA8U, /* Write Sector. */
+ /* Above commands could be used for preparing raw command but below one can
+ not be */
+ phNfc_eMifareReadN = 0x01, /* Proprietary Command */
+ phNfc_eMifareWriteN = 0x02, /* Proprietary Command */
+ phNfc_eMifareSectorSel = 0x03, /* Proprietary Command */
+ phNfc_eMifareAuth = 0x04, /* Proprietary Command */
+ phNfc_eMifareProxCheck = 0x05, /* Proprietary Command */
+ phNfc_eMifareInvalidCmd = 0xFFU /* Invalid Command */
+} phNfc_eMifareCmdList_t;
+
+/*
+ * Information about ISO14443A
+ */
+typedef struct phNfc_sIso14443AInfo {
+ uint8_t Uid[PHNFC_MAX_UID_LENGTH]; /* UID information of the TYPE A
+ * Tag Discovered */
+ uint8_t UidLength; /* UID information length */
+ uint8_t
+ AppData[PHNFC_MAX_ATR_LENGTH]; /* Application data information of the
+ 1 * tag discovered (= Historical bytes for
+ * type A) */
+ uint8_t AppDataLength; /* Application data length */
+ uint8_t Sak; /* SAK information of the TYPE A
+ * Tag Discovered */
+ uint8_t AtqA[PHNFC_ATQA_LENGTH]; /* ATQA informationof the TYPE A
+ * Tag Discovered */
+ uint8_t MaxDataRate; /* Maximum data rate supported
+ * by the tag Discovered */
+ uint8_t Fwi_Sfgt; /* Frame waiting time and start up
+ * frame guard */
+} phNfc_sIso14443AInfo_t;
+
+/* Remote device information structure */
+typedef union phNfc_uRemoteDevInfo {
+ phNfc_sIso14443AInfo_t Iso14443A_Info; /* ISO1443A Remote device info */
+} phNfc_uRemoteDevInfo_t;
+
+/*
+*
+* The RF Device Type List is used to identify the type of
+* remote device that is discovered and connected.
+*
+*/
+
+typedef enum phNfc_eRFDevType {
+ phNfc_eUnknown_DevType = 0x00U,
+
+ phNfc_eISO14443_A_PCD,
+ phNfc_eISO14443_B_PCD,
+ phNfc_eISO14443_BPrime_PCD,
+ phNfc_eFelica_PCD,
+ phNfc_eJewel_PCD,
+ phNfc_eISO15693_PCD,
+ phNfc_eEpcGen2_PCD,
+ phNfc_ePCD_DevType,
+
+ phNfc_ePICC_DevType,
+ phNfc_eISO14443_A_PICC,
+ phNfc_eISO14443_4A_PICC,
+ phNfc_eISO14443_3A_PICC,
+ phNfc_eMifare_PICC,
+ phNfc_eISO14443_B_PICC,
+ phNfc_eISO14443_4B_PICC,
+ phNfc_eISO14443_BPrime_PICC,
+ phNfc_eFelica_PICC,
+ phNfc_eJewel_PICC,
+ phNfc_eISO15693_PICC,
+ phNfc_eEpcGen2_PICC,
+
+ phNfc_eNfcIP1_Target,
+ phNfc_eNfcIP1_Initiator,
+
+ phNfc_eInvalid_DevType
+
+} phNfc_eRFDevType_t;
+
+/*
+ * The Remote Device Type List is used to identify the type of
+ * remote device that is discovered/connected
+ */
+typedef phNfc_eRFDevType_t phNfc_eRemDevType_t;
+typedef phNfc_eRemDevType_t phHal_eRemDevType_t;
+
+/*
+ * Union for each available type of Commands.
+ */
+
+typedef union phNfc_uCommand {
+ phNfc_eMifareCmdList_t MfCmd; /* Mifare command structure. */
+} phNfc_uCmdList_t;
+
+/*
+ * The Remote Device Information Structure holds information about one single
+ * Remote
+ * Device detected.
+ */
+typedef struct phNfc_sRemoteDevInformation {
+ uint8_t SessionOpened; /* Flag indicating the validity of
+ * the handle of the remote device.
+ * 1 = Device is not activer (Only discovered), 2 =
+ * Device is active and ready for use*/
+ phNfc_eRemDevType_t RemDevType; /* Remote device type */
+ phNfc_uRemoteDevInfo_t RemoteDevInfo; /* Union of available Remote Device */
+} phNfc_sRemoteDevInformation_t;
+
+/*
+ * Transceive Information Data Structure for sending commands/response to the
+ * remote device
+ */
+
+typedef struct phNfc_sTransceiveInfo {
+ phNfc_uCmdList_t cmd; /* Command for transceive */
+ uint8_t addr; /* Start Block Number */
+ uint8_t NumBlock; /* Number of Blocks to perform operation */
+ /* For Felica only*/
+ uint16_t* ServiceCodeList; /* 2 Byte service Code List */
+ uint16_t* Blocklist; /* 2 Byte Block list */
+ phNfc_sData_t sSendData; /* Send data */
+ phNfc_sData_t sRecvData; /* Recv data */
+ /* For EPC-GEN */
+ uint32_t dwWordPtr; /* Word address for the memory write */
+ uint8_t bWordPtrLen; /* Specifies the length of word pointer
+ 00: 8 bits
+ 01: 16 bits
+ 10: 24 bits
+ 11: 32 bits
+ */
+ uint8_t bWordCount; /* Number of words to be read or written */
+} phNfc_sTransceiveInfo_t;
+
+#define UNUSED(X) (void)X;
+
+#endif /* PHNFCTYPES_H */