From 5d9927ba30ba449badb9f6df0fbeb4d6aedc6e2a Mon Sep 17 00:00:00 2001 From: Nick Pelly Date: Thu, 23 Sep 2010 12:47:58 -0700 Subject: Initial libnfc checkin Source: Trusted_NFC_Device_Host_AA03.01e02_google.zip code drop (23-Sep-2010) Change-Id: Ie47f18423f949a8d3e0815d13f55c814312add24 Signed-off-by: Nick Pelly --- inc/nfc_custom_config.h | 201 +++++++ inc/phDbgTrace.h | 153 ++++++ inc/phNfcCompId.h | 112 ++++ inc/phNfcConfig.h | 525 +++++++++++++++++++ inc/phNfcHalTypes.h | 1323 +++++++++++++++++++++++++++++++++++++++++++++++ inc/phNfcInterface.h | 422 +++++++++++++++ inc/phNfcIoctlCode.h | 92 ++++ inc/phNfcLlcpTypes.h | 135 +++++ inc/phNfcStatus.h | 343 ++++++++++++ inc/phNfcTypes.h | 1127 ++++++++++++++++++++++++++++++++++++++++ 10 files changed, 4433 insertions(+) create mode 100644 inc/nfc_custom_config.h create mode 100644 inc/phDbgTrace.h create mode 100644 inc/phNfcCompId.h create mode 100644 inc/phNfcConfig.h create mode 100644 inc/phNfcHalTypes.h create mode 100644 inc/phNfcInterface.h create mode 100644 inc/phNfcIoctlCode.h create mode 100644 inc/phNfcLlcpTypes.h create mode 100644 inc/phNfcStatus.h create mode 100644 inc/phNfcTypes.h (limited to 'inc') diff --git a/inc/nfc_custom_config.h b/inc/nfc_custom_config.h new file mode 100644 index 0000000..0b4455a --- /dev/null +++ b/inc/nfc_custom_config.h @@ -0,0 +1,201 @@ +/* + * Copyright (C) 2010 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. + */ + + +/** +* \file nfc_custom_config.h +* \brief HAL Custom Configurations +* +* +* \note This is the configuration header file of the HAL 4.0. custom configurable +* parameters of the HAL 4.0 are provided in this file +* +* Project: NFC-FRI-1.1 / HAL4.0 +* +* $Date: Fri Jun 11 16:44:31 2010 $ +* $Author: ing04880 $ +* $Revision: 1.11 $ +* $Aliases: NFC_FRI1.1_WK1023_R35_1 $ +* +*/ + + +/*@{*/ +#ifndef NFC_CUSTOM_CONFIG_H +#define NFC_CUSTOM_CONFIG_H +/*@}*/ + + +/** +* \name Hal +* +* File: \ref nfc_custom_config.h +* +*/ + + +/* + ***************************************************************** + ********************** CUSTOM MACROS ************************** + ***************************************************************** + */ + +/**< Max number of remote devices supported*/ +#define MAX_REMOTE_DEVICES 0x10 + + +/**< Default Session ID for Initialisation */ +#define DEFAULT_SESSION "NXP-NFC2" + +/** Resolution value for the timer, here the + timer resolution is 100 milliseconds */ +#define TIMER_RESOLUTION 100U + +/**< Defines connection time out value for LLC timer, + 500 is in milliseconds */ +#define LINK_CONNECTION_TIMEOUT 500U + +/**< Defines guard time out value for LLC timer, + 250 is in milliseconds */ +#define LINK_GUARD_TIMEOUT 250U + +/**< Macro to Enable SMX Feature During + * Initialisation */ + + +/* PLEASE NOTE: This Macro should be only enabled if there is a SMART_MX + * Chip attached to the PN544. + */ +/* #define NXP_HAL_ENABLE_SMX */ + + + +/* PLEASE NOTE: Kindly change the DEFAULT_SESSION Macro for each of the + * configuration change done for the below Macros + */ + +/**< External Clock Request Configuration for the NFC Device, + 0x00U -> No Clock Request, + 0x01U -> Clock Request through CLKREQ pin (GPIO pin 2), + 0x02U -> Clock Request through NXP_EVT_CLK_REQUEST Event, + */ +#define NXP_DEFAULT_CLK_REQUEST 0x00U + +/**< External Input Clock Setting for the NFC Device, + 0x00U -> No Input Clock Required (Use the Xtal), + 0x01U -> 13 MHZ, + 0x02U -> 19.2 MHZ, + 0x03U -> 26 MHZ, + 0x04U -> 38.4 MHZ, + 0x05U -> Custom (Set the Custome Clock Registry), + */ +#define NXP_DEFAULT_INPUT_CLK 0x00U + + + +#define NFC_DEV_HWCONF_DEFAULT 0xBCU + +/**< TX LDO Configuration + 0x00 -> 00b 3.0 V, + 0x01 -> 01b 3.0 V, + 0x02 -> 10b 2.7 V, + 0x03 -> 11b 3.3 V, + + */ +#define NXP_DEFAULT_TX_LDO 0x00U + + +/**< External Clock Request Configuration for the NFC Device, + 0x00U -> No Power Request, + 0x01U -> Power Request through CLKREQ pin (GPIO pin 2), + 0x02U -> Power Request through PWR_REQUEST (GPIO Pin 3), + */ +#define NXP_UICC_PWR_REQUEST 0x00U + +/**< UICC Bit Rate Configuration + 0x02U -> 212Kbits/Sec + 0x04U -> 424Kbits/Sec + 0x08U -> 828Kbits/Sec + */ + +#define NXP_UICC_BIT_RATE 0x08U + +/**< Indicates PN544 Power Modes Configuration for the NFC Device, + 0x00U -> PN544 stays in active bat mode + (except when generating RF field) + 0x01U -> PN544 goes in standby when possible otherwise + stays in active bat mode + 0x02U -> PN544 goes in idle mode as soon as it can + (otherwise it is in active bat except when generating RF field) + 0x03U -> PN544 goes in standby when possible otherwise goes in idle mode + as soon as it can (otherwise it is in active bat except when + generating RF field) + */ + +#define NXP_SYSTEM_PWR_STATUS 0x01U + + +/**< System Event Notification + 0x01 Overcurrent + 0x02 PMUVCC Switch + 0x04 External RF Field + 0x08 Memory Violation + 0x10 Temperature Overheat + */ + +#define NXP_SYSTEM_EVT_INFO 0x10U + +/**< NFCIP Active Mode Configuration + 0x01 106 kbps + 0x02 212 kbps + 0x04 424 kbps + */ + +#define NXP_NFCIP_ACTIVE_DEFAULT 0x01U + + + +/* Reset the Default values of Host Link Timers */ +/* Macro to Enable the Host Side Link Timeout Configuration + * 0x00 ----> Default Pre-defined Configuration; + * 0x01 ----> Update only the Host Link Guard Timeout Configuration; + * 0x03 ----> Update Both the Host Link Guard Timeout + and ACK Timeout Configuration; + */ +#define HOST_LINK_TIMEOUT 0x00U + + +#define NXP_NFC_LINK_GRD_CFG_DEFAULT 0x0032U + + +#define NXP_NFC_LINK_ACK_CFG_DEFAULT 0x0005U + + +/* Macro to Enable the Interface Character Timeout Configuration + * 0x00 ----> Default Pre-defined Configuration; + * 0x01 ----> Update the IFC Timeout Default Configuration; + */ +#define NXP_NFC_IFC_TIMEOUT 0x00 + + +#define NXP_NFC_IFC_CONFIG_DEFAULT 0x203AU + + +#define NXP_NFCIP_PSL_BRS_DEFAULT 0x00U + + +#endif /* NFC_CUSTOM_CONFIG_H */ + diff --git a/inc/phDbgTrace.h b/inc/phDbgTrace.h new file mode 100644 index 0000000..7333866 --- /dev/null +++ b/inc/phDbgTrace.h @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2010 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. + */ + + +/** + * \file phDbgTrace.h + * Project: NFC-FRI-1.1 / HAL4.0 + * + * $Date: Tue Apr 28 11:48:33 2009 $ + * $Author: ing08203 $ + * $Revision: 1.17 $ + * $Aliases: NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ + * + */ + +/*@{*/ +#ifndef PHDBGTRACE_H +#define PHDBGTRACE_H +/*@}*/ + + + + +#ifdef PHDBG_TRACES +#define MAX_TRACE_BUFFER 300 + +#ifndef PHDBG_TRACES_LEVEL_0 +#ifndef PHDBG_TRACES_LEVEL_1 +#ifndef PHDBG_TRACES_LEVEL_2 +#define PHDBG_TRACES_LEVEL_0 +#endif +#endif +#endif + + extern char phOsalNfc_DbgTraceBuffer[]; + + #ifdef PHDBG_TRACES_LEVEL_0 + + /*indicates an error that causes a program to abort.*/ + #define PHDBG_FATAL_ERROR(Str) {\ + snprintf(phOsalNfc_DbgTraceBuffer,MAX_TRACE_BUFFER, \ + "FATAL ERROR in Module :%s\n",__FILE__);\ + phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ + snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ + "In Function:%s\n",__FUNCTION__ ); \ + phOsalNfc_DbgString (phOsalNfc_DbgTraceBuffer);\ + } + + #define PHDBG_CRITICAL_ERROR(Str) {\ + snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ + "CRITICAL ERROR in Module :%s\n",__FILE__);\ + phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ + snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ + "In Function:%s\n",__FUNCTION__ ); \ + phOsalNfc_DbgString (phOsalNfc_DbgTraceBuffer);\ + } + #define PHDBG_WARNING(Str) + #define PHDBG_INFO(Str) + #endif /*End of PHDBG_TRACES_LEVEL_0 */ + + #ifdef PHDBG_TRACES_LEVEL_1 + + /*indicates an error that causes a program to abort.*/ + #define PHDBG_FATAL_ERROR(Str) {\ + snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ + "FATAL ERROR in Module :%s\n",__FILE__);\ + phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ + snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ + "In Function:%s\n",__FUNCTION__ ); \ + phOsalNfc_DbgString (phOsalNfc_DbgTraceBuffer);\ + } + + #define PHDBG_CRITICAL_ERROR(Str) {\ + snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ + "CRITICAL ERROR in Module :%s\n",__FILE__);\ + phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ + snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ + "In Function:%s\n",__FUNCTION__ ); \ + phOsalNfc_DbgString (phOsalNfc_DbgTraceBuffer);\ + } + /*Normally this macro shall be used indicate system state that might cause problems in future.*/ + #define PHDBG_WARNING(Str) {\ + snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ + "WARNING :%s\n",__FILE__);\ + phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ + phOsalNfc_DbgString (Str);\ + phOsalNfc_DbgString ("\n");\ + } + #define PHDBG_INFO(Str) + #endif /*End of PHDBG_TRACES_LEVEL_1 */ + + #ifdef PHDBG_TRACES_LEVEL_2 + + /*indicates an error that causes a program to abort.*/ + #define PHDBG_FATAL_ERROR(Str) {\ + snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ + "FATAL ERROR in Module :%s\n",__FILE__);\ + phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ + snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ + "In Function:%s\n",__FUNCTION__ ); \ + phOsalNfc_DbgString (phOsalNfc_DbgTraceBuffer);\ + } + + #define PHDBG_CRITICAL_ERROR(Str) {\ + snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ + "CRITICAL ERROR in Module :%s\n",__FILE__);\ + phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ + snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ + "In Function:%s\n",__FUNCTION__ ); \ + phOsalNfc_DbgString (phOsalNfc_DbgTraceBuffer);\ + } + /*Normally this macro shall be used indicate system state that might cause problems in future.*/ + #define PHDBG_WARNING(Str) {\ + snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ + "WARNING :%s\n",__FILE__);\ + phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ + phOsalNfc_DbgString (Str);\ + phOsalNfc_DbgString ("\n");\ + } + + #define PHDBG_INFO(Str) {\ + snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ + "DBG INFO :%s\n",__FILE__);\ + phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ + phOsalNfc_DbgString (Str);\ + phOsalNfc_DbgString ("\n");\ + } + + + +#endif /*End of PHDBG_TRACES_LEVEL_2 */ +#else +#define PHDBG_FATAL_ERROR(Str) +#define PHDBG_CRITICAL_ERROR(Str) +#define PHDBG_WARNING(Str) +#define PHDBG_INFO(Str) + + +#endif /*end of DEBUG trace*/ +#endif /* end of PHDBGTRACE_H */ diff --git a/inc/phNfcCompId.h b/inc/phNfcCompId.h new file mode 100644 index 0000000..4cb95af --- /dev/null +++ b/inc/phNfcCompId.h @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2010 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. + */ + +/** + * \file phNfcCompId.h + * \brief NFC Component ID Values - Used for Function Return Codes + * + * Project: NFC MW / HAL + * + * $Date: Thu Mar 12 12:00:30 2009 $ + * $Author: ing04880 $ + * $Revision: 1.6 $ + * $Aliases: NFC_FRI1.1_WK912_PREP1,NFC_FRI1.1_WK912_R21_1,NFC_FRI1.1_WK914_PREP1,NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ + * + */ + +#ifndef PHNFCCOMPID_H /* */ +#define PHNFCCOMPID_H /* */ + +#ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */ + +/** + * \name NFC Comp. ID + * + * File: \ref phNfcCompId.h + * + */ +/*@{*/ +#define PHNFCCOMPID_FILEREVISION "$Revision: 1.6 $" /**< \ingroup grp_file_attributes */ +#define PHNFCCOMPID_FILEALIASES "$Aliases: NFC_FRI1.1_WK912_PREP1,NFC_FRI1.1_WK912_R21_1,NFC_FRI1.1_WK914_PREP1,NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ +/*@}*/ + +#endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */ + +/** + * \ingroup grp_comp_id + * + * \name 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) + * . + * + * \note The value \ref CID_NFC_NONE does not exist for Component IDs. Do not use this value except + * for \ref NFCSTATUS_SUCCESS. The enumeration function uses \ref CID_NFC_NONE + * to mark unassigned \ref phHal_sHwReference_t "Hardware References". + * + * \if hal + * \sa \ref phHalNfc_Enumerate + * \endif + */ +/*@{*/ +#define CID_NFC_NONE 0x00 /**< \ingroup grp_comp_id + Unassigned or doesn't apply (see \ref NFCSTATUS_SUCCESS). */ +#define CID_NFC_DAL 0x01 /**< \ingroup grp_comp_id + Driver Abstraction Layer + \if hal (\ref grp_subcomponents) \endif . */ +#define CID_NFC_LLC 0x07 /**< \ingroup grp_comp_id + Logical Link Control Layer + \if hal (\ref grp_subcomponents) \endif . */ +#define CID_NFC_HCI 0x08 /**< \ingroup grp_comp_id + Host Control Interface Layer + \if hal (\ref grp_subcomponents) \endif . */ +#define CID_NFC_DNLD 0x09 /**< \ingroup grp_comp_id + Firmware Download Management Layer + \if hal (\ref grp_subcomponents) \endif . */ +#define CID_NFC_HAL 0x10 /**< \ingroup grp_comp_id + Hardware Abstraction Layer \if hal (\ref grp_hal_common) \endif . */ +#define CID_FRI_NFC_OVR_HAL 0x20 /**< \ingroup grp_comp_id + NFC-Device, HAL-based. */ +#define CID_FRI_NFC_NDEF_RECORD 0x22 /**< \ingroup grp_comp_id + NDEF Record Tools Library. */ +#define CID_FRI_NFC_NDEF_MAP 0x23 /**< \ingroup grp_comp_id + NDEF Mapping. */ +#define CID_FRI_NFC_NDEF_REGISTRY 0x24 /**< \ingroup grp_comp_id + NDEF_REGISTRY. */ +#define CID_FRI_NFC_AUTO_DEV_DIS 0x25 /**< \ingroup grp_comp_id + Automatic Device Discovery. */ +#define CID_FRI_NFC_NDEF_SMTCRDFMT 0x26 /**< \ingroup grp_comp_id + Smart Card Formatting */ +#define CID_FRI_NFC_LLCP 0x27 /**< \ingroup grp_comp_id + LLCP Core. */ +#define CID_FRI_NFC_LLCP_MAC 0x28 /**< \ingroup grp_comp_id + LLCP Mac Mappings. */ +#define CID_FRI_NFC_LLCP_TRANSPORT 0x29 /**< \ingroup grp_comp_id + LLCP Transport. */ +#define CID_NFC_LIB 0x30 /**< \ingroup grp_comp_id + NFC Library Layer \if hal (\ref grp_hal_common) \endif . */ +#define CID_MAX_VALUE 0xF0 /**< \ingroup grp_comp_id + The maximum CID value that is defined. */ + +/*@}*/ + +#endif /* PHNFCCOMPID_H */ diff --git a/inc/phNfcConfig.h b/inc/phNfcConfig.h new file mode 100644 index 0000000..035d5bd --- /dev/null +++ b/inc/phNfcConfig.h @@ -0,0 +1,525 @@ +/* + * Copyright (C) 2010 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. + */ + + +/** +* \file phNfcConfig.h +* \brief HAL Configurations +* +* +* \note This is the configuration header file of the HAL 4.0.All configurable parameters of the HAL 4.0 +* are provided in this file +* +* Project: NFC-FRI-1.1 / HAL4.0 +* +* $Date: Fri Jun 11 16:20:17 2010 $ +* $Author: ing04880 $ +* $Revision: 1.37 $ +* $Aliases: NFC_FRI1.1_WK1023_R35_1 $ +* +*/ + + +/*@{*/ +#ifndef PHNFC_CONFIG_H +#define PHNFC_CONFIG_H +/*@}*/ + + +/** +* \name Hal +* +* File: \ref phNfcConfig.h +* +*/ + +/*@{*/ +#define PH_NFC_CONFIG_FILEREVISION "$Revision: 1.37 $" /**< \ingroup grp_file_attributes */ +#define PH_NFC_CONFIG_FILEALIASES "$Aliases: NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ +/*@}*/ + + +/* -----------------Include files ---------------------------------------*/ + +#ifdef NFC_CUSTOM_CONFIG_INCLUDE +#include +#endif + +/* ---------------- Macros ----------------------------------------------*/ + + + +/* + ***************************************************************** + ********************** DEFAULT MACROS ************************** + ***************************************************************** + */ + + +/**< External Clock Request Configuration for the NFC Device, + 0x00U No Clock Request, + 0x01U Clock Request through CLKREQ pin (GPIO pin 2), + 0x02U Clock Request through NXP_EVT_CLK_REQUEST Event, + */ +#ifndef NXP_DEFAULT_CLK_REQUEST +#define NXP_DEFAULT_CLK_REQUEST 0x00U +#endif + +/**< External Input Clock Setting for the NFC Device, + 0x00U No Input Clock Required (Use the Xtal), + 0x01U 13 MHZ, + 0x02U 19.2 MHZ, + 0x03U 26 MHZ, + 0x04U 38.4 MHZ, + 0x05U Custom (Set the Custome Clock Registry), + */ + +#ifndef NXP_DEFAULT_INPUT_CLK +#define NXP_DEFAULT_INPUT_CLK 0x00U +#endif + +/**< UICC Power Request configuration for the NFC Device, + 0x00U No Power Request, + 0x01U Power Request through CLKREQ pin (GPIO pin 2), + 0x02U Power Request through PWR_REQUEST (GPIO Pin 3), + */ + +#ifndef NXP_UICC_PWR_REQUEST +#define NXP_UICC_PWR_REQUEST 0x00U +#endif + +/**< TX LDO Configuration + 0x00 00b 3.0 V, + 0x01 01b 3.0 V, + 0x02 10b 2.7 V, + 0x03 11b 3.3 V, + */ + +#ifndef NXP_DEFAULT_TX_LDO +#define NXP_DEFAULT_TX_LDO 0x00U +#endif + +/**< UICC Bit Rate Configuration + 0x02 212Kbits/Sec + 0x04 424Kbits/Sec + 0x08 828Kbits/Sec + */ + +#ifndef NXP_UICC_BIT_RATE +#define NXP_UICC_BIT_RATE 0x08U +#endif + + +/**< Indicates PN544 Power Modes Configuration for the NFC Device, + 0x00U -> PN544 stays in active bat mode + (except when generating RF field) + 0x01U -> PN544 goes in standby when possible otherwise + stays in active bat mode + 0x02U -> PN544 goes in idle mode as soon as it can + (otherwise it is in active bat except when generating RF field) + 0x03U -> PN544 goes in standby when possible otherwise goes in idle mode + as soon as it can (otherwise it is in active bat except when + generating RF field) + */ + +#ifndef NXP_SYSTEM_PWR_STATUS +#define NXP_SYSTEM_PWR_STATUS 0x00U +#endif + +/**< Default Session ID for Initialisation */ +#ifndef DEFAULT_SESSION +#define DEFAULT_SESSION "NXP-NFC1" +#endif + + +/* The Other Integration Configuration Values */ + +/**< Max number of remote devices supported */ + +#ifndef MAX_REMOTE_DEVICES +#define MAX_REMOTE_DEVICES 0x0A +#endif + +/**< System Event Notification + 0x01 Overcurrent + 0x02 PMUVCC Switch + 0x04 External RF Field + 0x08 Memory Violation + 0x10 Temperature Overheat + */ + +#ifndef NXP_SYSTEM_EVT_INFO +#define NXP_SYSTEM_EVT_INFO 0x3DU +#endif + + +#ifndef NFC_DEV_HWCONF_DEFAULT +#define NFC_DEV_HWCONF_DEFAULT 0xBCU +#endif + + +#ifndef NXP_ISO_XCHG_TIMEOUT +#define NXP_ISO_XCHG_TIMEOUT 0x1AU +#endif + +#ifndef NXP_MIFARE_XCHG_TIMEOUT +#define NXP_MIFARE_XCHG_TIMEOUT 0x03U +#endif + +#ifndef NXP_FELICA_XCHG_TIMEOUT +#define NXP_FELICA_XCHG_TIMEOUT 0xFFU +#endif + + +#ifndef NXP_NFCIP_PSL_BRS_DEFAULT +#define NXP_NFCIP_PSL_BRS_DEFAULT 0x00U +#endif + + + +/**< ID For Invalid Timer */ +#ifndef NXP_INVALID_TIMER_ID +#define NXP_INVALID_TIMER_ID 0xFFFFFFFFU +#endif + +/**< Presence check interval in milliseconds */ +#ifndef PRESENCE_CHECK_INTERVAL +#define PRESENCE_CHECK_INTERVAL 500U +#endif + +/** Resolution value for the timer, here the + timer resolution is 500 milliseconds */ +#ifndef TIMER_RESOLUTION +#define TIMER_RESOLUTION 500U +#endif + +/* Kindly note that the below Timeout values should be + * in Multiples of the value provided to TIMER_RESOLUTION + */ + +/**< Defines guard time out value for LLC timer, + 1000 is in milliseconds */ +#ifndef LINK_GUARD_TIMEOUT +#define LINK_GUARD_TIMEOUT 1000U +#endif + + +/**< Defines connection time out value for LLC timer, + 1000 is in milliseconds */ +#ifndef LINK_CONNECTION_TIMEOUT +#define LINK_CONNECTION_TIMEOUT 1000U +#endif + + +/**< Defines Firmware Download Completion Timeout value , + 120000 is in milliseconds */ + + +#ifndef NXP_DNLD_COMPLETE_TIMEOUT +#define NXP_DNLD_COMPLETE_TIMEOUT 120000U +#endif + + +/**< Define to configure the Active Mode Polling Guard Time-out + */ + +#ifndef DEV_MGMT_ACT_GRD_TO_DEFAULT +#define DEV_MGMT_ACT_GRD_TO_DEFAULT 0x20U +#endif + +/**< NFCIP Active Mode Configuration + 0x01 106 kbps + 0x02 212 kbps + 0x04 424 kbps + */ + +#ifndef NXP_NFCIP_ACTIVE_DEFAULT +#define NXP_NFCIP_ACTIVE_DEFAULT 0x01U +#endif + + + + +#ifndef NXP_NFC_HCI_TIMER +#define NXP_NFC_HCI_TIMER 0 +#define NXP_NFC_HCI_TIMEOUT 0x5000 +#endif + + +/* + ***************************************************************** + DO NOT MODIFY THE BELOW MACROS UNLESS OTHERWISE MENTIONED + ***************************************************************** + */ + + + +#ifndef HOST_CE_A_SAK_DEFAULT +#define HOST_CE_A_SAK_DEFAULT 0x20U +#endif + +#ifndef NXP_CE_A_ATQA_HIGH +#define NXP_CE_A_ATQA_HIGH 0x00U +#endif + +#ifndef NXP_CE_A_ATQA_LOW +#define NXP_CE_A_ATQA_LOW 0x04U +#endif + + +#ifndef NXP_UICC_CE_RIGHTS +#define NXP_UICC_CE_RIGHTS 0x0FU +#endif + +#ifndef NXP_UICC_RD_RIGHTS +#define NXP_UICC_RD_RIGHTS 0x00U +#endif + + +/* + ***************************************************************** + DO NOT DISABLE/ENABLE BELOW MACROS UNLESS OTHERWISE MENTIONED + ***************************************************************** + */ + +#define ES_HW_VER 32 + +/* + ***************************************************************** + *************** FEATURE SPECIFIC MACROS ************************* + ***************************************************************** + */ + + + +/**< Macro to Enable SMX Feature During + * Initialisation */ + +#if !defined(NXP_SMX) +#define NXP_SMX 0 +#endif + +#if (NXP_SMX == 1) +#define NXP_HAL_ENABLE_SMX +#endif + +/**< Macro to Enable the Host Session + * Initialisation */ +#define ESTABLISH_SESSION + +/**< Macro to Enable the Peer to Peer Feature */ +#define ENABLE_P2P + +#define DEFAULT_NFCIP_MODE_SUPPORT 0x0FU + + +/**< Macro to Enable the ISO14443-B Feature */ +#define TYPE_B + +/**< Macro to Enable the Felica Feature */ +#define TYPE_FELICA + +/**< Macro to Enable the JEWEL Feature */ +#define TYPE_JEWEL + +/**< Macro to Enable the ISO15693 Feature */ +#define TYPE_ISO15693 + +/*< Macro to Verify the Poll Parameters Set */ +/* #define ENABLE_VERIFY_PARAM */ + +/**< Macro to Enable ISO 18092 Protocol compliancy + * SAK to be merged with the TYPE A Card RF Feature :3.1*/ +#define TGT_MERGE_SAK + + +/**< Macro to Configure the default power status + * to allow the PN544 to enter into the Standby */ +#define CFG_PWR_STATUS + + +/**< Macro to Enable the SWP Protocol + * to detect UICC During Initialisation */ +#define ENABLE_UICC + +/**< Macro to Enable the RAW Mode of Transaction + * for the ISO-14443-3A Compliant Targets */ +#define ENABLE_MIFARE_RAW + +/**< Macro to Enable the HOST List + * to allow the UICC Communication */ +#define HOST_WHITELIST + + +/**< Macro to Enable the Card Emulation Feature */ +/* #define HOST_EMULATION */ + +/**< Macro to Enable the Download Mode Feature */ +//#define FW_DOWNLOAD + +/**< Macro to Enable the Firmware Download Timer */ +#define FW_DOWNLOAD_TIMER + +/**< Macro to Verify the Firmware Download */ +/* #define FW_DOWNLOAD_VERIFY */ + +#ifndef FW_DOWNLOAD_VERIFY +#define NXP_FW_INTEGRITY_CHK +#endif + +#define UICC_CONNECTIVITY_PATCH + +/* Work around to Delay the initiator activation */ +/* #define NXP_NFCIP_ACTIVATE_DELAY */ + +/* Work around to Release the Discovered Target */ +#define SW_RELEASE_TARGET + +/* Macro to Allow the HCI Release in any state */ +#define NXP_HCI_SHUTDOWN_OVERRIDE + + +/* Macro to Enable The P2P Transaction Timers */ +#define P2P_TGT_TRANSACT_TIMER + +#if (ES_HW_VER == 32) +/* Macro to Configure the Target Disable Register */ +#define NFCIP_TGT_DISABLE_CFG + +#endif + +/*< Macro to Disable the Felica Mapping */ +/* #define DISABLE_FELICA_MAPPING */ + +/*< Macro to Disable the Felica Mapping */ +/* #define DISABLE_JEWEL_MAPPING */ + +/**< Macro to enable LLC timer */ +#define LLC_TIMER_ENABLE + +/**< Macro to enable HCI Response timer */ +/* #define NXP_NFC_HCI_TIMER 1 */ + +/* A Workaround to Delay and obtain the UICC Status Information */ +/* #define UICC_STATUS_DELAY */ + +#ifdef UICC_STATUS_DELAY +#define UICC_STATUS_DELAY_COUNT 0x00100000 +#endif + +/**< Macro to delay the LLC RESET response callback, + Value is in milli-seconds */ +#define LLC_RESET_DELAY 10 + +/* Macro to Enable the workaround for Tuning of + * RF for TYPE B and F + */ +/* #define SW_TYPE_RF_TUNING_BF */ + +/* Workaround to update the Active Guard Timeout */ +/* #define MAX_ACTIVATE_TIMEOUT */ + +/* #define ONE_BYTE_LEN */ + +#define NFC_RF_NOISE_SW + +/**< Define to configure the PMOS Modulation Index value + */ + +#ifndef NFC_DEV_PMOS_MOD_DEFAULT +/* 0x3F -> 6%, 0x3A -> 10%, 0x3C -> 10%, 0x35 -> 15.8%, 0x28 -> 25.8% */ +#define NFC_DEV_PMOS_MOD_DEFAULT 0x3CU +#endif + + +#ifndef SW_TYPE_RF_TUNING_BF +#define SW_TYPE_RF_TUNING_BF 0x80U +#endif + + +/* Reset the Default values of Host Link Timers */ +/* Macro to Enable the Host Side Link Timeout Configuration + * 0x00 ----> Default Pre-defined Configuration; + * 0x01 ----> Update only the Host Link Guard Timeout Configuration; + * 0x03 ----> Update Both the Host Link Guard Timeout + and ACK Timeout Configuration; + */ + +#ifndef HOST_LINK_TIMEOUT +#define HOST_LINK_TIMEOUT 0x00U +#endif + + +#ifndef NXP_NFC_LINK_GRD_CFG_DEFAULT +#define NXP_NFC_LINK_GRD_CFG_DEFAULT 0x0032U +#endif + +#ifndef NXP_NFC_LINK_ACK_CFG_DEFAULT +#define NXP_NFC_LINK_ACK_CFG_DEFAULT 0x0005U +#endif + +/* Macro to Enable the Interface Character Timeout Configuration + * 0x00 ----> Default Pre-defined Configuration; + * 0x01 ----> Update the IFC Timeout Default Configuration; + */ + +#ifndef NXP_NFC_IFC_TIMEOUT +#define NXP_NFC_IFC_TIMEOUT 0x00 +#endif + + +#ifndef NXP_NFC_IFC_CONFIG_DEFAULT +#define NXP_NFC_IFC_CONFIG_DEFAULT 0x203AU +#endif + + + +/* + ***************************************************************** + *********** MACROS ENABLE EEPROM REGISTER WRITE **************** + ***************************************************************** + */ + + +/* Enable this to Disable the WI Notification */ +/* #define DISABLE_WI_NOTIFICATION */ + +/* Macro to Enable the Configuration of Initiator + * speed during Discovery configuration + */ +#define INITIATOR_SPEED + + +/**/ +/* #define UICC_SESSION_RESET */ + +/* Macro to Enable the Configuration of UICC + * Timer and Bitrate during Initialisation + */ + + + + +/* -----------------Structures and Enumerations -------------------------*/ + + + + +/* -----------------Exported Functions----------------------------------*/ + + +#endif /*PHNFC_CONFIG_H*/ + diff --git a/inc/phNfcHalTypes.h b/inc/phNfcHalTypes.h new file mode 100644 index 0000000..748f01b --- /dev/null +++ b/inc/phNfcHalTypes.h @@ -0,0 +1,1323 @@ +/* + * Copyright (C) 2010 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. + */ + +/** + * \file phNfcHalTypes.h + * \brief Structure declarations/type definitions belonging to the HAL subsystem. + * + * Project: NFC MW / HAL + * + * $Date: Thu Apr 8 17:11:39 2010 $ + * $Author: ing04880 $ + * $Revision: 1.106 $ + * $Aliases: NFC_FRI1.1_WK1007_SDK,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ + * + */ + + +#ifndef PHNFCHALTYPES_H /* */ +#define PHNFCHALTYPES_H /* */ + +/** + * \name HAL Types + * + * File: \ref phNfcHalTypes.h + * + */ + +/*@{*/ +#define PHNFCHALTYPES_FILEREVISION "$Revision: 1.106 $" /**< \ingroup grp_file_attributes */ +#define PHNFCHALTYPES_FILEALIASES "$Aliases: NFC_FRI1.1_WK1007_SDK,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ +/*@}*/ + +#include +#include +#include + + +/** \ingroup grp_hal_common + * + * \if hal + * \brief Protocol Support Information + * \else + * \brief HAL-Specific + * \endif + * + * The Supported Protocols Structure holds all protocol supported by the current NFC + * device. + * + * \note All members of this structure are output parameters [out]. + * + */ +typedef phNfc_sSupProtocol_t phHal_sSupProtocol_t; + + +/** \ingroup grp_hal_common + * + * + * \if hal + * \brief Information related to the NFC Device + * \else + * \brief HAL-Specific + * \endif + * + * The Device Information Structure holds information + * related to the NFC IC read during initialization time. + * It allows the caller firware, hardware version, the model id, + * HCI verison supported and vendor name. Refer to the NFC Device + * User Manual on how to interpret each of the values. In addition + * it also contains capabilities of the NFC Device such as the + * protocols supported in Reader and emulation mode + * + */ + +typedef phNfc_sDeviceCapabilities_t phHal_sDeviceCapabilities_t; + + +/** + * \ingroup grp_hal_common + * + * \if hal + * \brief Hardware Reference - The Peripheral Representation + * \else + * \brief HAL-Specific + * \endif + * + * The Hardware Reference structure is filled as part of the open function and + * contains information regarding connected peripheral NFC device. It also + * stores the refernce to the communication driver passed by the HAL client + * for usage during communication with the NFC Device + * + * \note The caller can consider this structure atomic, no interpretation is required + * for HAL operation. + * + * \sa phHal4Nfc_Open . + * + */ + +/** + * \ingroup grp_hal_common + * + * \brief Hardware Reference - The Peripheral Representation + * + * The Hardware Reference structure is filled as part of the open function and + * contains information regarding connected peripheral NFC device. It also + * stores the refernce to the communication driver passed by the HAL client + * for usage during communication with the NFC Device + * + * \note The caller can consider this structure atomic, no interpretation is required + * for HAL operation. + * + */ +typedef struct phHal_sHwReference +{ + /**< Will be usable/valid after the Open function. */ + void *p_board_driver; + /**< Session Identifier for the established session */ + uint8_t session_id[SESSIONID_SIZE]; + /**< SMX Connected TRUE/FALSE */ + uint8_t smx_connected; + /**< UICC Connected TRUE/FALSE */ + uint8_t uicc_connected; + /**< UICC Reader Mode is Active TRUE/FALSE */ + uint8_t uicc_rdr_active; + /**< Device information. */ + phNfc_sDeviceCapabilities_t device_info; + /**< Context of the HAL Layer */ + void *hal_context; + /**< Context of the DAL Layer */ + void *dal_context; +} phHal_sHwReference_t; + + +/** \ingroup grp_hal_common + * + * \if hal + * \brief Hardware configuration - Configuration Parameters for the NFC Device + * \else + * \brief HAL-Specific + * \endif + * + * The parameters used to configure the device during the initialisation. + * This structure is used internally by the HAL implementation and is filled + * up based on various configuration parameters from the config file + * \note None. + * + */ + +typedef struct phHal_sHwConfig +{ + + uint8_t session_id[SESSIONID_SIZE]; /**< Session Identifier for + the established session */ + + uint8_t clk_req; /**< Clock Request Setting */ + + uint8_t input_clk; /**< Input Clock Setting */ + +} phHal_sHwConfig_t; + + + +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + +/* This data structure is not used anymore and will be removed in subsequent + release */ +typedef struct phHal_sDepFlags +{ + unsigned int MetaChaining : 1; + unsigned int NADPresent : 1; +} phHal_sDepFlags_t; + +/* This data structure is not used anymore and will be removed in subsequent + release */ + +typedef struct phHal_sDepAdditionalInfo +{ + phHal_sDepFlags_t DepFlags; + uint8_t NAD; +} phHal_sDepAdditionalInfo_t; + + +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + + + +/** \ingroup grp_hal_common + * + * \if hal + * \brief Enumerated MIFARE Commands + * \else + * \brief HAL-Specific + * \endif + * + * The Mifare Command List Enumerator lists all available Mifare native commands. + * + * \note None. + * + */ + +typedef phNfc_eMifareCmdList_t phHal_eMifareCmdList_t; + +#define phHal_eMifareRaw phNfc_eMifareRaw +#define phHal_eMifareAuthentA phNfc_eMifareAuthentA +#define phHal_eMifareAuthentB phNfc_eMifareAuthentB +#define phHal_eMifareRead16 phNfc_eMifareRead16 +#define phHal_eMifareRead phNfc_eMifareRead +#define phHal_eMifareWrite16 phNfc_eMifareWrite16 +#define phHal_eMifareWrite4 phNfc_eMifareWrite4 +#define phHal_eMifareInc phNfc_eMifareInc +#define phHal_eMifareDec phNfc_eMifareDec +#define phHal_eMifareTransfer phNfc_eMifareTransfer +#define phHal_eMifareRestore phNfc_eMifareRestore +#define phHal_eMifareReadSector phNfc_eMifareReadSector +#define phHal_eMifareWriteSector phNfc_eMifareWriteSector +#define phHal_eMifareInvalidCmd phNfc_eMifareInvalidCmd + + +/** \ingroup grp_hal_common + * + * The T=Cl Command List Enumerator lists all available T=Cl Commands. + * + * \note None. + * + */ +typedef phNfc_eIso14443_4_CmdList_t phHal_eIso14443_4_CmdList_t; + +#define phHal_eIso14443_4_Raw phNfc_eIso14443_4_Raw + + +/** \ingroup grp_hal_common + * + * The NFCIP1 Command List Enumerator lists all available NFCIP1 Commands. + * + * \note None. + * + */ +typedef phNfc_eNfcIP1CmdList_t phHal_eNfcIP1CmdList_t; + +#define phHal_eNfcIP1_Raw phNfc_eNfcIP1_Raw + + +/** \ingroup grp_hal_common + * + * The ISO15693 Command List Enumerator lists all available ISO15693 Commands. + * + * \note None. + * + */ + +typedef phNfc_eIso15693_CmdList_t phHal_eIso15693_CmdList_t; + +#if 0 +#define phHal_eIso15693_Raw phNfc_eIso15693_Raw +#endif +#define phHal_eIso15693_Cmd phNfc_eIso15693_Cmd +#define phHal_eIso15693_Invalid phNfc_eIso15693_Invalid + +/** \ingroup grp_hal_common + * + * The Felica Command List Enumerator lists all available Felica Commands. + * + * \note None. + * + */ + +typedef enum phHal_eFelicaCmdList +{ + phHal_eFelica_Raw = 0xF0U, /**< Felica Raw command:\n + - This command sends the data buffer directly + to the remote device */ + phHal_eFelica_Check = 0x00, /**< Felica Check command:\n + - This command checks the data from the Felica + remote device */ + phHal_eFelica_Update = 0x01, /**< Felica Update command:\n + - This command updates the data onto the Felica + remote device */ + phHal_eFelica_Invalid = 0xFFU /**< Invalid Command */ +} phHal_eFelicaCmdList_t; + + +typedef enum phHal_eJewelCmdList +{ + phHal_eJewel_Raw = 0x00U, /**< Jewel command:\n + - This command sends the data buffer directly + to the remote device */ + phHal_eJewel_Invalid = 0xFFU /**< Invalid jewel command */ +}phHal_eJewelCmdList_t; + + + +/** \ingroup grp_hal_nfci +* +* \if hal +* \brief Remote Device Reader A RF Gate Information Container +* \else +* \brief HAL-Specific +* \endif +* +* The Reader A structure includes the available information +* related to the discovered ISO14443A remote device. This information +* is updated for every device discovery. +* \note None. +* +*/ +typedef phNfc_sIso14443AInfo_t phHal_sIso14443AInfo_t; + +/** \ingroup grp_hal_nfci +* +* \if hal +* \brief Remote Device Reader B RF Gate Information Container +* \else +* \brief HAL-Specific +* \endif +* +* The Reader B structure includes the available information +* related to the discovered ISO14443B remote device. This information +* is updated for every device discovery. +* \note None. +* +*/ + +typedef phNfc_sIso14443BInfo_t phHal_sIso14443BInfo_t; + +typedef phNfc_sIso14443BPrimeInfo_t phHal_sIso14443BPrimeInfo; + + +/** \ingroup grp_hal_nfci +* +* \if hal +* \brief Remote Device Jewel Reader RF Gate Information Container +* \else +* \brief HAL-Specific +* \endif +* +* The Jewel Reader structure includes the available information +* related to the discovered Jewel remote device. This information +* is updated for every device discovery. +* \note None. +* +*/ + + +typedef phNfc_sJewelInfo_t phHal_sJewelInfo_t; + +/** \ingroup grp_hal_nfci +* +* \if hal +* \brief Remote Device Felica Reader RF Gate Information Container +* \else +* \brief HAL-Specific +* \endif +* +* The Felica Reader structure includes the available information +* related to the discovered Felica remote device. This information +* is updated for every device discovery. +* \note None. +* +*/ + +typedef phNfc_sFelicaInfo_t phHal_sFelicaInfo_t; + + +/** \ingroup grp_hal_nfci +* +* \if hal +* \brief Remote Device Reader 15693 RF Gate Information Container +* \else +* \brief HAL-Specific +* \endif +* +* The Reader A structure includes the available information +* related to the discovered ISO15693 remote device. This information +* is updated for every device discovery. +* \note None. +* +*/ + +typedef phNfc_sIso15693Info_t phHal_sIso15693Info_t; + + +/** \ingroup grp_hal_nfci +* +* \if hal +* \brief NFC Data Rate Supported between the Reader and the Target +* \else +* \brief HAL-Specific +* \endif +* +* The \ref phHalNfc_eDataRate enum lists all the Data Rate +* values to be used to determine the rate at which the data is transmitted +* to the target. +* +* \note None. +*/ + + +typedef phNfc_eDataRate_t phHalNfc_eDataRate_t; + + +/** \ingroup grp_hal_nfci +* +* \if hal +* \brief NFCIP1 Gate Information Container +* \else +* \brief HAL-Specific +* \endif +* +* The NFCIP1 structure includes the available information +* related to the discovered NFCIP1 remote device. This information +* is updated for every device discovery. +* \note None. +* +*/ + +typedef phNfc_sNfcIPInfo_t phHal_sNfcIPInfo_t; + + +/** \ingroup grp_hal_nfci +* +* \if hal +* \brief Remote Device Specific Information Container +* \else +* \brief HAL-Specific +* \endif +* +* The Remote Device Information Union includes the available Remote Device Information +* structures. Following the device detected, the corresponding data structure is used. +* +* \note None. +* +*/ + +typedef phNfc_uRemoteDevInfo_t phHal_uRemoteDevInfo_t; + +/** \ingroup grp_hal_nfci +* +* \if hal +* \brief RF Device Type Listing +* \else +* \brief HAL-Specific +* \endif +* +* The RF Device Type List is used to identify the type of +* remote device that is discovered/connected. There seperate +* types to identify a Remote Reader (denoted by _PCD) and +* Remote Tag (denoted by _PICC) +* \note None. +* +*/ + +typedef phNfc_eRFDevType_t phHal_eRFDevType_t; + +#define phHal_eUnknown_DevType phNfc_eUnknown_DevType + + /* Specific PCD Devices */ +#define phHal_eISO14443_A_PCD phNfc_eISO14443_A_PCD +#define phHal_eISO14443_B_PCD phNfc_eISO14443_B_PCD +#define phHal_eISO14443_BPrime_PCD phNfc_eISO14443_BPrime_PCD +#define phHal_eFelica_PCD phNfc_eFelica_PCD +#define phHal_eJewel_PCD phNfc_eJewel_PCD +#define phHal_eISO15693_PCD phNfc_eISO15693_PCD + /* Generic PCD Type */ +#define phHal_ePCD_DevType phNfc_ePCD_DevType + + /* Generic PICC Type */ +#define phHal_ePICC_DevType phNfc_ePICC_DevType + /* Specific PICC Devices */ +#define phHal_eISO14443_A_PICC phNfc_eISO14443_A_PICC +#define phHal_eISO14443_4A_PICC phNfc_eISO14443_4A_PICC +#define phHal_eISO14443_3A_PICC phNfc_eISO14443_3A_PICC +#define phHal_eMifare_PICC phNfc_eMifare_PICC +#define phHal_eISO14443_B_PICC phNfc_eISO14443_B_PICC +#define phHal_eISO14443_4B_PICC phNfc_eISO14443_4B_PICC +#define phHal_eISO14443_BPrime_PICC phNfc_eISO14443_BPrime_PICC +#define phHal_eFelica_PICC phNfc_eFelica_PICC +#define phHal_eJewel_PICC phNfc_eJewel_PICC +#define phHal_eISO15693_PICC phNfc_eISO15693_PICC + + /* NFC-IP1 Device Types */ +#define phHal_eNfcIP1_Target phNfc_eNfcIP1_Target +#define phHal_eNfcIP1_Initiator phNfc_eNfcIP1_Initiator + + /* Other Sources */ +#define phHal_eInvalid_DevType phNfc_eInvalid_DevType + +/** \ingroup grp_hal_nfci +* +* \if hal +* \brief Remote Device Type Listing +* \else +* \brief HAL-Specific +* \endif +* +* The Remote Device Type List is used to identify the type of +* remote device that is discovered/connected +* \note This is same as RF Device Type List. +* +*/ +typedef phNfc_eRemDevType_t phHal_eRemDevType_t; + +/** \ingroup grp_hal_common + * + * + * \if hal + * \brief Common Command Attribute + * \else + * \brief HAL-Specific + * \endif + * + * The Hal Command Union includes each available type of Commands. + * + * \note None. + * + */ + +typedef phNfc_uCmdList_t phHal_uCmdList_t; + + +/** \ingroup grp_hal_nfci + * + * \if hal + * \brief Remote Device Information Structure + * \else + * \brief HAL-Specific + * \endif + * + * The Remote Device Information Structure holds information about one single Remote + * Device detected by the polling function .\n + * It lists parameters common to all supported remote devices. + * + * \note + * + * \if hal + * \sa \ref phHal4Nfc_ConfigureDiscovery and \ref phHal4Nfc_Connect + * \else + * \sa + * \endif + * + */ + +typedef phNfc_sRemoteDevInformation_t phHal_sRemoteDevInformation_t; + + + +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + +/* This data structure is not used anymore and will be removed in subsequent + release */ + +typedef struct phHal_sDevInputParam +{ + uint8_t FelicaPollPayload[5]; + + + uint8_t NfcPollPayload[5]; + + + uint8_t NFCIDAuto; + + + uint8_t NFCID3i[PHHAL_NFCID_LENGTH]; + + + + uint8_t DIDiUsed; + + uint8_t CIDiUsed; + + uint8_t NfcNADiUsed; + + /*+ MantisId : 31 - JP - 09-01-2006 */ + /*uint8_t TClNADiUsed; */ + + /*- MantisId : 31 - JP - 09-01-2006 */ + uint8_t GeneralByte[48]; + + + uint8_t GeneralByteLength; + + + uint8_t ISO14443_4B_AFI; + +} phHal_sDevInputParam_t; + + + + +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + + +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* TARGET STRUCTURES */ + + +/** \ingroup grp_hal_common + * + * \if hal + * \brief Transceive Information Data Structure for sending commands/response + * to the remote device + * \else + * \brief HAL-Specific + * \endif + * + * The Transceive Information Data Structure is used to pass the + * Command, Address (only required for MIFARE) and the send and receive data + * data structure (buffer and length) for communication with remote device + * + * + */ + +typedef phNfc_sTransceiveInfo_t phHal_sTransceiveInfo_t; + + +/** \ingroup grp_hal_nfci +* +* \if hal +* \brief Input information for the Type A tags +* \else +* \brief HAL-Specific +* \endif +* +* The \ref phHal_sIso14443ACfg structure holds the information +* required for the NFC device to be used during ISO14443A target discovery +* +* \note None. +*/ +typedef struct phHal_sIso14443ACfg +{ + uint8_t Auto_Activation; /**< Enable Auto Activation for + Technology A \n + If set to 0, the activation procedure will stop + after Select (SAK has been received). + The host could evaluate SAK value and then decide: + - to start communicating with the remote card + using proprietary commands (see NXP_MIFARE_RAW + and NXP_MIFARE_CMD) + or + - to activate the remote card up to ISO14443-4 + level (RATS and PPS) using + CONTINUE ACTIVATION command + If set to 1, activation follows the flow described in + ETSI HCI specification (restrict detection to + ISO14443-4 compliant cards). + */ +}phHal_sIso14443ACfg_t; + + +/** \ingroup grp_hal_nfci +* +* \if hal +* \brief Input information for the Type B tags +* \else +* \brief HAL-Specific +* \endif +* +* The \ref phHal_sIso14443BCfg structure holds the information +* required for the NFC device to be used during ISO14443B target discovery +* +* \note None. +*/ +typedef struct phHal_sIso14443BCfg +{ + uint8_t AppFamily_ID; /**< Application Family Identifier for + Technology B, 0x00 means all application */ +}phHal_sIso14443BCfg_t; + +/** \ingroup grp_hal_nfci +* +* \if hal +* \brief Input information for the Felica tags +* \else +* \brief HAL-Specific +* \endif +* +* The \ref phHal_sFelicaCfg_t structure holds the information +* required for the NFC device to be used during Felica target discovery +* +* \note None. +*/ + +typedef struct phHal_sFelicaCfg +{ + uint8_t SystemCode[PHHAL_FEL_SYS_CODE_LEN]; /**< System code for Felica tags */ + +}phHal_sFelicaCfg_t; + + +/** \ingroup grp_hal_nfci +* +* \if hal +* \brief Poll Device Information for conifiguring the discovery wheel + Reader and Card Emulation Phases +* \else +* \brief HAL-Specific +* \endif +* +* The \ref phHal_sPollDevInfo_t enum is used to enable/disable +* phases of the discovery wheel related to specific reader types and +* card emulation phase +* \note Enabling specific Reader technology when NFCIP1 speed is set in the +* phNfc_sADD_Cfg_t is implicitly done in HAL. Use this structure to only +* enable/disable Card Reader Functionality +*/ +typedef phNfc_sPollDevInfo_t phHal_sPollDevInfo_t; + + +/** \ingroup grp_hal_common +* +* \if hal +* \brief Identifies Type of Host +* \else +* \brief HAL-Specific +* \endif +* +* This enumeration is used to identify the type of the host providing the +* information or the notification to the Terminal host. +* \note None. +*/ + +typedef enum phHal_HostType { + /* + * This type identifies the host controller + * in the NFC device + */ + phHal_eHostController = 0x00U, + /* + * This type identifies the Host Device + * controlling the NFC device. + */ + phHal_eTerminalHost = 0x01U, + /* + * This type identifies the uicc host + * connnected to the NFC device + */ + phHal_eUICCHost = 0x02U, + /* Host type is unknown */ + phHal_eUnknownHost = 0xFFU +}phHal_HostType_t; + + +/** \ingroup grp_hal_nfci +* +* \if hal +* \brief P2P speed for the Initiator +* \else +* \brief HAL-Specific +* \endif +* +* The \ref phHal_eP2PMode enum lists all the NFCIP1 speeds +* to be used for configuring the NFCIP1 discovery +* +* \note None. +*/ + +#define phHal_eDefaultP2PMode phNfc_eDefaultP2PMode +#define phHal_ePassive106 phNfc_ePassive106 +#define phHal_ePassive212 phNfc_ePassive212 +#define phHal_ePassive424 phNfc_ePassive424 +#define phHal_eActive phNfc_eActive +#define phHal_eP2P_ALL phNfc_eP2P_ALL +#define phHal_eInvalidP2PMode phNfc_eInvalidP2PMode + + +/** \ingroup grp_hal_common +* +* \if hal +* \brief Identities the type of Notification +* \else +* \brief HAL-Specific +* \endif +* +* This enumeration is used to specify the type of notification notified +* to the upper layer. This classifies the notification into two types +* one for the discovery notifications and the other for all the remaining +* event notifications +* \note None. +*/ + + +typedef phNfc_eNotificationType_t phHal_eNotificationType_t; + + +/** \ingroup grp_hal_common +* +* \if hal +* \brief Identifies the type of event notification +* \else +* \brief HAL-Specific +* \endif +* +* This enumeration is used to identify the type of the event notified +* to the Terminal host. +* \note None. +*/ + +typedef enum phHal_Event { + + + /* Transaction Events */ + NFC_EVT_END_OF_TRANSACTION = 0x11U , + NFC_EVT_TRANSACTION = 0x12U , + NFC_EVT_START_OF_TRANSACTION = 0x20U , + + /* Field Events */ + NFC_EVT_FIELD_ON = 0x31U, + NFC_EVT_FIELD_OFF = 0x34U, + + /* Card/Target Activation Events */ + NFC_EVT_ACTIVATED = 0x33U, + NFC_EVT_DEACTIVATED = 0x32U, + + NFC_EVT_PROTECTED = 0x24U , + + /* Reader Phases configuration request by UICC */ + NFC_UICC_RDPHASES_ACTIVATE_REQ = 0x43U, + NFC_UICC_RDPHASES_DEACTIVATE_REQ = 0x44U, + + /* Connectivity and Triggering Events - Future Use */ + NFC_EVT_CONNECTIVITY = 0x10U , + NFC_EVT_OPERATION_ENDED = 0x13U , + + /* NXP Specific System Information Events */ + NFC_INFO_TXLDO_OVERCUR = 0x71U, + NFC_INFO_MEM_VIOLATION = 0x73U, + NFC_INFO_TEMP_OVERHEAT = 0x74U + +}phHal_Event_t; + +typedef phNfc_sUiccInfo_t phHal_sUiccInfo_t; + +/** \ingroup grp_hal_common +* +* \if hal +* \brief Event notification Information +* \else +* \brief HAL-Specific +* \endif +* +* This structure provides the information about the event notified +* to the terminal host. +* \note None. +*/ + +typedef struct phHal_sEventInfo +{ + /* Type of the host issuing the event */ + phHal_HostType_t eventHost; + /* Type of the source issuing the event */ + phHal_eRFDevType_t eventSource; + /* Type of the source issuing the event */ + phHal_Event_t eventType; + union uEventInfo + { + /* Parameter information Information is obtained if the eventType is + * NFC_EVT_TRANSACTION for UICC. + */ + phHal_sUiccInfo_t uicc_info; + /* AID Information is obtained if the eventType is + * NFC_EVT_TRANSACTION. + */ + phNfc_sData_t aid; + /* Overheat Status Information is obtained if the eventType is + * NFC_INFO_TEMP_OVERHEAT. + */ + uint8_t overheat_status; + /* rd_phases Information is obtained if the eventType is + * NFC_UICC_RDPHASES_ACTIVATE_REQ. + */ + uint8_t rd_phases; + /* Remote Device Information is obtained if the eventType is + * NFC_EVT_ACTIVATED. + */ + phHal_sRemoteDevInformation_t *pRemoteDevInfo; + }eventInfo; +}phHal_sEventInfo_t; + + +/** \ingroup grp_hal_common +* +* \if hal +* \brief Information for the Host/Uicc Emulation Support +* \else +* \brief HAL-Specific +* \endif +* +* The \ref phHal_sEmuSupport structure holds the type +* of the target emulation supported. +* +* \note None. +*/ + +typedef struct phHal_sEmuSupport +{ + unsigned int TypeA:1; + unsigned int TypeB:1; + unsigned int TypeBPrime:1; + unsigned int TypeFelica:1; + unsigned int TypeMifare:1; + unsigned int TypeNfcIP1:1; + unsigned int RFU:2; + +}phHal_sEmuSupport_t; + + +/** \ingroup grp_hal_nfci +* +* \if hal +* \brief P2P Information for the Initiator +* \else +* \brief HAL-Specific +* \endif +* +* The \ref phHal_sNfcIPCfg holds the P2P related information +* use by the NFC Device during P2P Discovery and connection +* +* \note None. +*/ + +typedef phNfc_sNfcIPCfg_t phHal_sNfcIPCfg_t; + +/** \ingroup grp_hal_common +* +* \if hal +* \brief Enumeration used to choose which type of parameters +* are to be configured +* \else +* \brief HAL-Specific +* \endif +* +* +* \note None. +*/ +typedef enum phHal_eConfigType +{ + NFC_INVALID_CONFIG = 0x00U, /**< Invalid Configuration */ + NFC_RF_READER_CONFIG, /**< Reader Parmaeters */ + NFC_P2P_CONFIG, /**< NFCIP1 Parameters */ + NFC_SE_PROTECTION_CONFIG, /**< Secure Element + Protection Cofiguration */ + NFC_EMULATION_CONFIG /**< Emulation Parameters */ +}phHal_eConfigType_t; + +/** \ingroup grp_hal_common +* +* \if hal +* \brief Discovery Configuration Mode +* \else +* \brief HAL-Specific +* \endif +* +* This enumeration is used to choose the Discovery Configuration +* Mode :- Configure and Start, Stop or Start with last set +* configuration +* \note None. +*/ + +typedef phNfc_eDiscoveryConfigMode_t phHal_eDiscoveryConfigMode_t; + + +/** \ingroup grp_hal_common +* +* \if hal +* \brief Target or Tag Release Mode +* \else +* \brief HAL-Specific +* \endif +* +* This enumeration defines various modes of releasing an acquired target +* or tag. +* \note None. +*/ +typedef phNfc_eReleaseType_t phHal_eReleaseType_t; + + +/** \ingroup grp_hal_common +* +* \if hal +* \brief Configuration of specific Emulation Feature +* \else +* \brief HAL-Specific +* \endif +* +* This enumeration is used to choose configuration for a specific +* emulation feature. +* \note None. +*/ + +typedef enum phHal_eEmulationType +{ + NFC_UNKNOWN_EMULATION = 0x00U, /**< Invalid Configuration */ + NFC_HOST_CE_A_EMULATION = 0x01U, /**< Configure parameters for Type A + card emulation from host */ + NFC_HOST_CE_B_EMULATION = 0x02U, /**< Configure parameters for Type B + card emulation from host */ + NFC_B_PRIME_EMULATION = 0x03U, /**< Configure parameters for Type B' + card emulation from host */ + NFC_FELICA_EMULATION = 0x04U, /**< Configure parameters for Type F + card emulation from host */ + NFC_MIFARE_EMULATION = 0x06U, /**< Configure parameters for MIFARE + card emulation - For Future Use */ + NFC_SMARTMX_EMULATION = 0x07U, /**< Configure parameters for SmartMX + */ + NFC_UICC_EMULATION = 0x08U /**< Configure parameters for UICC + emulation */ +}phHal_eEmulationType_t; + +#if 0 +/** \ingroup grp_hal_nfct + * + * \if hal + * \brief Information for Target Mode Start-Up + * \else + * \brief HAL-Specific + * \endif + * + * The Target Information Structure required to start Target mode. + * It contains all the information for the Target mode. + * + * \note None. + * + */ + +typedef struct phHal_sTargetInfo +{ + uint8_t enableEmulation; + phHal_sNfcIPCfg_t targetConfig; +} phHal_sTargetInfo_t; +#endif + + +/** \ingroup grp_hal_common +* +* \if hal +* \brief Mode of operation for SmartMX +* \else +* \brief HAL-Specific +* \endif +* +* This enumeration is used to choose the mode of operation for the SmartMx Module. +* Default static configuration at initialization time. +* \note None. +*/ + +typedef enum phHal_eSmartMX_Mode{ + eSmartMx_Wired = 0x00U, /* SmartMX is in Wired Mode */ + eSmartMx_Default, /* SmartMX is in Default Configuration Mode */ + eSmartMx_Virtual, /* SmartMx in the Virutal Mode */ + eSmartMx_Off /* SmartMx Feature is Switched off */ +} phHal_eSmartMX_Mode_t; + + +/** \ingroup grp_hal_common +* +* \if hal +* \brief Mode of operation for SWP +* \else +* \brief HAL-Specific +* \endif +* +* This enumeration is used to choose the mode of operation for the SWP Link +* for UICC Module. Default static configuration at initialization time. +* \note None. +*/ + +typedef enum phHal_eSWP_Mode{ + eSWP_Switch_Off = 0x00U, /* SWP Link is Switched off */ + eSWP_Switch_Default, /* SWP is in Default Configuration Mode */ + eSWP_Switch_On /* SWP Link is Switched on */ +} phHal_eSWP_Mode_t; + + +/** \ingroup grp_hal_common +* +* \if hal +* \brief Information for the Configuring the SmartMX +* \else +* \brief HAL-Specific +* \endif +* +* The \ref phHal_sSmartMX_Cfg structure holds the information +* to configure the SmartMX Module in the NFC Device. +* +* \note None. +*/ + + +typedef struct phHal_sSmartMX_Cfg +{ + uint8_t enableEmulation; + uint8_t lowPowerMode; + phHal_eSmartMX_Mode_t smxMode; +}phHal_sSmartMX_Cfg_t; + + +/** \ingroup grp_hal_common +* +* \if hal +* \brief Information for the Configuring the UICC +* \else +* \brief HAL-Specific +* \endif +* +* The \ref phHal_sUiccEmuCfg structure holds the information +* to configure the UICC Host. +* +* \note None. +*/ + + +typedef struct phHal_sUiccEmuCfg +{ + uint8_t enableUicc; + uint8_t uiccEmuSupport; + uint8_t uiccReaderSupport; + uint8_t lowPowerMode; + /* TODO: This will be updated later */ +}phHal_sUiccEmuCfg_t; + +/** \ingroup grp_hal_common +* +* \if hal +* \brief Information for the Configuring the Type A Host Emulation Feature +* \else +* \brief HAL-Specific +* \endif +* +* The \ref phHal_sHostEmuCfg_A structure holds the information +* to configure the Host Emulation for Type A. +* +* \note None. +*/ + +typedef struct phHal_sHostEmuCfg_A +{ + uint8_t enableEmulation; + phNfc_sIso14443AInfo_t hostEmuCfgInfo; + uint8_t enableCID; +}phHal_sHostEmuCfg_A_t; + + +/** \ingroup grp_hal_common +* +* \if hal +* \brief Information for the Configuring the Type B Host Emulation Feature +* \else +* \brief HAL-Specific +* \endif +* +* The \ref phHal_sHostEmuCfg_B structure holds the information +* to configure the Host Emulation for Type B. +* +* \note None. +*/ + +typedef struct phHal_sHostEmuCfg_B +{ + uint8_t enableEmulation; + phNfc_sIso14443BInfo_t hostEmuCfgInfo; +}phHal_sHostEmuCfg_B_t; + +/** \ingroup grp_hal_common +* +* \if hal +* \brief Information for the Configuring the Felica Host Emulation Feature +* \else +* \brief HAL-Specific +* \endif +* +* The \ref phHal_sHostEmuCfg_F structure holds the information +* to configure the Felica Host Emulation. +* +* \note None. +*/ + + +typedef struct phHal_sHostEmuCfg_F +{ + uint8_t enableEmulation; +}phHal_sHostEmuCfg_F_t; + + +/** \ingroup grp_hal_common +* +* \if hal +* \brief Information for the Configuring the Emulation +* \else +* \brief HAL-Specific +* \endif +* +* The \ref phHal_sEmulationCfg structure holds the information +* required for the device to act as a Tag or NFCIP1 Target. +* +* \note phHal_sHostEmuCfg_F_t Type F emulation is not presently supported +* is reserved for future use. +*/ + +typedef struct phHal_sEmulationCfg +{ + phHal_HostType_t hostType; + phHal_eEmulationType_t emuType; + union phHal_uEmuConfig + { + phHal_sSmartMX_Cfg_t smartMxCfg; + phHal_sHostEmuCfg_A_t hostEmuCfg_A; + phHal_sHostEmuCfg_B_t hostEmuCfg_B; + phHal_sHostEmuCfg_F_t hostEmuCfg_F; + phHal_sUiccEmuCfg_t uiccEmuCfg; + }config; +}phHal_sEmulationCfg_t; + +/** \ingroup grp_hal_common +* +* \if hal +* \brief Information for the Configuring the Reader parameters +* \else +* \brief HAL-Specific +* \endif +* +* The \ref phHal_sReaderCfg structure holds the information +* to configure the Reader A or Reader B parameters. +* +* \note None. +*/ + +typedef struct phHal_sReaderCfg +{ + phHal_eRFDevType_t readerType; + union phHal_uReaderCfg + { + phHal_sIso14443ACfg_t Iso14443ACfg; + phHal_sIso14443BCfg_t Iso14443BCfg; + }config; +}phHal_sReaderCfg_t; + + +/** \ingroup grp_hal_common +* +* \if hal +* \brief Information for Configuring the Protected Mode for +* the Secure Elements. +* \else +* \brief HAL-Specific +* \endif +* +* The \ref phHal_sSEProtectionCfg structure holds the +* information to configure the Secure Element Protection configuration. +* +* \note None. +*/ + +typedef struct phHal_sSEProtectionCfg +{ + uint8_t mode; +}phHal_sSEProtectionCfg_t; + + +/** \ingroup grp_hal_common +* +* \if hal +* \brief Poll configuration structure +* \else +* \brief HAL-Specific +* \endif +* +* The Poll configuration structure holds information about the +* enabling the the type of discovery required by the application. This +* structure is the input parameter for the discovery call +* +* \note All members of this structure are input parameters [out]. +* +* \if hal +* \sa \ref phHal4Nfc_Connect, \ref phHal4Nfc_ConfigParameters, +* \ref phHal_eP2PMode_t and \ref phHal4Nfc_Disconnect. +* \endif +* +*/ + +typedef phNfc_sADD_Cfg_t phHal_sADD_Cfg_t; + + +/** \ingroup grp_hal_common +* +* \if hal +* \brief Configuration information. +* \else +* \brief HAL-Specific +* \endif +* +* The \ref phHal_uConfig structure holds the information +* required for Configuring the Device. +* +* \note None. +*/ + + +typedef union phHal_uConfig +{ + phHal_sEmulationCfg_t emuConfig; + phHal_sNfcIPCfg_t nfcIPConfig; /**< Gives the information about + * the General Bytes for NFC-IP + * Communication. + */ + phHal_sReaderCfg_t readerConfig; + phHal_sSEProtectionCfg_t protectionConfig; +}phHal_uConfig_t; + + +#endif + +/* EOF */ diff --git a/inc/phNfcInterface.h b/inc/phNfcInterface.h new file mode 100644 index 0000000..fdae2ed --- /dev/null +++ b/inc/phNfcInterface.h @@ -0,0 +1,422 @@ +/* + * Copyright (C) 2010 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. + */ + + +/*! +* ============================================================================= +* \file phNfcInterface.h +* \brief Generic Interface Layer Function Definitions. +* +* Project: NFC-FRI-1.1 +* +* $Date: Thu Feb 11 19:01:36 2010 $ +* $Author: ing04880 $ +* $Revision: 1.42 $ +* $Aliases: NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ +* +* ============================================================================= +*/ + +#ifndef PHNFCINTERFACE_H /* */ +#define PHNFCINTERFACE_H /* */ + +/** +* \name NFC Inteface +* +* File: \ref phNfcInterface.h +* +*/ + +/*@{*/ +#define PHNFCINTERFACE_FILEREVISION "$Revision: 1.42 $" /**< \ingroup grp_file_attributes */ +#define PHNFCINTERFACE_FILEALIASES "$Aliases: NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ +/*@}*/ + +/* +################################################################################ +***************************** Header File Inclusion **************************** +################################################################################ +*/ + +#include +#include + + +/* +################################################################################ +****************************** Macro Definitions ******************************* +################################################################################ +*/ + +#define NFC_FSM_IN_PROGRESS 0x01U +#define NFC_FSM_COMPLETE 0x00U + +#define NFC_FSM_CURRENT 0x00U +#define NFC_FSM_NEXT 0x01U + +/* NFC Notification Types */ + +#define NFC_NOTIFY_INIT_COMPLETED 0x01 +#define NFC_NOTIFY_INIT_FAILED 0xF1 + +#define NFC_NOTIFY_DEINIT_COMPLETED 0x02 +#define NFC_NOTIFY_DEINIT_FAILED 0xF2 + +#define NFC_NOTIFY_EVENT 0x70 + +#define NFC_NOTIFY_DEVICE_ACTIVATED 0x82 +#define NFC_NOTIFY_DEVICE_DEACTIVATED 0x83 + +#define NFC_NOTIFY_SEND_COMPLETED 0x03 +#define NFC_NOTIFY_SEND_ERROR 0xF3 + +#define NFC_NOTIFY_RECV_COMPLETED 0x04 +#define NFC_NOTIFY_RECV_ERROR 0xF4 +#define NFC_NOTIFY_RECV_EVENT 0x74 +#define NFC_NOTIFY_RECV_CANCELLED 0x34 + +#define NFC_NOTIFY_TRANSCEIVE_COMPLETED 0x05 +#define NFC_NOTIFY_TRANSCEIVE_ERROR 0xF5 + +#define NFC_NOTIFY_POLL_ENABLED 0x06 +#define NFC_NOTIFY_POLL_RESTARTED 0x16 +#define NFC_NOTIFY_POLL_DISABLED 0x26 +#define NFC_NOTIFY_CONFIG_SUCCESS 0x36 +#define NFC_NOTIFY_CONFIG_ERROR 0xF6 + +#define NFC_NOTIFY_TARGET_DISCOVERED 0x10 +#define NFC_NOTIFY_DISCOVERY_ERROR 0xFA +#define NFC_NOTIFY_TARGET_RELEASED 0x11 +#define NFC_NOTIFY_TARGET_CONNECTED 0x12 +#define NFC_NOTIFY_TARGET_PRESENT 0x13 +#define NFC_NOTIFY_TARGET_REACTIVATED 0x14 +#define NFC_NOTIFY_CONNECT_FAILED 0xFC +#define NFC_NOTIFY_TARGET_DISCONNECTED 0x15 +#define NFC_NOTIFY_DISCONNECT_FAILED 0xFD + +#define NFC_NOTIFY_TRANSACTION 0x07 + +#define NFC_NOTIFY_RESULT 0x08 + +#define NFC_NOTIFY_DEVICE_ERROR 0xFEU +#define NFC_NOTIFY_ERROR 0xFFU + + +#define BYTE_SIZE 0x08U +#define BYTE_MASK 0xFFU +/* HCI GET and SET BITS Macros */ +#define MASK_BITS8(p,l) \ + ( ( (((uint8_t)(p))+((uint8_t)(l)))<=BYTE_SIZE )? \ + (~(0xFFU<<((p)+(l))) & (0xFFU<<(p))):(0U) ) +#ifdef MASK_BITS +#define GET_BITS8(num,p,l) \ + ( ((((uint8_t)(p))+((uint8_t)(l)))<=BYTE_SIZE)? \ + (((num)& (MASK_BITS8(p,l)))>>(p)):(0U) ) +#else +#define GET_BITS8(num,p,l) \ + ( ((((p)+(l))<=BYTE_SIZE))? \ + (((num)>>(p))& (~(0xFFU<<(l)))):(0U) ) +#endif +#define SET_BITS8(num,p,l,val) \ + ( ((((uint8_t)(p))+((uint8_t)(l)))<=BYTE_SIZE)? \ + (((num)& (~MASK_BITS8(p,l)))|((val)<<(p))):(0U)) + +/* +################################################################################ +******************** Enumeration and Structure Definition ********************** +################################################################################ +*/ + + +enum phNfcIF_eExecution{ + NFC_EXEC_NORMAL = 0x00, /**< Normal Execution Sequence */ + NFC_EXEC_CALLBACK = 0x01, /**< Callback Execution Sequence */ + NFC_EXEC_UNKNOWN = 0xFF /**< Callback Execution Sequence */ +}; + + +typedef enum phNfc_eModeType{ + MODE_ON = 0x00U, /**< Switches the particular feature ON*/ + MODE_OFF /**< Switches the particular feature OFF*/ +}phNfc_eModeType_t; + +/** + * State Structure to hold the State Information + * + * This structure holds the state Information of a specified + * Layer . + * + */ + +typedef struct phNfc_sState +{ + uint8_t cur_state; + uint8_t transition; + uint8_t next_state; + /* uint8_t event; */ + +}phNfc_sState_t; + + + +/** + * Transaction Completion Information Structure + * + * This structure holds the completion callback information of the + * transaction passed from the lower layer to the upper layer + * along with the completion callback. + */ + +typedef struct phNfc_sTransactionInfo +{ + /* Returns the status of the Transaction Completion routine */ + NFCSTATUS status; + /* Indicates the Type of the Transaction */ + uint8_t type; + /* To contain more Transaction Notification specific info */ + void *info; + /* The data response from the Transaction */ + uint8_t *buffer; + /* The size of the data response from the Transaction */ + uint16_t length; +}phNfc_sTransactionInfo_t; + +/** + * Notification Information Structure + * + * This structure holds the notification callback information passed from + * the lower layer to the upper layer along with the notification callback. + */ + +typedef struct phNfc_sCompletionInfo +{ + /* Returns the status of the completion routine */ + NFCSTATUS status; + + /* Indicates the Type of the Information + * associated with the completion + */ + uint8_t type; + + /* To contain more completion specific info */ + void *info; + +}phNfc_sCompletionInfo_t; + + +/** + * Notification Information + * + */ +typedef struct phNfc_sNotificationInfo +{ + /* Returns the status of the Notification routine */ + NFCSTATUS status; + /* Indicates the Type of the Notification */ + phHal_eNotificationType_t type; + /* To contain more Notification specific info */ + void *info; + +}phNfc_sNotificationInfo_t; + + +/* +################################################################################ +********************* Callback Function Type Definition ************************ +################################################################################ +*/ + +/** +* Interface Notification Callback +* +* This callback notifies the occurrance of an event in the Lower Interface. +* +* \param [in] pContext Context for the Callback Function +* \param [in] pHwRef Pointer to the Hardware Reference +* \param [in] type Type of the Notification sent +* \param [out] pInfo Pointer to the Transaction Information Structure +* which contains the Status of the operation, data +* obtained or sent and size of the data sent or received +*/ + +typedef void (*pphNfcIF_Notification_CB_t) ( + void *pContext, + void *pHwRef, + uint8_t type, + void *pInfo + ); + +/** +* asynchronous Interface Transaction Completion callback +* +* This callback signals the completion of the asynchronous send or receive +* operation. The number of bytes sent or recieved is returned back. +* +* \param [in] pContext Context for the Callback Function +* \param [in] pHwRef Pointer to the Hardware Reference +* \param [out] pInfo Pointer to the Transaction Information Structure +* which contains the Status of the operation, data +* obtained or sent and size of the data sent or received +*/ + +typedef void (*pphNfcIF_Transact_Completion_CB_t) ( + void *pContext, + void *pHwRef, + phNfc_sTransactionInfo_t *pInfo + ); + +/* +################################################################################ +********************** Generic Interface Function Prototype ******************** +################################################################################ +*/ + +/** + * Generic NFC Interface Function Type . + * + * \param [in] pContext Context pointer for the Generic Interface. + * \param [in] pHwRef pointer for the device interface link information. + */ + +typedef NFCSTATUS (*pphNfcIF_Interface_t) ( + void *pContext, + void *pHwRef + ); +/** + * Data Transaction between the lower layer interface + * + * Sends or Receives the given amount of data to the lower layer. + * The call returns immediately and the registered callback is + * called when all data has been written. + *

