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