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