├── Android.mk ├── CleanSpec.mk ├── Linux_x86 ├── phDal4Nfc.c ├── phDal4Nfc_debug.h ├── phDal4Nfc_i2c.c ├── phDal4Nfc_i2c.h ├── phDal4Nfc_link.h ├── phDal4Nfc_messageQueueLib.c ├── phDal4Nfc_uart.c ├── phDal4Nfc_uart.h ├── phOsalNfc.c ├── phOsalNfc_Common.h ├── phOsalNfc_Timer.c └── phOsalNfc_Utils.c ├── MODULE_LICENSE_APACHE2 ├── NOTICE ├── inc ├── nfc_custom_config_example.h ├── phDbgTrace.h ├── phNfcCompId.h ├── phNfcConfig.h ├── phNfcHalTypes.h ├── phNfcInterface.h ├── phNfcIoctlCode.h ├── phNfcLlcpTypes.h ├── phNfcStatus.h └── phNfcTypes.h └── src ├── nfc_osal_deferred_call.h ├── phDal4Nfc.h ├── phDal4Nfc_DeferredCall.h ├── phDal4Nfc_messageQueueLib.h ├── phDnldNfc.c ├── phDnldNfc.h ├── phFriNfc.h ├── phFriNfc_DesfireFormat.c ├── phFriNfc_DesfireFormat.h ├── phFriNfc_DesfireMap.c ├── phFriNfc_DesfireMap.h ├── phFriNfc_FelicaMap.c ├── phFriNfc_FelicaMap.h ├── phFriNfc_ISO15693Format.c ├── phFriNfc_ISO15693Format.h ├── phFriNfc_ISO15693Map.c ├── phFriNfc_ISO15693Map.h ├── phFriNfc_IntNdefMap.c ├── phFriNfc_IntNdefMap.h ├── phFriNfc_Llcp.c ├── phFriNfc_Llcp.h ├── phFriNfc_LlcpMac.c ├── phFriNfc_LlcpMac.h ├── phFriNfc_LlcpMacNfcip.c ├── phFriNfc_LlcpMacNfcip.h ├── phFriNfc_LlcpTransport.c ├── phFriNfc_LlcpTransport.h ├── phFriNfc_LlcpTransport_Connection.c ├── phFriNfc_LlcpTransport_Connection.h ├── phFriNfc_LlcpTransport_Connectionless.c ├── phFriNfc_LlcpTransport_Connectionless.h ├── phFriNfc_LlcpUtils.c ├── phFriNfc_LlcpUtils.h ├── phFriNfc_MapTools.c ├── phFriNfc_MapTools.h ├── phFriNfc_MifStdFormat.c ├── phFriNfc_MifStdFormat.h ├── phFriNfc_MifULFormat.c ├── phFriNfc_MifULFormat.h ├── phFriNfc_MifareStdMap.c ├── phFriNfc_MifareStdMap.h ├── phFriNfc_MifareULMap.c ├── phFriNfc_MifareULMap.h ├── phFriNfc_NdefMap.c ├── phFriNfc_NdefMap.h ├── phFriNfc_NdefRecord.c ├── phFriNfc_NdefRecord.h ├── phFriNfc_NdefReg.c ├── phFriNfc_NdefReg.h ├── phFriNfc_OvrHal.c ├── phFriNfc_OvrHal.h ├── phFriNfc_OvrHalCmd.h ├── phFriNfc_SmtCrdFmt.c ├── phFriNfc_SmtCrdFmt.h ├── phFriNfc_TopazDynamicMap.c ├── phFriNfc_TopazMap.c ├── phFriNfc_TopazMap.h ├── phHal4Nfc.c ├── phHal4Nfc.h ├── phHal4Nfc_ADD.c ├── phHal4Nfc_Emulation.c ├── phHal4Nfc_Internal.h ├── phHal4Nfc_P2P.c ├── phHal4Nfc_Reader.c ├── phHciNfc.c ├── phHciNfc.h ├── phHciNfc_AdminMgmt.c ├── phHciNfc_AdminMgmt.h ├── phHciNfc_CE_A.c ├── phHciNfc_CE_A.h ├── phHciNfc_CE_B.c ├── phHciNfc_CE_B.h ├── phHciNfc_DevMgmt.c ├── phHciNfc_DevMgmt.h ├── phHciNfc_Emulation.c ├── phHciNfc_Emulation.h ├── phHciNfc_Felica.c ├── phHciNfc_Felica.h ├── phHciNfc_Generic.c ├── phHciNfc_Generic.h ├── phHciNfc_IDMgmt.c ├── phHciNfc_IDMgmt.h ├── phHciNfc_ISO15693.c ├── phHciNfc_ISO15693.h ├── phHciNfc_Jewel.c ├── phHciNfc_Jewel.h ├── phHciNfc_LinkMgmt.c ├── phHciNfc_LinkMgmt.h ├── phHciNfc_NfcIPMgmt.c ├── phHciNfc_NfcIPMgmt.h ├── phHciNfc_Pipe.c ├── phHciNfc_Pipe.h ├── phHciNfc_PollingLoop.c ├── phHciNfc_PollingLoop.h ├── phHciNfc_RFReader.c ├── phHciNfc_RFReader.h ├── phHciNfc_RFReaderA.c ├── phHciNfc_RFReaderA.h ├── phHciNfc_RFReaderB.c ├── phHciNfc_RFReaderB.h ├── phHciNfc_SWP.c ├── phHciNfc_SWP.h ├── phHciNfc_Sequence.c ├── phHciNfc_Sequence.h ├── phHciNfc_WI.c ├── phHciNfc_WI.h ├── phLibNfc.c ├── phLibNfc.h ├── phLibNfcStatus.h ├── phLibNfc_Internal.h ├── phLibNfc_Ioctl.c ├── phLibNfc_SE.c ├── phLibNfc_SE.h ├── phLibNfc_discovery.c ├── phLibNfc_discovery.h ├── phLibNfc_initiator.c ├── phLibNfc_initiator.h ├── phLibNfc_ioctl.h ├── phLibNfc_llcp.c ├── phLibNfc_ndef_raw.c ├── phLibNfc_ndef_raw.h ├── phLibNfc_target.c ├── phLlcNfc.c ├── phLlcNfc.h ├── phLlcNfc_DataTypes.h ├── phLlcNfc_Frame.c ├── phLlcNfc_Frame.h ├── phLlcNfc_Interface.c ├── phLlcNfc_Interface.h ├── phLlcNfc_StateMachine.c ├── phLlcNfc_Timer.c ├── phLlcNfc_Timer.h ├── phOsalNfc.h ├── phOsalNfc_Msg.h └── phOsalNfc_Timer.h /Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | # 4 | # libnfc 5 | # 6 | 7 | include $(CLEAR_VARS) 8 | 9 | LOCAL_ARM_MODE := arm 10 | 11 | #phLibNfc 12 | LOCAL_SRC_FILES:= \ 13 | src/phLibNfc.c \ 14 | src/phLibNfc_discovery.c \ 15 | src/phLibNfc_initiator.c \ 16 | src/phLibNfc_llcp.c \ 17 | src/phLibNfc_Ioctl.c \ 18 | src/phLibNfc_ndef_raw.c \ 19 | src/phLibNfc_SE.c \ 20 | src/phLibNfc_target.c 21 | 22 | #phHalNfc 23 | LOCAL_SRC_FILES += src/phHal4Nfc_ADD.c 24 | LOCAL_SRC_FILES += src/phHal4Nfc.c 25 | LOCAL_SRC_FILES += src/phHal4Nfc_Emulation.c 26 | LOCAL_SRC_FILES += src/phHal4Nfc_P2P.c 27 | LOCAL_SRC_FILES += src/phHal4Nfc_Reader.c 28 | 29 | #phDnldNfc 30 | LOCAL_SRC_FILES += src/phDnldNfc.c 31 | 32 | #phHciNfc 33 | LOCAL_SRC_FILES += src/phHciNfc_AdminMgmt.c 34 | LOCAL_SRC_FILES += src/phHciNfc.c 35 | LOCAL_SRC_FILES += src/phHciNfc_CE_A.c 36 | LOCAL_SRC_FILES += src/phHciNfc_CE_B.c 37 | LOCAL_SRC_FILES += src/phHciNfc_DevMgmt.c 38 | LOCAL_SRC_FILES += src/phHciNfc_Emulation.c 39 | LOCAL_SRC_FILES += src/phHciNfc_Felica.c 40 | LOCAL_SRC_FILES += src/phHciNfc_Generic.c 41 | LOCAL_SRC_FILES += src/phHciNfc_IDMgmt.c 42 | LOCAL_SRC_FILES += src/phHciNfc_ISO15693.c 43 | LOCAL_SRC_FILES += src/phHciNfc_Jewel.c 44 | LOCAL_SRC_FILES += src/phHciNfc_LinkMgmt.c 45 | LOCAL_SRC_FILES += src/phHciNfc_NfcIPMgmt.c 46 | LOCAL_SRC_FILES += src/phHciNfc_Pipe.c 47 | LOCAL_SRC_FILES += src/phHciNfc_PollingLoop.c 48 | LOCAL_SRC_FILES += src/phHciNfc_RFReaderA.c 49 | LOCAL_SRC_FILES += src/phHciNfc_RFReaderB.c 50 | LOCAL_SRC_FILES += src/phHciNfc_RFReader.c 51 | LOCAL_SRC_FILES += src/phHciNfc_Sequence.c 52 | LOCAL_SRC_FILES += src/phHciNfc_SWP.c 53 | LOCAL_SRC_FILES += src/phHciNfc_WI.c 54 | 55 | #phLlcNfc 56 | LOCAL_SRC_FILES += src/phLlcNfc.c 57 | LOCAL_SRC_FILES += src/phLlcNfc_Frame.c 58 | LOCAL_SRC_FILES += src/phLlcNfc_Interface.c 59 | LOCAL_SRC_FILES += src/phLlcNfc_StateMachine.c 60 | LOCAL_SRC_FILES += src/phLlcNfc_Timer.c 61 | 62 | #phFricNfc_Llcp 63 | LOCAL_SRC_FILES += src/phFriNfc_Llcp.c 64 | LOCAL_SRC_FILES += src/phFriNfc_LlcpUtils.c 65 | LOCAL_SRC_FILES += src/phFriNfc_LlcpTransport.c 66 | LOCAL_SRC_FILES += src/phFriNfc_LlcpTransport_Connectionless.c 67 | LOCAL_SRC_FILES += src/phFriNfc_LlcpTransport_Connection.c 68 | LOCAL_SRC_FILES += src/phFriNfc_LlcpMac.c 69 | LOCAL_SRC_FILES += src/phFriNfc_LlcpMacNfcip.c 70 | 71 | #phFriNfc_NdefMap 72 | LOCAL_SRC_FILES += src/phFriNfc_FelicaMap.c 73 | LOCAL_SRC_FILES += src/phFriNfc_MifareStdMap.c 74 | LOCAL_SRC_FILES += src/phFriNfc_MifareULMap.c 75 | LOCAL_SRC_FILES += src/phFriNfc_MapTools.c 76 | LOCAL_SRC_FILES += src/phFriNfc_TopazMap.c 77 | LOCAL_SRC_FILES += src/phFriNfc_TopazDynamicMap.c 78 | LOCAL_SRC_FILES += src/phFriNfc_DesfireMap.c 79 | LOCAL_SRC_FILES += src/phFriNfc_ISO15693Map.c 80 | LOCAL_SRC_FILES += src/phFriNfc_NdefMap.c 81 | LOCAL_SRC_FILES += src/phFriNfc_IntNdefMap.c 82 | 83 | #phFriNfc_NdefReg 84 | LOCAL_SRC_FILES += src/phFriNfc_NdefReg.c 85 | 86 | #phFriNfc_SmtCrdFmt 87 | LOCAL_SRC_FILES += src/phFriNfc_DesfireFormat.c 88 | LOCAL_SRC_FILES += src/phFriNfc_MifULFormat.c 89 | LOCAL_SRC_FILES += src/phFriNfc_MifStdFormat.c 90 | LOCAL_SRC_FILES += src/phFriNfc_SmtCrdFmt.c 91 | LOCAL_SRC_FILES += src/phFriNfc_ISO15693Format.c 92 | 93 | #phFriNfc_OvrHal 94 | LOCAL_SRC_FILES += src/phFriNfc_OvrHal.c 95 | 96 | #phOsalNfc 97 | LOCAL_SRC_FILES += Linux_x86/phOsalNfc_Timer.c 98 | LOCAL_SRC_FILES += Linux_x86/phOsalNfc.c 99 | LOCAL_SRC_FILES += Linux_x86/phOsalNfc_Utils.c 100 | 101 | #phDal4Nfc 102 | LOCAL_SRC_FILES += Linux_x86/phDal4Nfc_uart.c 103 | LOCAL_SRC_FILES += Linux_x86/phDal4Nfc.c 104 | LOCAL_SRC_FILES += Linux_x86/phDal4Nfc_i2c.c 105 | LOCAL_SRC_FILES += Linux_x86/phDal4Nfc_messageQueueLib.c 106 | 107 | LOCAL_CFLAGS += -DNXP_MESSAGING -DANDROID -DNFC_TIMER_CONTEXT -fno-strict-aliasing 108 | 109 | ifeq ($(TARGET_HAS_NFC_CUSTOM_CONFIG),true) 110 | LOCAL_CFLAGS += -DNFC_CUSTOM_CONFIG_INCLUDE 111 | LOCAL_CFLAGS += -I$(TARGET_OUT_HEADERS)/libnfc-nxp 112 | endif 113 | 114 | # Uncomment for Chipset command/responses 115 | # Or use "setprop debug.nfc.LOW_LEVEL_TRACES" at run-time 116 | # LOCAL_CFLAGS += -DLOW_LEVEL_TRACES 117 | 118 | # Uncomment for DAL traces 119 | # LOCAL_CFLAGS += -DDEBUG -DDAL_TRACE 120 | 121 | # Uncomment for LLC traces 122 | # LOCAL_CFLAGS += -DDEBUG -DLLC_TRACE 123 | 124 | # Uncomment for LLCP traces 125 | # LOCAL_CFLAGS += -DDEBUG -DLLCP_TRACE 126 | 127 | # Uncomment for HCI traces 128 | # LOCAL_CFLAGS += -DDEBUG -DHCI_TRACE 129 | 130 | #includes 131 | LOCAL_CFLAGS += -I$(LOCAL_PATH)/inc 132 | LOCAL_CFLAGS += -I$(LOCAL_PATH)/Linux_x86 133 | LOCAL_CFLAGS += -I$(LOCAL_PATH)/src 134 | 135 | LOCAL_CFLAGS += -Wno-unused-parameter 136 | 137 | LOCAL_MODULE:= libnfc 138 | LOCAL_MODULE_TAGS := optional 139 | LOCAL_SHARED_LIBRARIES := libcutils libnfc_ndef libdl libhardware liblog 140 | 141 | include $(BUILD_SHARED_LIBRARY) 142 | 143 | # 144 | # libnfc_ndef 145 | # 146 | 147 | include $(CLEAR_VARS) 148 | 149 | LOCAL_SRC_FILES += src/phFriNfc_NdefRecord.c 150 | 151 | LOCAL_CFLAGS += -I$(LOCAL_PATH)/inc 152 | LOCAL_CFLAGS += -I$(LOCAL_PATH)/src 153 | 154 | LOCAL_MODULE:= libnfc_ndef 155 | LOCAL_MODULE_TAGS := optional 156 | LOCAL_SHARED_LIBRARIES := libcutils liblog 157 | 158 | include $(BUILD_SHARED_LIBRARY) 159 | -------------------------------------------------------------------------------- /CleanSpec.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # If you don't need to do a full clean build but would like to touch 17 | # a file or delete some intermediate files, add a clean step to the end 18 | # of the list. These steps will only be run once, if they haven't been 19 | # run before. 20 | # 21 | # E.g.: 22 | # $(call add-clean-step, touch -c external/sqlite/sqlite3.h) 23 | # $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates) 24 | # 25 | # Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with 26 | # files that are missing or have been moved. 27 | # 28 | # Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory. 29 | # Use $(OUT_DIR) to refer to the "out" directory. 30 | # 31 | # If you need to re-do something that's already mentioned, just copy 32 | # the command and add it to the bottom of the list. E.g., if a change 33 | # that you made last week required touching a file and a change you 34 | # made today requires touching the same file, just copy the old 35 | # touch step and add it to the end of the list. 36 | # 37 | # ************************************************ 38 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 39 | # ************************************************ 40 | 41 | # For example: 42 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates) 43 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates) 44 | #$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f) 45 | #$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*) 46 | 47 | # ************************************************ 48 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 49 | # ************************************************ 50 | $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libnfc_intermediates/) 51 | $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libnfc_ndef_intermediates/) 52 | $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/libnfc.so) 53 | $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/libnfc_ndef.so) 54 | -------------------------------------------------------------------------------- /Linux_x86/phDal4Nfc_debug.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | /*----------------------------------------------------------------------------------- 5 | DEBUG CORNER 6 | ------------------------------------------------------------------------------------*/ 7 | #ifdef DAL_TRACE 8 | #include 9 | 10 | #define MAX_TRACE_BUFFER 150 11 | 12 | #define DAL_PRINT( str ) phOsalNfc_DbgString(str) 13 | #define DAL_DEBUG(str, arg) \ 14 | { \ 15 | char trace[MAX_TRACE_BUFFER]; \ 16 | snprintf(trace,MAX_TRACE_BUFFER,str,arg); \ 17 | phOsalNfc_DbgString(trace); \ 18 | } 19 | 20 | #define DAL_PRINT_BUFFER(msg,buf,len) \ 21 | { \ 22 | uint16_t i = 0; \ 23 | char trace[MAX_TRACE_BUFFER]; \ 24 | snprintf(trace,MAX_TRACE_BUFFER,"\n\t %s:",msg); \ 25 | phOsalNfc_DbgString(trace); \ 26 | phOsalNfc_DbgTrace(buf,len); \ 27 | phOsalNfc_DbgString("\r"); \ 28 | } 29 | 30 | #define DAL_ASSERT_STR(x, str) { if (!(x)) { phOsalNfc_DbgString(str); while(1); } } 31 | 32 | #else 33 | #define DAL_PRINT( str ) 34 | #define DAL_DEBUG(str, arg) 35 | #define DAL_PRINT_BUFFER(msg,buf,len) 36 | #define DAL_ASSERT_STR(x, str) 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /Linux_x86/phDal4Nfc_i2c.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * \file phDalNfc_i2c.h 19 | * \brief DAL I2C port implementation for linux 20 | * 21 | * Project: Trusted NFC Linux 22 | * 23 | */ 24 | 25 | /**< Basic type definitions */ 26 | #include 27 | /**< Generic Interface Layer Function Definitions */ 28 | #include 29 | #include 30 | 31 | void phDal4Nfc_i2c_initialize(void); 32 | void phDal4Nfc_i2c_set_open_from_handle(phHal_sHwReference_t * pDalHwContext); 33 | int phDal4Nfc_i2c_is_opened(void); 34 | void phDal4Nfc_i2c_flush(void); 35 | void phDal4Nfc_i2c_close(void); 36 | NFCSTATUS phDal4Nfc_i2c_open_and_configure(pphDal4Nfc_sConfig_t pConfig, void ** pLinkHandle); 37 | int phDal4Nfc_i2c_read(uint8_t * pBuffer, int nNbBytesToRead); 38 | int phDal4Nfc_i2c_write(uint8_t * pBuffer, int nNbBytesToWrite); 39 | int phDal4Nfc_i2c_reset(long level); 40 | -------------------------------------------------------------------------------- /Linux_x86/phDal4Nfc_link.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * \file phDalNfc_link.h 19 | * \brief DAL generic link interface for linux 20 | * 21 | * Project: Trusted NFC Linux Lignt 22 | * 23 | * $Date: 10 aug 2009 24 | * $Author: Jonathan roux 25 | * $Revision: 1.0 $ 26 | * 27 | */ 28 | 29 | /**< Basic type definitions */ 30 | #include 31 | /**< Generic Interface Layer Function Definitions */ 32 | #include 33 | #include 34 | 35 | typedef void (*phDal4Nfc_link_initialize_CB_t) (void); 36 | typedef void (*phDal4Nfc_link_set_open_from_handle_CB_t) (phHal_sHwReference_t * pDalHwContext); 37 | typedef int (*phDal4Nfc_link_is_opened_CB_t) (void); 38 | typedef void (*phDal4Nfc_link_flush_CB_t) (void); 39 | typedef void (*phDal4Nfc_link_close_CB_t) (void); 40 | typedef NFCSTATUS (*phDal4Nfc_link_open_and_configure_CB_t) (pphDal4Nfc_sConfig_t pConfig, void ** pLinkHandle); 41 | typedef int (*phDal4Nfc_link_read_CB_t) (uint8_t * pBuffer, int nNbBytesToRead); 42 | typedef int (*phDal4Nfc_link_write_CB_t) (uint8_t * pBuffer, int nNbBytesToWrite); 43 | typedef int (*phDal4Nfc_link_download_CB_t) (long level); 44 | typedef int (*phDal4Nfc_link_reset_CB_t) (long level); 45 | 46 | 47 | typedef struct 48 | { 49 | phDal4Nfc_link_initialize_CB_t init; 50 | phDal4Nfc_link_set_open_from_handle_CB_t open_from_handle; 51 | phDal4Nfc_link_is_opened_CB_t is_opened; 52 | phDal4Nfc_link_flush_CB_t flush; 53 | phDal4Nfc_link_close_CB_t close; 54 | phDal4Nfc_link_open_and_configure_CB_t open_and_configure; 55 | phDal4Nfc_link_read_CB_t read; 56 | phDal4Nfc_link_write_CB_t write; 57 | phDal4Nfc_link_download_CB_t download; 58 | phDal4Nfc_link_reset_CB_t reset; 59 | } phDal4Nfc_link_cbk_interface_t; 60 | 61 | 62 | -------------------------------------------------------------------------------- /Linux_x86/phDal4Nfc_messageQueueLib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * \file phDalNfc_messageQueueLib.c 19 | * \brief DAL independant message queue implementation for android (can be used under linux too) 20 | * 21 | * Project: Trusted NFC Linux Lignt 22 | * 23 | * $Date: 13 aug 2009 24 | * $Author: Jonathan roux 25 | * $Revision: 1.0 $ 26 | * 27 | */ 28 | 29 | #include 30 | #ifdef ANDROID 31 | #include 32 | #else 33 | #include 34 | #endif 35 | 36 | #include 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | typedef struct phDal4Nfc_message_queue_item 44 | { 45 | phLibNfc_Message_t nMsg; 46 | struct phDal4Nfc_message_queue_item * pPrev; 47 | struct phDal4Nfc_message_queue_item * pNext; 48 | } phDal4Nfc_message_queue_item_t; 49 | 50 | 51 | typedef struct phDal4Nfc_message_queue 52 | { 53 | phDal4Nfc_message_queue_item_t * pItems; 54 | pthread_mutex_t nCriticalSectionMutex; 55 | sem_t nProcessSemaphore; 56 | 57 | } phDal4Nfc_message_queue_t; 58 | 59 | 60 | /** 61 | * \ingroup grp_nfc_dal 62 | * 63 | * \brief DAL message get function 64 | * This function allocates the message queue. The parameters are ignored, this is 65 | * just to keep the same api as Linux queue. 66 | * 67 | * \retval -1 Can not allocate memory or can not init mutex. 68 | * \retval handle The handle on the message queue. 69 | */ 70 | intptr_t phDal4Nfc_msgget ( key_t key, int msgflg ) 71 | { 72 | phDal4Nfc_message_queue_t * pQueue; 73 | pQueue = (phDal4Nfc_message_queue_t *) phOsalNfc_GetMemory(sizeof(phDal4Nfc_message_queue_t)); 74 | if (pQueue == NULL) 75 | return -1; 76 | memset(pQueue, 0, sizeof(phDal4Nfc_message_queue_t)); 77 | if (pthread_mutex_init (&pQueue->nCriticalSectionMutex, NULL) == -1) 78 | return -1; 79 | if (sem_init (&pQueue->nProcessSemaphore, 0, 0) == -1) 80 | return -1; 81 | return ((intptr_t)pQueue); 82 | } 83 | 84 | /** 85 | * \ingroup grp_nfc_dal 86 | * 87 | * \brief DAL message control function 88 | * This function destroys the message queue. The cmd and buf parameters are ignored, 89 | * this is just to keep the same api as Linux queue. 90 | * 91 | * \param[in] msqid The handle of the message queue. 92 | * 93 | * \retval 0 If success. 94 | * \retval -1 Bad passed parameter 95 | */ 96 | int phDal4Nfc_msgctl ( intptr_t msqid, int cmd, void *buf ) 97 | { 98 | phDal4Nfc_message_queue_t * pQueue; 99 | phDal4Nfc_message_queue_item_t * p; 100 | 101 | if (msqid == 0) 102 | return -1; 103 | 104 | pQueue = (phDal4Nfc_message_queue_t *)msqid; 105 | pthread_mutex_lock(&pQueue->nCriticalSectionMutex); 106 | if (pQueue->pItems != NULL) 107 | { 108 | p = pQueue->pItems; 109 | while(p->pNext != NULL) { p = p->pNext; } 110 | while(p->pPrev != NULL) 111 | { 112 | p = p->pPrev; 113 | phOsalNfc_FreeMemory(p->pNext); 114 | p->pNext = NULL; 115 | } 116 | phOsalNfc_FreeMemory(p); 117 | } 118 | pQueue->pItems = NULL; 119 | pthread_mutex_unlock(&pQueue->nCriticalSectionMutex); 120 | pthread_mutex_destroy(&pQueue->nCriticalSectionMutex); 121 | phOsalNfc_FreeMemory(pQueue); 122 | return 0; 123 | } 124 | 125 | /** 126 | * \ingroup grp_nfc_dal 127 | * 128 | * \brief DAL message send function 129 | * Use this function to send a message to the queue. The message will be added at the end of 130 | * the queue with respect to FIFO policy. The msgflg parameter is ignored. 131 | * 132 | * \param[in] msqid The handle of the message queue. 133 | * \param[in] msgp The message to send. 134 | * \param[in] msgsz The message size. 135 | * 136 | * \retval 0 If success. 137 | * \retval -1 Bad passed parameter, or can not allocate memory 138 | */ 139 | int phDal4Nfc_msgsnd (intptr_t msqid, void * msgp, size_t msgsz, int msgflg) 140 | { 141 | phDal4Nfc_message_queue_t * pQueue; 142 | phDal4Nfc_message_queue_item_t * p; 143 | phDal4Nfc_message_queue_item_t * pNew; 144 | 145 | if ((msqid == 0) || (msgp == NULL) || (msgsz == 0)) 146 | return -1; 147 | 148 | if (msgsz != sizeof(phLibNfc_Message_t)) 149 | return -1; 150 | 151 | pQueue = (phDal4Nfc_message_queue_t *)msqid; 152 | pNew = (phDal4Nfc_message_queue_item_t *)phOsalNfc_GetMemory(sizeof(phDal4Nfc_message_queue_item_t)); 153 | if (pNew == NULL) 154 | return -1; 155 | memset(pNew, 0, sizeof(phDal4Nfc_message_queue_item_t)); 156 | memcpy(&pNew->nMsg, &((phDal4Nfc_Message_Wrapper_t*)msgp)->msg, sizeof(phLibNfc_Message_t)); 157 | pthread_mutex_lock(&pQueue->nCriticalSectionMutex); 158 | if (pQueue->pItems != NULL) 159 | { 160 | p = pQueue->pItems; 161 | while(p->pNext != NULL) { p = p->pNext; } 162 | p->pNext = pNew; 163 | pNew->pPrev = p; 164 | } 165 | else 166 | { 167 | pQueue->pItems = pNew; 168 | } 169 | pthread_mutex_unlock(&pQueue->nCriticalSectionMutex); 170 | 171 | sem_post(&pQueue->nProcessSemaphore); 172 | return 0; 173 | } 174 | 175 | /** 176 | * \ingroup grp_nfc_dal 177 | * 178 | * \brief DAL message receive function 179 | * The call to this function will get the older message from the queue. If the queue is empty the function waits 180 | * (blocks on a mutex) until a message is posted to the queue with phDal4Nfc_msgsnd. 181 | * The msgtyp and msgflg parameters are ignored. 182 | * 183 | * \param[in] msqid The handle of the message queue. 184 | * \param[out] msgp The received message. 185 | * \param[in] msgsz The message size. 186 | * 187 | * \retval 0 If success. 188 | * \retval -1 Bad passed parameter. 189 | */ 190 | int phDal4Nfc_msgrcv (intptr_t msqid, void * msgp, size_t msgsz, long msgtyp, int msgflg) 191 | { 192 | phDal4Nfc_message_queue_t * pQueue; 193 | phDal4Nfc_message_queue_item_t * p; 194 | 195 | if ((msqid == 0) || (msgp == NULL)) 196 | return -1; 197 | 198 | if (msgsz != sizeof(phLibNfc_Message_t)) 199 | return -1; 200 | 201 | pQueue = (phDal4Nfc_message_queue_t *)msqid; 202 | sem_wait(&pQueue->nProcessSemaphore); 203 | pthread_mutex_lock(&pQueue->nCriticalSectionMutex); 204 | if (pQueue->pItems != NULL) 205 | { 206 | memcpy(&((phDal4Nfc_Message_Wrapper_t*)msgp)->msg, &(pQueue->pItems)->nMsg, sizeof(phLibNfc_Message_t)); 207 | p = pQueue->pItems->pNext; 208 | phOsalNfc_FreeMemory(pQueue->pItems); 209 | pQueue->pItems = p; 210 | } 211 | pthread_mutex_unlock(&pQueue->nCriticalSectionMutex); 212 | return 0; 213 | } 214 | 215 | 216 | 217 | 218 | 219 | -------------------------------------------------------------------------------- /Linux_x86/phDal4Nfc_uart.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * \file phDalNfc_uart.h 19 | * \brief DAL com port implementation for linux 20 | * 21 | * Project: Trusted NFC Linux Lignt 22 | * 23 | * $Date: 07 aug 2009 24 | * $Author: Jonathan roux 25 | * $Revision: 1.0 $ 26 | * 27 | */ 28 | 29 | /**< Basic type definitions */ 30 | #include 31 | /**< Generic Interface Layer Function Definitions */ 32 | #include 33 | #include 34 | 35 | void phDal4Nfc_uart_initialize(void); 36 | void phDal4Nfc_uart_set_open_from_handle(phHal_sHwReference_t * pDalHwContext); 37 | int phDal4Nfc_uart_is_opened(void); 38 | void phDal4Nfc_uart_flush(void); 39 | void phDal4Nfc_uart_close(void); 40 | NFCSTATUS phDal4Nfc_uart_open_and_configure(pphDal4Nfc_sConfig_t pConfig, void ** pLinkHandle); 41 | int phDal4Nfc_uart_read(uint8_t * pBuffer, int nNbBytesToRead); 42 | int phDal4Nfc_uart_write(uint8_t * pBuffer, int nNbBytesToWrite); 43 | int phDal4Nfc_uart_reset(); 44 | int phDal4Nfc_uart_download(); 45 | -------------------------------------------------------------------------------- /Linux_x86/phOsalNfc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * \file phOsalNfc.c 19 | * \brief OSAL Implementation for linux 20 | * 21 | * Project: Trusted NFC Linux Light 22 | * 23 | * $Date: 03 aug 2009 24 | * $Author: Jérémie Corbier 25 | * $Revision: 1.0 26 | * 27 | */ 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include 36 | 37 | #ifdef ANDROID 38 | #define LOG_TAG "NFC-HCI" 39 | 40 | #include 41 | 42 | phOsalNfc_Exception_t phOsalNfc_Exception; 43 | #endif 44 | 45 | #ifdef DEBUG 46 | #define MAX_PRINT_BUFSIZE (0x450U) 47 | char phOsalNfc_DbgTraceBuffer[MAX_PRINT_BUFSIZE]; 48 | #endif 49 | 50 | void phLibNfc_Mgt_Recovery(); 51 | 52 | /*! 53 | * \brief Allocates memory. 54 | * This function attempts to allocate \a size bytes on the heap and 55 | * returns a pointer to the allocated block. 56 | * 57 | * \param size size of the memory block to be allocated on the heap. 58 | * 59 | * \return pointer to allocated memory block or NULL in case of error. 60 | */ 61 | void *phOsalNfc_GetMemory(uint32_t size) 62 | { 63 | void *pMem = (void *)malloc(size); 64 | return pMem; 65 | } 66 | 67 | /*! 68 | * \brief Frees allocated memory block. 69 | * This function deallocates memory region pointed to by \a pMem. 70 | * 71 | * \param pMem pointer to memory block to be freed. 72 | */ 73 | void phOsalNfc_FreeMemory(void *pMem) 74 | { 75 | if(NULL != pMem) 76 | free(pMem); 77 | } 78 | 79 | void phOsalNfc_DbgString(const char *pString) 80 | { 81 | #ifdef DEBUG 82 | if(pString != NULL) 83 | #ifndef ANDROID 84 | printf(pString); 85 | #else 86 | ALOGD("%s", pString); 87 | #endif 88 | #endif 89 | } 90 | 91 | void phOsalNfc_DbgTrace(uint8_t data[], uint32_t size) 92 | { 93 | #ifdef DEBUG 94 | uint32_t i; 95 | #ifdef ANDROID 96 | char buf[10]; 97 | #endif 98 | 99 | if(size == 0) 100 | return; 101 | 102 | #ifndef ANDROID 103 | for(i = 0; i < size; i++) 104 | { 105 | if((i % 10) == 0) 106 | printf("\n\t\t\t"); 107 | printf("%02X ", data[i]); 108 | } 109 | printf("\n\tBlock size is: %d\n", size); 110 | #else 111 | phOsalNfc_DbgTraceBuffer[0] = '\0'; 112 | for(i = 0; i < size; i++) 113 | { 114 | if((i % 10) == 0) 115 | { 116 | ALOGD("%s", phOsalNfc_DbgTraceBuffer); 117 | phOsalNfc_DbgTraceBuffer[0] = '\0'; 118 | } 119 | 120 | snprintf(buf, 10, "%02X ", data[i]); 121 | strncat(phOsalNfc_DbgTraceBuffer, buf, 10); 122 | } 123 | ALOGD("%s", phOsalNfc_DbgTraceBuffer); 124 | ALOGD("Block size is: %d", size); 125 | #endif 126 | #endif 127 | } 128 | 129 | /*! 130 | * \brief Raises exception. 131 | * This function raises an exception of type \a eExceptionType with 132 | * reason \a reason to stack clients. 133 | * 134 | * \param eExceptionType exception type. 135 | * \param reason reason for this exception. 136 | * 137 | * \note Clients willing to catch exceptions are to handle the SIGABRT signal. 138 | * On Linux, exception type and reason are passed to the signal handler as 139 | * a pointer to a phOsalNfc_Exception_t structure. 140 | * As sigqueue is not available in Android, exception information are 141 | * stored in the phOsalNfc_Exception global. 142 | */ 143 | void phOsalNfc_RaiseException(phOsalNfc_ExceptionType_t eExceptionType, uint16_t reason) 144 | { 145 | if(eExceptionType == phOsalNfc_e_UnrecovFirmwareErr) 146 | { 147 | ALOGE("HCI Timeout - Exception raised - Force restart of NFC service"); 148 | phLibNfc_Mgt_Recovery(); 149 | abort(); 150 | } else { 151 | ALOGD("phOsalNfc_RaiseException() called"); 152 | } 153 | } 154 | 155 | /*! 156 | * \brief display data bytes. 157 | * This function displays data bytes for debug purpose 158 | * \param[in] pString pointer to string to be displayed. 159 | * \param[in] length number of bytes to be displayed. 160 | * \param[in] pBuffer pointer to data bytes to be displayed. 161 | * 162 | */ 163 | void phOsalNfc_PrintData(const char *pString, uint32_t length, uint8_t *pBuffer, 164 | int verbosity) 165 | { 166 | char print_buffer[length * 3 + 1]; 167 | unsigned int i; 168 | 169 | if (pString == NULL) { 170 | pString = ""; 171 | } 172 | print_buffer[0] = '\0'; 173 | for (i = 0; i < length; i++) { 174 | snprintf(&print_buffer[i*3], 4, " %02X", pBuffer[i]); 175 | } 176 | 177 | char llc[40] = ""; 178 | 179 | if (verbosity >= 2) { 180 | uint8_t llc_header = 0; 181 | if (!strcmp(pString, "SEND") && length >= 2) { 182 | llc_header = pBuffer[1]; 183 | } else if (!strcmp(pString, "RECV") && length >= 2) { 184 | llc_header = pBuffer[0]; 185 | } 186 | 187 | if ((llc_header & 0xC0) == 0x80) { 188 | // I 189 | uint8_t ns = (llc_header & 0x38) >> 3; 190 | uint8_t nr = llc_header & 0x07; 191 | snprintf(&llc[0], sizeof(llc), "I %d (%d)", ns, nr); 192 | } else if ((llc_header & 0xE0) == 0xC0) { 193 | // S 194 | uint8_t t = (llc_header & 0x18) >> 3; 195 | uint8_t nr = llc_header & 0x07; 196 | char *type; 197 | switch (t) { 198 | case 0x00: type = "RR "; break; 199 | case 0x01: type = "REJ"; break; 200 | case 0x02: type = "RNR"; break; 201 | case 0x03: type = "SREJ"; break; 202 | default: type = "???"; break; 203 | } 204 | snprintf(&llc[0], sizeof(llc), "S %s (%d)", type, nr); 205 | } else if ((llc_header & 0xE0) == 0xE0) { 206 | // U 207 | snprintf(&llc[0], sizeof(llc), "U"); 208 | } else if (length > 1) { 209 | snprintf(&llc[0], sizeof(llc), "???"); 210 | } 211 | } 212 | 213 | ALOGD("> %s:%s\t%s", pString, print_buffer, llc); 214 | } 215 | -------------------------------------------------------------------------------- /Linux_x86/phOsalNfc_Common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /*! 18 | * \file phOsalNfc_Common.h 19 | * 20 | * Project: NFC FRI / OSAL 21 | * 22 | * $Workfile:: phOsalNfc_Common.h $ 23 | * $Modtime:: $ 24 | * $Author: frq09147 $ 25 | * $Revision: 1.1 $ 26 | * 27 | */ 28 | 29 | #ifndef PHOSALNFC_COMMON_H 30 | #define PHOSALNFC_COMMON_H 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | #define MAX_MESSAGE_SIZE 256 41 | 42 | typedef enum phOsalNfc_eHandleType 43 | { 44 | phOsalNfc_eHandleTypeInvalid = 0, 45 | phOsalNfc_eHandleTypeThread = 1, 46 | phOsalNfc_eHandleTypeSemaphore = 2, 47 | 48 | }phOsalNfc_eHandleType_t; 49 | 50 | typedef struct phOsalNfc_sMsg 51 | { 52 | phOsalNfc_Message_t Msg; 53 | uint32_t sourceID; /* pthread_t = unsigned long int */ 54 | struct phOsalNfc_sMsg *nextMsg; 55 | } phOsalNfc_sMsg_t; 56 | 57 | typedef struct phOsalNfc_sOsalHandle 58 | { 59 | phOsalNfc_eHandleType_t HandleType; 60 | pthread_t *pThread; 61 | pphOsalNfc_ThreadFunction_t pThreadFunction; 62 | void *pParams; 63 | 64 | sem_t *pSemaphore; 65 | sem_t handleSem; 66 | int32_t semValue; 67 | uint32_t semMax; 68 | 69 | struct sembuf semBuf; 70 | int32_t semId; 71 | 72 | phOsalNfc_sMsg_t *pMsg; 73 | sem_t msgSem; 74 | struct phOsalNfc_sOsalHandle *nextThread; 75 | } phOsalNfc_sOsalHandle_t; 76 | 77 | 78 | #endif /* PHOSALNFC_COMMON_H */ 79 | -------------------------------------------------------------------------------- /Linux_x86/phOsalNfc_Timer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * \file phOsalNfc_Timer.c 19 | * \brief OSAL Timer Implementation for linux 20 | * 21 | * Project: Trusted NFC Linux Light 22 | * 23 | * $Date: 03 aug 2009 24 | * $Author: Jérémie Corbier 25 | * $Revision: 1.0 26 | * 27 | */ 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | #include 38 | 39 | #define NSECS 1000000 40 | #define MAX_NO_TIMERS 16 41 | 42 | /*! 43 | * \struct phOsalNfc_Timer 44 | * Internal OSAL timer structure 45 | */ 46 | struct phOsalNfc_Timer 47 | { 48 | timer_t handle; /*!< System timer handle. */ 49 | ppCallBck_t callback; /*!< Callback to be called when timer expires. */ 50 | void* pContext; /*!< Callback context. */ 51 | #ifdef NXP_MESSAGING 52 | void *ptr; 53 | #endif 54 | int nIsStopped; 55 | }; 56 | 57 | static struct phOsalNfc_Timer timers[MAX_NO_TIMERS] = 58 | { 59 | {0, NULL, NULL 60 | #ifdef NXP_MESSAGING 61 | , NULL 62 | #endif 63 | , 0 64 | }, 65 | }; 66 | 67 | #ifdef NXP_MESSAGING 68 | extern int nDeferedCallMessageQueueId; 69 | 70 | void phOsalNfc_Timer_DeferredCall(void *params) 71 | { 72 | phOsalNfc_Timer_Msg_t *timer_msg; 73 | 74 | if(params == NULL) 75 | return; 76 | 77 | timer_msg = (phOsalNfc_Timer_Msg_t *)params; 78 | 79 | if((timer_msg != NULL) && (timer_msg->pCallBck != NULL)) 80 | timer_msg->pCallBck(timer_msg->TimerId, timer_msg->pContext); 81 | 82 | if ((timer_msg->TimerId >= MAX_NO_TIMERS) || (timer_msg->TimerId < 0)) 83 | { 84 | printf("Bad TimerId=%d, should be <= to %d\n", timer_msg->TimerId, MAX_NO_TIMERS); 85 | } 86 | else 87 | { 88 | if(timers[timer_msg->TimerId].ptr != NULL) 89 | { 90 | phOsalNfc_FreeMemory(timers[timer_msg->TimerId].ptr); 91 | timers[timer_msg->TimerId].ptr = NULL; 92 | } 93 | } 94 | phOsalNfc_FreeMemory(timer_msg); 95 | } 96 | #endif 97 | 98 | /*! 99 | * \brief System timer callback. 100 | * This callback is called by Linux whenever one the timers expires. It 101 | * calls the corresponding registered callback. 102 | * 103 | * \param sv structure storing the expired timer ID. 104 | */ 105 | static void phOsalNfc_Timer_Expired(union sigval sv) 106 | { 107 | uint32_t timerid = (uint32_t)(sv.sival_int); 108 | 109 | if((timerid < MAX_NO_TIMERS)&&(timers[timerid].nIsStopped == 1)) 110 | { 111 | //printf("phOsalNfc_Timer_Expired : Expired but already stopped TimerId=%d\n", timerid); 112 | return; 113 | } 114 | 115 | if(timerid < MAX_NO_TIMERS) 116 | { 117 | #ifndef CYCLIC_TIMER 118 | phOsalNfc_Timer_Stop(timerid); 119 | #else 120 | 121 | #endif 122 | #ifdef NXP_MESSAGING 123 | phOsalNfc_Timer_Msg_t *timer_msg; 124 | phOsalNfc_DeferedCalldInfo_t *osal_defer_msg; 125 | phDal4Nfc_Message_Wrapper_t wrapper; 126 | 127 | timer_msg = phOsalNfc_GetMemory(sizeof(phOsalNfc_Timer_Msg_t)); 128 | if(timer_msg == NULL) 129 | phOsalNfc_RaiseException(phOsalNfc_e_NoMemory, 0); 130 | 131 | osal_defer_msg = phOsalNfc_GetMemory(sizeof(phOsalNfc_DeferedCalldInfo_t)); 132 | if(osal_defer_msg == NULL) 133 | { 134 | phOsalNfc_FreeMemory(timer_msg); 135 | phOsalNfc_RaiseException(phOsalNfc_e_NoMemory, 0); 136 | } 137 | 138 | timer_msg->TimerId = timerid; 139 | timer_msg->pCallBck = timers[timerid].callback; 140 | timer_msg->pContext = timers[timerid].pContext; 141 | 142 | osal_defer_msg->pCallback = phOsalNfc_Timer_DeferredCall; 143 | osal_defer_msg->pParameter = timer_msg; 144 | 145 | wrapper.mtype = 1; 146 | wrapper.msg.eMsgType = PH_OSALNFC_TIMER_MSG; 147 | wrapper.msg.pMsgData = osal_defer_msg; 148 | wrapper.msg.Size = sizeof(phOsalNfc_DeferedCalldInfo_t); 149 | 150 | timers[timerid].ptr = osal_defer_msg; 151 | 152 | phDal4Nfc_msgsnd(nDeferedCallMessageQueueId, (void *)&wrapper, 153 | sizeof(phOsalNfc_Message_t), 0); 154 | #else 155 | (timers[timerid].callback)(timerid, timers[timerid].pContext); 156 | #endif 157 | } 158 | } 159 | 160 | static void phOsalNfc_Timer_Dummy_Cb(uint32_t timerid, void *pContext) {} 161 | 162 | /*! 163 | * \brief Creates a new timer. 164 | * This function checks whether there is an available timer slot. If 165 | * this is the case, then it reserves it for future usage and returns its 166 | * ID. 167 | * 168 | * \return a valid timer ID or PH_OSALNFC_INVALID_TIMER_ID if an error occured. 169 | */ 170 | uint32_t phOsalNfc_Timer_Create(void) 171 | { 172 | uint32_t timerid; 173 | struct sigevent se; 174 | 175 | se.sigev_notify = SIGEV_THREAD; 176 | se.sigev_notify_function = phOsalNfc_Timer_Expired; 177 | se.sigev_notify_attributes = NULL; 178 | 179 | /* Look for available timer slot */ 180 | for(timerid = 0; timerid < MAX_NO_TIMERS; timerid++) 181 | if(timers[timerid].callback == NULL) 182 | break; 183 | if(timerid == MAX_NO_TIMERS) 184 | return PH_OSALNFC_INVALID_TIMER_ID; 185 | 186 | se.sigev_value.sival_int = (int)timerid; 187 | 188 | /* Create POSIX timer */ 189 | if(timer_create(CLOCK_REALTIME, &se, &(timers[timerid].handle)) == -1) 190 | return PH_OSALNFC_INVALID_TIMER_ID; 191 | timers[timerid].callback = phOsalNfc_Timer_Dummy_Cb; 192 | #ifdef NXP_MESSAGING 193 | timers[timerid].ptr = NULL; 194 | #endif 195 | 196 | return timerid; 197 | } 198 | 199 | /*! 200 | * \brief Starts a timer. 201 | * This function starts the timer \a TimerId with an expiration time of 202 | * \a RegTimeCnt milliseconds. Each time it expires, \a 203 | * Application_callback is called. 204 | * 205 | * \param TimerId a valid timer ID. 206 | * \param RegTimeCnt expiration time in milliseconds. 207 | * \param Application_callback callback to be called when timer expires. 208 | */ 209 | void phOsalNfc_Timer_Start(uint32_t TimerId, 210 | uint32_t RegTimeCnt, 211 | ppCallBck_t Application_callback, 212 | void *pContext) 213 | { 214 | struct itimerspec its; 215 | 216 | if(TimerId >= MAX_NO_TIMERS) 217 | return; 218 | if(Application_callback == NULL) 219 | return; 220 | if(timers[TimerId].callback == NULL) 221 | return; 222 | 223 | its.it_interval.tv_sec = 0; 224 | its.it_interval.tv_nsec = 0; 225 | its.it_value.tv_sec = RegTimeCnt / 1000; 226 | its.it_value.tv_nsec = 1000000 * (RegTimeCnt % 1000); 227 | if(its.it_value.tv_sec == 0 && its.it_value.tv_nsec == 0) 228 | { 229 | // this would inadvertently stop the timer 230 | its.it_value.tv_nsec = 1; 231 | } 232 | 233 | timers[TimerId].callback = Application_callback; 234 | timers[TimerId].pContext = pContext; 235 | timers[TimerId].nIsStopped = 0; 236 | 237 | timer_settime(timers[TimerId].handle, 0, &its, NULL); 238 | } 239 | 240 | /*! 241 | * \brief Stops a timer. 242 | * This function stops an already started timer. 243 | * 244 | * \param TimerId a valid timer ID. 245 | */ 246 | void phOsalNfc_Timer_Stop(uint32_t TimerId) 247 | { 248 | struct itimerspec its = {{0, 0}, {0, 0}}; 249 | 250 | if(TimerId >= MAX_NO_TIMERS) 251 | return; 252 | if(timers[TimerId].callback == NULL) 253 | return; 254 | if(timers[TimerId].nIsStopped == 1) 255 | return; 256 | 257 | timers[TimerId].nIsStopped = 1; 258 | timer_settime(timers[TimerId].handle, 0, &its, NULL); 259 | } 260 | 261 | /*! 262 | * \brief Deletes a timer. 263 | * This function deletes a timer. 264 | * 265 | * \param TimerId a valid timer ID. 266 | */ 267 | void phOsalNfc_Timer_Delete(uint32_t TimerId) 268 | { 269 | if(TimerId >= MAX_NO_TIMERS) 270 | return; 271 | if(timers[TimerId].callback == NULL) 272 | return; 273 | 274 | timer_delete(timers[TimerId].handle); 275 | 276 | timers[TimerId].callback = NULL; 277 | timers[TimerId].pContext = NULL; 278 | } 279 | -------------------------------------------------------------------------------- /Linux_x86/phOsalNfc_Utils.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * \file phOsalNfc_Utils.c 19 | * \brief OSAL Implementation. 20 | * 21 | * Project: NFC-FRI 1.1 22 | * 23 | * $Date: Wed Jun 24 10:35:10 2009 $ 24 | * $Author: ravindrau $ 25 | * $Revision: 1.1 $ 26 | * $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 $ 27 | * 28 | */ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | 36 | /*The function does a comparison of two strings and returns a non zero value 37 | if two strings are unequal*/ 38 | int phOsalNfc_MemCompare ( void *src, void *dest, unsigned int n ) 39 | { 40 | int8_t *b1 =(int8_t *)src; 41 | int8_t *b2 =(int8_t *)dest; 42 | int8_t diff = 0; 43 | #ifdef VERIFY_MEMORY 44 | if((NULL != src) && (NULL != dest)) 45 | #endif 46 | { 47 | for(;((n>0)&&(diff==0));n--,b1++,b2++) 48 | { 49 | diff = *b1 - *b2; 50 | } 51 | } 52 | return (int)diff; 53 | } 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_external_libnfc-nxp/978e1ce3fc660546a6e0b4432e2af95e1621ce82/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /inc/nfc_custom_config_example.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | /** 19 | * \file nfc_custom_config.h 20 | * \brief HAL Custom Configurations 21 | * 22 | * 23 | * \note This is the configuration header file of the HAL 4.0. custom configurable 24 | * parameters of the HAL 4.0 are provided in this file 25 | * 26 | * Project: NFC-FRI-1.1 / HAL4.0 27 | * 28 | * $Date: Fri Jun 11 16:44:31 2010 $ 29 | * $Author: ing04880 $ 30 | * $Revision: 1.11 $ 31 | * $Aliases: NFC_FRI1.1_WK1023_R35_1 $ 32 | * 33 | */ 34 | 35 | 36 | /*@{*/ 37 | #ifndef NFC_CUSTOM_CONFIG_H 38 | #define NFC_CUSTOM_CONFIG_H 39 | /*@}*/ 40 | 41 | 42 | /** 43 | * \name Hal 44 | * 45 | * File: \ref nfc_custom_config.h 46 | * 47 | */ 48 | 49 | 50 | /* 51 | ***************************************************************** 52 | ********************** CUSTOM MACROS ************************** 53 | ***************************************************************** 54 | */ 55 | 56 | /**< Max number of remote devices supported*/ 57 | #define MAX_REMOTE_DEVICES 0x10 58 | 59 | 60 | /**< Default Session ID for Initialisation */ 61 | #define DEFAULT_SESSION "NXP-NFC2" 62 | 63 | /** Resolution value for the timer, here the 64 | timer resolution is 100 milliseconds */ 65 | #define TIMER_RESOLUTION 100U 66 | 67 | /**< Defines connection time out value for LLC timer, 68 | 500 is in milliseconds */ 69 | #define LINK_CONNECTION_TIMEOUT 500U 70 | 71 | /**< Defines guard time out value for LLC timer, 72 | 250 is in milliseconds */ 73 | #define LINK_GUARD_TIMEOUT 250U 74 | 75 | /**< Macro to Enable SMX Feature During 76 | * Initialisation */ 77 | 78 | 79 | /* PLEASE NOTE: This Macro should be only enabled if there is a SMART_MX 80 | * Chip attached to the PN544. 81 | */ 82 | /* #define NXP_HAL_ENABLE_SMX */ 83 | 84 | 85 | 86 | /* PLEASE NOTE: Kindly change the DEFAULT_SESSION Macro for each of the 87 | * configuration change done for the below Macros 88 | */ 89 | 90 | /**< External Clock Request Configuration for the NFC Device, 91 | 0x00U -> No Clock Request, 92 | 0x01U -> Clock Request through CLKREQ pin (GPIO pin 2), 93 | 0x02U -> Clock Request through NXP_EVT_CLK_REQUEST Event, 94 | */ 95 | #define NXP_DEFAULT_CLK_REQUEST 0x00U 96 | 97 | /**< External Input Clock Setting for the NFC Device, 98 | 0x00U -> No Input Clock Required (Use the Xtal), 99 | 0x01U -> 13 MHZ, 100 | 0x02U -> 19.2 MHZ, 101 | 0x03U -> 26 MHZ, 102 | 0x04U -> 38.4 MHZ, 103 | 0x05U -> Custom (Set the Custome Clock Registry), 104 | */ 105 | #define NXP_DEFAULT_INPUT_CLK 0x00U 106 | 107 | 108 | 109 | #define NFC_DEV_HWCONF_DEFAULT 0xBCU 110 | 111 | /**< TX LDO Configuration 112 | 0x00 -> 00b 3.0 V, 113 | 0x01 -> 01b 3.0 V, 114 | 0x02 -> 10b 2.7 V, 115 | 0x03 -> 11b 3.3 V, 116 | 117 | */ 118 | #define NXP_DEFAULT_TX_LDO 0x00U 119 | 120 | 121 | /**< External Clock Request Configuration for the NFC Device, 122 | 0x00U -> No Power Request, 123 | 0x01U -> Power Request through CLKREQ pin (GPIO pin 2), 124 | 0x02U -> Power Request through PWR_REQUEST (GPIO Pin 3), 125 | */ 126 | #define NXP_UICC_PWR_REQUEST 0x00U 127 | 128 | /**< UICC Bit Rate Configuration 129 | 0x02U -> 212Kbits/Sec 130 | 0x04U -> 424Kbits/Sec 131 | 0x08U -> 828Kbits/Sec 132 | */ 133 | 134 | #define NXP_UICC_BIT_RATE 0x08U 135 | 136 | /**< Indicates PN544 Power Modes Configuration for the NFC Device, 137 | 0x00U -> PN544 stays in active bat mode 138 | (except when generating RF field) 139 | 0x01U -> PN544 goes in standby when possible otherwise 140 | stays in active bat mode 141 | 0x02U -> PN544 goes in idle mode as soon as it can 142 | (otherwise it is in active bat except when generating RF field) 143 | 0x03U -> PN544 goes in standby when possible otherwise goes in idle mode 144 | as soon as it can (otherwise it is in active bat except when 145 | generating RF field) 146 | */ 147 | 148 | #define NXP_SYSTEM_PWR_STATUS 0x01U 149 | 150 | 151 | /**< System Event Notification 152 | 0x01 Overcurrent 153 | 0x02 PMUVCC Switch 154 | 0x04 External RF Field 155 | 0x08 Memory Violation 156 | 0x10 Temperature Overheat 157 | */ 158 | 159 | #define NXP_SYSTEM_EVT_INFO 0x10U 160 | 161 | /**< NFCIP Active Mode Configuration 162 | 0x01 106 kbps 163 | 0x02 212 kbps 164 | 0x04 424 kbps 165 | */ 166 | 167 | #define NXP_NFCIP_ACTIVE_DEFAULT 0x01U 168 | 169 | 170 | 171 | /* Reset the Default values of Host Link Timers */ 172 | /* Macro to Enable the Host Side Link Timeout Configuration 173 | * 0x00 ----> Default Pre-defined Configuration; 174 | * 0x01 ----> Update only the Host Link Guard Timeout Configuration; 175 | * 0x03 ----> Update Both the Host Link Guard Timeout 176 | and ACK Timeout Configuration; 177 | */ 178 | #define HOST_LINK_TIMEOUT 0x00U 179 | 180 | 181 | #define NXP_NFC_LINK_GRD_CFG_DEFAULT 0x0032U 182 | 183 | 184 | #define NXP_NFC_LINK_ACK_CFG_DEFAULT 0x0005U 185 | 186 | 187 | /* Macro to Enable the Interface Character Timeout Configuration 188 | * 0x00 ----> Default Pre-defined Configuration; 189 | * 0x01 ----> Update the IFC Timeout Default Configuration; 190 | */ 191 | #define NXP_NFC_IFC_TIMEOUT 0x00 192 | 193 | 194 | #define NXP_NFC_IFC_CONFIG_DEFAULT 0x203AU 195 | 196 | 197 | #define NXP_NFCIP_PSL_BRS_DEFAULT 0x00U 198 | 199 | 200 | #endif /* NFC_CUSTOM_CONFIG_H */ 201 | -------------------------------------------------------------------------------- /inc/phDbgTrace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | /** 19 | * \file phDbgTrace.h 20 | * Project: NFC-FRI-1.1 / HAL4.0 21 | * 22 | * $Date: Tue Apr 28 11:48:33 2009 $ 23 | * $Author: ing08203 $ 24 | * $Revision: 1.17 $ 25 | * $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 $ 26 | * 27 | */ 28 | 29 | /*@{*/ 30 | #ifndef PHDBGTRACE_H 31 | #define PHDBGTRACE_H 32 | /*@}*/ 33 | 34 | #include 35 | 36 | 37 | #ifdef PHDBG_TRACES 38 | #define MAX_TRACE_BUFFER 300 39 | 40 | #ifndef PHDBG_TRACES_LEVEL_0 41 | #ifndef PHDBG_TRACES_LEVEL_1 42 | #ifndef PHDBG_TRACES_LEVEL_2 43 | #define PHDBG_TRACES_LEVEL_0 44 | #endif 45 | #endif 46 | #endif 47 | 48 | extern char phOsalNfc_DbgTraceBuffer[]; 49 | 50 | #ifdef PHDBG_TRACES_LEVEL_0 51 | 52 | /*indicates an error that causes a program to abort.*/ 53 | #define PHDBG_FATAL_ERROR(Str) {\ 54 | snprintf(phOsalNfc_DbgTraceBuffer,MAX_TRACE_BUFFER, \ 55 | "FATAL ERROR in Module :%s\n",__FILE__);\ 56 | phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ 57 | snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ 58 | "In Function:%s\n",__FUNCTION__ ); \ 59 | phOsalNfc_DbgString (phOsalNfc_DbgTraceBuffer);\ 60 | } 61 | 62 | #define PHDBG_CRITICAL_ERROR(Str) {\ 63 | snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ 64 | "CRITICAL ERROR in Module :%s\n",__FILE__);\ 65 | phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ 66 | snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ 67 | "In Function:%s\n",__FUNCTION__ ); \ 68 | phOsalNfc_DbgString (phOsalNfc_DbgTraceBuffer);\ 69 | } 70 | #define PHDBG_WARNING(Str) 71 | #define PHDBG_INFO(Str) 72 | #endif /*End of PHDBG_TRACES_LEVEL_0 */ 73 | 74 | #ifdef PHDBG_TRACES_LEVEL_1 75 | 76 | /*indicates an error that causes a program to abort.*/ 77 | #define PHDBG_FATAL_ERROR(Str) {\ 78 | snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ 79 | "FATAL ERROR in Module :%s\n",__FILE__);\ 80 | phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ 81 | snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ 82 | "In Function:%s\n",__FUNCTION__ ); \ 83 | phOsalNfc_DbgString (phOsalNfc_DbgTraceBuffer);\ 84 | } 85 | 86 | #define PHDBG_CRITICAL_ERROR(Str) {\ 87 | snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ 88 | "CRITICAL ERROR in Module :%s\n",__FILE__);\ 89 | phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ 90 | snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ 91 | "In Function:%s\n",__FUNCTION__ ); \ 92 | phOsalNfc_DbgString (phOsalNfc_DbgTraceBuffer);\ 93 | } 94 | /*Normally this macro shall be used indicate system state that might cause problems in future.*/ 95 | #define PHDBG_WARNING(Str) {\ 96 | snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ 97 | "WARNING :%s\n",__FILE__);\ 98 | phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ 99 | phOsalNfc_DbgString (Str);\ 100 | phOsalNfc_DbgString ("\n");\ 101 | } 102 | #define PHDBG_INFO(Str) 103 | #endif /*End of PHDBG_TRACES_LEVEL_1 */ 104 | 105 | #ifdef PHDBG_TRACES_LEVEL_2 106 | 107 | /*indicates an error that causes a program to abort.*/ 108 | #define PHDBG_FATAL_ERROR(Str) {\ 109 | snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ 110 | "FATAL ERROR in Module :%s\n",__FILE__);\ 111 | phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ 112 | snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ 113 | "In Function:%s\n",__FUNCTION__ ); \ 114 | phOsalNfc_DbgString (phOsalNfc_DbgTraceBuffer);\ 115 | } 116 | 117 | #define PHDBG_CRITICAL_ERROR(Str) {\ 118 | snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ 119 | "CRITICAL ERROR in Module :%s\n",__FILE__);\ 120 | phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ 121 | snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ 122 | "In Function:%s\n",__FUNCTION__ ); \ 123 | phOsalNfc_DbgString (phOsalNfc_DbgTraceBuffer);\ 124 | } 125 | /*Normally this macro shall be used indicate system state that might cause problems in future.*/ 126 | #define PHDBG_WARNING(Str) {\ 127 | snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ 128 | "WARNING :%s\n",__FILE__);\ 129 | phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ 130 | phOsalNfc_DbgString (Str);\ 131 | phOsalNfc_DbgString ("\n");\ 132 | } 133 | 134 | #define PHDBG_INFO(Str) {\ 135 | snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ 136 | "DBG INFO :%s\n",__FILE__);\ 137 | phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ 138 | phOsalNfc_DbgString (Str);\ 139 | phOsalNfc_DbgString ("\n");\ 140 | } 141 | 142 | 143 | 144 | #endif /*End of PHDBG_TRACES_LEVEL_2 */ 145 | #else 146 | #define PHDBG_FATAL_ERROR(Str) 147 | #define PHDBG_CRITICAL_ERROR(Str) 148 | #define PHDBG_WARNING(Str) 149 | #define PHDBG_INFO(Str) 150 | 151 | 152 | #endif /*end of DEBUG trace*/ 153 | #endif /* end of PHDBGTRACE_H */ 154 | -------------------------------------------------------------------------------- /inc/phNfcCompId.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * \file phNfcCompId.h 19 | * \brief NFC Component ID Values - Used for Function Return Codes 20 | * 21 | * Project: NFC MW / HAL 22 | * 23 | * $Date: Thu Mar 12 12:00:30 2009 $ 24 | * $Author: ing04880 $ 25 | * $Revision: 1.6 $ 26 | * $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 $ 27 | * 28 | */ 29 | 30 | #ifndef PHNFCCOMPID_H /* */ 31 | #define PHNFCCOMPID_H /* */ 32 | 33 | #ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */ 34 | 35 | /** 36 | * \name NFC Comp. ID 37 | * 38 | * File: \ref phNfcCompId.h 39 | * 40 | */ 41 | /*@{*/ 42 | #define PHNFCCOMPID_FILEREVISION "$Revision: 1.6 $" /**< \ingroup grp_file_attributes */ 43 | #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 */ 44 | /*@}*/ 45 | 46 | #endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */ 47 | 48 | /** 49 | * \ingroup grp_comp_id 50 | * 51 | * \name Component IDs 52 | * 53 | * IDs for all NFC components. Combined with the Status Code they build the value (status) 54 | * returned by each function. 55 | * 56 | * ID Number Spaces: 57 | * - 01..1F: HAL 58 | * - 20..3F: NFC-MW (Local Device) 59 | * - 40..5F: NFC-MW (Remote Device) 60 | * . 61 | * 62 | * \note The value \ref CID_NFC_NONE does not exist for Component IDs. Do not use this value except 63 | * for \ref NFCSTATUS_SUCCESS. The enumeration function uses \ref CID_NFC_NONE 64 | * to mark unassigned \ref phHal_sHwReference_t "Hardware References". 65 | * 66 | * \if hal 67 | * \sa \ref phHalNfc_Enumerate 68 | * \endif 69 | */ 70 | /*@{*/ 71 | #define CID_NFC_NONE 0x00 /**< \ingroup grp_comp_id 72 | Unassigned or doesn't apply (see \ref NFCSTATUS_SUCCESS). */ 73 | #define CID_NFC_DAL 0x01 /**< \ingroup grp_comp_id 74 | Driver Abstraction Layer 75 | \if hal (\ref grp_subcomponents) \endif . */ 76 | #define CID_NFC_LLC 0x07 /**< \ingroup grp_comp_id 77 | Logical Link Control Layer 78 | \if hal (\ref grp_subcomponents) \endif . */ 79 | #define CID_NFC_HCI 0x08 /**< \ingroup grp_comp_id 80 | Host Control Interface Layer 81 | \if hal (\ref grp_subcomponents) \endif . */ 82 | #define CID_NFC_DNLD 0x09 /**< \ingroup grp_comp_id 83 | Firmware Download Management Layer 84 | \if hal (\ref grp_subcomponents) \endif . */ 85 | #define CID_NFC_HAL 0x10 /**< \ingroup grp_comp_id 86 | Hardware Abstraction Layer \if hal (\ref grp_hal_common) \endif . */ 87 | #define CID_FRI_NFC_OVR_HAL 0x20 /**< \ingroup grp_comp_id 88 | NFC-Device, HAL-based. */ 89 | #define CID_FRI_NFC_NDEF_RECORD 0x22 /**< \ingroup grp_comp_id 90 | NDEF Record Tools Library. */ 91 | #define CID_FRI_NFC_NDEF_MAP 0x23 /**< \ingroup grp_comp_id 92 | NDEF Mapping. */ 93 | #define CID_FRI_NFC_NDEF_REGISTRY 0x24 /**< \ingroup grp_comp_id 94 | NDEF_REGISTRY. */ 95 | #define CID_FRI_NFC_AUTO_DEV_DIS 0x25 /**< \ingroup grp_comp_id 96 | Automatic Device Discovery. */ 97 | #define CID_FRI_NFC_NDEF_SMTCRDFMT 0x26 /**< \ingroup grp_comp_id 98 | Smart Card Formatting */ 99 | #define CID_FRI_NFC_LLCP 0x27 /**< \ingroup grp_comp_id 100 | LLCP Core. */ 101 | #define CID_FRI_NFC_LLCP_MAC 0x28 /**< \ingroup grp_comp_id 102 | LLCP Mac Mappings. */ 103 | #define CID_FRI_NFC_LLCP_TRANSPORT 0x29 /**< \ingroup grp_comp_id 104 | LLCP Transport. */ 105 | #define CID_NFC_LIB 0x30 /**< \ingroup grp_comp_id 106 | NFC Library Layer \if hal (\ref grp_hal_common) \endif . */ 107 | #define CID_MAX_VALUE 0xF0 /**< \ingroup grp_comp_id 108 | The maximum CID value that is defined. */ 109 | 110 | /*@}*/ 111 | 112 | #endif /* PHNFCCOMPID_H */ 113 | -------------------------------------------------------------------------------- /inc/phNfcIoctlCode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | /** 19 | * \file phNfcIoctlCode.h 20 | * \brief IOCTL Code Definition. 21 | * 22 | * This file contains control codes for the IOCTL function. 23 | * 24 | * 25 | * Project: NFC MW / HAL 26 | * 27 | * $Date: Wed May 26 16:44:03 2010 $ 28 | * $Author: ing04880 $ 29 | * $Revision: 1.11 $ 30 | * $Aliases: NFC_FRI1.1_WK1023_R35_1 $ 31 | * 32 | */ 33 | 34 | 35 | #ifndef PHNFCIOCTLCODE_H /* */ 36 | #define PHNFCIOCTLCODE_H /* */ 37 | 38 | /** 39 | * \name IOCTL Codes 40 | * 41 | * File: \ref phNfcIoctlCode.h 42 | * 43 | */ 44 | /*@{*/ 45 | #define PHNFCIOCTLCODE_FILEREVISION "$Revision: 1.11 $" /**< \ingroup grp_file_attributes */ 46 | #define PHNFCIOCTLCODE_FILEALIASES "$Aliases: NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ 47 | /*@}*/ 48 | 49 | 50 | 51 | /* The Return Status for the IOCTL Operation */ 52 | #define NFC_IO_SUCCESS (0x90U) 53 | #define NFC_IO_ERROR (0x9FU) 54 | 55 | 56 | 57 | 58 | #define NFC_GPIO_READ (0xF82AU) 59 | 60 | #define NFC_FW_DOWNLOAD (0x09FFU) 61 | #define NFC_FW_DOWNLOAD_CHECK (0x09F7U) 62 | 63 | #define NFC_ANTENNA_CWG (0x989FU) 64 | 65 | 66 | /* The PN544 DEVICE Management Control : 0x90*/ 67 | #define DEVMGMT_CTL (0x90U) 68 | 69 | 70 | /* Ioctl codes for PN544 System Tests */ 71 | #define DEVMGMT_TEST_MASK (0xFFU) 72 | #define DEVMGMT_ANTENNA_TEST ((DEVMGMT_CTL << 8)|(0x20U)) 73 | #define DEVMGMT_SWP_TEST ((DEVMGMT_CTL << 8)|(0x21U)) 74 | #define DEVMGMT_NFCWI_TEST ((DEVMGMT_CTL << 8)|(0x22U)) 75 | #define DEVMGMT_PRBS_TEST ((DEVMGMT_CTL << 8)|(0x25U)) 76 | 77 | #define NFC_MEM_READ (0xD0U) 78 | #define NFC_MEM_WRITE (0xD1U) 79 | 80 | #define NFC_SWITCH_SWP_MODE (0xEE) 81 | 82 | 83 | #if 0 84 | #define DEVMGMT_HOSTINTERFACE_TEST ((DEVMGMT_CTL << 8)|(0x23U)) 85 | #endif 86 | 87 | 88 | #endif /* PHNFCIOCTLCODE */ 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /inc/phNfcLlcpTypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * \file phNfcLlcpTypes.h 19 | * \brief NFC LLCP public types 20 | * 21 | * Project: NFC-FRI 22 | * 23 | */ 24 | 25 | 26 | #ifndef PHNFCLLCPTYPES_H /* */ 27 | #define PHNFCLLCPTYPES_H /* */ 28 | 29 | #include 30 | #include 31 | 32 | /*=========== CONSTANTS ===========*/ 33 | 34 | /** 35 | * \name LLCP default parameters. 36 | * 37 | * Definitions for use when wanting to use default LLCP parameter values. 38 | * 39 | */ 40 | /*@{*/ 41 | #define PHFRINFC_LLCP_MIU_DEFAULT 128 /**< Default MIU value (in bytes).*/ 42 | #define PHFRINFC_LLCP_WKS_DEFAULT 1 /**< Default WKS value (bitfield).*/ 43 | #define PHFRINFC_LLCP_LTO_DEFAULT 10 /**< Default LTO value (in step of 10ms).*/ 44 | #define PHFRINFC_LLCP_RW_DEFAULT 1 /**< Default RW value (in frames).*/ 45 | #define PHFRINFC_LLCP_OPTION_DEFAULT 0 /**< Default OPTION value (in frames).*/ 46 | #define PHFRINFC_LLCP_MIUX_DEFAULT 0 /**< Default MIUX value (in bytes) */ 47 | #define PHFRINFC_LLCP_MIUX_MAX 0x7FF /**< Max MIUX value (in bytes) */ 48 | #define PHFRINFC_LLCP_PDU_HEADER_MAX 3 /**< Max size of PDU header (in bytes) */ 49 | #define PHFRINFC_LLCP_SN_MAX_LENGTH 255 /**< Max length value for the Service Name */ 50 | #define PHFRINFC_LLCP_RW_MAX 15 /**< Max RW value (in frames).*/ 51 | /*@}*/ 52 | 53 | /** 54 | * \name LLCP config parameters. 55 | * 56 | * Definitions used for internal LLCP configuration. 57 | * 58 | */ 59 | /*@{*/ 60 | #define PHFRINFC_LLCP_NB_SOCKET_MAX 10 /**< Max.number of simultaneous sockets */ 61 | #define PHFRINFC_LLCP_SNL_RESPONSE_MAX 256 /**< Max.number of simultaneous discovery requests */ 62 | /*@}*/ 63 | 64 | /** 65 | * \internal 66 | * \name Fixed value for ERROR op code. 67 | * 68 | */ 69 | /*@{*/ 70 | #define PHFRINFC_LLCP_ERR_DISCONNECTED 0x00 71 | #define PHFRINFC_LLCP_ERR_FRAME_REJECTED 0x01 72 | #define PHFRINFC_LLCP_ERR_BUSY_CONDITION 0x02 73 | #define PHFRINFC_LLCP_ERR_NOT_BUSY_CONDITION 0x03 74 | 75 | /** 76 | * \internal 77 | * \name Fixed value for DM op code. 78 | * 79 | */ 80 | /*@{*/ 81 | #define PHFRINFC_LLCP_DM_OPCODE_DISCONNECTED 0x00 82 | #define PHFRINFC_LLCP_DM_OPCODE_SAP_NOT_ACTIVE 0x01 83 | #define PHFRINFC_LLCP_DM_OPCODE_SAP_NOT_FOUND 0x02 84 | #define PHFRINFC_LLCP_DM_OPCODE_CONNECT_REJECTED 0x03 85 | #define PHFRINFC_LLCP_DM_OPCODE_CONNECT_NOT_ACCEPTED 0x20 86 | #define PHFRINFC_LLCP_DM_OPCODE_SOCKET_NOT_AVAILABLE 0x21 87 | 88 | 89 | /*========== ENUMERATES ===========*/ 90 | 91 | /* Enum reperesents the different LLCP Link status*/ 92 | typedef enum phFriNfc_LlcpMac_eLinkStatus 93 | { 94 | phFriNfc_LlcpMac_eLinkDefault, 95 | phFriNfc_LlcpMac_eLinkActivated, 96 | phFriNfc_LlcpMac_eLinkDeactivated 97 | }phFriNfc_LlcpMac_eLinkStatus_t; 98 | 99 | /* Enum represents the different Socket types */ 100 | typedef enum phFriNfc_LlcpTransport_eSocketType 101 | { 102 | phFriNfc_LlcpTransport_eDefaultType, 103 | phFriNfc_LlcpTransport_eConnectionOriented, 104 | phFriNfc_LlcpTransport_eConnectionLess 105 | }phFriNfc_LlcpTransport_eSocketType_t; 106 | 107 | 108 | /*========== STRUCTURES ===========*/ 109 | 110 | typedef struct phFriNfc_LlcpTransport_sSocketOptions 111 | { 112 | /** The remote Maximum Information Unit Extension (NOTE: this is MIUX, not MIU !)*/ 113 | uint16_t miu; 114 | 115 | /** The Receive Window size (4 bits)*/ 116 | uint8_t rw; 117 | 118 | }phFriNfc_LlcpTransport_sSocketOptions_t; 119 | 120 | typedef struct phFriNfc_Llcp_sLinkParameters 121 | { 122 | /** The remote Maximum Information Unit (NOTE: this is MIU, not MIUX !)*/ 123 | uint16_t miu; 124 | 125 | /** The remote Well-Known Services*/ 126 | uint16_t wks; 127 | 128 | /** The remote Link TimeOut (in 1/100s)*/ 129 | uint8_t lto; 130 | 131 | /** The remote options*/ 132 | uint8_t option; 133 | 134 | } phFriNfc_Llcp_sLinkParameters_t; 135 | 136 | #endif 137 | 138 | /* EOF */ 139 | -------------------------------------------------------------------------------- /inc/phNfcTypes.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_external_libnfc-nxp/978e1ce3fc660546a6e0b4432e2af95e1621ce82/inc/phNfcTypes.h -------------------------------------------------------------------------------- /src/nfc_osal_deferred_call.h: -------------------------------------------------------------------------------- 1 | #ifndef __NFC_OSAL_DEFERRED_CALL_H_ 2 | #define __NFC_OSAL_DEFERRED_CALL_H_ 3 | 4 | /** 5 | * \ingroup grp_osal_nfc 6 | *\brief Deferred call declaration. 7 | * This type of API is called from ClientApplication ( main thread) to notify 8 | * specific callback. 9 | */ 10 | typedef pphLibNfc_DeferredCallback_t nfc_osal_def_call_t; 11 | 12 | /** 13 | * \ingroup grp_osal_nfc 14 | *\brief Deferred message specific info declaration. 15 | * This type information packed as WPARAM when \ref PHOSALNFC_MESSAGE_BASE type 16 | *windows message is posted to main thread. 17 | */ 18 | typedef phLibNfc_DeferredCall_t nfc_osal_def_call_msg_t; 19 | 20 | /** 21 | * \ingroup grp_osal_nfc 22 | *\brief Deferred call declaration. 23 | * This Deferred call post message of type \ref PH_OSALNFC_TIMER_MSG along with 24 | * timer specific details.ain thread,which is responsible for timer callback notification 25 | * consumes of this message and notifies respctive timer callback. 26 | *\note: This API packs upper timer specific callback notification information and post 27 | *ref\PHOSALNFC_MESSAGE_BASE to main thread via windows post messaging mechanism. 28 | */ 29 | 30 | void nfc_osal_deferred_call(nfc_osal_def_call_t func, void *param); 31 | 32 | #endif -------------------------------------------------------------------------------- /src/phDal4Nfc_DeferredCall.h: -------------------------------------------------------------------------------- 1 | #ifndef PHDAL4NFC_DEFERREDCALL_H 2 | #define PHDAL4NFC_DEFERREDCALL_H 3 | 4 | #ifdef PH_NFC_CUSTOMINTEGRATION 5 | #include 6 | #else 7 | 8 | #ifdef _DAL_4_NFC_C 9 | #define _ext_ 10 | #else 11 | #define _ext_ extern 12 | #endif 13 | 14 | typedef pphLibNfc_DeferredCallback_t pphDal4Nfc_Deferred_Call_t; 15 | 16 | typedef phLibNfc_DeferredCall_t phDal4Nfc_DeferredCall_Msg_t; 17 | 18 | #ifndef WIN32 19 | 20 | #ifdef USE_MQ_MESSAGE_QUEUE 21 | #include 22 | #define MQ_NAME_IDENTIFIER "/nfc_queue" 23 | 24 | _ext_ const struct mq_attr MQ_QUEUE_ATTRIBUTES 25 | #ifdef _DAL_4_NFC_C 26 | = { 0, /* flags */ 27 | 10, /* max number of messages on queue */ 28 | sizeof(phDal4Nfc_DeferredCall_Msg_t), /* max message size in bytes */ 29 | 0 /* number of messages currently in the queue */ 30 | } 31 | #endif 32 | ; 33 | #endif 34 | 35 | #endif 36 | 37 | void phDal4Nfc_DeferredCall(pphDal4Nfc_Deferred_Call_t func, void *param); 38 | #endif 39 | #endif 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/phDal4Nfc_messageQueueLib.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * \file phDalNfc_messageQueueLib.h 19 | * \brief DAL independant message queue implementation for android (can be used under linux too) 20 | * 21 | * Project: Trusted NFC Linux Lignt 22 | * 23 | * $Date: 13 aug 2009 24 | * $Author: Jonathan roux 25 | * $Revision: 1.0 $ 26 | * 27 | */ 28 | #ifndef PHDAL4NFC_MESSAGEQUEUE_H 29 | #define PHDAL4NFC_MESSAGEQUEUE_H 30 | 31 | #ifndef WIN32 32 | #ifdef ANDROID 33 | #include 34 | #else 35 | #include 36 | #endif 37 | 38 | typedef struct phDal4Nfc_Message_Wrapper 39 | { 40 | long mtype; 41 | phLibNfc_Message_t msg; 42 | } phDal4Nfc_Message_Wrapper_t; 43 | 44 | intptr_t phDal4Nfc_msgget(key_t key, int msgflg); 45 | int phDal4Nfc_msgctl(intptr_t msqid, int cmd, void *buf); 46 | int phDal4Nfc_msgsnd(intptr_t msqid, void * msgp, size_t msgsz, int msgflg); 47 | int phDal4Nfc_msgrcv(intptr_t msqid, void * msgp, size_t msgsz, long msgtyp, int msgflg); 48 | #endif 49 | 50 | #endif /* PHDAL4NFC_MESSAGEQUEUE_H */ 51 | -------------------------------------------------------------------------------- /src/phDnldNfc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /*! 18 | * =========================================================================== * 19 | * * 20 | * * 21 | * \file phDnldNfc.h * 22 | * \brief Download Mgmt Header for the Generic Download Management. * 23 | * * 24 | * * 25 | * Project: NFC-FRI-1.1 * 26 | * * 27 | * $Date: Thu Aug 26 15:39:56 2010 $ * 28 | * $Author: ing04880 $ * 29 | * $Revision: 1.7 $ * 30 | * $Aliases: $ 31 | * * 32 | * =========================================================================== * 33 | */ 34 | 35 | 36 | /*@{*/ 37 | 38 | #ifndef PHDNLDNFC_H 39 | #define PHDNLDNFC_H 40 | 41 | /*@}*/ 42 | /** 43 | * \name Download Mgmt 44 | * 45 | * File: \ref phDnldNfc.h 46 | * 47 | */ 48 | /*@{*/ 49 | #define PH_DNLDNFC_FILEREVISION "$Revision: 1.7 $" /**< \ingroup grp_file_attributes */ 50 | #define PH_DNLDNFC_FILEALIASES "$Aliases: $" /**< \ingroup grp_file_attributes */ 51 | /*@}*/ 52 | 53 | /* 54 | ################################################################################ 55 | ***************************** Header File Inclusion **************************** 56 | ################################################################################ 57 | */ 58 | 59 | #include 60 | #include 61 | 62 | /* 63 | ################################################################################ 64 | ****************************** Macro Definitions ******************************* 65 | ################################################################################ 66 | */ 67 | 68 | 69 | /* 70 | ################################################################################ 71 | ******************** Enumeration and Structure Definition ********************** 72 | ################################################################################ 73 | */ 74 | 75 | #ifndef NXP_FW_PARAM 76 | extern const uint8_t *nxp_nfc_fw; 77 | #endif /* NXP_FW_PARAM */ 78 | 79 | 80 | 81 | 82 | /* 83 | ################################################################################ 84 | *********************** Function Prototype Declaration ************************* 85 | ################################################################################ 86 | */ 87 | 88 | /** 89 | * \ingroup grp_hci_nfc 90 | * 91 | * The phDnldNfc_Upgrade function Upgrades the firmware of 92 | * connected NFC Device with the data provided. 93 | * 94 | * \param[in] pHwRef pHwRef is the Information of 95 | * the Device Interface Link . 96 | * \param[in] pHalNotify Upper layer Notification function 97 | * pointer. 98 | * \param[in] psContext psContext is the context of 99 | * the Upper Layer. 100 | * 101 | * \retval NFCSTATUS_PENDING Upgrade of Download Layer is in Progress. 102 | * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 103 | * could not be interpreted properly. 104 | * \retval Other errors Errors related to the other layers 105 | * 106 | */ 107 | 108 | extern 109 | NFCSTATUS 110 | phDnldNfc_Upgrade ( 111 | phHal_sHwReference_t *pHwRef, 112 | #ifdef NXP_FW_PARAM 113 | uint8_t *nxp_nfc_fw, 114 | uint32_t fw_length, 115 | #endif 116 | pphNfcIF_Notification_CB_t upgrade_complete, 117 | void *context 118 | ); 119 | 120 | 121 | #if !defined (NXP_FW_INTEGRITY_VERIFY) 122 | 123 | extern 124 | NFCSTATUS 125 | phDnldNfc_Run_Check( 126 | phHal_sHwReference_t *pHwRef 127 | #ifdef NXP_FW_PARAM 128 | ,uint8_t *nxp_nfc_fw 129 | uint32_t fw_length 130 | #endif 131 | ); 132 | #endif /* #if !defined (NXP_FW_INTEGRITY_VERIFY) */ 133 | 134 | 135 | #endif /* PHDNLDNFC_H */ 136 | 137 | 138 | -------------------------------------------------------------------------------- /src/phFriNfc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /*! 18 | * \file phFriNfc.h 19 | * \brief NFC FRI Main Header. 20 | * 21 | * Project: NFC-FRI 22 | * 23 | * $Date: Mon Dec 13 14:14:13 2010 $ 24 | * $Author: ing02260 $ 25 | * $Revision: 1.20 $ 26 | * $Aliases: $ 27 | * 28 | */ 29 | 30 | #ifndef PHFRINFC_H /* */ 31 | #define PHFRINFC_H /* */ 32 | #include 33 | #include 34 | 35 | #define PH_HAL4_ENABLE 36 | 37 | #ifdef PH_HAL4_ENABLE 38 | #include 39 | #define LOCK_BITS_CHECK_ENABLE 40 | #endif 41 | 42 | #define FRINFC_READONLY_NDEF 43 | 44 | #ifdef DISABLE_MIFARE_MAPPING 45 | #define PH_FRINFC_MAP_MIFAREUL_DISABLED 46 | #define PH_FRINFC_MAP_MIFARESTD_DISABLED 47 | #define PH_FRINFC_MAP_DESFIRE_DISABLED 48 | #else 49 | #define PH_NDEF_MIFARE_ULC 50 | #endif 51 | 52 | #ifdef DISABLE_FELICA_MAPPING 53 | #define PH_FRINFC_MAP_FELICA_DISABLED 54 | #endif 55 | 56 | #ifdef DISABLE_JEWEL_MAPPING 57 | #define PH_FRINFC_MAP_TOPAZ_DISABLED 58 | #define PH_FRINFC_MAP_TOPAZ_DYNAMIC_DISABLED 59 | #endif 60 | 61 | #ifdef DISABLE_ISO15693_MAPPING 62 | #define PH_FRINFC_MAP_ISO15693_DISABLED 63 | #endif 64 | 65 | 66 | #ifdef DISABLE_FORMAT 67 | #define PH_FRINFC_FMT_DESFIRE_DISABLED 68 | #define PH_FRINFC_FMT_MIFAREUL_DISABLED 69 | #define PH_FRINFC_FMT_MIFARESTD_DISABLED 70 | #define PH_FRINFC_FMT_ISO15693_DISABLED 71 | #endif /* #ifdef DISABLE_FORMAT */ 72 | 73 | #define PH_FRINFC_FMT_TOPAZ_DISABLED 74 | 75 | /*! 76 | * \name NFC FRI Main Header 77 | * 78 | * File: \ref phFriNfc.h 79 | * 80 | */ 81 | /*@{*/ 82 | 83 | #define PH_FRINFC_FILEREVISION "$Revision: 1.20 $" /**< \ingroup grp_file_attributes */ 84 | #define PH_FRINFC_FILEALIASES "$Aliases: $" /**< \ingroup grp_file_attributes */ 85 | 86 | /*@}*/ 87 | 88 | 89 | /*! 90 | * \ingroup grp_fri_nfc_common 91 | * 92 | * \brief \copydoc page_cb Completion Routine 93 | * 94 | * NFC-FRI components that work in an overlapped style need to provide a function that is compatible 95 | * to this definition.\n\n 96 | * It is \b mandatory to define such a routine for components that interact with other components up or 97 | * down the stack. Moreover, such components shall provide a function within their API to enable the 98 | * setting of the \b Completion \b Routine address and parameters. 99 | * 100 | * \par First Parameter: Context 101 | * Set to the address of the called instance (component instance context structure). For instance, 102 | * a component that needs to give control to a component up the stack needs to call the completion 103 | * routine of the \b upper component. The value to assign to this parameter is the \b address of 104 | * the context structure instance of the called component. Such a structure usually contains all 105 | * variables, data or state information a component member needs for operation. The address of the 106 | * upper instance must be known by the lower (completing) instance. The mechanism to ensure that this 107 | * information is present involves the structure \ref phFriNfc_CplRt_t . See its documentation for 108 | * further information. 109 | * 110 | * \par Second Parameter: Status Value 111 | * The lower layer hands over the completion status via this parameter. The completion 112 | * routine that has been called needs to process the status in a way that is comparable to what 113 | * a regular function return value would require. 114 | * 115 | * \note The prototype of the component's \b Process(ing) functions has to be compatible to this 116 | * function pointer declaration for components interacting with others. In other cases, where 117 | * there is no interaction or asynchronous processing the definition of the \b Process(ing) 118 | * function can be arbitrary, if present at all. 119 | */ 120 | 121 | typedef void (*pphFriNfc_Cr_t)(void*, NFCSTATUS); 122 | 123 | 124 | /*! 125 | * \ingroup grp_fri_nfc_common 126 | * 127 | * \brief Completion Routine structure 128 | * 129 | * This structure finds itself within each component that requires to report completion 130 | * to an upper (calling) component.\n\n 131 | * Depending on the actual implementation (static or dynamic completion information) the stack 132 | * initialisation \b or the calling component needs to inform the initialised \b or called component 133 | * about the completion path. This information is submitted via this structure. 134 | * 135 | */ 136 | typedef struct phFriNfc_CplRt 137 | { 138 | pphFriNfc_Cr_t CompletionRoutine; /*!< Address of the upper Layer's \b Process(ing) function to call upon completion. 139 | * The stack initialiser (or depending on the implementation: the calling component) 140 | * needs to set this member to the address of the function that needs to be within 141 | * the completion path: A calling component would give its own processing function 142 | * address to the lower layer. 143 | */ 144 | void *Context; /*!< Instance address (context) parameter. 145 | * The stack initialiser (or depending on the implementation: the calling component) 146 | * needs to set this member to the address of the component context structure instance 147 | * within the completion path: A calling component would give its own instance address 148 | * to the lower layer. 149 | */ 150 | } phFriNfc_CplRt_t; 151 | 152 | 153 | #define NFCSTATUS_INVALID_DEVICE_REQUEST (0x10F5) 154 | 155 | 156 | #endif /* __PHFRINFC_H__ */ 157 | -------------------------------------------------------------------------------- /src/phFriNfc_FelicaMap.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_external_libnfc-nxp/978e1ce3fc660546a6e0b4432e2af95e1621ce82/src/phFriNfc_FelicaMap.c -------------------------------------------------------------------------------- /src/phFriNfc_ISO15693Format.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /*! 18 | * \file phFriNfc_ISO15693Format.h 19 | * \brief ISO-15693 Smart card formatting. 20 | * 21 | * Project: NFC-FRI 22 | * 23 | * $Date: $ 24 | * $Author: ing02260 $ 25 | * $Revision: 1.0 $ 26 | * $Aliases: $ 27 | * 28 | */ 29 | 30 | #ifndef PHFRINFC_ISO15693FORMAT_H 31 | #define PHFRINFC_ISO15693FORMAT_H 32 | 33 | /****************************** Macro definitions start ********************************/ 34 | 35 | /****************************** Macro definitions end ********************************/ 36 | 37 | /****************************** Data structures start ********************************/ 38 | 39 | /****************************** Data structures end ********************************/ 40 | 41 | /*********************** External function declarations start ***********************/ 42 | /*! 43 | * \brief \copydoc page_reg Resets the component instance to the initial state and lets the component forget about 44 | * the list of registered items. Moreover, the lower device is set. 45 | * 46 | * \param[in] NdefSmtCrdFmt Pointer to a valid or uninitialized instance of \ref phFriNfc_sNdefSmtCrdFmt_t. 47 | * 48 | * \note This function has to be called at the beginning, after creating an instance of 49 | * \ref phFriNfc_sNdefSmtCrdFmt_t. Use this function to reset the instance of smart card 50 | formatting context variables. 51 | */ 52 | void 53 | phFriNfc_ISO15693_FmtReset ( 54 | phFriNfc_sNdefSmtCrdFmt_t *psNdefSmtCrdFmt); 55 | 56 | /*! 57 | * \ingroup grp_fri_smart_card_formatting 58 | * 59 | * \brief Initiates the card formatting procedure for Remote Smart Card Type. 60 | * 61 | * \copydoc page_ovr The function initiates and formats the ISO-15693 Card.After this 62 | * operation,remote card would be properly initialized and 63 | * Ndef Compliant.Depending upon the different card type, this 64 | * function handles formatting procedure.This function also handles 65 | * the different recovery procedures for different types of the cards. 66 | * For both Format and Recovery Management same API is used. 67 | * 68 | * \param[in] phFriNfc_sNdefSmartCardFmt_t Pointer to a valid instance of the \ref phFriNfc_sNdefSmartCardFmt_t 69 | * structure describing the component context. 70 | * 71 | * \retval NFCSTATUS_SUCCESS Card formatting has been successfully completed. 72 | * \retval NFCSTATUS_PENDING The action has been successfully triggered. 73 | * \retval NFCSTATUS_FORMAT_ERROR Error occured during the formatting procedure. 74 | * \retval NFCSTATUS_INVALID_REMOTE_DEVICE Card Type is unsupported. 75 | * \retval NFCSTATUS_INVALID_DEVICE_REQUEST Command or Operation types are mismatching. 76 | * 77 | */ 78 | NFCSTATUS 79 | phFriNfc_ISO15693_Format ( 80 | phFriNfc_sNdefSmtCrdFmt_t *psNdefSmtCrdFmt); 81 | 82 | /** 83 | *\ingroup grp_fri_smart_card_formatting 84 | * 85 | * \brief Smart card Formatting \b Completion \b Routine or \b Process function 86 | * 87 | * \copydoc page_ovr Completion Routine: This function is called by the lower layer (OVR HAL) 88 | * when an I/O operation has finished. The internal state machine decides 89 | * whether to call into the lower device again or to complete the process 90 | * by calling into the upper layer's completion routine, stored within this 91 | * component's context (\ref phFriNfc_sNdefSmtCrdFmt_t). 92 | * 93 | * The function call scheme is according to \ref grp_interact. No State reset is performed during 94 | * operation. 95 | * 96 | * \param[in] Context The context of the current (not the lower/upper) instance, as set by the lower, 97 | * calling layer, upon its completion. 98 | * \param[in] Status The completion status of the lower layer (to be handled by the implementation of 99 | * the state machine of this function like a regular return value of an internally 100 | * called function). 101 | * 102 | * \note For general information about the completion routine interface please see \ref pphFriNfc_Cr_t . 103 | * The Different Status Values are as follows 104 | * 105 | */ 106 | void 107 | phFriNfc_ISO15693_FmtProcess ( 108 | void *pContext, 109 | NFCSTATUS Status); 110 | 111 | /*********************** External function declarations end ***********************/ 112 | 113 | #endif /* #define PHFRINFC_ISO15693FORMAT_H */ 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /src/phFriNfc_IntNdefMap.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_external_libnfc-nxp/978e1ce3fc660546a6e0b4432e2af95e1621ce82/src/phFriNfc_IntNdefMap.c -------------------------------------------------------------------------------- /src/phFriNfc_IntNdefMap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * \file phFriNfc_IntNdefMap.h 19 | * \brief NFC Internal Ndef Mapping File. 20 | * 21 | * Project: NFC-FRI 22 | * 23 | * $Date: Mon Sep 15 15:10:49 2008 $ 24 | * $Author: ing08205 $ 25 | * $Revision: 1.5 $ 26 | * $Aliases: NFC_FRI1.1_WK838_R9_PREP2,NFC_FRI1.1_WK838_R9_1,NFC_FRI1.1_WK840_R10_PREP1,NFC_FRI1.1_WK840_R10_1,NFC_FRI1.1_WK842_R11_PREP1,NFC_FRI1.1_WK842_R11_PREP2,NFC_FRI1.1_WK842_R11_1,NFC_FRI1.1_WK844_PREP1,NFC_FRI1.1_WK844_R12_1,NFC_FRI1.1_WK846_PREP1,NFC_FRI1.1_WK846_R13_1,NFC_FRI1.1_WK848_PREP1,NFC_FRI1.1_WK848_R14_1,NFC_FRI1.1_WK850_PACK1,NFC_FRI1.1_WK851_PREP1,NFC_FRI1.1_WK850_R15_1,NFC_FRI1.1_WK902_PREP1,NFC_FRI1.1_WK902_R16_1,NFC_FRI1.1_WK904_PREP1,NFC_FRI1.1_WK904_R17_1,NFC_FRI1.1_WK906_R18_1,NFC_FRI1.1_WK908_PREP1,NFC_FRI1.1_WK908_R19_1,NFC_FRI1.1_WK910_PREP1,NFC_FRI1.1_WK910_R20_1,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 $ 27 | * 28 | */ 29 | 30 | #ifndef PHFRINFC_INTNDEFMAP_H 31 | #define PHFRINFC_INTNDEFMAP_H 32 | 33 | #include 34 | #ifdef PH_HAL4_ENABLE 35 | #include 36 | #else 37 | #include 38 | #endif 39 | #include 40 | #include 41 | #include 42 | 43 | 44 | 45 | /*! 46 | * \name phFriNfc_IntNdefMap.h 47 | * This file has functions which are used common across all the 48 | typ1/type2/type3/type4 tags. 49 | * 50 | */ 51 | /*@{*/ 52 | 53 | #define PH_FRINFC_NDEFMAP_TLVLEN_ZERO 0 54 | 55 | /* NFC Device Major and Minor Version numbers*/ 56 | /* !!CAUTION!! these needs to be updated periodically.Major and Minor version numbers 57 | should be compatible to the version number of currently implemented mapping document. 58 | Example : NFC Device version Number : 1.0 , specifies 59 | Major VNo is 1, 60 | Minor VNo is 0 */ 61 | #define PH_NFCFRI_NDEFMAP_NFCDEV_MAJOR_VER_NUM 0x01 62 | #define PH_NFCFRI_NDEFMAP_NFCDEV_MINOR_VER_NUM 0x00 63 | 64 | /* Macros to find major and minor TAG : Ex:Type1/Type2/Type3/Type4 version numbers*/ 65 | #define PH_NFCFRI_NDEFMAP_GET_MAJOR_TAG_VERNO(a) (((a) & (0xf0))>>(4)) 66 | #define PH_NFCFRI_NDEFMAP_GET_MINOR_TAG_VERNO(a) ((a) & (0x0f)) 67 | 68 | 69 | /*! 70 | * \name NDEF Mapping - states of the Finite State machine 71 | * 72 | */ 73 | /*@{*/ 74 | 75 | NFCSTATUS phFriNfc_NdefMap_CheckSpecVersion(phFriNfc_NdefMap_t *NdefMap, 76 | uint8_t VersionIndex); 77 | 78 | NFCSTATUS phFriNfc_NdefMap_SetCardState(phFriNfc_NdefMap_t *NdefMap, 79 | uint16_t Length); 80 | 81 | #endif /* PHFRINFC_INTNDEFMAP_H */ 82 | -------------------------------------------------------------------------------- /src/phFriNfc_LlcpMac.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * \file phFriNfc_LlcpMac.c 19 | * \brief NFC LLCP MAC Mappings For Different RF Technologies. 20 | * 21 | * Project: NFC-FRI 22 | * 23 | */ 24 | 25 | 26 | /*include files*/ 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | NFCSTATUS phFriNfc_LlcpMac_Reset (phFriNfc_LlcpMac_t *LlcpMac, 34 | void *LowerDevice, 35 | phFriNfc_LlcpMac_LinkStatus_CB_t LinkStatus_Cb, 36 | void *pContext) 37 | { 38 | NFCSTATUS status = NFCSTATUS_SUCCESS; 39 | /* Store the Linkstatus callback function of the upper layer */ 40 | LlcpMac->LinkStatus_Cb = LinkStatus_Cb; 41 | 42 | /* Store a pointer to the upper layer context */ 43 | LlcpMac->LinkStatus_Context = pContext; 44 | 45 | /* Set the LinkStatus variable to the default state */ 46 | LlcpMac->LinkState = phFriNfc_LlcpMac_eLinkDefault; 47 | 48 | /* Store a pointer to the lower layer */ 49 | LlcpMac->LowerDevice = LowerDevice; 50 | 51 | LlcpMac->psRemoteDevInfo = NULL; 52 | LlcpMac->PeerRemoteDevType = 0; 53 | LlcpMac->MacType = 0; 54 | LlcpMac->MacReceive_Cb = NULL; 55 | LlcpMac->MacSend_Cb = NULL; 56 | LlcpMac->psSendBuffer = NULL; 57 | LlcpMac->RecvPending = 0; 58 | LlcpMac->SendPending = 0; 59 | 60 | return status; 61 | } 62 | 63 | NFCSTATUS phFriNfc_LlcpMac_ChkLlcp (phFriNfc_LlcpMac_t *LlcpMac, 64 | phHal_sRemoteDevInformation_t *psRemoteDevInfo, 65 | phFriNfc_LlcpMac_Chk_CB_t ChkLlcpMac_Cb, 66 | void *pContext) 67 | { 68 | NFCSTATUS status = NFCSTATUS_SUCCESS; 69 | if (NULL == LlcpMac || NULL == psRemoteDevInfo) 70 | { 71 | status = PHNFCSTVAL(CID_FRI_NFC_LLCP_MAC, NFCSTATUS_INVALID_PARAMETER); 72 | } 73 | else 74 | { 75 | /* Store the Remote Device info received from Device Discovery */ 76 | LlcpMac->psRemoteDevInfo = psRemoteDevInfo; 77 | 78 | if(LlcpMac->psRemoteDevInfo->RemDevType == phHal_eNfcIP1_Initiator) 79 | { 80 | /* Set the PeerRemoteDevType variable to the Target type */ 81 | LlcpMac->PeerRemoteDevType = phFriNfc_LlcpMac_ePeerTypeTarget; 82 | } 83 | else if(LlcpMac->psRemoteDevInfo->RemDevType == phHal_eNfcIP1_Target) 84 | { 85 | /* Set the PeerRemoteDevType variable to the Initiator type */ 86 | LlcpMac->PeerRemoteDevType = phFriNfc_LlcpMac_ePeerTypeInitiator; 87 | } 88 | 89 | switch(LlcpMac->psRemoteDevInfo->RemDevType) 90 | { 91 | case phHal_eNfcIP1_Initiator: 92 | case phHal_eNfcIP1_Target: 93 | { 94 | /* Set the MAC mapping type detected */ 95 | LlcpMac->MacType = phFriNfc_LlcpMac_eTypeNfcip; 96 | 97 | /* Register the lower layer to the MAC mapping component */ 98 | status = phFriNfc_LlcpMac_Nfcip_Register (LlcpMac); 99 | if(status == NFCSTATUS_SUCCESS) 100 | { 101 | status = LlcpMac->LlcpMacInterface.chk(LlcpMac,ChkLlcpMac_Cb,pContext); 102 | } 103 | else 104 | { 105 | status = PHNFCSTVAL(CID_FRI_NFC_LLCP_MAC, NFCSTATUS_FAILED); 106 | } 107 | }break; 108 | default: 109 | { 110 | status = PHNFCSTVAL(CID_FRI_NFC_LLCP_MAC, NFCSTATUS_INVALID_DEVICE); 111 | }break; 112 | } 113 | } 114 | 115 | return status; 116 | } 117 | 118 | NFCSTATUS phFriNfc_LlcpMac_Activate (phFriNfc_LlcpMac_t *LlcpMac) 119 | { 120 | NFCSTATUS status = NFCSTATUS_SUCCESS; 121 | 122 | if(LlcpMac->LlcpMacInterface.activate == NULL) 123 | { 124 | status = PHNFCSTVAL(CID_FRI_NFC_LLCP_MAC, NFCSTATUS_INVALID_PARAMETER); 125 | } 126 | else 127 | { 128 | status = LlcpMac->LlcpMacInterface.activate(LlcpMac); 129 | } 130 | return status; 131 | } 132 | 133 | NFCSTATUS phFriNfc_LlcpMac_Deactivate (phFriNfc_LlcpMac_t *LlcpMac) 134 | { 135 | NFCSTATUS status = NFCSTATUS_SUCCESS; 136 | if(LlcpMac->LlcpMacInterface.deactivate == NULL) 137 | { 138 | status = PHNFCSTVAL(CID_FRI_NFC_LLCP_MAC, NFCSTATUS_INVALID_PARAMETER); 139 | } 140 | else 141 | { 142 | status = LlcpMac->LlcpMacInterface.deactivate(LlcpMac); 143 | } 144 | return status; 145 | } 146 | 147 | NFCSTATUS phFriNfc_LlcpMac_Send (phFriNfc_LlcpMac_t *LlcpMac, 148 | phNfc_sData_t *psData, 149 | phFriNfc_LlcpMac_Send_CB_t LlcpMacSend_Cb, 150 | void *pContext) 151 | { 152 | NFCSTATUS status = NFCSTATUS_SUCCESS; 153 | 154 | if(NULL== LlcpMac->LlcpMacInterface.send || NULL==psData || NULL==LlcpMacSend_Cb || NULL==pContext) 155 | { 156 | status = PHNFCSTVAL(CID_FRI_NFC_LLCP_MAC, NFCSTATUS_INVALID_PARAMETER); 157 | } 158 | else 159 | { 160 | status = LlcpMac->LlcpMacInterface.send(LlcpMac,psData,LlcpMacSend_Cb,pContext); 161 | } 162 | return status; 163 | } 164 | 165 | NFCSTATUS phFriNfc_LlcpMac_Receive (phFriNfc_LlcpMac_t *LlcpMac, 166 | phNfc_sData_t *psData, 167 | phFriNfc_LlcpMac_Reveive_CB_t ReceiveLlcpMac_Cb, 168 | void *pContext) 169 | { 170 | NFCSTATUS status = NFCSTATUS_SUCCESS; 171 | 172 | if(LlcpMac->LlcpMacInterface.receive == NULL || NULL==psData || NULL==ReceiveLlcpMac_Cb || NULL==pContext) 173 | { 174 | status = PHNFCSTVAL(CID_FRI_NFC_LLCP_MAC, NFCSTATUS_INVALID_PARAMETER); 175 | } 176 | else 177 | { 178 | status = LlcpMac->LlcpMacInterface.receive(LlcpMac,psData,ReceiveLlcpMac_Cb,pContext); 179 | } 180 | return status; 181 | 182 | } 183 | 184 | 185 | -------------------------------------------------------------------------------- /src/phFriNfc_LlcpMacNfcip.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * \file phFriNfc_LlcpMacNfcip.h 19 | * \brief NFC LLCP MAC Mapping for NFCIP. 20 | * 21 | * Project: NFC-FRI 22 | * 23 | */ 24 | 25 | #ifndef PHFRINFC_LLCPMACNFCIP_H 26 | #define PHFRINFC_LLCPMACNFCIP_H 27 | 28 | 29 | /*include files*/ 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | /** 36 | * \name MAC Mapping for NFCIP 37 | * 38 | * File: \ref phFriNfc_LlcpMacNfcip.h 39 | * 40 | */ 41 | 42 | 43 | /** \defgroup grp_fri_nfc_llcp_macnfcip NFCIP MAC Mapping 44 | * 45 | * TODO 46 | * 47 | */ 48 | NFCSTATUS phFriNfc_LlcpMac_Nfcip_Register (phFriNfc_LlcpMac_t *LlcpMac); 49 | 50 | #endif /* PHFRINFC_LLCPMACNFCIP_H */ 51 | -------------------------------------------------------------------------------- /src/phFriNfc_LlcpTransport_Connectionless.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * \file phFriNfc_LlcpTransport_Connectionless.h 19 | * \brief 20 | * 21 | * Project: NFC-FRI 22 | * 23 | */ 24 | #ifndef PHFRINFC_LLCP_TRANSPORT_CONNECTIONLESS_H 25 | #define PHFRINFC_LLCP_TRANSPORT_CONNECTIONLESS_H 26 | /*include files*/ 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | 34 | void Handle_Connectionless_IncommingFrame(phFriNfc_LlcpTransport_t *pLlcpTransport, 35 | phNfc_sData_t *psData, 36 | uint8_t dsap, 37 | uint8_t ssap); 38 | 39 | NFCSTATUS phFriNfc_LlcpTransport_Connectionless_HandlePendingOperations(phFriNfc_LlcpTransport_Socket_t *pSocket); 40 | 41 | /** 42 | * \ingroup grp_fri_nfc 43 | * \brief Close a socket on a LLCP-connectionless device. 44 | * 45 | * This function closes a LLCP socket previously created using phFriNfc_LlcpTransport_Socket. 46 | * 47 | * \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. 48 | 49 | * \retval NFCSTATUS_SUCCESS Operation successful. 50 | * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 51 | * could not be properly interpreted. 52 | * \retval NFCSTATUS_FAILED Operation failed. 53 | */ 54 | NFCSTATUS phFriNfc_LlcpTransport_Connectionless_Close(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket); 55 | 56 | /** 57 | * \ingroup grp_fri_nfc 58 | * \brief Send data on a socket to a given destination SAP. 59 | * 60 | * This function is used to write data on a socket to a given destination SAP. 61 | * This function can only be called on a connectionless socket. 62 | * 63 | * 64 | * \param[in] pLlcpSocket A pointer to a LlcpSocket created. 65 | * \param[in] nSap The destination SAP. 66 | * \param[in] psBuffer The buffer containing the data to send. 67 | * \param[in] pSend_RspCb The callback to be called when the 68 | * operation is completed. 69 | * \param[in] pContext Upper layer context to be returned in 70 | * the callback. 71 | * 72 | * \retval NFCSTATUS_SUCCESS Operation successful. 73 | * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 74 | * could not be properly interpreted. 75 | * \retval NFCSTATUS_PENDING Reception operation is in progress, 76 | * pSend_RspCb will be called upon completion. 77 | * \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of 78 | * a valid type to perform the requsted operation. 79 | * \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. 80 | * \retval NFCSTATUS_SHUTDOWN Shutdown in progress. 81 | * \retval NFCSTATUS_FAILED Operation failed. 82 | */ 83 | NFCSTATUS phFriNfc_LlcpTransport_Connectionless_SendTo(phFriNfc_LlcpTransport_Socket_t *pLlcpSocket, 84 | uint8_t nSap, 85 | phNfc_sData_t* psBuffer, 86 | pphFriNfc_LlcpTransportSocketSendCb_t pSend_RspCb, 87 | void* pContext); 88 | 89 | /** 90 | * \ingroup grp_lib_nfc 91 | * \brief Read data on a socket and get the source SAP. 92 | * 93 | * This function is the same as phLibNfc_Llcp_Recv, except that the callback includes 94 | * the source SAP. This functions can only be called on a connectionless socket. 95 | * 96 | * 97 | * \param[in] pLlcpSocket A pointer to a LlcpSocket created. 98 | * \param[in] psBuffer The buffer receiving the data. 99 | * \param[in] pRecv_RspCb The callback to be called when the 100 | * operation is completed. 101 | * \param[in] pContext Upper layer context to be returned in 102 | * the callback. 103 | * 104 | * \retval NFCSTATUS_SUCCESS Operation successful. 105 | * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 106 | * could not be properly interpreted. 107 | * \retval NFCSTATUS_PENDING Reception operation is in progress, 108 | * pRecv_RspCb will be called upon completion. 109 | * \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of 110 | * a valid type to perform the requsted operation. 111 | * \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. 112 | * \retval NFCSTATUS_SHUTDOWN Shutdown in progress. 113 | * \retval NFCSTATUS_FAILED Operation failed. 114 | */ 115 | NFCSTATUS phLibNfc_LlcpTransport_Connectionless_RecvFrom(phFriNfc_LlcpTransport_Socket_t *pLlcpSocket, 116 | phNfc_sData_t* psBuffer, 117 | pphFriNfc_LlcpTransportSocketRecvFromCb_t pRecv_Cb, 118 | void* pContext); 119 | 120 | #endif /* PHFRINFC_LLCP_TRANSPORT_CONNECTIONLESS_H */ 121 | -------------------------------------------------------------------------------- /src/phFriNfc_LlcpUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * \file phFriNfc_LlcpUtils.h 19 | * \brief NFC LLCP utils 20 | * 21 | * Project: NFC-FRI 22 | * 23 | */ 24 | 25 | #ifndef PHFRINFC_LLCPUTILS_H 26 | #define PHFRINFC_LLCPUTILS_H 27 | 28 | /*include files*/ 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | /** 36 | * \name NFC Forum Logical Link Control Protocol Utils 37 | * 38 | * File: \ref phFriNfc_LlcpUtils.h 39 | * 40 | */ 41 | 42 | /** 43 | * UTIL_FIFO_BUFFER - A Cyclic FIFO buffer 44 | * If pIn == pOut the buffer is empty. 45 | */ 46 | typedef struct UTIL_FIFO_BUFFER 47 | { 48 | uint8_t *pBuffStart; /* Points to first valid location in buffer */ 49 | uint8_t *pBuffEnd; /* Points to last valid location in buffer */ 50 | volatile uint8_t *pIn; /* Points to 1 before where the next TU1 will enter buffer */ 51 | volatile uint8_t *pOut; /* Points to 1 before where the next TU1 will leave buffer */ 52 | volatile bool_t bFull; /* TRUE if buffer is full */ 53 | }UTIL_FIFO_BUFFER, *P_UTIL_FIFO_BUFFER; 54 | 55 | 56 | /** \defgroup grp_fri_nfc_llcp NFC Forum Logical Link Control Protocol Component 57 | * 58 | * TODO 59 | * 60 | */ 61 | 62 | NFCSTATUS phFriNfc_Llcp_DecodeTLV( phNfc_sData_t *psRawData, 63 | uint32_t *pOffset, 64 | uint8_t *pType, 65 | phNfc_sData_t *psValueBuffer ); 66 | 67 | NFCSTATUS phFriNfc_Llcp_EncodeTLV( phNfc_sData_t *psValueBuffer, 68 | uint32_t *pOffset, 69 | uint8_t type, 70 | uint8_t length, 71 | uint8_t *pValue); 72 | 73 | NFCSTATUS phFriNfc_Llcp_AppendTLV( phNfc_sData_t *psValueBuffer, 74 | uint32_t nTlvOffset, 75 | uint32_t *pCurrentOffset, 76 | uint8_t length, 77 | uint8_t *pValue); 78 | 79 | void phFriNfc_Llcp_EncodeMIUX(uint16_t pMiux, 80 | uint8_t* pMiuxEncoded); 81 | 82 | void phFriNfc_Llcp_EncodeRW(uint8_t *pRw); 83 | 84 | /** 85 | * Initializes a Fifo Cyclic Buffer to point to some allocated memory. 86 | */ 87 | void phFriNfc_Llcp_CyclicFifoInit(P_UTIL_FIFO_BUFFER sUtilFifo, 88 | const uint8_t *pBuffStart, 89 | uint32_t buffLength); 90 | 91 | /** 92 | * Clears the Fifo Cyclic Buffer - loosing any data that was in it. 93 | */ 94 | void phFriNfc_Llcp_CyclicFifoClear(P_UTIL_FIFO_BUFFER sUtilFifo); 95 | 96 | 97 | /** 98 | * Attempts to write dataLength bytes to the specified Fifo Cyclic Buffer. 99 | */ 100 | uint32_t phFriNfc_Llcp_CyclicFifoWrite(P_UTIL_FIFO_BUFFER sUtilFifo, 101 | uint8_t *pData, 102 | uint32_t dataLength); 103 | 104 | /** 105 | * Attempts to read dataLength bytes from the specified Fifo Cyclic Buffer. 106 | */ 107 | uint32_t phFriNfc_Llcp_CyclicFifoFifoRead(P_UTIL_FIFO_BUFFER sUtilFifo, 108 | uint8_t *pBuffer, 109 | uint32_t dataLength); 110 | 111 | /** 112 | * Returns the number of bytes currently stored in Fifo Cyclic Buffer. 113 | */ 114 | uint32_t phFriNfc_Llcp_CyclicFifoUsage(P_UTIL_FIFO_BUFFER sUtilFifo); 115 | 116 | /** 117 | * Returns the available room for writing in Fifo Cyclic Buffer. 118 | */ 119 | uint32_t phFriNfc_Llcp_CyclicFifoAvailable(P_UTIL_FIFO_BUFFER sUtilFifo); 120 | 121 | uint32_t phFriNfc_Llcp_Header2Buffer( phFriNfc_Llcp_sPacketHeader_t *psHeader, 122 | uint8_t *pBuffer, 123 | uint32_t nOffset ); 124 | 125 | uint32_t phFriNfc_Llcp_Sequence2Buffer( phFriNfc_Llcp_sPacketSequence_t *psSequence, 126 | uint8_t *pBuffer, 127 | uint32_t nOffset ); 128 | 129 | uint32_t phFriNfc_Llcp_Buffer2Header( uint8_t *pBuffer, 130 | uint32_t nOffset, 131 | phFriNfc_Llcp_sPacketHeader_t *psHeader ); 132 | 133 | uint32_t phFriNfc_Llcp_Buffer2Sequence( uint8_t *pBuffer, 134 | uint32_t nOffset, 135 | phFriNfc_Llcp_sPacketSequence_t *psSequence ); 136 | 137 | 138 | #endif /* PHFRINFC_LLCPUTILS_H */ 139 | -------------------------------------------------------------------------------- /src/phFriNfc_MapTools.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_external_libnfc-nxp/978e1ce3fc660546a6e0b4432e2af95e1621ce82/src/phFriNfc_MapTools.c -------------------------------------------------------------------------------- /src/phFriNfc_MapTools.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * \file phFriNfc_MapTools.h 19 | * \brief NFC Internal Ndef Mapping File. 20 | * 21 | * Project: NFC-FRI 22 | * 23 | * $Date: Fri Oct 15 13:50:54 2010 $ 24 | * $Author: ing02260 $ 25 | * $Revision: 1.6 $ 26 | * $Aliases: $ 27 | * 28 | */ 29 | 30 | #ifndef PHFRINFC_MAPTOOLS_H 31 | #define PHFRINFC_MAPTOOLS_H 32 | 33 | #include 34 | #ifdef PH_HAL4_ENABLE 35 | #include 36 | #else 37 | #include 38 | #endif 39 | #include 40 | #include 41 | #include 42 | 43 | /*! 44 | * \name phFriNfc_MapTools.h 45 | * This file has functions which are used common across all the 46 | typ1/type2/type3/type4 tags. 47 | * 48 | */ 49 | /*@{*/ 50 | 51 | #define PH_FRINFC_NDEFMAP_TLVLEN_ZERO 0 52 | 53 | /* NFC Device Major and Minor Version numbers*/ 54 | /* !!CAUTION!! these needs to be updated periodically.Major and Minor version numbers 55 | should be compatible to the version number of currently implemented mapping document. 56 | Example : NFC Device version Number : 1.0 , specifies 57 | Major VNo is 1, 58 | Minor VNo is 0 */ 59 | #define PH_NFCFRI_NDEFMAP_NFCDEV_MAJOR_VER_NUM 0x01 60 | #ifdef DESFIRE_EV1 61 | #define PH_NFCFRI_NDEFMAP_NFCDEV_MAJOR_VER_NUM_2 0x02 62 | #endif /* */ 63 | #define PH_NFCFRI_NDEFMAP_NFCDEV_MINOR_VER_NUM 0x00 64 | 65 | /* Macros to find major and minor TAG : Ex:Type1/Type2/Type3/Type4 version numbers*/ 66 | #define PH_NFCFRI_NDEFMAP_GET_MAJOR_TAG_VERNO(a) (((a) & (0xf0))>>(4)) 67 | #define PH_NFCFRI_NDEFMAP_GET_MINOR_TAG_VERNO(a) ((a) & (0x0f)) 68 | 69 | /* NFC Device Major and Minor Version numbers*/ 70 | /* !!CAUTION!! these needs to be updated periodically.Major and Minor version numbers 71 | should be compatible to the version number of currently implemented mapping document. 72 | Example : NFC Device version Number : 1.0 , specifies 73 | Major VNo is 1, 74 | Minor VNo is 0 */ 75 | #define PH_NFCFRI_MFSTDMAP_NFCDEV_MAJOR_VER_NUM 0x40 76 | #define PH_NFCFRI_MFSTDMAP_NFCDEV_MINOR_VER_NUM 0x00 77 | 78 | /* Macros to find major and minor TAG : Ex:Type1/Type2/Type3/Type4 version numbers*/ 79 | #define PH_NFCFRI_MFSTDMAP_GET_MAJOR_TAG_VERNO(a) ((a) & (0x40)) // must be 0xC0 80 | #define PH_NFCFRI_MFSTDMAP_GET_MINOR_TAG_VERNO(a) ((a) & (0x30)) 81 | 82 | /*! 83 | * \name NDEF Mapping - states of the Finite State machine 84 | * 85 | */ 86 | /*@{*/ 87 | 88 | 89 | NFCSTATUS phFriNfc_MapTool_ChkSpcVer( const phFriNfc_NdefMap_t *NdefMap, 90 | uint8_t VersionIndex); 91 | 92 | NFCSTATUS phFriNfc_MapTool_SetCardState(phFriNfc_NdefMap_t *NdefMap, 93 | uint32_t Length); 94 | 95 | #endif //PHFRINFC_MAPTOOLS_H 96 | -------------------------------------------------------------------------------- /src/phFriNfc_MifULFormat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * \file phFriNfc_MifULFormat.h 19 | * \brief NFC Ndef Formatting For Mifare standard card. 20 | * 21 | * Project: NFC-FRI 22 | * 23 | * $Date: Mon Dec 13 14:14:12 2010 $ 24 | * $Author: ing02260 $ 25 | * $Revision: 1.5 $ 26 | * $Aliases: $ 27 | * 28 | */ 29 | 30 | #ifndef PHFRINFC_MIFULFORMAT_H 31 | #define PHFRINFC_MIFULFORMAT_H 32 | 33 | #include 34 | #ifdef PH_HAL4_ENABLE 35 | #include 36 | #else 37 | #include 38 | #endif 39 | #include 40 | #include 41 | #include 42 | 43 | #ifdef PH_NDEF_MIFARE_ULC 44 | #include 45 | #endif /* #ifdef PH_NDEF_MIFARE_ULC */ 46 | 47 | #define PH_FRINFC_MIFUL_FORMAT_FILEREVISION "$Revision: 1.5 $" 48 | #define PH_FRINFC_MIFUL_FORMAT_FILEALIASES "$Aliases: $" 49 | 50 | 51 | /*! 52 | * \name Mifare UL - constants for the state 53 | * 54 | */ 55 | /*@{*/ 56 | #define PH_FRINFC_MFUL_FMT_RESET_INIT 0 /*!< Reset state */ 57 | #define PH_FRINFC_MFUL_FMT_RD_16BYTES 1 /*!< Read 16 bytes */ 58 | #define PH_FRINFC_MFUL_FMT_WR_OTPBYTES 2 /*!< Write OTP bytes */ 59 | #define PH_FRINFC_MFUL_FMT_WR_TLV 3 /*!< Write TLV */ 60 | #ifdef PH_NDEF_MIFARE_ULC 61 | #define PH_FRINFC_MFUL_FMT_WR_TLV1 4 /*!< Write TLV (second part) */ 62 | #endif /* #ifdef PH_NDEF_MIFARE_ULC */ 63 | #ifdef FRINFC_READONLY_NDEF 64 | #define PH_FRINFC_MFUL_FMT_RO_RD_16BYTES 5 /*!< Read only the tag */ 65 | #define PH_FRINFC_MFUL_FMT_RO_WR_LOCK_BYTES 6 /*!< Write lock bytes to make the tag Read only */ 66 | #define PH_FRINFC_MFUL_FMT_RO_WR_OTP_BYTES 7 /*!< Write OTP bytes to make the tag Read only */ 67 | 68 | #ifdef PH_NDEF_MIFARE_ULC 69 | #define PH_FRINFC_MFUL_FMT_RO_RD_DYN_LOCK_BYTES 8 /*!< Read default dynamic lock bytes address */ 70 | #define PH_FRINFC_MFUL_FMT_RO_WR_DYN_LOCK_BYTES 9 /*!< Write default dynamic lock bytes address */ 71 | #define PH_FRINFC_MFUL_FMT_RO_PARSE_NDEF 10 /*!< Write default dynamic lock bytes address */ 72 | #define PH_FRINFC_MFUL_FMT_RO_NDEF_PARSE_RD_BYTES 12 /*!< Read bytes from the card for parsing NDEF */ 73 | #endif /* #ifdef PH_NDEF_MIFARE_ULC */ 74 | 75 | #endif /* #ifdef FRINFC_READONLY_NDEF */ 76 | 77 | /*@}*/ 78 | 79 | 80 | /*! 81 | * \name Mifare standard - Block numbers 82 | * 83 | */ 84 | /*@{*/ 85 | #define PH_FRINFC_MFUL_FMT_LOCK_BITS_VAL 0x00 /*!< Lock bits block is 2 */ 86 | 87 | /*@}*/ 88 | 89 | /*! 90 | * \name Mifare UL - OTP bytes 91 | * 92 | */ 93 | /*@{*/ 94 | #ifdef PH_NDEF_MIFARE_ULC 95 | #define PH_FRINFC_MFULC_FMT_OTP_BYTES {0xE1, 0x10, 0x12, 0x00} /*!< OTP bytes macro */ 96 | #endif /* #ifdef PH_NDEF_MIFARE_ULC */ 97 | #define PH_FRINFC_MFUL_FMT_OTP_BYTES {0xE1, 0x10, 0x06, 0x00} /*!< OTP bytes macro */ 98 | 99 | /*@}*/ 100 | 101 | /*! 102 | * \name Mifare UL - enums the values 103 | * 104 | */ 105 | /*@{*/ 106 | enum{ 107 | PH_FRINFC_MFUL_FMT_VAL_0, 108 | PH_FRINFC_MFUL_FMT_VAL_1, 109 | PH_FRINFC_MFUL_FMT_VAL_2, 110 | PH_FRINFC_MFUL_FMT_VAL_3, 111 | PH_FRINFC_MFUL_FMT_VAL_4, 112 | PH_FRINFC_MFUL_FMT_VAL_5, 113 | PH_FRINFC_MFUL_FMT_VAL_6, 114 | PH_FRINFC_MFUL_FMT_VAL_7 115 | }; 116 | /*@}*/ 117 | 118 | /*! 119 | * \name Mifare UL - constants 120 | * 121 | */ 122 | /*@{*/ 123 | #define PH_FRINFC_MFUL_FMT_NON_NDEF_COMPL 0 /*!< Card is not ndef compliant */ 124 | #define PH_FRINFC_MFUL_FMT_NDEF_COMPL 1 /*!< Card is ndef compliant */ 125 | /*@}*/ 126 | 127 | /*! 128 | * \name Mifare UL - constants 129 | * 130 | */ 131 | /*@{*/ 132 | #define PH_FRINFC_MFUL_FMT_MAX_RECV_LENGTH 252 /*!< Maximum receive length */ 133 | #define PH_FRINFC_MFUL_FMT_WR_SEND_LENGTH 5 /*!< Send length for write */ 134 | #define PH_FRINFC_MFUL_FMT_MAX_BLK 16 /*!< Maximum blocks */ 135 | 136 | /*@}*/ 137 | 138 | /*! 139 | * \name Mifare UL - constants for filling send buffer, calculating the block number, 140 | * checking the authenticate state 141 | * 142 | */ 143 | /*@{*/ 144 | 145 | /*@}*/ 146 | 147 | 148 | /** 149 | * \ingroup grp_fri_smart_card_formatting 150 | * \brief Smart Card Formatting \b Reset function 151 | * 152 | * \copydoc page_reg Resets the component instance to the initial state and initializes the 153 | * internal variables. 154 | */ 155 | void phFriNfc_MfUL_Reset(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt); 156 | 157 | /*! 158 | * \ingroup grp_fri_smart_card_formatting 159 | * 160 | * \brief Initiates the card formatting procedure for Remote Smart Card Type. 161 | * 162 | * \copydoc page_ovr The function initiates and formats the Smart Card.After this formation, remote 163 | * card would be properly initialized and Ndef Compliant. 164 | * Depending upon the different card type, this function handles formatting procedure. 165 | * This function also handles the different recovery procedures for different types of the cards. For both 166 | * Format and Recovery Management same API is used. 167 | * 168 | * \param[in] phFriNfc_sNdefSmartCardFmt_t Pointer to a valid instance of the \ref phFriNfc_sNdefSmartCardFmt_t 169 | * structure describing the component context. 170 | * \retval NFCSTATUS_PENDING The action has been successfully triggered. 171 | * \retval Other values An error has occurred. 172 | * 173 | */ 174 | NFCSTATUS phFriNfc_MfUL_Format(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt); 175 | 176 | #ifdef FRINFC_READONLY_NDEF 177 | 178 | /*! 179 | * \ingroup grp_fri_smart_card_formatting 180 | * 181 | * \brief Initiates the conversion of the already NDEF formatted tag to READ ONLY. 182 | * 183 | * \copydoc page_ovr The function initiates the conversion of the already NDEF formatted 184 | * tag to READ ONLY.After this formation, remote card would be properly Ndef Compliant and READ ONLY. 185 | * Depending upon the different card type, this function handles formatting procedure. 186 | * 187 | * \param[in] phFriNfc_sNdefSmartCardFmt_t Pointer to a valid instance of the \ref phFriNfc_sNdefSmartCardFmt_t 188 | * structure describing the component context. 189 | * \retval NFCSTATUS_PENDING The action has been successfully triggered. 190 | * \retval Other values An error has occurred. 191 | * 192 | */ 193 | NFCSTATUS 194 | phFriNfc_MfUL_ConvertToReadOnly ( 195 | phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt); 196 | 197 | #endif /* #ifdef FRINFC_READONLY_NDEF */ 198 | 199 | /** 200 | *\ingroup grp_fri_smart_card_formatting 201 | * 202 | * \brief Smart card Formatting \b Completion \b Routine or \b Process function 203 | * 204 | * \copydoc page_ovr Completion Routine: This function is called by the lower layer (OVR HAL) 205 | * when an I/O operation has finished. The internal state machine decides 206 | * whether to call into the lower device again or to complete the process 207 | * by calling into the upper layer's completion routine, stored within this 208 | * component's context (\ref phFriNfc_sNdefSmtCrdFmt_t). 209 | * 210 | * The function call scheme is according to \ref grp_interact. No State reset is performed during 211 | * operation. 212 | * 213 | * \param[in] Context The context of the current (not the lower/upper) instance, as set by the lower, 214 | * calling layer, upon its completion. 215 | * \param[in] Status The completion status of the lower layer (to be handled by the implementation of 216 | * the state machine of this function like a regular return value of an internally 217 | * called function). 218 | * 219 | * \note For general information about the completion routine interface please see \ref pphFriNfc_Cr_t . * The Different Status Values are as follows 220 | * 221 | */ 222 | void phFriNfc_MfUL_Process(void *Context, 223 | NFCSTATUS Status); 224 | #endif /* PHFRINFC_MIFULFORMAT_H */ 225 | 226 | -------------------------------------------------------------------------------- /src/phFriNfc_TopazMap.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_external_libnfc-nxp/978e1ce3fc660546a6e0b4432e2af95e1621ce82/src/phFriNfc_TopazMap.c -------------------------------------------------------------------------------- /src/phHciNfc_AdminMgmt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /*! 18 | * =========================================================================== * 19 | * * 20 | * * 21 | * \file phHciNfc_AdminMgmt.h * 22 | * \brief HCI Header for the Admin Gate Management. * 23 | * * 24 | * * 25 | * Project: NFC-FRI-1.1 * 26 | * * 27 | * $Date: Mon Mar 29 17:34:48 2010 $ * 28 | * $Author: ing04880 $ * 29 | * $Revision: 1.7 $ * 30 | * $Aliases: 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 $ * 31 | * * 32 | * =========================================================================== * 33 | */ 34 | 35 | 36 | #ifndef PHHCINFC_ADMINMGMT_H 37 | #define PHHCINFC_ADMINMGMT_H 38 | 39 | /*@}*/ 40 | 41 | 42 | /** 43 | * \name HCI 44 | * 45 | * File: \ref phHciNfc_AdminMgmt.h 46 | * 47 | */ 48 | /*@{*/ 49 | #define PHHCINFC_ADMINMGMT_FILEREVISION "$Revision: 1.7 $" /**< \ingroup grp_file_attributes */ 50 | #define PHHCINFC_ADMINMGMT_FILEALIASES "$Aliases: 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 */ 51 | /*@}*/ 52 | 53 | /* 54 | ***************************** Header File Inclusion **************************** 55 | */ 56 | 57 | #include 58 | 59 | /* 60 | ****************************** Macro Definitions ******************************* 61 | */ 62 | 63 | #define EVT_HOT_PLUG 0x03 64 | 65 | /* 66 | ******************** Enumeration and Structure Definition ********************** 67 | */ 68 | 69 | /** \defgroup grp_hci_nfc HCI Component 70 | * 71 | * 72 | */ 73 | 74 | 75 | /* 76 | *********************** Function Prototype Declaration ************************* 77 | */ 78 | 79 | /** 80 | * \ingroup grp_hci_nfc 81 | * 82 | * The phHciNfc_Admin_Initialise function Initialises the AdminGate and opens the 83 | * Admin Gate pipe 84 | * 85 | * \param[in] psHciContext psHciContext is the pointer to HCI Layer 86 | * context Structure. 87 | * \param[in] pHwRef pHwRef is the Information of 88 | * the Device Interface Link . 89 | * 90 | * \retval NFCSTATUS_PENDING AdminGate Initialisation is pending. 91 | * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 92 | * could not be interpreted properly. 93 | * \retval Other errors Errors related to the other layers 94 | * 95 | */ 96 | 97 | extern 98 | NFCSTATUS 99 | phHciNfc_Admin_Initialise( 100 | phHciNfc_sContext_t *psHciContext, 101 | void *pHwRef 102 | ); 103 | 104 | /** 105 | * \ingroup grp_hci_nfc 106 | * 107 | * The phHciNfc_Admin_Release function closes the opened pipes between 108 | * the Host Controller Device and the NFC Device. 109 | * 110 | * \param[in] psHciContext psHciContext is the pointer to HCI Layer 111 | * context Structure. 112 | * \param[in] pHwRef pHwRef is the Information of 113 | * the Device Interface Link . 114 | * \param[in] host_type host_type is the type of the host 115 | * to be released. 116 | * 117 | * \retval NFCSTATUS_PENDING Release of the Admingate resources are 118 | * pending. 119 | * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 120 | * could not be interpreted properly. 121 | * \retval Other errors Errors related to the other layers 122 | * 123 | */ 124 | 125 | extern 126 | NFCSTATUS 127 | phHciNfc_Admin_Release( 128 | phHciNfc_sContext_t *psHciContext, 129 | void *pHwRef, 130 | phHciNfc_HostID_t host_type 131 | ); 132 | 133 | 134 | /** 135 | * \ingroup grp_hci_nfc 136 | * 137 | * The phHciNfc_Send_Admin_Cmd function Sends the Particular AdminGate 138 | * command to the Host Controller Device. 139 | * 140 | * \param[in] psHciContext psHciContext is the pointer to HCI Layer 141 | * context Structure. 142 | * \param[in] pHwRef pHwRef is the Information of 143 | * the Device Interface Link . 144 | * \param[in] cmd cmd to be sent to the Admin gate of the 145 | * Host controller. 146 | * \param[in] length Size of the data sent in the parameter. 147 | * \param[in,out] params params contains the parameters that are 148 | * required by the particular HCI command. 149 | * 150 | * \retval None 151 | * 152 | */ 153 | 154 | extern 155 | NFCSTATUS 156 | phHciNfc_Send_Admin_Cmd ( 157 | phHciNfc_sContext_t *psHciContext, 158 | void *pHwRef, 159 | uint8_t cmd, 160 | uint8_t length, 161 | void *params 162 | ); 163 | 164 | 165 | /** 166 | * \ingroup grp_hci_nfc 167 | * 168 | * The phHciNfc_Send_Admin_Cmd function Sends the Particular AdminGate 169 | * command to the Host Controller Device. 170 | * 171 | * \param[in] psHciContext psHciContext is the pointer to HCI Layer 172 | * context Structure. 173 | * \param[in] pHwRef pHwRef is the Information of 174 | * the Device Interface Link . 175 | * \param[in] Event Event to be sent to the Admin gate of the 176 | * Host controller. 177 | * \param[in] length Size of the data sent in the parameter. 178 | * \param[in,out] params params contains the parameters that are 179 | * required by the particular HCI command. 180 | * 181 | * \retval None 182 | * 183 | */ 184 | 185 | extern 186 | NFCSTATUS 187 | phHciNfc_Send_Admin_Event ( 188 | phHciNfc_sContext_t *psHciContext, 189 | void *pHwRef, 190 | uint8_t event, 191 | uint8_t length, 192 | void *params 193 | ); 194 | 195 | extern 196 | NFCSTATUS 197 | phHciNfc_Admin_CE_Init( 198 | phHciNfc_sContext_t *psHciContext, 199 | void *pHwRef, 200 | phHciNfc_GateID_t ce_gate 201 | ); 202 | 203 | 204 | #endif 205 | 206 | -------------------------------------------------------------------------------- /src/phHciNfc_Emulation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /*! 18 | * =========================================================================== * 19 | * * 20 | * * 21 | * \file phHciNfc_Emulation.h * 22 | * \brief HCI emulation management routines. * 23 | * * 24 | * * 25 | * Project: NFC-FRI-1.1 * 26 | * * 27 | * $Date: Fri Aug 14 17:01:26 2009 $ * 28 | * $Author: ing04880 $ * 29 | * $Revision: 1.10 $ * 30 | * $Aliases: 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 $ * 31 | * * 32 | * =========================================================================== * 33 | */ 34 | 35 | 36 | #ifndef PHHCINFC_EMULATION_H 37 | #define PHHCINFC_EMULATION_H 38 | 39 | /*@}*/ 40 | 41 | 42 | /** 43 | * \name HCI 44 | * 45 | * File: \ref phHciNfc_Emulation.h 46 | * 47 | */ 48 | /*@{*/ 49 | #define PHHCINFC_EMULATION_FILEREVISION "$Revision: 1.10 $" /**< \ingroup grp_file_attributes */ 50 | #define PHHCINFC_EMULATION_FILEALIASES "$Aliases: 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 */ 51 | /*@}*/ 52 | 53 | /* 54 | ***************************** Header File Inclusion **************************** 55 | */ 56 | 57 | #include 58 | 59 | /* 60 | ****************************** Macro Definitions ******************************* 61 | */ 62 | /* Connectivity Gate Command Support */ 63 | #define PRO_HOST_REQUEST (0x10U) 64 | 65 | /* Connectivity Gate Event Support */ 66 | #define EVT_CONNECTIVITY (0x10U) 67 | #define EVT_END_OF_TRANSACTION (0x11U) 68 | #define EVT_TRANSACTION (0x12U) 69 | #define EVT_OPERATION_ENDED (0x13U) 70 | 71 | #define TRANSACTION_MIN_LEN (0x03U) 72 | #define TRANSACTION_AID (0x81U) 73 | #define TRANSACTION_PARAM (0x82U) 74 | 75 | #define HOST_CE_MODE_ENABLE (0x02U) 76 | #define HOST_CE_MODE_DISABLE (0xFFU) 77 | 78 | #define NXP_PIPE_CONNECTIVITY (0x60U) 79 | 80 | 81 | /* Card Emulation Gate Events */ 82 | #define CE_EVT_NFC_SEND_DATA (0x10U) 83 | #define CE_EVT_NFC_FIELD_ON (0x11U) 84 | #define CE_EVT_NFC_DEACTIVATED (0x12U) 85 | #define CE_EVT_NFC_ACTIVATED (0x13U) 86 | #define CE_EVT_NFC_FIELD_OFF (0x14U) 87 | 88 | /* 89 | ******************** Enumeration and Structure Definition ********************** 90 | */ 91 | 92 | 93 | 94 | /* 95 | *********************** Function Prototype Declaration ************************* 96 | */ 97 | 98 | extern 99 | NFCSTATUS 100 | phHciNfc_Uicc_Update_PipeInfo( 101 | phHciNfc_sContext_t *psHciContext, 102 | uint8_t pipe_id, 103 | phHciNfc_Pipe_Info_t *pPipeInfo 104 | ); 105 | 106 | extern 107 | NFCSTATUS 108 | phHciNfc_EmuMgmt_Update_Seq( 109 | phHciNfc_sContext_t *psHciContext, 110 | phHciNfc_eSeqType_t seq_type 111 | ); 112 | 113 | extern 114 | NFCSTATUS 115 | phHciNfc_EmuMgmt_Initialise( 116 | phHciNfc_sContext_t *psHciContext, 117 | void *pHwRef 118 | ); 119 | 120 | extern 121 | NFCSTATUS 122 | phHciNfc_EmuMgmt_Release( 123 | phHciNfc_sContext_t *psHciContext, 124 | void *pHwRef 125 | ); 126 | 127 | 128 | extern 129 | NFCSTATUS 130 | phHciNfc_Emulation_Cfg ( 131 | phHciNfc_sContext_t *psHciContext, 132 | void *pHwRef, 133 | phHciNfc_eConfigType_t cfg_type 134 | ); 135 | 136 | extern 137 | NFCSTATUS 138 | phHciNfc_Uicc_Get_PipeID( 139 | phHciNfc_sContext_t *psHciContext, 140 | uint8_t *ppipe_id 141 | ); 142 | 143 | extern 144 | NFCSTATUS 145 | phHciNfc_Uicc_Connect_Status( 146 | phHciNfc_sContext_t *psHciContext, 147 | void *pHwRef 148 | ); 149 | 150 | extern 151 | void 152 | phHciNfc_Uicc_Connectivity( 153 | phHciNfc_sContext_t *psHciContext, 154 | void *pHwRef 155 | ); 156 | 157 | 158 | #endif /* PHHCINFC_EMULATION_H */ 159 | -------------------------------------------------------------------------------- /src/phHciNfc_IDMgmt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /*! 18 | * =========================================================================== * 19 | * * 20 | * * 21 | * \file phHciNfc_IDMgmt.h * 22 | * \brief HCI Header for the Identity Management Gate. * 23 | * * 24 | * * 25 | * Project: NFC-FRI-1.1 * 26 | * * 27 | * $Date: Fri Aug 14 17:01:26 2009 $ * 28 | * $Author: ing04880 $ * 29 | * $Revision: 1.5 $ * 30 | * $Aliases: 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 $ * 31 | * * 32 | * =========================================================================== * 33 | */ 34 | 35 | 36 | #ifndef PHHCINFC_IDMGMT_H 37 | #define PHHCINFC_IDMGMT_H 38 | 39 | /*@}*/ 40 | 41 | 42 | /** 43 | * \name HCI 44 | * 45 | * File: \ref phHciNfc_IDMgmt.h 46 | * 47 | */ 48 | /*@{*/ 49 | #define PHHCINFC_IDMGMT_FILEREVISION "$Revision: 1.5 $" /**< \ingroup grp_file_attributes */ 50 | #define PHHCINFC_IDMGMT_FILEALIASES "$Aliases: 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 */ 51 | /*@}*/ 52 | 53 | /* 54 | ***************************** Header File Inclusion **************************** 55 | */ 56 | 57 | #include 58 | 59 | /* 60 | ****************************** Macro Definitions ******************************* 61 | */ 62 | 63 | /* 64 | ******************** Enumeration and Structure Definition ********************** 65 | */ 66 | 67 | 68 | 69 | /* 70 | *********************** Function Prototype Declaration ************************* 71 | */ 72 | 73 | /** 74 | * \ingroup grp_hci_nfc 75 | * 76 | * The phHciNfc_IDMgmt_Initialise function creates and the opens Identity 77 | * Management Gate 78 | * 79 | * \param[in] psHciContext psHciContext is the pointer to HCI Layer 80 | * context Structure. 81 | * \param[in] pHwRef pHwRef is the Information of 82 | * the Device Interface Link . 83 | * 84 | * \retval NFCSTATUS_PENDING Identity Mgmt Gate Initialisation is pending. 85 | * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 86 | * could not be interpreted properly. 87 | * \retval Other errors Errors related to the other layers 88 | * 89 | */ 90 | extern 91 | NFCSTATUS 92 | phHciNfc_IDMgmt_Initialise( 93 | phHciNfc_sContext_t *psHciContext, 94 | void *pHwRef 95 | ); 96 | /** 97 | * \ingroup grp_hci_nfc 98 | * 99 | * The phHciNfc_IDMgmt_Info_Sequence function obtains the information 100 | * from the Identity Management Gate 101 | * 102 | * \param[in] psHciContext psHciContext is the pointer to HCI Layer 103 | * context Structure. 104 | * \param[in] pHwRef pHwRef is the Information of 105 | * the Device Interface Link . 106 | * 107 | * \retval NFCSTATUS_PENDING Identity Mgmt Gate Information is pending. 108 | * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 109 | * could not be interpreted properly. 110 | * \retval Other errors Errors related to the other layers 111 | * 112 | */ 113 | extern 114 | NFCSTATUS 115 | phHciNfc_IDMgmt_Info_Sequence( 116 | phHciNfc_sContext_t *psHciContext, 117 | void *pHwRef 118 | ); 119 | 120 | /** 121 | * \ingroup grp_hci_nfc 122 | * 123 | * The phHciNfc_IDMgmt_Release function closes the opened pipes between 124 | * the Host Controller Device and the NFC Device. 125 | * 126 | * \param[in] psHciContext psHciContext is the pointer to HCI Layer 127 | * context Structure. 128 | * \param[in] pHwRef pHwRef is the Information of 129 | * the Device Interface Link . 130 | * 131 | * \retval NFCSTATUS_PENDING Release of the Identity Management gate 132 | * resources are pending. 133 | * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 134 | * could not be interpreted properly. 135 | * \retval Other errors Errors related to the other layers 136 | * 137 | */ 138 | extern 139 | NFCSTATUS 140 | phHciNfc_IDMgmt_Release( 141 | phHciNfc_sContext_t *psHciContext, 142 | void *pHwRef 143 | ); 144 | 145 | /** 146 | * \ingroup grp_hci_nfc 147 | * 148 | * The phHciNfc_IDMgmt_Update_PipeInfo function updates the pipe_id of the Idetity 149 | * Gate Managment Struction. 150 | * 151 | * \param[in] psHciContext psHciContext is the pointer to HCI Layer 152 | * context Structure. 153 | * \param[in] pipeID pipeID of the Identity management Gate 154 | * \param[in] pPipeInfo Update the pipe Information of the Identity 155 | * Management Gate. 156 | * 157 | * \retval NFCSTATUS_SUCCESS AdminGate Response received Successfully. 158 | * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 159 | * could not be interpreted properly. 160 | * 161 | */ 162 | 163 | extern 164 | NFCSTATUS 165 | phHciNfc_IDMgmt_Update_PipeInfo( 166 | phHciNfc_sContext_t *psHciContext, 167 | uint8_t pipeID, 168 | phHciNfc_Pipe_Info_t *pPipeInfo 169 | ); 170 | 171 | 172 | /*! 173 | * \brief Updates the Sequence of Identity Managment Gate. 174 | * 175 | * This function Updates the Sequence of the Identity Management 176 | * gate Information Structure. 177 | * 178 | */ 179 | extern 180 | NFCSTATUS 181 | phHciNfc_IDMgmt_Update_Sequence( 182 | phHciNfc_sContext_t *psHciContext, 183 | phHciNfc_eSeqType_t reader_seq 184 | ); 185 | 186 | /*! 187 | * \brief Allocates the resources of Identity Managment Gate. 188 | * 189 | * This function Allocates the resources of the Identity Management 190 | * gate Information Structure. 191 | * 192 | */ 193 | extern 194 | NFCSTATUS 195 | phHciNfc_IDMgmt_Init_Resources( 196 | phHciNfc_sContext_t *psHciContext 197 | ); 198 | 199 | 200 | /*! 201 | * \brief Get the pipe_id of Identity Managment Gate. 202 | * 203 | * This function Get the pipe_id of Identity Managment Gate. 204 | * 205 | */ 206 | 207 | extern 208 | NFCSTATUS 209 | phHciNfc_IDMgmt_Get_PipeID( 210 | phHciNfc_sContext_t *psHciContext, 211 | uint8_t *ppipe_id 212 | ); 213 | 214 | 215 | 216 | #endif 217 | 218 | -------------------------------------------------------------------------------- /src/phHciNfc_LinkMgmt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /*! 18 | * =========================================================================== * 19 | * * 20 | * * 21 | * \file phHciNfc_LinkMgmt.h * 22 | * \brief HCI Header for the Link Management Gate. * 23 | * * 24 | * * 25 | * Project: NFC-FRI-1.1 * 26 | * * 27 | * $Date: Tue Mar 30 09:32:13 2010 $ * 28 | * $Author: ing04880 $ * 29 | * $Revision: 1.5 $ * 30 | * $Aliases: 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 $ 31 | * * 32 | * =========================================================================== * 33 | */ 34 | 35 | 36 | #ifndef PHHCINFC_LINKMGMT_H 37 | #define PHHCINFC_LINKMGMT_H 38 | 39 | /*@}*/ 40 | 41 | 42 | /** 43 | * \name HCI 44 | * 45 | * File: \ref phHciNfc_LinkMgmt.h 46 | * 47 | */ 48 | /*@{*/ 49 | #define PHHCINFC_LINK_MGMT_FILEREVISION "$Revision: 1.5 $" /**< \ingroup grp_file_attributes */ 50 | #define PHHCINFC_LINK_MGMT_FILEALIASES "$Aliases: 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 */ 51 | /*@}*/ 52 | 53 | /* 54 | ***************************** Header File Inclusion **************************** 55 | */ 56 | 57 | #include 58 | 59 | /* 60 | ****************************** Macro Definitions ******************************* 61 | */ 62 | 63 | /* 64 | ******************** Enumeration and Structure Definition ********************** 65 | */ 66 | 67 | 68 | 69 | /* 70 | *********************** Function Prototype Declaration ************************* 71 | */ 72 | 73 | /** 74 | * \ingroup grp_hci_nfc 75 | * 76 | * The phHciNfc_LinkMgmt_Initialise function creates and the opens Link 77 | * Management Gate 78 | * 79 | * \param[in] psHciContext psHciContext is the pointer to HCI Layer 80 | * context Structure. 81 | * \param[in] pHwRef pHwRef is the Information of 82 | * the Device Interface Link . 83 | * 84 | * \retval NFCSTATUS_PENDING Link Mgmt Gate Initialisation is pending. 85 | * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 86 | * could not be interpreted properly. 87 | * \retval Other errors Errors related to the other layers 88 | * 89 | */ 90 | extern 91 | NFCSTATUS 92 | phHciNfc_LinkMgmt_Initialise( 93 | phHciNfc_sContext_t *psHciContext, 94 | void *pHwRef 95 | ); 96 | /** 97 | * \ingroup grp_hci_nfc 98 | * 99 | * The phHciNfc_LinkMgmt_Release function closes the opened pipes between 100 | * the Host Controller Device and the NFC Device. 101 | * 102 | * \param[in] psHciContext psHciContext is the pointer to HCI Layer 103 | * context Structure. 104 | * \param[in] pHwRef pHwRef is the Information of 105 | * the Device Interface Link . 106 | * 107 | * \retval NFCSTATUS_PENDING Release of the Link Management gate 108 | * resources are pending. 109 | * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 110 | * could not be interpreted properly. 111 | * \retval Other errors Errors related to the other layers 112 | * 113 | */ 114 | extern 115 | NFCSTATUS 116 | phHciNfc_LinkMgmt_Release( 117 | phHciNfc_sContext_t *psHciContext, 118 | void *pHwRef 119 | ); 120 | 121 | 122 | /** 123 | * \ingroup grp_hci_nfc 124 | * 125 | * The phHciNfc_LinkMgmt_Open function opens Link 126 | * Management Gate 127 | * 128 | * \param[in] psHciContext psHciContext is the pointer to HCI Layer 129 | * context Structure. 130 | * \param[in] pHwRef pHwRef is the Information of 131 | * the Device Interface Link . 132 | * 133 | * \retval NFCSTATUS_PENDING Link Mgmt Gate open is pending. 134 | * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 135 | * could not be interpreted properly. 136 | * \retval Other errors Errors related to the other layers 137 | * 138 | */ 139 | 140 | extern 141 | NFCSTATUS 142 | phHciNfc_LinkMgmt_Open( 143 | phHciNfc_sContext_t *psHciContext, 144 | void *pHwRef 145 | ); 146 | 147 | 148 | #endif 149 | 150 | -------------------------------------------------------------------------------- /src/phHciNfc_PollingLoop.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /*! 18 | * =========================================================================== * 19 | * * 20 | * * 21 | * \file phHciNfc_PollingLoop.h * 22 | * \brief HCI Header for the Polling loop Management. * 23 | * * 24 | * * 25 | * Project: NFC-FRI-1.1 * 26 | * * 27 | * $Date: Mon Mar 29 17:34:49 2010 $ * 28 | * $Author: ing04880 $ * 29 | * $Revision: 1.6 $ * 30 | * $Aliases: 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 $ * 31 | * * 32 | * =========================================================================== * 33 | */ 34 | 35 | 36 | #ifndef PHHCINFC_POLLINGLOOP_H 37 | #define PHHCINFC_POLLINGLOOP_H 38 | 39 | /*@}*/ 40 | 41 | 42 | /** 43 | * \name HCI 44 | * 45 | * File: \ref phHciNfc_PollingLoop.h 46 | * 47 | */ 48 | /*@{*/ 49 | #define PHHCINFC_POLLINGLOOP_FILEREVISION "$Revision: 1.6 $" /**< \ingroup grp_file_attributes */ 50 | #define PHHCINFC_POLLINGLOOP_FILEALIASES "$Aliases: 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 */ 51 | /*@}*/ 52 | 53 | /* 54 | ***************************** Header File Inclusion **************************** 55 | */ 56 | 57 | #include 58 | 59 | /* 60 | ****************************** Macro Definitions ******************************* 61 | */ 62 | #define PL_DURATION 0x00U 63 | #define PL_RD_PHASES 0x01U 64 | #define PL_DISABLE_TARGET 0x02U 65 | 66 | 67 | 68 | #define PL_RD_PHASES_DISABLE 0x80U 69 | 70 | /* 71 | ******************** Enumeration and Structure Definition ********************** 72 | */ 73 | 74 | /** \defgroup grp_hci_nfc HCI Component 75 | * 76 | * 77 | */ 78 | 79 | 80 | /* 81 | *********************** Function Prototype Declaration ************************* 82 | */ 83 | 84 | /** 85 | * \ingroup grp_hci_nfc 86 | * 87 | * The phHciNfc_PollLoop_Initialise function Initialises the polling loop and opens the 88 | * polling loop pipe 89 | * 90 | * \param[in] psHciContext psHciContext is the pointer to HCI Layer 91 | * context Structure. 92 | * \param[in] pHwRef pHwRef is the Information of 93 | * the Device Interface Link . 94 | * 95 | * \retval NFCSTATUS_PENDING Polling loop gate Initialisation is pending. 96 | * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 97 | * could not be interpreted properly. 98 | * \retval Other errors Errors related to the other layers 99 | * 100 | */ 101 | 102 | extern 103 | NFCSTATUS 104 | phHciNfc_PollLoop_Initialise( 105 | phHciNfc_sContext_t *psHciContext, 106 | void *pHwRef 107 | ); 108 | 109 | /** 110 | * \ingroup grp_hci_nfc 111 | * 112 | * The phHciNfc_PollLoop_Release function closes the polling loop gate pipe 113 | * between the Host Controller Device and the NFC Device. 114 | * 115 | * \param[in] psHciContext psHciContext is the pointer to HCI Layer 116 | * context Structure. 117 | * \param[in] pHwRef pHwRef is the Information of 118 | * the Device Interface Link . 119 | * 120 | * \retval NFCSTATUS_PENDING Release of the Polling loop gate resources are 121 | * pending. 122 | * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 123 | * could not be interpreted properly. 124 | * \retval Other errors Errors related to the other layers 125 | * 126 | */ 127 | 128 | extern 129 | NFCSTATUS 130 | phHciNfc_PollLoop_Release( 131 | phHciNfc_sContext_t *psHciContext, 132 | void *pHwRef 133 | ); 134 | 135 | 136 | /** 137 | * \ingroup grp_hci_nfc 138 | * 139 | * The phHciNfc_PollLoop_Update_PipeInfo function updates the pipe_id of the polling 140 | * loop gate Managment Struction. 141 | * 142 | * \param[in] psHciContext psHciContext is the pointer to HCI Layer 143 | * context Structure. 144 | * \param[in] pHwRef pHwRef is the Information of 145 | * the Device Interface Link 146 | * \param[in] cfg_type Poll configuration type 147 | * 148 | * \param[in] pcfg_info Poll configuration info. 149 | * 150 | * \retval NFCSTATUS_SUCCESS Polling loop gate Response received Successfully. 151 | * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 152 | * could not be interpreted properly. 153 | * 154 | */ 155 | extern 156 | NFCSTATUS 157 | phHciNfc_PollLoop_Cfg ( 158 | void *psHciHandle, 159 | void *pHwRef, 160 | uint8_t cfg_type, 161 | void *pcfg_info 162 | ); 163 | 164 | /** 165 | * \ingroup grp_hci_nfc 166 | * 167 | * The phHciNfc_PollLoop_Update_PipeInfo function updates the pipe_id of the polling 168 | * loop gate management structure. This function is used by the pipe management to 169 | * update the pipe id 170 | * 171 | * \param[in] psHciContext psHciContext is the pointer to HCI Layer 172 | * context Structure. 173 | * \param[in] pipeID pipeID of the polling loop gate 174 | * \param[in] pPipeInfo Update the pipe Information of the polling loop 175 | * gate. 176 | * 177 | * \retval NFCSTATUS_SUCCESS Polling loop gate Response received Successfully. 178 | * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 179 | * could not be interpreted properly. 180 | * 181 | */ 182 | 183 | extern 184 | NFCSTATUS 185 | phHciNfc_PollLoop_Update_PipeInfo( 186 | phHciNfc_sContext_t *psHciContext, 187 | uint8_t pipeID, 188 | phHciNfc_Pipe_Info_t *pPipeInfo 189 | ); 190 | 191 | 192 | /*! 193 | * \brief Allocates the resources of Polling loop Managment Gate. 194 | * 195 | * This function Allocates the resources of the Polling loop management 196 | * gate Information Structure. 197 | * 198 | */ 199 | extern 200 | NFCSTATUS 201 | phHciNfc_PollLoop_Init_Resources( 202 | phHciNfc_sContext_t *psHciContext 203 | ); 204 | 205 | 206 | /*! 207 | * \brief Get the pipe_id of Polling loop managment Gate. 208 | * 209 | * This function Get the pipe_id of Polling loop managment Gate. 210 | * 211 | */ 212 | 213 | extern 214 | NFCSTATUS 215 | phHciNfc_PollLoop_Get_PipeID( 216 | phHciNfc_sContext_t *psHciContext, 217 | uint8_t *ppipe_id 218 | ); 219 | 220 | #endif /* PHHCINFC_POLLINGLOOP_H */ 221 | 222 | 223 | -------------------------------------------------------------------------------- /src/phLibNfcStatus.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * \file phLibNfcStatus.h 19 | * \brief NFC Status Values - Function Return Codes 20 | * 21 | * Project: NFC MW / HAL 22 | * 23 | * $Date: Thu Feb 25 19:16:41 2010 $ 24 | * $Author: ing07385 $ 25 | * $Revision: 1.24 $ 26 | * $Aliases: NFC_FRI1.1_WK1008_SDK,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1007_SDK,NFC_FRI1.1_WK1014_SDK,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1019_SDK,NFC_FRI1.1_WK1024_SDK $ 27 | * 28 | */ 29 | #ifndef PHLIBNFCSTATUS_H /* */ 30 | #define PHLIBNFCSTATUS_H/* */ 31 | 32 | #include 33 | 34 | #define LLCP_CHANGES 35 | #define LLCP_TRANSACT_CHANGES 36 | 37 | #ifdef LLCP_TRANSACT_CHANGES 38 | /* These two macros are defined due to non availibity of the below macros in header files 39 | #define PHFRINFC_LLCP_STATE_RESET_INIT 0 // \internal Initial state 40 | #define PHFRINFC_LLCP_STATE_CHECKED 1 // \internal The tag has been checked for LLCP compliance 41 | */ 42 | #define LLCP_STATE_RESET_INIT 0x00U 43 | #define LLCP_STATE_CHECKED 0x01U 44 | 45 | 46 | #endif /* #ifdef LLCP_TRANSACT_CHANGES */ 47 | #define LIB_NFC_VERSION_SET(v,major,minor,patch,build) ((v) = \ 48 | ( ((major) << 24) & 0xFF000000 ) | \ 49 | ( ((minor) << 16) & 0x00FF0000 ) | \ 50 | ( ((patch) << 8) & 0x0000FF00 ) | \ 51 | ( (build) & 0x000000FF ) ) 52 | 53 | #define NFCSTATUS_SHUTDOWN (0x0091) 54 | #define NFCSTATUS_TARGET_LOST (0x0092) 55 | #define NFCSTATUS_REJECTED (0x0093) 56 | #define NFCSTATUS_TARGET_NOT_CONNECTED (0x0094) 57 | #define NFCSTATUS_INVALID_HANDLE (0x0095) 58 | #define NFCSTATUS_ABORTED (0x0096) 59 | #define NFCSTATUS_COMMAND_NOT_SUPPORTED (0x0097) 60 | #define NFCSTATUS_NON_NDEF_COMPLIANT (0x0098) 61 | #define NFCSTATUS_OK (0x0000) 62 | 63 | #ifndef NFCSTATUS_NOT_ENOUGH_MEMORY 64 | #define NFCSTATUS_NOT_ENOUGH_MEMORY (0x001F) 65 | #endif 66 | 67 | 68 | #endif /* PHNFCSTATUS_H */ 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/phLibNfc_SE.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /*! 18 | * \file phLibNfc_SE.h 19 | * 20 | * Project: NFC-FRI 1.1 21 | * 22 | * $Workfile:: phLibNfc_1.1.h $ 23 | * $Modtime:: $ 24 | * $Author: ing07299 $ 25 | * $Revision: 1.14 $ 26 | * 27 | */ 28 | #ifndef PHLIBNFC_SE_H 29 | #define PHLIBNFC_SE_H 30 | 31 | #define LIBNFC_SE_INVALID_HANDLE 0 32 | #define LIBNFC_SE_SUPPORTED 2 33 | #define LIBNFC_SE_BASE_HANDLE 0xABCDEF 34 | 35 | #define LIBNFC_SE_SMARTMX_INDEX 0 36 | #define LIBNFC_SE_UICC_INDEX 1 37 | 38 | #define PAUSE_PHASE 0x0824 /*Indicates the Pause phase duration*/ 39 | #define EMULATION_PHASE 0x5161 /*Indicates the Emulation phase duration*/ 40 | 41 | typedef struct phLibNfc_SeCallbackInfo 42 | { 43 | /* SE set mode callback and its context */ 44 | pphLibNfc_SE_SetModeRspCb_t pSEsetModeCb; 45 | void *pSEsetModeCtxt; 46 | /* Store SE discovery notification callback and its context */ 47 | pphLibNfc_SE_NotificationCb_t pSeListenerNtfCb; 48 | void *pSeListenerCtxt; 49 | 50 | }phLibNfc_SECallbackInfo_t; 51 | 52 | /*SE State */ 53 | typedef enum { 54 | phLibNfc_eSeInvalid = 0x00, 55 | phLibNfc_eSeInit, 56 | phLibNfc_eSeReady, 57 | phLibNfc_eSeVirtual, 58 | phLibNfc_eSeWired 59 | }phLibNfc_SeState_t; 60 | 61 | 62 | /* Context for secured element */ 63 | typedef struct phLibNfc_SeCtxt 64 | { 65 | 66 | /* UICC Status in Virtual Mode */ 67 | uint8_t uUiccActivate; 68 | 69 | /* SMX Status in Virtual Mode */ 70 | uint8_t uSmxActivate; 71 | 72 | /* Count of the Secure Elements Present */ 73 | uint8_t uSeCount; 74 | 75 | /* Se Temp handle */ 76 | phLibNfc_Handle hSetemp; 77 | 78 | /*Current SE state*/ 79 | phLibNfc_SeState_t eSE_State; 80 | 81 | /*Current SE Mode */ 82 | 83 | phLibNfc_eSE_ActivationMode eActivatedMode; 84 | 85 | /* SE callback information */ 86 | phLibNfc_SECallbackInfo_t sSeCallabackInfo; 87 | 88 | }phLibNfc_SeCtxt_t; 89 | 90 | extern phLibNfc_SE_List_t sSecuredElementInfo[PHLIBNFC_MAXNO_OF_SE]; 91 | 92 | 93 | 94 | #endif 95 | 96 | 97 | -------------------------------------------------------------------------------- /src/phLibNfc_discovery.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /*! 18 | * \file phLibNfc_1.1.h 19 | * 20 | * Project: NFC-FRI 1.1 21 | * 22 | * $Workfile:: phLibNfc_1.1.h $ 23 | * $Modtime:: $ 24 | * $Author: ing07299 $ 25 | * $Revision: 1.9 $ 26 | * 27 | */ 28 | #ifndef PHLIBNFC_DISCOVERY_H 29 | #define PHLIBNFC_DISCOVERY_H 30 | 31 | 32 | 33 | extern void 34 | phLibNfc_config_discovery_cb(void *context, 35 | NFCSTATUS status 36 | ); 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /src/phLibNfc_initiator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /*! 18 | * \file phLibNfc_initiator.h 19 | * 20 | * Project: NFC-FRI 1.1 21 | * 22 | * $Workfile:: phLibNfc_1.1.h $ 23 | * $Modtime:: $ 24 | * $Author: ing07299 $ 25 | * $Revision: 1.13 $ 26 | * 27 | */ 28 | #ifndef PHLIBNFC_INITIATOR_H 29 | #define PHLIBNFC_INITIATOR_H 30 | 31 | typedef struct phLibNfc_NfcIpInfo 32 | { 33 | phNfc_sData_t *p_recv_data; 34 | uint32_t recv_index; 35 | /*NFC-IP Call back & it's context*/ 36 | pphLibNfc_RspCb_t pClientNfcIpCfgCb; 37 | void *pClientNfcIpCfgCntx; 38 | /*NFC-IP send callback and its context*/ 39 | pphLibNfc_RspCb_t pClientNfcIpTxCb; 40 | void *pClientNfcIpTxCntx; 41 | 42 | /*NFC-IP receive callback and its context*/ 43 | pphLibNfc_Receive_RspCb_t pClientNfcIpRxCb; 44 | void *pClientNfcIpRxCntx; 45 | /*Store the role of remote device*/ 46 | phHal4Nfc_TransactInfo_t TransactInfoRole; 47 | 48 | /*NFC IP remote initator handle */ 49 | uint32_t Rem_Initiator_Handle; 50 | 51 | }phLibNfc_NfcIpInfo_t; 52 | 53 | 54 | #endif 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/phLibNfc_ioctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /*! 18 | *\file phLibNfc_ioctl.h 19 | *\brief Contains LibNfc IOCTL details. 20 | *Project: NFC-FRI 1.1 21 | * $Workfile:: phLibNfc_ioctl.h $ 22 | * $Modtime:: $ 23 | * $Author: ing07299 $ 24 | * $Revision: 1.9 $ 25 | * $Aliases: NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK949_SDK_INT,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK1003_SDK,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1008_SDK,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1007_SDK,NFC_FRI1.1_WK1014_SDK,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1019_SDK,NFC_FRI1.1_WK1024_SDK $ 26 | *\defgroup grp_lib_ioctl IOCTL code details 27 | */ 28 | 29 | 30 | #ifndef PHLIBNFCIOCTL_H /* */ 31 | #define PHLIBNFCIOCTL_H /* */ 32 | 33 | #include 34 | #include 35 | 36 | /** 37 | * \ingroup grp_lib_ioctl 38 | * \brief Allows to initiate firmware download to connected PN544 39 | * 40 | */ 41 | #define PHLIBNFC_FW_DOWNLOAD NFC_FW_DOWNLOAD 42 | /** 43 | * \ingroup grp_lib_ioctl 44 | * \brief Allows to read memory from connected PN544 . 45 | * 46 | */ 47 | #define PHLIBNFC_MEM_READ NFC_MEM_READ 48 | 49 | /** 50 | * \ingroup grp_lib_ioctl 51 | * \brief Allows to write PN544 memory. 52 | * 53 | */ 54 | #define PHLIBNFC_MEM_WRITE NFC_MEM_WRITE 55 | 56 | /** 57 | * \ingroup grp_lib_ioctl 58 | * \brief Allows to do Antenna test. 59 | * 60 | */ 61 | #define PHLIBNFC_ANTENNA_TEST DEVMGMT_ANTENNA_TEST 62 | /** 63 | * \ingroup grp_lib_ioctl 64 | * \brief Allows to do SWP test. 65 | * 66 | */ 67 | #define PHLIBNFC_SWP_TEST DEVMGMT_SWP_TEST 68 | /** 69 | * \ingroup grp_lib_ioctl 70 | * \brief Allows to do PRBS test. 71 | * 72 | */ 73 | #define PHLIBNFC_PRBS_TEST DEVMGMT_PRBS_TEST 74 | 75 | /** 76 | * \ingroup grp_lib_ioctl 77 | * \brief Allows to switch UICC mode. 78 | * 79 | */ 80 | #define PHLIBNFC_SWITCH_SWP_MODE NFC_SWITCH_SWP_MODE 81 | 82 | typedef struct 83 | { 84 | void *pCliCntx; 85 | pphLibNfc_IoctlCallback_t CliRspCb; 86 | phHal_sHwReference_t *psHwReference; 87 | phNfc_sData_t* pOutParam; 88 | uint16_t IoctlCode; 89 | }phLibNfc_Ioctl_Cntx_t; 90 | 91 | #endif /* PHLIBNFCIOCTL_H */ 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /src/phLibNfc_ndef_raw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /*! 18 | * \file phLibNfc_ndef_raw.h 19 | * 20 | * Project: NFC-FRI 1.1 21 | * 22 | * $Workfile:: phLibNfc_1.1.h $ 23 | * $Modtime:: $ 24 | * $Author: ing07299 $ 25 | * $Revision: 1.15 $ 26 | * 27 | */ 28 | #ifndef PHLIBNFC_NDEF_RAW_H 29 | #define PHLIBNFC_NDEF_RAW_H 30 | 31 | /*Check for type of NDEF Calls*/ 32 | typedef enum phLibNfc_Last_Call{ 33 | ChkNdef = 0x00, 34 | NdefRd, 35 | NdefWr, 36 | NdefFmt, 37 | #ifdef LIBNFC_READONLY_NDEF 38 | NdefReadOnly, 39 | #endif /* #ifdef LIBNFC_READONLY_NDEF */ 40 | RawTrans 41 | } phLibNfc_Last_Call_t; 42 | 43 | #define TAG_MIFARE 0x01 44 | #define TAG_FELICA 0x02 45 | #define TAG_JEWEL 0x04 46 | #define TAG_ISO14443_4A 0x08 47 | #define TAG_ISO14443_4B 0x10 48 | #define TAG_NFC_IP1 0x20 49 | 50 | #define NDEF_READ_TIMER_TIMEOUT 60U 51 | #define CHK_NDEF_TIMER_TIMEOUT 60U 52 | #define NDEF_SENDRCV_BUF_LEN 252U 53 | #define NDEF_TEMP_RECV_LEN 256U 54 | #define NDEF_MIFARE_UL_LEN 46U 55 | #define NDEF_FELICA_LEN 0U/*len to be set when supported*/ 56 | #define NDEF_JEWEL_TOPAZ_LEN 0U 57 | #define NDEF_ISO14443_4A_LEN 4096U 58 | #define NDEF_ISO14443_4B_LEN 0U 59 | #define NDEF_MIFARE_4K_LEN 3356U 60 | #define NDEF_MIFARE_1K_LEN 716U 61 | #define MIFARE_STD_DEFAULT_KEY {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} 62 | #define MIFARE_STD_KEY_LEN 6 63 | #define ISO_SAK_VALUE 0x20U 64 | 65 | 66 | #define UNKNOWN_BLOCK_ADDRESS 0xFF /***/ 67 | #define SESSION_OPEN 0x01 68 | 69 | 70 | extern void phLibNfc_Ndef_Init(void); 71 | extern void phLibNfc_Ndef_DeInit(void); 72 | extern phLibNfc_Ndef_Info_t NdefInfo; 73 | extern phFriNfc_NdefRecord_t *pNdefRecord; 74 | 75 | #endif 76 | 77 | -------------------------------------------------------------------------------- /src/phLlcNfc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /*! 18 | * \file phLlcNfc.h 19 | * \brief Common LLC for the upper layer. 20 | * 21 | * Project: NFC-FRI-1.1 22 | * 23 | * $Date: Thu Sep 11 12:18:52 2008 $ 24 | * $Author: ing02260 $ 25 | * $Revision: 1.7 $ 26 | * $Aliases: NFC_FRI1.1_WK838_PREP1,NFC_FRI1.1_WK838_R9_PREP2,NFC_FRI1.1_WK838_R9_1,NFC_FRI1.1_WK840_R10_PREP1,NFC_FRI1.1_WK840_R10_1,NFC_FRI1.1_WK842_R11_PREP1,NFC_FRI1.1_WK842_R11_PREP2,NFC_FRI1.1_WK842_R11_1,NFC_FRI1.1_WK844_PREP1,NFC_FRI1.1_WK844_R12_1,NFC_FRI1.1_WK846_PREP1,NFC_FRI1.1_WK846_R13_1,NFC_FRI1.1_WK848_PREP1,NFC_FRI1.1_WK848_R14_1,NFC_FRI1.1_WK849_PACK1_PREP1,NFC_FRI1.1_WK850_PACK1,NFC_FRI1.1_WK851_PREP1,NFC_FRI1.1_WK850_R15_1,NFC_FRI1.1_WK902_PREP1,NFC_FRI1.1_WK902_R16_1,NFC_FRI1.1_WK904_PREP1,NFC_FRI1.1_WK904_R17_1,NFC_FRI1.1_WK906_R18_1,NFC_FRI1.1_WK908_PREP1,NFC_FRI1.1_WK908_R19_1,NFC_FRI1.1_WK910_PREP1,NFC_FRI1.1_WK910_R20_1,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_WK926_R28_2,NFC_FRI1.1_WK926_R28_3,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 $ 27 | * 28 | */ 29 | 30 | #ifndef PHLLCNFC_H 31 | #define PHLLCNFC_H 32 | 33 | #ifdef ANDROID 34 | #include 35 | #endif 36 | 37 | /** 38 | * \name LLC NFC 39 | * 40 | * File: \ref phLlcNfc.h 41 | * 42 | */ 43 | /*@{*/ 44 | #define PH_LLCNFC_FILEREVISION "$Revision: 1.7 $" /**< \ingroup grp_file_attributes */ 45 | #define PH_LLCNFC_FILEALIASES "$Aliases: NFC_FRI1.1_WK838_PREP1,NFC_FRI1.1_WK838_R9_PREP2,NFC_FRI1.1_WK838_R9_1,NFC_FRI1.1_WK840_R10_PREP1,NFC_FRI1.1_WK840_R10_1,NFC_FRI1.1_WK842_R11_PREP1,NFC_FRI1.1_WK842_R11_PREP2,NFC_FRI1.1_WK842_R11_1,NFC_FRI1.1_WK844_PREP1,NFC_FRI1.1_WK844_R12_1,NFC_FRI1.1_WK846_PREP1,NFC_FRI1.1_WK846_R13_1,NFC_FRI1.1_WK848_PREP1,NFC_FRI1.1_WK848_R14_1,NFC_FRI1.1_WK849_PACK1_PREP1,NFC_FRI1.1_WK850_PACK1,NFC_FRI1.1_WK851_PREP1,NFC_FRI1.1_WK850_R15_1,NFC_FRI1.1_WK902_PREP1,NFC_FRI1.1_WK902_R16_1,NFC_FRI1.1_WK904_PREP1,NFC_FRI1.1_WK904_R17_1,NFC_FRI1.1_WK906_R18_1,NFC_FRI1.1_WK908_PREP1,NFC_FRI1.1_WK908_R19_1,NFC_FRI1.1_WK910_PREP1,NFC_FRI1.1_WK910_R20_1,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_WK926_R28_2,NFC_FRI1.1_WK926_R28_3,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 */ 46 | /*@}*/ 47 | /*************************** Includes *******************************/ 48 | 49 | /*********************** End of includes ****************************/ 50 | /** \defgroup grp_hal_nfc_llc LLC Component 51 | * 52 | * 53 | * 54 | */ 55 | 56 | /***************************** Macros *******************************/ 57 | 58 | /************************ End of macros *****************************/ 59 | 60 | /********************** Callback functions **************************/ 61 | 62 | /******************* End of Callback functions **********************/ 63 | 64 | /********************* Structures and enums *************************/ 65 | 66 | 67 | /****************** End of structures and enums *********************/ 68 | 69 | 70 | /******************** Function declarations *************************/ 71 | /** 72 | * \ingroup grp_hal_nfc_llc 73 | * 74 | * \brief \b Register function 75 | * 76 | * \copydoc page_reg Provides the callback to the LLC layer and register 77 | * the calling functions to the upper layer (Synchronous function). 78 | * 79 | * \param[out] psReference Structure is used to give the LLC calling functions 80 | * and also LLC context information to the upper layer 81 | * \param[in] if_callback Callback information provided by the upper layer 82 | * \param[in] psIFConfig This gives the information of the next register call 83 | * 84 | * \retval NFCSTATUS_SUCCESS Operation successful. 85 | * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. 86 | * \retval Other errors Errors related to the lower layers 87 | * 88 | */ 89 | 90 | NFCSTATUS 91 | phLlcNfc_Register ( 92 | phNfcIF_sReference_t *psReference, 93 | phNfcIF_sCallBack_t if_callback, 94 | void *psIFConfig 95 | ); 96 | 97 | 98 | 99 | /****************** End of function declarations ********************/ 100 | #endif /* PHLLCNFC_H */ 101 | -------------------------------------------------------------------------------- /src/phLlcNfc_Interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /*! 18 | * \file phLlcNfc_Interface.h 19 | * \brief Interface for both LLC and transport layer 20 | * 21 | * Project: NFC-FRI-1.1 22 | * 23 | * $Date: Thu Sep 11 12:19:29 2008 $ 24 | * $Author: ing02260 $ 25 | * $Revision: 1.9 $ 26 | * $Aliases: NFC_FRI1.1_WK838_PREP1,NFC_FRI1.1_WK838_R9_PREP2,NFC_FRI1.1_WK838_R9_1,NFC_FRI1.1_WK840_R10_PREP1,NFC_FRI1.1_WK840_R10_1,NFC_FRI1.1_WK842_R11_PREP1,NFC_FRI1.1_WK842_R11_PREP2,NFC_FRI1.1_WK842_R11_1,NFC_FRI1.1_WK844_PREP1,NFC_FRI1.1_WK844_R12_1,NFC_FRI1.1_WK846_PREP1,NFC_FRI1.1_WK846_R13_1,NFC_FRI1.1_WK848_PREP1,NFC_FRI1.1_WK848_R14_1,NFC_FRI1.1_WK849_PACK1_PREP1,NFC_FRI1.1_WK850_PACK1,NFC_FRI1.1_WK851_PREP1,NFC_FRI1.1_WK850_R15_1,NFC_FRI1.1_WK902_PREP1,NFC_FRI1.1_WK902_R16_1,NFC_FRI1.1_WK904_PREP1,NFC_FRI1.1_WK904_R17_1,NFC_FRI1.1_WK906_R18_1,NFC_FRI1.1_WK908_PREP1,NFC_FRI1.1_WK908_R19_1,NFC_FRI1.1_WK910_PREP1,NFC_FRI1.1_WK910_R20_1,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_WK926_R28_2,NFC_FRI1.1_WK926_R28_3,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 $ 27 | * 28 | */ 29 | 30 | #ifndef PHLLCNFC_INTERFACE_H 31 | #define PHLLCNFC_INTERFACE_H 32 | 33 | /** 34 | * \name LLC TL NFC interface 35 | * 36 | * File: \ref phLlcTlNfc_Interface.h 37 | * 38 | */ 39 | /*@{*/ 40 | #define PH_LLCNFC_INTERFACE_FILEREVISION "$Revision: 1.9 $" /**< \ingroup grp_hal_nfc_llc */ 41 | #define PH_LLCNFC_INTERFACE_FILEALIASES "$Aliases: NFC_FRI1.1_WK838_PREP1,NFC_FRI1.1_WK838_R9_PREP2,NFC_FRI1.1_WK838_R9_1,NFC_FRI1.1_WK840_R10_PREP1,NFC_FRI1.1_WK840_R10_1,NFC_FRI1.1_WK842_R11_PREP1,NFC_FRI1.1_WK842_R11_PREP2,NFC_FRI1.1_WK842_R11_1,NFC_FRI1.1_WK844_PREP1,NFC_FRI1.1_WK844_R12_1,NFC_FRI1.1_WK846_PREP1,NFC_FRI1.1_WK846_R13_1,NFC_FRI1.1_WK848_PREP1,NFC_FRI1.1_WK848_R14_1,NFC_FRI1.1_WK849_PACK1_PREP1,NFC_FRI1.1_WK850_PACK1,NFC_FRI1.1_WK851_PREP1,NFC_FRI1.1_WK850_R15_1,NFC_FRI1.1_WK902_PREP1,NFC_FRI1.1_WK902_R16_1,NFC_FRI1.1_WK904_PREP1,NFC_FRI1.1_WK904_R17_1,NFC_FRI1.1_WK906_R18_1,NFC_FRI1.1_WK908_PREP1,NFC_FRI1.1_WK908_R19_1,NFC_FRI1.1_WK910_PREP1,NFC_FRI1.1_WK910_R20_1,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_WK926_R28_2,NFC_FRI1.1_WK926_R28_3,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_hal_nfc_llc */ 42 | /*@}*/ 43 | /*************************** Includes *******************************/ 44 | 45 | /*********************** End of includes ****************************/ 46 | 47 | /***************************** Macros *******************************/ 48 | #define PH_LLCNFC_READWAIT_OFF 0 49 | #define PH_LLCNFC_READWAIT_ON 1 50 | 51 | /************************ End of macros *****************************/ 52 | 53 | /********************** Callback functions **************************/ 54 | 55 | /******************* End of Callback functions **********************/ 56 | 57 | /********************* Structures and enums *************************/ 58 | 59 | /****************** End of structures and enums *********************/ 60 | 61 | /******************** Function declarations *************************/ 62 | 63 | NFCSTATUS 64 | phLlcNfc_Interface_Register( 65 | phLlcNfc_Context_t *psLlcCtxt, 66 | phNfcLayer_sCfg_t *psIFConfig 67 | ); 68 | 69 | NFCSTATUS 70 | phLlcNfc_Interface_Init( 71 | phLlcNfc_Context_t *psLlcCtxt 72 | ); 73 | 74 | NFCSTATUS 75 | phLlcNfc_Interface_Read( 76 | phLlcNfc_Context_t *psLlcCtxt, 77 | uint8_t readWaitOn, 78 | uint8_t *pLlcBuffer, 79 | uint32_t llcBufferLength 80 | ); 81 | 82 | NFCSTATUS 83 | phLlcNfc_Interface_Write( 84 | phLlcNfc_Context_t *psLlcCtxt, 85 | uint8_t *pLlcBuffer, 86 | uint32_t llcBufferLength 87 | ); 88 | 89 | /** 90 | * \ingroup grp_hal_nfc_llc 91 | * 92 | * \brief \b Release function 93 | * 94 | * \copydoc page_reg Release all the variables of the LLC component, that has been 95 | * initialised in \b phLlcNfc_Init function (Synchronous function). 96 | * 97 | * \param[in] pContext LLC context is provided by the upper layer. The LLC 98 | * context earlier was given to the upper layer through the 99 | * \ref phLlcNfc_Register function 100 | * \param[in] pLinkInfo Link information of the hardware 101 | * 102 | * \retval NFCSTATUS_PENDING If the command is yet to be processed. 103 | * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. 104 | * \retval Other errors Errors related to the lower layers 105 | * 106 | */ 107 | extern 108 | NFCSTATUS 109 | phLlcNfc_Release( 110 | void *pContext, 111 | void *pLinkInfo 112 | ); 113 | /****************** End of Function declarations ********************/ 114 | #endif /* PHLLCTLNFC_INTERFACE_H */ 115 | -------------------------------------------------------------------------------- /src/phLlcNfc_StateMachine.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /*! 18 | * \file phLlcNfc_StateMachine.c 19 | * \brief Llc state machine implemenatation. 20 | * 21 | * Project: NFC-FRI-1.1 22 | * 23 | * $Date: Fri Apr 17 09:17:48 2009 $ 24 | * $Author: ing02260 $ 25 | * $Revision: 1.8 $ 26 | * $Aliases: 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_WK926_R28_2,NFC_FRI1.1_WK926_R28_3,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 $ 27 | * 28 | */ 29 | 30 | /*************************** Includes *******************************/ 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | /*********************** End of includes ****************************/ 39 | 40 | /***************************** Macros *******************************/ 41 | 42 | /************************ End of macros *****************************/ 43 | 44 | /*********************** Local functions ****************************/ 45 | 46 | /******************** End of Local functions ************************/ 47 | 48 | /********************** Global variables ****************************/ 49 | 50 | /******************** End of Global Variables ***********************/ 51 | 52 | NFCSTATUS 53 | phLlcNfc_H_ChangeState( 54 | phLlcNfc_Context_t *psLlcCtxt, 55 | phLlcNfc_State_t changeStateTo 56 | ) 57 | { 58 | NFCSTATUS result = PHNFCSTVAL(CID_NFC_LLC, 59 | NFCSTATUS_INVALID_STATE); 60 | if ((NULL != psLlcCtxt) && 61 | (changeStateTo != phLlcNfc_Uninitialise_State)) 62 | { 63 | switch(psLlcCtxt->state) 64 | { 65 | case phLlcNfc_Uninitialise_State: 66 | { 67 | if (phLlcNfc_Initialising_State == changeStateTo) 68 | { 69 | result = NFCSTATUS_SUCCESS; 70 | psLlcCtxt->state = changeStateTo; 71 | } 72 | break; 73 | } 74 | case phLlcNfc_Initialising_State: 75 | { 76 | if (phLlcNfc_Initialised_State == changeStateTo) 77 | { 78 | result = NFCSTATUS_SUCCESS; 79 | psLlcCtxt->state = changeStateTo; 80 | } 81 | break; 82 | } 83 | case phLlcNfc_Initialised_State: 84 | { 85 | if (changeStateTo > phLlcNfc_Initialising_State) 86 | { 87 | result = NFCSTATUS_SUCCESS; 88 | psLlcCtxt->state = changeStateTo; 89 | } 90 | break; 91 | } 92 | case phLlcNfc_ReceiveWait_State: 93 | { 94 | if (changeStateTo >= phLlcNfc_Initialised_State) 95 | { 96 | result = NFCSTATUS_SUCCESS; 97 | psLlcCtxt->state = changeStateTo; 98 | } 99 | break; 100 | } 101 | case phLlcNfc_Sending_State: 102 | { 103 | if ((phLlcNfc_Initialised_State == changeStateTo) || 104 | (phLlcNfc_Sending_State == changeStateTo)) 105 | { 106 | result = NFCSTATUS_SUCCESS; 107 | psLlcCtxt->state = changeStateTo; 108 | } 109 | break; 110 | } 111 | case phLlcNfc_Receiving_State: 112 | { 113 | if ((phLlcNfc_Initialised_State == changeStateTo) || 114 | (phLlcNfc_Sending_State == changeStateTo)) 115 | { 116 | result = NFCSTATUS_SUCCESS; 117 | psLlcCtxt->state = changeStateTo; 118 | } 119 | break; 120 | } 121 | case phLlcNfc_Resend_State: 122 | { 123 | if (phLlcNfc_Initialised_State == changeStateTo) 124 | { 125 | result = NFCSTATUS_SUCCESS; 126 | psLlcCtxt->state = changeStateTo; 127 | } 128 | if (phLlcNfc_Sending_State == changeStateTo) 129 | { 130 | result = NFCSTATUS_SUCCESS; 131 | if (0 != psLlcCtxt->s_frameinfo.s_send_store.winsize_cnt) 132 | { 133 | psLlcCtxt->state = changeStateTo; 134 | } 135 | } 136 | break; 137 | } 138 | default: 139 | { 140 | /* Error scenario: There cant be any change in the state, 141 | while LLC is in these states */ 142 | result = PHNFCSTVAL(CID_NFC_LLC, 143 | NFCSTATUS_INVALID_FORMAT); 144 | break; 145 | } 146 | } 147 | } 148 | if ((NULL != psLlcCtxt) && 149 | (phLlcNfc_Uninitialise_State == changeStateTo)) 150 | { 151 | psLlcCtxt->state = changeStateTo; 152 | } 153 | return result; 154 | } 155 | -------------------------------------------------------------------------------- /src/phLlcNfc_Timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /*! 18 | * \file phLlcNfc_Timer.h 19 | * \brief To create, start, stop and destroy timer. 20 | * 21 | * Project: NFC-FRI-1.1 22 | * 23 | * $Date: Thu Jun 10 17:26:41 2010 $ 24 | * $Author: ing02260 $ 25 | * $Revision: 1.14 $ 26 | * $Aliases: NFC_FRI1.1_WK1023_R35_1 $ 27 | * 28 | */ 29 | 30 | #ifndef PHLLCNFC_TIMER_H 31 | #define PHLLCNFC_TIMER_H 32 | 33 | /** 34 | * \name LLC NFC state machine handling 35 | * 36 | * File: \ref phLlcNfc_StateMachine.h 37 | * 38 | */ 39 | /*@{*/ 40 | #define PH_LLCNFC_TIMER_FILEREVISION "$Revision: 1.14 $" /**< \ingroup grp_hal_nfc_llc_helper */ 41 | #define PH_LLCNFC_TIMER_FILEALIASES "$Aliases: NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_hal_nfc_llc_helper */ 42 | /*@}*/ 43 | /*************************** Includes *******************************/ 44 | 45 | /*********************** End of includes ****************************/ 46 | 47 | /***************************** Macros *******************************/ 48 | #define PH_LLCNFC_CONNECTIONTIMER (0x00) /**< Timer for connection time out */ 49 | #define PH_LLCNFC_GUARDTIMER (0x01) /**< Timer for guard time out */ 50 | #define PH_LLCNFC_ACKTIMER (0x02) /**< Timer for ack time out */ 51 | #define PH_LLCNFC_MAX_RETRY_COUNT (0x03) /**< Retries */ 52 | /** Resolution value for the timer */ 53 | #define PH_LLCNFC_RESOLUTION TIMER_RESOLUTION 54 | /**< 0x05 Timer for connection time out value */ 55 | #define PH_LLCNFC_CONNECTION_TO_VALUE LINK_CONNECTION_TIMEOUT 56 | /**< 0x05 Timer for guard time out value */ 57 | #define PH_LLCNFC_GUARD_TO_VALUE LINK_GUARD_TIMEOUT 58 | 59 | #ifdef PIGGY_BACK 60 | 61 | #define PH_LLCNFC_ACK_TO_VALUE LINK_ACK_TIMEOUT 62 | 63 | #endif /* #ifdef PIGGY_BACK */ 64 | 65 | #ifdef LLC_RESET_DELAY 66 | #define LLC_URSET_DELAY_TIME_OUT LLC_RESET_DELAY 67 | #else 68 | #define LLC_URSET_DELAY_TIME_OUT 50 69 | #endif /* */ 70 | 71 | 72 | 73 | /************************ End of macros *****************************/ 74 | 75 | /********************** Callback functions **************************/ 76 | 77 | /******************* End of Callback functions **********************/ 78 | 79 | /********************* Structures and enums *************************/ 80 | 81 | /****************** End of structures and enums *********************/ 82 | 83 | /******************** Function declarations *************************/ 84 | /** 85 | * \ingroup grp_hal_nfc_llc_helper 86 | * 87 | * \brief LLC timer functions \b Timer Init function 88 | * 89 | * \copydoc page_reg This is to store LLCs main context structure 90 | * 91 | * \param[in, out] psLlcCtxt Llc main structure information 92 | * 93 | * \retval NFCSTATUS_SUCCESS Operation successful. 94 | * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. 95 | * 96 | */ 97 | NFCSTATUS 98 | phLlcNfc_TimerInit ( 99 | phLlcNfc_Context_t *psLlcCtxt 100 | ); 101 | 102 | /** 103 | * \ingroup grp_hal_nfc_llc_helper 104 | * 105 | * \brief LLC timer functions \b Timer UnInit function 106 | * 107 | * \copydoc page_reg This is to uninitialise all timer related information 108 | * 109 | * \param[in, out] psLlcCtxt Llc main structure information 110 | * 111 | * \retval NFCSTATUS_SUCCESS Operation successful. 112 | * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. 113 | * 114 | */ 115 | void 116 | phLlcNfc_TimerUnInit ( 117 | phLlcNfc_Context_t *psLlcCtxt 118 | ); 119 | 120 | /** 121 | * \ingroup grp_hal_nfc_llc_helper 122 | * 123 | * \brief LLC timer functions \b Create timer function 124 | * 125 | * \copydoc page_reg creates all the timers in the LLC context 126 | * 127 | * 128 | */ 129 | void 130 | phLlcNfc_CreateTimers (void); 131 | 132 | /** 133 | * \ingroup grp_hal_nfc_llc_helper 134 | * 135 | * \brief LLC timer functions \b Start timer function 136 | * 137 | * \copydoc page_reg starts the timer type given by the user 138 | * 139 | * \param[in] TimerType Timer type to start 140 | * \param[in] ns_value Value of N(S) for which the timer is started 141 | * 142 | * \retval NFCSTATUS_SUCCESS Operation successful. 143 | * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. 144 | * \retval Others Errors related to OsalNfc. 145 | * 146 | */ 147 | NFCSTATUS 148 | phLlcNfc_StartTimers ( 149 | uint8_t TimerType, 150 | uint8_t ns_value 151 | ); 152 | 153 | /** 154 | * \ingroup grp_hal_nfc_llc_helper 155 | * 156 | * \brief LLC timer functions \b Stop timer function 157 | * 158 | * \copydoc page_reg stop the timer type given by the user 159 | * 160 | * \param[in] TimerType Timer type to start 161 | * \param[in] no_of_gaurd_to_del Guard time-out count shall be decreased as and when 162 | * frame is removed 163 | * 164 | * 165 | */ 166 | void 167 | phLlcNfc_StopTimers ( 168 | uint8_t TimerType, 169 | uint8_t no_of_guard_to_del 170 | ); 171 | 172 | /** 173 | * \ingroup grp_hal_nfc_llc_helper 174 | * 175 | * \brief LLC timer functions \b Stop timer function 176 | * 177 | * \copydoc page_reg stop the timer type given by the user 178 | * 179 | * 180 | * 181 | * 182 | */ 183 | void 184 | phLlcNfc_StopAllTimers (void); 185 | 186 | 187 | /** 188 | * \ingroup grp_hal_nfc_llc_helper 189 | * 190 | * \brief LLC timer functions \b Delete timer function 191 | * 192 | * \copydoc page_reg deletes all the timers in the LLC context 193 | * 194 | * \retval NFCSTATUS_SUCCESS Operation successful. 195 | * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. 196 | * \retval Others Errors related to OsalNfc. 197 | * 198 | */ 199 | void 200 | phLlcNfc_DeleteTimer (void); 201 | 202 | #ifdef LLC_URSET_NO_DELAY 203 | 204 | /* NO definition required */ 205 | 206 | #else /* #ifdef LLC_URSET_NO_DELAY */ 207 | 208 | void 209 | phLlcNfc_URSET_Delay_Notify ( 210 | 211 | uint32_t delay_id); 212 | 213 | 214 | 215 | #endif /* #ifdef LLC_URSET_NO_DELAY */ 216 | 217 | /****************** End of Function declarations ********************/ 218 | #endif /* PHLLCNFC_TIMER_H */ 219 | -------------------------------------------------------------------------------- /src/phOsalNfc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * \file phOsalNfc.h 19 | * \brief OSAL Implementation. 20 | * 21 | * Project: NFC-FRI 1.1 22 | * $Date: Fri Jun 26 14:41:31 2009 $ 23 | * $Author: ing04880 $ 24 | * $Revision: 1.21 $ 25 | * $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 $ 26 | * 27 | */ 28 | #ifndef PHOSALNFC_H 29 | #define PHOSALNFC_H 30 | 31 | 32 | /** \defgroup grp_osal_nfc OSAL Component 33 | * 34 | *\note: API listed here encompasses Operating System Abstraction Layer interfaces required to be mapped to underlying OS platforms. 35 | * 36 | */ 37 | #include 38 | 39 | #ifdef PH_NFC_CUSTOMINTEGRATION 40 | #include 41 | #else 42 | #include 43 | 44 | /**< OSAL Message Type */ 45 | #ifdef WIN32 46 | //#define PH_OSALNFC_MESSAGE_BASE (WM_USER+0x3FF) 47 | #define PH_OSALNFC_MESSAGE_BASE PH_LIBNFC_MESSAGE_BASE 48 | #endif 49 | 50 | /*! 51 | * \ingroup grp_osal_nfc 52 | * 53 | * OSAL Message structure contains message specific details like 54 | * message type, message specific data block details, etc. 55 | */ 56 | //typedef struct phOsalNfc_Message 57 | //{ 58 | // uint32_t eMsgType;/**< Type of the message to be posted*/ 59 | // void * pMsgData;/**< Pointer to message specific data block in case any*/ 60 | // uint16_t Size;/**< Size of the datablock*/ 61 | //} phOsalNfc_Message_t,*pphOsalNfc_Message_t; 62 | typedef phLibNfc_Message_t phOsalNfc_Message_t; 63 | typedef pphLibNfc_Message_t pphOsalNfc_Message_t; 64 | 65 | /*! 66 | * \ingroup grp_osal_nfc 67 | * 68 | * Enum definition contains supported exception types 69 | */ 70 | typedef enum 71 | { 72 | phOsalNfc_e_NoMemory, /** 33 | #else 34 | #ifdef __linux__ 35 | #include 36 | #else 37 | #include 38 | #endif 39 | #endif 40 | 41 | #endif /* PHOSALNFC_MSG_H */ 42 | -------------------------------------------------------------------------------- /src/phOsalNfc_Timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 NXP Semiconductors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * \file phOsalNfc_Timer.h 19 | * \brief Timer Implementation. 20 | * 21 | * Project: NFC-FRI 1.1 22 | * 23 | * $Date: Mon Mar 16 20:30:44 2009 $ 24 | * $Author: ing01697 $ 25 | * $Revision: 1.19 $ 26 | * $Aliases: 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 $ 27 | * 28 | */ 29 | #ifndef PHOSALNFC_TIMER_H 30 | #define PHOSALNFC_TIMER_H 31 | 32 | /* -----------------Include files ---------------------------------------*/ 33 | #include 34 | #ifdef PH_NFC_CUSTOMINTEGRATION 35 | #include 36 | #else 37 | #ifdef NXP_MESSAGING 38 | #include 39 | #endif 40 | 41 | #ifdef NXP_MESSAGING 42 | /** 43 | * \ingroup grp_osal_nfc 44 | *\brief Deferred message specific info declaration. 45 | * This type information packed as WPARAM when \ref PH_OSALNFC_MESSAGE_BASE type windows message 46 | * is posted to message handler thread. 47 | */ 48 | //typedef struct phOsalNfc_DeferedCalldInfo 49 | //{ 50 | // nfc_osal_def_call_t pDeferedCall;/**< pointer to Deferred callback */ 51 | // void *pParam;/**< contains timer message specific details*/ 52 | //}phOsalNfc_DeferedCalldInfo_t; 53 | typedef phLibNfc_DeferredCall_t phOsalNfc_DeferedCalldInfo_t; 54 | #endif 55 | 56 | /* ---------------- Macros ----------------------------------------------*/ 57 | /** 58 | *\ingroup grp_osal_nfc 59 | * OSAL timer message .This message type will be posted to calling application thread. 60 | */ 61 | //#define PH_OSALNFC_TIMER_MSG (0x315) 62 | #define PH_OSALNFC_TIMER_MSG PH_LIBNFC_DEFERREDCALL_MSG 63 | 64 | /** 65 | * \ingroup grp_osal_nfc 66 | * Invalid timer ID type.This ID used indicate timer creation is failed. 67 | */ 68 | #define PH_OSALNFC_INVALID_TIMER_ID (0xFFFF) 69 | 70 | /*! 71 | * \ingroup grp_osal_nfc 72 | * \brief Timer callback interface which will be called once registered timer 73 | * timeout expires. 74 | * \param[in] TimerId Timer Id for which callback is called. 75 | * \retval None 76 | */ 77 | typedef void (*ppCallBck_t)(uint32_t TimerId, void *pContext); 78 | 79 | /* -----------------Structures and Enumerations -------------------------*/ 80 | /** 81 | * \ingroup grp_osal_nfc 82 | **\brief Timer message structure definition. 83 | * Timer Message Structure contains timer specific informations like timer identifier 84 | * and timer callback. 85 | * 86 | */ 87 | typedef struct phOsalNfc_TimerMsg 88 | { 89 | uint32_t TimerId;/**< Timer ID*/ 90 | ppCallBck_t pCallBck;/**< pointer to Timer Callback*/ 91 | void* pContext; /**< Timer Callback context*/ 92 | }phOsalNfc_Timer_Msg_t,*pphOsalNfc_TimerMsg_t; 93 | 94 | /* -----------------Exported Functions----------------------------------*/ 95 | /** 96 | * \ingroup grp_osal_nfc 97 | * \brief Allows to create new timer. 98 | * 99 | * This API creates a cyclic timer. In case a valid timer is created returned 100 | * timer ID will be other than \ref PH_OSALNFC_INVALID_TIMER_ID. In case returned 101 | * timer id is \ref PH_OSALNFC_INVALID_TIMER_ID, this indicates timer creation 102 | * has failed. 103 | * 104 | * When a timer is created, it is not started by default. The application has to 105 | * explicitly start it using \ref phOsalNfc_Timer_Start(). 106 | * 107 | * \param[in] void 108 | * \retval Created timer ID. 109 | * \note If timer ID value is PH_OSALNFC_INVALID_TIMER_ID, it indicates 110 | * an error occured during timer creation. 111 | * 112 | * \msc 113 | * Application,phOsalNfc; 114 | * Application=>phOsalNfc [label="phOsalNfc_Timer_Create()",URL="\ref phOsalNfc_Timer_Create"]; 115 | * Application<phOsalNfc [label="phOsalNfc_Timer_Create()", URL="\ref phOsalNfc_Timer_Create"]; 142 | * Application<phOsalNfc [label="phOsalNfc_Timer_Start(TIMERID, TIMEOUT, CB)", URL="\ref phOsalNfc_Timer_Start"]; 144 | * --- [label=" : On timer time out expired "]; 145 | * phOsalNfc=>phOsalNfc [label="CB()"]; 146 | * Application<-phOsalNfc[label="PH_OSALNFC_TIMER_MSG"]; 147 | * \endmsc 148 | */ 149 | void phOsalNfc_Timer_Start(uint32_t TimerId, 150 | uint32_t RegTimeCnt, 151 | ppCallBck_t Application_callback, 152 | void *pContext); 153 | 154 | /** 155 | * \ingroup grp_osal_nfc 156 | * \brief Stop an already started timer. 157 | * 158 | * This API allows to stop running timers. In case the timer is stopped, its callback will not be 159 | * notified any more. 160 | * 161 | * \param[in] TimerId valid timer ID obtained suring timer creation. 162 | * \param[in] Application_callback Application Callback interface to be called when timer expires. 163 | * 164 | * \msc 165 | * Application,phOsalNfc; 166 | * Application=>phOsalNfc [label="phOsalNfc_Timer_Create()",URL="\ref phOsalNfc_Timer_Create"]; 167 | * Application<phOsalNfc [label="phOsalNfc_Timer_Start(TIMERID, TIMEOUT, CB)",URL="\ref phOsalNfc_Timer_Start"]; 169 | * --- [label=" : On timer time out expired "]; 170 | * phOsalNfc=>phOsalNfc [label="CB()"]; 171 | * Application=>phOsalNfc [label="phOsalNfc_Timer_Stop(TIMERID)",URL="\ref phOsalNfc_Timer_Stop"]; 172 | \endmsc 173 | */ 174 | void phOsalNfc_Timer_Stop(uint32_t TimerId); 175 | 176 | /** 177 | * \ingroup grp_osal_nfc 178 | * \brief Allows to delete the timer which is already created. 179 | * 180 | * This API allows to delete a timer. Incase timer is running 181 | * it is stopped first and then deleted. if the given timer ID is invalid, this 182 | * function doesn't return any error. Application has to explicitly ensure 183 | * timer ID sent is valid. 184 | * 185 | * \param[in] TimerId timer identieir to delete the timer. 186 | */ 187 | void phOsalNfc_Timer_Delete(uint32_t TimerId); 188 | 189 | #endif 190 | #endif /* PHOSALNFC_TIMER_H */ 191 | --------------------------------------------------------------------------------