1 /* 2 * Copyright (C) 2010-2019 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 #ifndef PHNFCTYPES_H 18 #define PHNFCTYPES_H 19 20 #include <stdbool.h> 21 #include <stdint.h> 22 #include <stdio.h> 23 #include <stdlib.h> 24 #include <string.h> 25 #include <unistd.h> 26 #include "Nxp_Features.h" 27 28 #ifndef TRUE 29 #define TRUE (0x01) /* Logical True Value */ 30 #endif 31 #ifndef FALSE 32 #define FALSE (0x00) /* Logical False Value */ 33 #endif 34 typedef uint8_t utf8_t; /* UTF8 Character String */ 35 typedef uint8_t bool_t; /* boolean data type */ 36 typedef uint16_t NFCSTATUS; /* Return values */ 37 #define STATIC static 38 39 #define PHNFC_MAX_UID_LENGTH 0x0AU /* Maximum UID length expected */ 40 /* Maximum ATR_RES (General Bytes) length expected */ 41 #define PHNFC_MAX_ATR_LENGTH 0x30U 42 #define PHNFC_NFCID_LENGTH 0x0AU /* Maximum length of NFCID 1.3*/ 43 #define PHNFC_ATQA_LENGTH 0x02U /* ATQA length */ 44 45 /* 46 * Possible Hardware Configuration exposed to upper layer. 47 * Typically this should be port name (Ex:"COM1","COM2") to which PN54X is 48 * connected. 49 */ 50 typedef enum { 51 ENUM_LINK_TYPE_COM1, 52 ENUM_LINK_TYPE_COM2, 53 ENUM_LINK_TYPE_COM3, 54 ENUM_LINK_TYPE_COM4, 55 ENUM_LINK_TYPE_COM5, 56 ENUM_LINK_TYPE_COM6, 57 ENUM_LINK_TYPE_COM7, 58 ENUM_LINK_TYPE_COM8, 59 ENUM_LINK_TYPE_I2C, 60 ENUM_LINK_TYPE_SPI, 61 ENUM_LINK_TYPE_USB, 62 ENUM_LINK_TYPE_TCP, 63 ENUM_LINK_TYPE_NB 64 } phLibNfc_eConfigLinkType; 65 66 /* 67 * Deferred message. This message type will be posted to the client application 68 * thread 69 * to notify that a deferred call must be invoked. 70 */ 71 #define PH_LIBNFC_DEFERREDCALL_MSG (0x311) 72 73 /* 74 * Deferred call declaration. 75 * This type of API is called from ClientApplication ( main thread) to notify 76 * specific callback. 77 */ 78 typedef void (*pphLibNfc_DeferredCallback_t)(void*); 79 80 /* 81 * Deferred parameter declaration. 82 * This type of data is passed as parameter from ClientApplication (main thread) 83 * to the 84 * callback. 85 */ 86 typedef void* pphLibNfc_DeferredParameter_t; 87 88 /* 89 * Possible Hardware Configuration exposed to upper layer. 90 * Typically this should be at least the communication link (Ex:"COM1","COM2") 91 * the controller is connected to. 92 */ 93 typedef struct phLibNfc_sConfig { 94 uint8_t* pLogFile; /* Log File Name*/ 95 /* Hardware communication link to the controller */ 96 phLibNfc_eConfigLinkType nLinkType; 97 /* The client ID (thread ID or message queue ID) */ 98 uintptr_t nClientId; 99 } phLibNfc_sConfig_t, *pphLibNfc_sConfig_t; 100 101 /* 102 * NFC Message structure contains message specific details like 103 * message type, message specific data block details, etc. 104 */ 105 typedef struct phLibNfc_Message { 106 uint32_t eMsgType; /* Type of the message to be posted*/ 107 void* pMsgData; /* Pointer to message specific data block in case any*/ 108 uint32_t Size; /* Size of the datablock*/ 109 } phLibNfc_Message_t, *pphLibNfc_Message_t; 110 111 /* 112 * Deferred message specific info declaration. 113 * This type of information is packed as message data when 114 * PH_LIBNFC_DEFERREDCALL_MSG 115 * type message is posted to message handler thread. 116 */ 117 typedef struct phLibNfc_DeferredCall { 118 pphLibNfc_DeferredCallback_t pCallback; /* pointer to Deferred callback */ 119 pphLibNfc_DeferredParameter_t pParameter; /* pointer to Deferred parameter */ 120 } phLibNfc_DeferredCall_t; 121 122 /* 123 * Enumerated MIFARE Commands 124 */ 125 126 #define UNUSED(X) (void)(X); 127 128 #endif /* PHNFCTYPES_H */ 129