• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 2018 NXP
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 #ifndef NXP_FEATURES_H
20 #define NXP_FEATURES_H
21 #include <unistd.h>
22 #include <string>
23 
24 #define FW_MOBILE_MAJOR_NUMBER_PN553 0x01
25 #define FW_MOBILE_MAJOR_NUMBER_PN81A 0x02
26 #define FW_MOBILE_MAJOR_NUMBER_PN551 0x05
27 #define FW_MOBILE_MAJOR_NUMBER_PN557 0x01
28 using namespace std;
29 typedef enum {
30   unknown,
31   pn547C2,
32   pn65T,
33   pn548C2,
34   pn66T,
35   pn551,
36   pn67T,
37   pn553,
38   pn80T,
39   pn557,
40   pn81T
41 } tNFC_chipType;
42 
43 typedef struct {
44   tNFC_chipType chipType;
45   std::string _FW_LIB_PATH;
46   std::string _FW_BIN_PATH;
47   uint16_t _PHDNLDNFC_USERDATA_EEPROM_OFFSET;
48   uint16_t _PHDNLDNFC_USERDATA_EEPROM_LEN;
49   uint8_t _FW_MOBILE_MAJOR_NUMBER;
50 } tNfc_featureList;
51 
52 extern tNfc_featureList nfcFL;
53 
54 #define CONFIGURE_FEATURELIST(chipType)  \
55   {                                      \
56     nfcFL.chipType = chipType;           \
57     if (chipType == pn81T) {             \
58       nfcFL.chipType = pn557;            \
59     } else if (chipType == pn80T) {      \
60       nfcFL.chipType = pn553;            \
61     } else if (chipType == pn67T) {      \
62       nfcFL.chipType = pn551;            \
63     }                                    \
64     CONFIGURE_FEATURELIST_NFCC(chipType) \
65   }
66 
67 #define CONFIGURE_FEATURELIST_NFCC(chipType)                        \
68   {                                                                 \
69     nfcFL._PHDNLDNFC_USERDATA_EEPROM_OFFSET = 0x023CU;              \
70     nfcFL._PHDNLDNFC_USERDATA_EEPROM_LEN = 0x0C80U;                 \
71                                                                     \
72     if (chipType == pn557 || chipType == pn81T) {                   \
73       STRCPY_FW_LIB("libpn557_fw")                                  \
74       STRCPY_FW_BIN("pn557")                                        \
75                                                                     \
76       nfcFL._FW_MOBILE_MAJOR_NUMBER = FW_MOBILE_MAJOR_NUMBER_PN557; \
77     } else if (chipType == pn553 || chipType == pn80T) {            \
78       STRCPY_FW_LIB("libpn553_fw")                                  \
79       STRCPY_FW_BIN("pn553")                                        \
80                                                                     \
81       nfcFL._FW_MOBILE_MAJOR_NUMBER = FW_MOBILE_MAJOR_NUMBER_PN553; \
82                                                                     \
83     } else if (chipType == pn551 || chipType == pn67T) {            \
84       STRCPY_FW_LIB("libpn551_fw")                                  \
85       STRCPY_FW_BIN("pn551")                                        \
86                                                                     \
87       nfcFL._PHDNLDNFC_USERDATA_EEPROM_OFFSET = 0x02BCU;            \
88       nfcFL._PHDNLDNFC_USERDATA_EEPROM_LEN = 0x0C00U;               \
89       nfcFL._FW_MOBILE_MAJOR_NUMBER = FW_MOBILE_MAJOR_NUMBER_PN551; \
90     }                                                               \
91   }
92 #define STRCPY_FW_LIB(str)                       \
93   {                                              \
94     nfcFL._FW_LIB_PATH.clear();                  \
95     nfcFL._FW_LIB_PATH.append(FW_LIB_ROOT_DIR);  \
96     nfcFL._FW_LIB_PATH.append(str);              \
97     nfcFL._FW_LIB_PATH.append(FW_LIB_EXTENSION); \
98   }
99 #define STRCPY_FW_BIN(str)                       \
100   {                                              \
101     nfcFL._FW_BIN_PATH.clear();                  \
102     nfcFL._FW_BIN_PATH.append(FW_BIN_ROOT_DIR);  \
103     nfcFL._FW_BIN_PATH.append(str);              \
104     nfcFL._FW_BIN_PATH.append(FW_BIN_EXTENSION); \
105   }
106 #endif
107