+ * + * @note If the interface is not initialized the function does nothing. + * + * \param [in] pContext Context pointer for sending the data. + * \param [in] pHwRef pointer for the device interface link information. + * \param[in] data pointer to data buffer containing the data to be sent or + * to be received. The data pointer is valid at least until + * the registered callback is called. + * \param[in] length length of the data to be sent or to be received. + */ + +typedef NFCSTATUS (*pphNfcIF_Transact_t) ( + void *pContext, + void *pHwRef, + uint8_t *data, + uint16_t length + ); + + +/** + * Generic Interface structure with the Lower Layer + * + * This structure holds the context and function pointers of all functions + * required to interface with the Lower Layers. + */ + +typedef struct phNfc_sLowerIF +{ + void *pcontext; + pphNfcIF_Interface_t init; + pphNfcIF_Interface_t release; + pphNfcIF_Transact_t send; + pphNfcIF_Transact_t receive; + pphNfcIF_Transact_t receive_wait; + pphNfcIF_Interface_t transact_abort; + pphNfcIF_Interface_t unregister; +} phNfc_sLowerIF_t,*pphNfc_sLowerIF_t; + + +/** + * Generic Callback interface structure for the Lower layer. + * + * This structure holds the callback function pointers of the functions that + * performs the completion of a particular operation. These functions are used + * by the Lower Layer interface to convey the completion of an operation. + */ + +typedef struct phNfcIF_sCallBack +{ + /** +#include + +/*=========== CONSTANTS ===========*/ + +/** + * \name LLCP default parameters. + * + * Definitions for use when wanting to use default LLCP parameter values. + * + */ + /*@{*/ +#define PHFRINFC_LLCP_MIU_DEFAULT 128 /**< Default MIU value (in bytes).*/ +#define PHFRINFC_LLCP_WKS_DEFAULT 1 /**< Default WKS value (bitfield).*/ +#define PHFRINFC_LLCP_LTO_DEFAULT 10 /**< Default LTO value (in step of 10ms).*/ +#define PHFRINFC_LLCP_RW_DEFAULT 1 /**< Default RW value (in frames).*/ +#define PHFRINFC_LLCP_OPTION_DEFAULT 0 /**< Default OPTION value (in frames).*/ +#define PHFRINFC_LLCP_MIUX_DEFAULT 0 /**< Default MIUX value (in bytes) */ +#define PHFRINFC_LLCP_SN_MAX_LENGTH 255 /**< Max length value for the Service Name */ +#define PHFRINFC_LLCP_RW_MAX 15 /**< Max RW value (in frames).*/ +/*@}*/ + +/** + * \name LLCP config parameters. + * + * Definitions used for internal LLCP configuration. + * + */ + /*@{*/ +#define PHFRINFC_LLCP_NB_SOCKET_MAX 5 /**< Max.number of simultaneous sockets */ +/*@}*/ + +/** + * \internal + * \name Fixed value for ERROR op code. + * + */ +/*@{*/ +#define PHFRINFC_LLCP_ERR_DISCONNECTED 0x00 +#define PHFRINFC_LLCP_ERR_FRAME_REJECTED 0x01 +#define PHFRINFC_LLCP_ERR_BUSY_CONDITION 0x02 +#define PHFRINFC_LLCP_ERR_NOT_BUSY_CONDITION 0x03 + +/** + * \internal + * \name Fixed value for DM op code. + * + */ +/*@{*/ +#define PHFRINFC_LLCP_DM_OPCODE_DISCONNECTED 0x00 +#define PHFRINFC_LLCP_DM_OPCODE_SAP_NOT_ACTIVE 0x01 +#define PHFRINFC_LLCP_DM_OPCODE_SAP_NOT_FOUND 0x02 +#define PHFRINFC_LLCP_DM_OPCODE_CONNECT_REJECTED 0x03 +#define PHFRINFC_LLCP_DM_OPCODE_CONNECT_NOT_ACCEPTED 0x20 +#define PHFRINFC_LLCP_DM_OPCODE_SOCKET_NOT_AVAILABLE 0x21 + + +/*========== ENUMERATES ===========*/ + +/* Enum reperesents the different LLCP Link status*/ +typedef enum phFriNfc_LlcpMac_eLinkStatus +{ + phFriNfc_LlcpMac_eLinkDefault, + phFriNfc_LlcpMac_eLinkActivated, + phFriNfc_LlcpMac_eLinkDeactivated +}phFriNfc_LlcpMac_eLinkStatus_t; + +/* Enum represents the different Socket types */ +typedef enum phFriNfc_LlcpTransport_eSocketType +{ + phFriNfc_LlcpTransport_eDefaultType, + phFriNfc_LlcpTransport_eConnectionOriented, + phFriNfc_LlcpTransport_eConnectionLess +}phFriNfc_LlcpTransport_eSocketType_t; + + +/*========== STRUCTURES ===========*/ + +typedef struct phFriNfc_LlcpTransport_sSocketOptions +{ + /** The remote Maximum Information Unit Extension (NOTE: this is MIUX, not MIU !)*/ + uint16_t miu; + + /** The Receive Window size (4 bits)*/ + uint8_t rw; + +}phFriNfc_LlcpTransport_sSocketOptions_t; + +typedef struct phFriNfc_Llcp_sLinkParameters +{ + /** The remote Maximum Information Unit (NOTE: this is MIU, not MIUX !)*/ + uint16_t miu; + + /** The remote Well-Known Services*/ + uint16_t wks; + + /** The remote Link TimeOut (in 1/100s)*/ + uint8_t lto; + + /** The remote options*/ + uint8_t option; + +} phFriNfc_Llcp_sLinkParameters_t; + +#endif + +/* EOF */ diff --git a/inc/phNfcStatus.h b/inc/phNfcStatus.h new file mode 100644 index 0000000..01f48fb --- /dev/null +++ b/inc/phNfcStatus.h @@ -0,0 +1,343 @@ +/* + * Copyright (C) 2010 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. + */ + +/** + * \file phNfcStatus.h + * \brief NFC Status Values - Function Return Codes + * + * Project: NFC MW / HAL + * + * $Date: Wed Apr 29 16:28:21 2009 $ + * $Author: ing04880 $ + * $Revision: 1.31 $ + * $Aliases: NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ + * + */ + +#ifndef PHNFCSTATUS_H /* */ +#define PHNFCSTATUS_H/* */ + +#ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */ + +/** + * \name NFC Status + * + * File: \ref phNfcStatus.h + * + *\defgroup grp_retval ERROR Status Codes + */ +/*@{*/ +#define PHNFCSTATUS_FILEREVISION "$Revision: 1.31 $" /**< \ingroup grp_file_attributes */ +#define PHNFCSTATUS_FILEALIASES "$Aliases: NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ +/*@}*/ + +#endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */ + +#include + +/* Internally required by \ref PHNFCSTVAL. */ +#define PHNFCSTSHL8 (8U) +/* Required by \ref PHNFCSTVAL. */ +#define PHNFCSTBLOWER ((NFCSTATUS)(0x00FFU)) + +/** + * \name NFC Status Composition Macro + * + * This is the macro which must be used to compose status values. + * + * \param[in] phNfcCompID Component ID, as defined in \ref phNfcCompId.h . + * \param[in] phNfcStatus Status values, as defined in \ref phNfcStatus.h . + * + * \note The macro is not required for the \ref NFCSTATUS_SUCCESS value. This is the only + * return value to be used directly. + * For all other values it shall be used in assigment 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)) ) ) /**< \ingroup grp_retval + Use this macro for return value composition. */ +#define PHNFCSTATUS(phNfcStatus) ((phNfcStatus) & 0x00FFU) +#define PHNFCCID(phNfcStatus) (((phNfcStatus) & 0xFF00U)>>8) + +/** + * \name Status Codes + * + * Generic Status codes for the NFC components. Combined with the Component ID + * they build the value (status) returned by each + * function. Some Specific E.g.:\n + *

    + *
  • \ref 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. + * + * \note The \ref grp_comp_id "Component ID" used for return codes + must not be \ref CID_NFC_NONE + * except for the value \ref NFCSTATUS_SUCCESS. + */ +/*@{*/ + +/** \ingroup grp_retval + The function indicates successful completion. */ +#define NFCSTATUS_SUCCESS (0x0000) + +/** \ingroup grp_retval + At least one paramter could not be properly interpreted. */ +#define NFCSTATUS_INVALID_PARAMETER (0x0001) + +/** \ingroup grp_retval + The buffer provided by the caller is too small. */ +#define NFCSTATUS_BUFFER_TOO_SMALL (0x0003) + +/** \ingroup grp_retval + Device specifier/handle value is invalid for the operation. */ +#define NFCSTATUS_INVALID_DEVICE (0x0006) + +/** \ingroup grp_retval + The function executed successfully but could have returned + more information than space provided by the caller. */ +#define NFCSTATUS_MORE_INFORMATION (0x0008) + +/** \ingroup grp_retval + No response from the remote device received: Time-out.*/ +#define NFCSTATUS_RF_TIMEOUT (0x0009) + +/** \ingroup grp_retval + RF Error during data transaction with the remote device.*/ +#define NFCSTATUS_RF_ERROR (0x000A) + +/** \ingroup grp_retval + Not enough resources (e.g. allocation failed.). */ +#define NFCSTATUS_INSUFFICIENT_RESOURCES (0x000C) + +/** \ingroup grp_retval + A non-blocking function returns this immediately to indicate + that an internal operation is in progress. */ +#define NFCSTATUS_PENDING (0x000D) + +/** \ingroup grp_retval + A board communication error occurred + (e.g. configuration went wrong). */ +#define NFCSTATUS_BOARD_COMMUNICATION_ERROR (0x000F) + +/** \ingroup grp_retval + Invalid State of the particular state machine + */ +#define NFCSTATUS_INVALID_STATE (0x0011) + + +/** \ingroup grp_retval + This Layer is Not initialised, hence initialisation required. + */ +#define NFCSTATUS_NOT_INITIALISED (0x0031) + + +/** \ingroup grp_retval + The Layer is already initialised, hence initialisation repeated. + */ +#define NFCSTATUS_ALREADY_INITIALISED (0x0032) + + +/** \ingroup grp_retval + Feature not supported . */ +#define NFCSTATUS_FEATURE_NOT_SUPPORTED (0x0033) + +/** \ingroup grp_retval + 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) + + +/** \ingroup grp_retval + 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) + +/** \ingroup grp_retval + Single Tag with Multiple + Protocol support detected. */ +#define NFCSTATUS_MULTIPLE_PROTOCOLS (0x0036) + +/** \ingroup grp_retval + Feature not supported . */ +#define NFCSTATUS_MULTIPLE_TAGS (0x0037) + +/** \ingroup grp_retval + A DESELECT event has occurred. */ +#define NFCSTATUS_DESELECTED (0x0038) + +/** \ingroup grp_retval + A RELEASE event has occurred. */ +#define NFCSTATUS_RELEASED (0x0039) + +/** \ingroup grp_retval + The operation is currently not possible or not allowed */ +#define NFCSTATUS_NOT_ALLOWED (0x003A) + +/** \ingroup grp_retval + The sytem is busy with the previous operation. +*/ +#define NFCSTATUS_BUSY (0x006F) + + +/* NDEF Mapping error codes */ + +/** \ingroup grp_retval + The remote device (type) is not valid for this request. */ +#define NFCSTATUS_INVALID_REMOTE_DEVICE (0x001D) + +/** \ingroup grp_retval + Smart tag functionality not supported */ +#define NFCSTATUS_SMART_TAG_FUNC_NOT_SUPPORTED (0x0013) + +/** \ingroup grp_retval + Read operation failed */ +#define NFCSTATUS_READ_FAILED (0x0014) + +/** \ingroup grp_retval + Write operation failed */ +#define NFCSTATUS_WRITE_FAILED (0x0015) + +/** \ingroup grp_retval + Non Ndef Compliant */ +#define NFCSTATUS_NO_NDEF_SUPPORT (0x0016) + +/** \ingroup grp_retval + Could not proceed further with the write operation: reached card EOF*/ +#define NFCSTATUS_EOF_NDEF_CONTAINER_REACHED (0x001A) + +/** \ingroup grp_retval + Incorrect number of bytes received from the card*/ +#define NFCSTATUS_INVALID_RECEIVE_LENGTH (0x001B) + +/** \ingroup grp_retval + The data format/composition is not understood/correct. */ +#define NFCSTATUS_INVALID_FORMAT (0x001C) + + +/** \ingroup grp_retval + There is not sufficient storage available. */ +#define NFCSTATUS_INSUFFICIENT_STORAGE (0x001F) + +/** \ingroup grp_retval + The Ndef Format procedure has failed. */ +#define NFCSTATUS_FORMAT_ERROR (0x0023) + + +/* + * Macros Required for FRI Stack +NFCSTATUS_INVALID_PARAMETER +NFCSTATUS_CMD_ABORTED +NFCSTATUS_FORMAT_STATUS +NFSTATUS_SUCCESS +NFCSTATUS_INVALID_REMOTE_DEVICE +NFCSTATUS_PENDING +NFCSTATUS_EOF_NDEF_CONTAINED_REACHED +NFCSTATUS_NO_NDEF_SUPPORT +NFCSTATUS_SMART_TAG_FUNC_NOT_SUPPORTED +NFCSTATUS_READ_FAILED +NFCSTATUS_WRITE_FAILED +NFCSTATUS_INVALID_RECEIVE_LENGTH +NFCSTATUS_BUFFER_TOO_SMALL +NFCSTATUS_NODE_NOT_FOUND +*/ + + +/* 0x70 to 0xCF Values are Component Specific Error Values */ + + +/** \ingroup grp_retval + Max number of Status Codes*/ +#define NFCSTATUS_FAILED (0x00FF) + +/*@}*/ + +#ifdef RFU_STATUS_CODES /* To Be Removed later */ + +/** \ingroup grp_retval + The function/command has been aborted. */ +#define NFCSTATUS_CMD_ABORTED (0x0002) + +/** \ingroup grp_retval + * Repeated call of the connecting function is not allowed. + * \if hal + * \sa \ref phHalNfc_Connect + * \endif */ +#define NFCSTATUS_ALREADY_CONNECTED (0x0004) + +/** \ingroup grp_retval + * Calling the polling function is not allowed when remote device + * are allready connected. + * \if hal + * \sa \ref phHalNfc_Poll + * \endif */ +#define NFCSTATUS_MULTI_POLL_NOT_SUPPORTED (0x0005) + + +/** \ingroup grp_retval + No target found after poll.*/ +#define NFCSTATUS_NO_DEVICE_FOUND (0x000A) + +/** \ingroup grp_retval + No target found after poll.*/ +#define NFCSTATUS_NO_TARGET_FOUND (0x000A) + +/** \ingroup grp_retval + Attempt to disconnect a not connected remote device. */ +#define NFCSTATUS_NO_DEVICE_CONNECTED (0x000B) + +/** \ingroup grp_retval + External RF field detected. */ +#define NFCSTATUS_EXTERNAL_RF_DETECTED (0x000E) + +/** \ingroup grp_retval + Message is not allowed by the state machine + (e.g. configuration went wrong). */ +#define NFCSTATUS_MSG_NOT_ALLOWED_BY_FSM (0x0010) + +/** \ingroup grp_retval + No access has been granted. */ +#define NFCSTATUS_ACCESS_DENIED (0x001E) + +/** \ingroup grp_retval + No registry node matches the specified input data. */ +#define NFCSTATUS_NODE_NOT_FOUND (0x0017) + +/** \ingroup grp_retval + The current module is busy ; one might retry later */ +#define NFCSTATUS_SMX_BAD_STATE (0x00F0) + + +/** \ingroup grp_retval + The Abort mechanism has failed for unexpected reason: user can try again*/ +#define NFCSTATUS_ABORT_FAILED (0x00F2) + + +/** \ingroup grp_retval + 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) + + +#endif + + +#endif /* PHNFCSTATUS_H */ + diff --git a/inc/phNfcTypes.h b/inc/phNfcTypes.h new file mode 100644 index 0000000..3536721 --- /dev/null +++ b/inc/phNfcTypes.h @@ -0,0 +1,1127 @@ +/* + * Copyright (C) 2010 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. + */ + +/* + * \file phNfcTypes.h + * \brief Basic type definitions. + * + * Project: NFC MW / HAL + * + * $Date: Thu Jun 25 21:24:53 2009 $ + * $Author: ing04880 $ + * $Revision: 1.13 $ + * $Aliases: NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ + * + */ + +#ifndef PHNFCTYPES /* */ +#define PHNFCTYPES /* */ + +/** + * \name NFC Types + * + * File: \ref phNfcTypes.h + * + */ +/*@{*/ +#define PHNFCTYPES_FILEREVISION "$Revision: 1.13 $" /**< \ingroup grp_file_attributes */ +#define PHNFCTYPES_FILEALIASES "$Aliases: NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ +/*@}*/ + +#ifndef _WIN32 +#include +#else +#include +#include +#define snprintf _snprintf + +#ifndef linux +/** + * \name Basic Type Definitions + * + * Constant-length-type definition ('C99). + * + */ +/*@{*/ +#ifndef __int8_t_defined /* */ +#define __int8_t_defined /* */ +typedef signed char int8_t; /**< \ingroup grp_nfc_common + 8 bit signed integer */ +#endif + +#ifndef __int16_t_defined /* */ +#define __int16_t_defined /* */ +typedef signed short int16_t; /**< \ingroup grp_nfc_common + 16 bit signed integer */ +#endif + +#ifndef __stdint_h +#ifndef __int32_t_defined /* */ +#define __int32_t_defined /* */ +typedef signed long int32_t; /**< \ingroup grp_nfc_common + 32 bit signed integer */ +#endif +#endif + +#ifndef __uint8_t_defined /* */ +#define __uint8_t_defined /* */ +typedef unsigned char uint8_t; /**< \ingroup grp_nfc_common + 8 bit unsigned integer */ +#endif + +#ifndef __uint16_t_defined /* */ +#define __uint16_t_defined /* */ +typedef unsigned short uint16_t; /**< \ingroup grp_nfc_common + 16 bit unsigned integer */ +#endif + +#ifndef __stdint_h +#ifndef __uint32_t_defined /* */ +#define __uint32_t_defined /* */ +typedef unsigned long uint32_t; /**< \ingroup grp_nfc_common + 32 bit unsigned integer */ +#endif +#endif + +#endif /* linux */ + +#endif /* _WIN32 */ + +#ifndef TRUE +#define TRUE (0x01) /**< \ingroup grp_nfc_common + Logical True Value */ +#endif + +#ifndef FALSE +#define FALSE (0x00) /**< \ingroup grp_nfc_common + Logical False Value */ +#endif + +typedef uint8_t utf8_t; /**< \ingroup grp_nfc_common + UTF8 Character String */ + +typedef uint8_t bool_t; /**< \ingroup grp_nfc_common + boolean data type */ + +typedef uint16_t NFCSTATUS; /**< \ingroup grp_nfc_common + NFC return values + \ref phNfcStatus.h for different status + values */ + +#ifndef NULL +#define NULL ((void *)0) +#endif + +/* This Macro to be used to resolve Unused and unreference + * compiler warnings. + */ + +#define PHNFC_UNUSED_VARIABLE(x) for((x)=(x);(x)!=(x);) + +/*@}*/ + +/** + * + * \name HAL Overall Definitions + * + * Definitions applicable to a variety of purposes and functions/features. + * + */ + /*@{*/ + +#define PHHAL_COMMON_MAX_STRING_LENGTH 0x40U /**< \ingroup grp_hal_common + Maximum vendor name length in bytes. */ +#define PHHAL_UNKNOWN_DEVICE_TYPE 0x00U /**< \ingroup grp_hal_common + Unknown device type. */ +#define PHHAL_SERIAL_DEVICE 0x01U /**< \ingroup grp_hal_common + Serial device type. */ +#define PHHAL_USB_DEVICE 0x02U /**< \ingroup grp_hal_common + USB device type. */ +#define PHHAL_I2C_DEVICE 0x03U /**< \ingroup grp_hal_common + I2C device type. */ +#define PHHAL_SPI_DEVICE 0x04U /**< \ingroup grp_hal_common + SPI device type. */ +#define PHHAL_PARALLEL_DEVICE 0x05U /**< \ingroup grp_hal_common + Parallel device type. */ +#define PHHAL_NFCID_LENGTH 0x0AU /**< \ingroup grp_hal_common + Maximum length of NFCID 1..3. */ + +#define PHHAL_MAX_DATASIZE 0xFBU /* 256 * Maximum Data size sent + * by the HAL + */ + +#define PHHAL_ATQA_LENGTH 0x02U /**< ATQA length */ +#define PHHAL_MAX_UID_LENGTH 0x0AU /**< Maximum UID length expected */ +#define PHHAL_MAX_ATR_LENGTH 0x30U /**< Maximum ATR_RES (General Bytes) + * length expected */ + +#define PHHAL_ATQB_LENGTH 0x0BU /**< ATQB length */ + +#define PHHAL_PUPI_LENGTH 0x04U /**< PUPI length */ +#define PHHAL_APP_DATA_B_LENGTH 0x04U /**< Application Data length for Type B */ +#define PHHAL_PROT_INFO_B_LENGTH 0x03U /**< Protocol info length for Type B */ +#define PHHAL_FEL_SYS_CODE_LEN 0x02U /**< Felica System Code Length */ +#define PHHAL_FEL_ID_LEN 0x08U /**< Felica current ID Length */ +#define PHHAL_FEL_PM_LEN 0x08U /**< Felica current PM Length */ +#define PHHAL_15693_UID_LENGTH 0x08U /**< Length of the Inventory bytes for + ISO15693 Tag */ + +#define VENDOR_NAME_LEN 0x14U +#define MAX_TRANSFER_UNIT 0x21U +#define SESSIONID_SIZE 0x08U +#define MAX_AID_LEN 0x10U +#define MAX_UICC_PARAM_LEN 0xFFU + +#define MIFARE_BITMASK 0x08U +#define ISO_14443_BITMASK 0x20U +#define ISO_14443_DETECTED 0x20U +#define NFCIP_BITMASK 0x40U +#define NFCIP_DETECTED 0x40U + +#define MAX_TARGET_SUPPORTED MAX_REMOTE_DEVICES + +#define NFC_HW_PN65N 0x10U + +#define NXP_NFCIP_NFCID2_ID 0x01FEU + +#define NXP_FULL_VERSION_LEN 0x0BU + + +/*@}*/ + + +/** + * \name NFC specific Type Definitions + * + */ +/*@{*/ + +/** + * Data Buffer Structure to hold the Data Buffer + * + * This structure holds the Data in the Buffer of the specified + * size. + * + */ +typedef struct phNfc_sData_t +{ + uint8_t *buffer; + uint32_t length; +} phNfc_sData_t; + + +/** + *\brief Possible Hardware Configuration exposed to upper layer. + * Typically this should be port name (Ex:"COM1","COM2") to which PN544 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_USB, + ENUM_LINK_TYPE_TCP, + + ENUM_LINK_TYPE_NB, +} phLibNfc_eConfigLinkType; + +/** + * \brief 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_t +{ + /** Hardware communication link to the controller */ + phLibNfc_eConfigLinkType nLinkType; + /** The client ID (thread ID or message queue ID) */ + unsigned int 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_t +{ + 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; + + +#ifdef WIN32 +#define PH_LIBNFC_MESSAGE_BASE (WM_USER+0x3FF) +#endif +/** + * 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) + +/** + *\brief Deferred call declaration. + * This type of API is called from ClientApplication ( main thread) to notify + * specific callback. + */ +typedef void (*pphLibNfc_DeferredCallback_t) (void*); +/** + *\brief Deferred parameter declaration. + * This type of data is passed as parameter from ClientApplication (main thread) to the + * callback. + */ +typedef void *pphLibNfc_DeferredParameter_t; +/** + *\brief Deferred message specific info declaration. + * This type of information is packed as message data when \ref PH_LIBNFC_DEFERREDCALL_MSG + * type message is posted to message handler thread. + */ +typedef struct phLibNfc_DeferredCall_t +{ + pphLibNfc_DeferredCallback_t pCallback;/**< pointer to Deferred callback */ + pphLibNfc_DeferredParameter_t pParameter;/**< pointer to Deferred parameter */ +} phLibNfc_DeferredCall_t; + + +/** \ingroup grp_hal_common + * + * \brief Protocol Support Information + * + * The Supported Protocols Structure holds all protocol supported by the current NFC + * device. + * + * \note All members of this structure are output parameters [out]. + * + */ +typedef struct phNfc_sSupProtocol_t +{ + 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. */ + /*** TODO: Add SWP, ETSI HCI to this list **/ +} phNfc_sSupProtocol_t; + + +/** \ingroup grp_hal_common + * + * + * \brief Information related to the NFC Device + * + * The Device Information Structure holds information + * related to the NFC IC read during initialization time. + * It allows the caller firware, hardware version, the model id, + * HCI verison supported and vendor name. Refer to the NFC Device + * User Manual on how to interpret each of the values. In addition + * it also contains capabilities of the NFC Device such as the + * protocols supported in Reader and emulation mode + * + */ +typedef struct phNfc_sDeviceCapabilities_t +{ + /* */ + uint32_t hal_version; /**< \ingroup grp_hal_common + HAL 4.0 Version Information. */ + uint32_t fw_version; /**< \ingroup grp_hal_common + Firmware Version Info. */ + uint32_t hw_version; /**< \ingroup grp_hal_common + Hardware Version Info. */ + uint8_t model_id; /**< \ingroup grp_hal_common + IC Variant . */ + uint8_t hci_version; /**< \ingroup grp_hal_common + ETSI HCI Version Supported */ + utf8_t vendor_name[VENDOR_NAME_LEN]; /**< \ingroup grp_hal_common + Vendor name (Null terminated string)*/ + uint8_t full_version[NXP_FULL_VERSION_LEN]; + + phNfc_sSupProtocol_t ReaderSupProtocol; /**< Supported protocols + (Bitmapped) in Reader mode. */ + phNfc_sSupProtocol_t EmulationSupProtocol; /**< Supported protocols + (Bitmapped) in Emulation + mode. */ +} phNfc_sDeviceCapabilities_t; + + +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + + +/** \ingroup grp_hal_common + * + * \brief Enumerated MIFARE Commands + * + * The Mifare Command List Enumerator lists all available Mifare native commands. + * + * \note None. + * + */ +typedef enum phNfc_eMifareCmdList_t +{ + phNfc_eMifareRaw = 0x00U, /**< This command performs raw transcations . + Format of the phLibNfc_sTransceiveInfo_t + content in this case shall be as below: + • cmd: filed shall set to phHal_eMifareRaw . + • addr : doesn't carry any significance. + • sSendData : Shall contain formatted raw buffer + based on MIFARE commands type used. + Formatted buffer shall follow below + formating scheme. + + CmdType+ Block No + CommandSpecific data + 2 byte CRC + Ex: With Write 4 byte command on block 8 looks as + " 0xA2,0x08,0x01,0x02,0x03,0x04,CRC1,CRC2 + Note : For MIFARE Std card we recommend use MIFARE + commands directly. + */ + phNfc_eMifareAuthentA = 0x60U, /**< Mifare Standard:\n + This command performs an authentication with KEY A for a sector.\n + Format of the phLibNfc_sTransceiveInfo_t content in this case is : + • cmd: field shall set to phHal_eMifareAuthentA . + • addr : indicates MIFARE block address. + Ex: 0x08 indicates block 8 needs to be authenticated. + • sSendData : Shall contain authentication key values. + sSendData ,buffer shall contain authentication + key values 01 02 03 04 05 06 authenticates + block 08 with the key 0x01[..]06. If this + command fails, then user needs to reactivate + the remote Mifare card. + */ + phNfc_eMifareAuthentB = 0x61U, /**< Mifare Standard:\n + This command performs an authentication with KEY B for a sector.\n + Format of the phLibNfc_sTransceiveInfo_t content in this case is : + • cmd: field shall set to phHal_eMifareAuthentB . + • addr : indicates MIFARE block address. + Ex: 0x08 indicates block 8 needs to be authenticated. + • sSendData : Shall contain authentication key values. + sSendData ,buffer shall contain authentication + key values 01 02 03 04 05 06 authenticates + block 08 with the key 0x01[..]06. If this + command fails, then user needs to reactivate + the remote Mifare card. + */ + phNfc_eMifareRead16 = 0x30U, /**< Mifare Standard and Ultra Light:\n + Read 16 Bytes from a Mifare Standard block or 4 Mifare Ultra Light pages.\n + Format of the phLibNfc_sTransceiveInfo_t content in this case is : + • cmd: field shall set to phHal_eMifareRead16 . + • addr : memory adress to read. + • sRecvData : Shall contain buffer of size 16 + to read the data into. + + If this command fails, the user needs to reactivate the + the remote Mifare card + */ + phNfc_eMifareRead = 0x30U, + phNfc_eMifareWrite16 = 0xA0U, /**< Mifare Standard and Ultra Light:\n + Write 16 Bytes to a Mifare Standard block or 4 Mifare Ultra Light pages.\n + Format of the phLibNfc_sTransceiveInfo_t content in this case is : + • cmd: field shall set to phHal_eMifareWrite16 . + • addr : starting memory adress to write from. + • sSendData : Shall contain buffer of size 16 containing + the data bytes to be written. + + If this command fails, the user needs to reactivate the + the remote Mifare card + */ + phNfc_eMifareWrite4 = 0xA2U, /**< Mifare Ultra Light:\n + Write 4 bytes.\n + Format of the phLibNfc_sTransceiveInfo_t content in this case is : + • cmd: field shall set to phHal_eMifareWrite4 . + • addr : starting memory adress to write from. + • sSendData : Shall contain buffer of size 4 containing + the data bytes to be written. + + If this command fails, the user needs to reactivate the + the remote Mifare card + */ + phNfc_eMifareInc = 0xC1U, /**< Increment. */ + phNfc_eMifareDec = 0xC0U, /**< Decrement. */ + phNfc_eMifareTransfer = 0xB0U, /**< Tranfer. */ + phNfc_eMifareRestore = 0xC2U, /**< Restore. */ + phNfc_eMifareReadSector = 0x38U, /**< Read Sector. */ + phNfc_eMifareWriteSector= 0xA8U, /**< Write Sector. */ + phNfc_eMifareInvalidCmd = 0xFFU /**< Invalid Command */ +} phNfc_eMifareCmdList_t; + + +/** \ingroup grp_hal_common + * + * The T=Cl Command List Enumerator lists all available T=Cl Commands. + * + * \note None. + * + */ +typedef enum phNfc_eIso14443_4_CmdList_t +{ + phNfc_eIso14443_4_Raw = 0x00U /**< ISO 14443-4 Exchange command:\n + - This command sends the data buffer directly + to the remote device */ + +} phNfc_eIso14443_4_CmdList_t; + + +/** \ingroup grp_hal_common + * + * The NFCIP1 Command List Enumerator lists all available NFCIP1 Commands. + * + * \note None. + * + */ +typedef enum phNfc_eNfcIP1CmdList_t +{ + phNfc_eNfcIP1_Raw = 0x00U /**< NfcIP Exchange command:\n + - This command sends the data buffer directly + to the remote device */ +}phNfc_eNfcIP1CmdList_t; + + +/** \ingroup grp_hal_common + * + * The ISO15693 Command List Enumerator lists all available ISO15693 Commands. + * + * \note None. + * + */ +typedef enum phNfc_eIso15693_CmdList_t +{ +#if 0 + phNfc_eIso15693_Raw = 0x00U, /**< ISO 15693 Exchange Raw command:\n + - This command sends the data buffer directly + to the remote device */ +#endif + phNfc_eIso15693_Cmd = 0x20U, /**< ISO 15693 Exchange command:\n + - This command is used to access the card + to the remote device */ + phNfc_eIso15693_Invalid = 0xFFU /**< Invalid Command */ +} phNfc_eIso15693_CmdList_t; + + +/** \ingroup grp_hal_common + * + * The Felica Command List Enumerator lists all available Felica Commands. + * + * \note None. + * + */ +typedef enum phNfc_eFelicaCmdList_t +{ + phNfc_eFelica_Raw = 0xF0U, /**< Felica Raw command:\n + - This command sends the data buffer directly + to the remote device */ + phNfc_eFelica_Check = 0x00, /**< Felica Check command:\n + - This command checks the data from the Felica + remote device */ + phNfc_eFelica_Update = 0x01, /**< Felica Update command:\n + - This command updates the data onto the Felica + remote device */ + phNfc_eFelica_Invalid = 0xFFU /**< Invalid Command */ +} phNfc_eFelicaCmdList_t; + + +/** \ingroup grp_hal_common + * + * The Jewel Command List Enumerator lists all available Jewel Commands. + * + * \note None. + * + */ +typedef enum phNfc_eJewelCmdList_t +{ + phNfc_eJewel_Raw = 0x00U, /**< Jewel command:\n + - This command sends the data buffer directly + to the remote device */ + phNfc_eJewel_Invalid = 0xFFU /**< Invalid jewel command */ +}phNfc_eJewelCmdList_t; + + +/** \ingroup grp_hal_nfci +* +* \brief Remote Device Reader A RF Gate Information Container +* +* The Reader A structure includes the available information +* related to the discovered ISO14443A remote device. This information +* is updated for every device discovery. +* \note None. +* +*/ +typedef struct phNfc_sIso14443AInfo_t +{ + uint8_t Uid[PHHAL_MAX_UID_LENGTH]; /**< UID information of the TYPE A + Tag Discovered */ + uint8_t UidLength; /**< UID information length, shall not be greater + than PHHAL_MAX_UID_LENGTH i.e., 10 */ + uint8_t AppData[PHHAL_MAX_ATR_LENGTH]; /**< Application data information of the + tag discovered (= Historical bytes for + type A) */ + uint8_t AppDataLength; /**< Application data length */ + uint8_t Sak; /**< SAK informationof the TYPE A + Tag Discovered */ + uint8_t AtqA[PHHAL_ATQA_LENGTH]; /**< ATQA informationof the TYPE A + Tag Discovered */ + uint8_t MaxDataRate; /**< Maximum data rate supported by the TYPE A + Tag Discovered */ + uint8_t Fwi_Sfgt; /**< Frame waiting time and start up frame guard + time as defined in ISO/IEC 14443-4[7] for + type A */ +} phNfc_sIso14443AInfo_t; + + +/** \ingroup grp_hal_nfci +* +* \brief Remote Device Reader B RF Gate Information Container +* +* The Reader B structure includes the available information +* related to the discovered ISO14443B remote device. This information +* is updated for every device discovery. +* \note None. +* +*/ +typedef struct phNfc_sIso14443BInfo_t +{ + union phNfc_uAtqBInfo + { + struct phNfc_sAtqBInfo + { + uint8_t Pupi[PHHAL_PUPI_LENGTH]; /**< PUPI information of the TYPE B + Tag Discovered */ + uint8_t AppData[PHHAL_APP_DATA_B_LENGTH]; /**< Application Data of the TYPE B + Tag Discovered */ + uint8_t ProtInfo[PHHAL_PROT_INFO_B_LENGTH]; /**< Protocol Information of the TYPE B + Tag Discovered */ + } AtqResInfo; + uint8_t AtqRes[PHHAL_ATQB_LENGTH]; /**< ATQB Response Information of TYPE B + Tag Discovered */ + } AtqB; + uint8_t HiLayerResp[PHHAL_MAX_ATR_LENGTH]; /**< Higher Layer Response information + in answer to ATRRIB Command for Type B */ + uint8_t HiLayerRespLength; /**< Higher Layer Response length */ + uint8_t Afi; /**< Application Family Identifier of TYPE B + Tag Discovered */ + uint8_t MaxDataRate; /**< Maximum data rate supported by the TYPE B + Tag Discovered */ +} phNfc_sIso14443BInfo_t; + + +/** \ingroup grp_hal_nfci +* +* \brief Remote Device Reader B prime RF Gate Information Container +* +*/ +typedef struct phNfc_sIso14443BPrimeInfo_t +{ + /* TODO: This will be updated later */ + void *BPrimeCtxt; +} phNfc_sIso14443BPrimeInfo_t; + + +/** \ingroup grp_hal_nfci +* +* \brief Remote Device Jewel Reader RF Gate Information Container +* +* The Jewel Reader structure includes the available information +* related to the discovered Jewel remote device. This information +* is updated for every device discovery. +* \note None. +* +*/ +typedef struct phNfc_sJewelInfo_t +{ + uint8_t Uid[PHHAL_MAX_UID_LENGTH]; /**< UID information of the TYPE A + Tag Discovered */ + uint8_t UidLength; /**< UID information length, shall not be greater + than PHHAL_MAX_UID_LENGTH i.e., 10 */ + uint8_t HeaderRom0; /**< Header Rom byte zero */ + uint8_t HeaderRom1; /**< Header Rom byte one */ + +} phNfc_sJewelInfo_t; + + +/** \ingroup grp_hal_nfci +* +* \brief Remote Device Felica Reader RF Gate Information Container +* +* The Felica Reader structure includes the available information +* related to the discovered Felica remote device. This information +* is updated for every device discovery. +* \note None. +* +*/ +typedef struct phNfc_sFelicaInfo_t +{ + uint8_t IDm[(PHHAL_FEL_ID_LEN + 2)]; /**< Current ID of Felica tag */ + uint8_t IDmLength; /**< IDm length, shall not be greater + than PHHAL_FEL_ID_LEN i.e., 8 */ + uint8_t PMm[PHHAL_FEL_PM_LEN]; /**< Current PM of Felica tag */ + uint8_t SystemCode[PHHAL_FEL_SYS_CODE_LEN]; /**< System code of Felica tag */ +} phNfc_sFelicaInfo_t; + + +/** \ingroup grp_hal_nfci +* +* \brief Remote Device Reader 15693 RF Gate Information Container +* +* The Reader A structure includes the available information +* related to the discovered ISO15693 remote device. This information +* is updated for every device discovery. +* \note None. +* +*/ + +typedef struct phNfc_sIso15693Info_t +{ + uint8_t Uid[PHHAL_15693_UID_LENGTH]; /**< UID information of the 15693 + Tag Discovered */ + uint8_t UidLength; /**< UID information length, shall not be greater + than PHHAL_15693_UID_LENGTH i.e., 8 */ + uint8_t Dsfid; /**< DSF information of the 15693 + Tag Discovered */ + uint8_t Flags; /**< Information about the Flags + in the 15693 Tag Discovered */ + uint8_t Afi; /**< Application Family Identifier of + 15693 Tag Discovered */ +} phNfc_sIso15693Info_t; + + +/** \ingroup grp_hal_nfci +* +* \brief NFC Data Rate Supported between the Reader and the Target +* +* The \ref phHalNfc_eDataRate enum lists all the Data Rate +* values to be used to determine the rate at which the data is transmitted +* to the target. +* +* \note None. +*/ + + +/** \ingroup grp_hal_nfci +* +* \brief NFCIP1 Data rates +* +*/ +typedef enum phNfc_eDataRate_t{ + phNfc_eDataRate_106 = 0x00U, + phNfc_eDataRate_212, + phNfc_eDataRate_424, + /* phNfc_eDataRate_848, + phNfc_eDataRate_1696, + phNfc_eDataRate_3392, + phNfc_eDataRate_6784,*/ + phNfc_eDataRate_RFU +} phNfc_eDataRate_t; + + +/** \ingroup grp_hal_nfci +* +* \brief NFCIP1 Gate Information Container +* +* The NFCIP1 structure includes the available information +* related to the discovered NFCIP1 remote device. This information +* is updated for every device discovery. +* \note None. +* +*/ +typedef struct phNfc_sNfcIPInfo_t +{ + /* Contains the random NFCID3I conveyed with the ATR_REQ. + always 10 bytes length + or contains the random NFCID3T conveyed with the ATR_RES. + always 10 bytes length */ + uint8_t NFCID[PHHAL_MAX_UID_LENGTH]; + uint8_t NFCID_Length; + /* ATR_RES = General bytes length, Max length = 48 bytes */ + uint8_t ATRInfo[PHHAL_MAX_ATR_LENGTH]; + uint8_t ATRInfo_Length; + /**< SAK information of the tag discovered */ + uint8_t SelRes; + /**< ATQA information of the tag discovered */ + uint8_t SenseRes[PHHAL_ATQA_LENGTH]; + /**< Is Detection Mode of the NFCIP Target Active */ + uint8_t Nfcip_Active; + /**< Maximum frame length supported by the NFCIP device */ + uint16_t MaxFrameLength; + /**< Data rate supported by the NFCIP device */ + phNfc_eDataRate_t Nfcip_Datarate; + +} phNfc_sNfcIPInfo_t; + + +/** \ingroup grp_hal_nfci +* +* \brief Remote Device Specific Information Container +* +* The Remote Device Information Union includes the available Remote Device Information +* structures. Following the device detected, the corresponding data structure is used. +* +* \note None. +* +*/ +typedef union phNfc_uRemoteDevInfo_t +{ + phNfc_sIso14443AInfo_t Iso14443A_Info; + phNfc_sIso14443BInfo_t Iso14443B_Info; + phNfc_sIso14443BPrimeInfo_t Iso14443BPrime_Info; + phNfc_sNfcIPInfo_t NfcIP_Info; + phNfc_sFelicaInfo_t Felica_Info; + phNfc_sJewelInfo_t Jewel_Info; + phNfc_sIso15693Info_t Iso15693_Info; +} phNfc_uRemoteDevInfo_t; + + +/** \ingroup grp_hal_nfci +* +* \brief RF Device Type Listing +* +* The RF Device Type List is used to identify the type of +* remote device that is discovered/connected. There seperate +* types to identify a Remote Reader (denoted by _PCD) and +* Remote Tag (denoted by _PICC) +* \note None. +* +*/ +typedef enum phNfc_eRFDevType_t +{ + phNfc_eUnknown_DevType = 0x00U, + + /* Specific PCD Devices */ + phNfc_eISO14443_A_PCD, + phNfc_eISO14443_B_PCD, + phNfc_eISO14443_BPrime_PCD, + phNfc_eFelica_PCD, + phNfc_eJewel_PCD, + phNfc_eISO15693_PCD, + /* Generic PCD Type */ + phNfc_ePCD_DevType, + + /* Generic PICC Type */ + phNfc_ePICC_DevType, + /* Specific PICC Devices */ + 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, + + /* NFC-IP1 Device Types */ + phNfc_eNfcIP1_Target, + phNfc_eNfcIP1_Initiator, + + /* Other Sources */ + phNfc_eInvalid_DevType + +} phNfc_eRFDevType_t; + + +/** \ingroup grp_hal_nfci +* +* \brief Remote Device Type Listing +* +* The Remote Device Type List is used to identify the type of +* remote device that is discovered/connected +* \note This is same as RF Device Type List. +* +*/ +typedef phNfc_eRFDevType_t phNfc_eRemDevType_t; + + +/** \ingroup grp_hal_common + * + * + * \brief Common Command Attribute + * + * The Hal Command Union includes each available type of Commands. + * + * \note None. + * + */ +typedef union phNfc_uCommand_t +{ + phNfc_eMifareCmdList_t MfCmd; /**< Mifare command structure. */ + phNfc_eIso14443_4_CmdList_t Iso144434Cmd; /**< ISO 14443-4 command structure. */ + phNfc_eFelicaCmdList_t FelCmd; /**< Felica command structure. */ + phNfc_eJewelCmdList_t JewelCmd; /**< Jewel command structure. */ + phNfc_eIso15693_CmdList_t Iso15693Cmd; /**< ISO 15693 command structure. */ + phNfc_eNfcIP1CmdList_t NfcIP1Cmd; /**< ISO 18092 (NFCIP1) command structure */ +} phNfc_uCmdList_t; + + +/** \ingroup grp_hal_nfci + * + * \brief Remote Device Information Structure + * + * The Remote Device Information Structure holds information about one single Remote + * Device detected by the polling function .\n + * It lists parameters common to all supported remote devices. + * + * \note + * + * \sa \ref phHal4Nfc_ConfigureDiscovery and \ref phHal4Nfc_Connect + * + */ +typedef struct phNfc_sRemoteDevInformation_t +{ + uint8_t SessionOpened; /**< [out] Boolean + * Flag indicating the validity of + * the handle of the remote device. */ + phNfc_eRemDevType_t RemDevType; /**< [out] Remote device type which says that remote + is Reader A or Reader B or NFCIP or Felica or + Reader B Prime or Jewel*/ + phNfc_uRemoteDevInfo_t RemoteDevInfo; /**< Union of available Remote Device. + * \ref phNfc_uRemoteDevInfo_t Information. */ +} phNfc_sRemoteDevInformation_t; + + +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* TARGET STRUCTURES */ + + +/** \ingroup grp_hal_common + * + * \brief Transceive Information Data Structure for sending commands/response + * to the remote device + * + * The Transceive Information Data Structure is used to pass the + * Command, Address (only required for MIFARE) and the send and receive data + * data structure (buffer and length) for communication with remote device + * + * + */ +typedef struct phNfc_sTransceiveInfo_t +{ + phNfc_uCmdList_t cmd; + + /** \internal Address Field required for only Mifare + * Family Proprietary Cards. + * The Address Size is Valid only upto 255 Blocks limit + * i:e for Mifare 4K + */ + uint8_t addr; + phNfc_sData_t sSendData; + phNfc_sData_t sRecvData; +} phNfc_sTransceiveInfo_t; + + +/** \ingroup grp_hal_nfci +* +* \brief Poll Device Information for conifiguring the discovery wheel + Reader and Card Emulation Phases +* +* The \ref phNfc_sPollDevInfo_t enum is used to enable/disable +* phases of the discovery wheel related to specific reader types and +* card emulation phase +* \note Enabling specific Reader technology when NFCIP1 speed is set in the +* phNfc_sADD_Cfg_t is implicitly done in HAL. Use this structure to only +* enable/disable Card Reader Functionality +*/ +typedef struct phNfc_sPollDevInfo_t +{ + unsigned EnableIso14443A : 1; /**< Flag to enable + Reader A discovery */ + unsigned EnableIso14443B : 1; /**< Flag to enable + Reader B discovery */ + unsigned EnableFelica212 : 1; /**< Flag to enable + Felica 212 discovery */ + unsigned EnableFelica424 : 1; /**< Flag to enable + Felica 424 discovery */ + unsigned EnableIso15693 : 1; /**< Flag to enable + ISO 15693 discovery */ + unsigned EnableNfcActive : 1; /**< Flag to enable + Active Mode of NFC-IP discovery. + This is updated internally + based on the NFC-IP speed. + */ + unsigned RFU : 1; /**< Reserved for future use */ + unsigned DisableCardEmulation : 1; /**< Flag to + disable the card emulation */ +} phNfc_sPollDevInfo_t; + + +/** \ingroup grp_hal_nfci +* +* \brief P2P speed for the Initiator +* +* The \ref phNfc_eP2PMode_t enum lists all the NFCIP1 speeds +* to be used for configuring the NFCIP1 discovery +* +* \note None. +*/ +typedef enum phNfc_eP2PMode_t +{ + phNfc_eDefaultP2PMode = 0x00U, + phNfc_ePassive106 = 0x01U, + phNfc_ePassive212 = 0x02U, + phNfc_ePassive424 = 0x04U, + phNfc_eActive = 0x08U, + phNfc_eP2P_ALL = 0x0FU, + phNfc_eInvalidP2PMode = 0xFFU +} phNfc_eP2PMode_t; + + +/** \ingroup grp_hal_common +* +* \brief Identities the type of Notification +* +* This enumeration is used to specify the type of notification notified +* to the upper layer. This classifies the notification into two types +* one for the discovery notifications and the other for all the remaining +* event notifications +* \note None. +*/ +typedef enum phNfc_eNotificationType_t +{ + INVALID_NFC_NOTIFICATION = 0x00U, /* Invalid Notification */ + NFC_DISCOVERY_NOTIFICATION, /* Remote Device Discovery Notification */ + NFC_EVENT_NOTIFICATION /* Event Notification from the other hosts */ +} phNfc_eNotificationType_t; + + +/** \ingroup grp_hal_common +* +* \brief +* +* \note None. +*/ +typedef struct phNfc_sUiccInfo_t +{ + /* AID and Parameter Information is obtained if the + * eventType is NFC_EVT_TRANSACTION. + */ + phNfc_sData_t aid; + phNfc_sData_t param; + +} phNfc_sUiccInfo_t; + + +/** \ingroup grp_hal_nfci +* +* \brief P2P Information for the Initiator +* +* The \ref phNfc_sNfcIPCfg_t holds the P2P related information +* use by the NFC Device during P2P Discovery and connection +* +* \note None. +*/ +typedef struct phNfc_sNfcIPCfg_t +{ + /* ATR_RES = General bytes length, Max length = 48 bytes */ + uint8_t generalBytesLength; + uint8_t generalBytes[PHHAL_MAX_ATR_LENGTH]; + + /* TODO: This will be updated later for any additional params*/ +} phNfc_sNfcIPCfg_t; + + +/** \ingroup grp_hal_common +* +* \brief Discovery Configuration Mode +* +* This enumeration is used to choose the Discovery Configuration +* Mode :- Configure and Start, Stop or Start with last set +* configuration +* \note None. +*/ +typedef enum phNfc_eDiscoveryConfigMode_t +{ + NFC_DISCOVERY_CONFIG = 0x00U,/**< Configure discovery with values + in phNfc_sADD_Cfg_t and start + discovery */ + NFC_DISCOVERY_START, /**< Start Discovery with previously set + configuration */ + NFC_DISCOVERY_STOP, /**< Stop the Discovery */ + NFC_DISCOVERY_RESUME /**< Resume the Discovery with previously + * set configuration. + * This is valid only when the Target + * is not connected. + */ +}phNfc_eDiscoveryConfigMode_t; + +/** \ingroup grp_hal_common +* +* \brief Target or Tag Release Mode +* +* This enumeration defines various modes of releasing an acquired target +* or tag. +* \note None. +*/ +typedef enum phNfc_eReleaseType_t +{ + NFC_INVALID_RELEASE_TYPE =0x00U,/** Poll configuration structure holds information about the +* enabling the the type of discovery required by the application. This +* structure is the input parameter for the discovery call +* +* \note All members of this structure are input parameters [out]. +* +* \sa \ref phNfc_eP2PMode_t +* +*/ +typedef struct phNfc_sADD_Cfg_t +{ + union + { + phNfc_sPollDevInfo_t PollCfgInfo; /**< Enable/Disable Specific + Reader Functionality and + Card Emulation */ + unsigned PollEnabled; /** Can be used to set polling 'Off' + by setting PollEnabled to zero */ + + } PollDevInfo; + uint32_t Duration; /**< Duration of virtual or idle + period in microseconds in the step size + of 48 microseconds.If duration is set less + than 48 microseconds then default value is + used.For more details please refer PN 544 + user manual*/ + uint8_t NfcIP_Mode ; /**< Select the P2P + speeds using phNfc_eP2PMode_t type. + This is used to enable NFC-IP Discovery + The related Reader Type will be implicitly + selected */ + uint8_t NfcIP_Tgt_Disable; /**< Flag to + disable the NFCIP1 TARGET */ +} phNfc_sADD_Cfg_t; + +/*@}*/ + +#endif /* PHNFCTYPES */ + -- cgit v1.1