• 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                                                                             \
74       STRCPY_FW_LIB("libpn557_fw")                                          \
75       STRCPY_FW_BIN("pn557")                                                \
76                                                                             \
77       nfcFL._FW_MOBILE_MAJOR_NUMBER = FW_MOBILE_MAJOR_NUMBER_PN557;         \
78     } else if (chipType == pn553 || chipType == pn80T) {                    \
79                                                                             \
80       STRCPY_FW_LIB("libpn553_fw")                                          \
81       STRCPY_FW_BIN("pn553")                                                \
82                                                                             \
83       nfcFL._FW_MOBILE_MAJOR_NUMBER = FW_MOBILE_MAJOR_NUMBER_PN553;         \
84                                                                             \
85     } else if (chipType == pn551 || chipType == pn67T) {                    \
86                                                                             \
87       STRCPY_FW_LIB("libpn551_fw")                                          \
88       STRCPY_FW_BIN("pn551")                                                \
89                                                                             \
90       nfcFL._PHDNLDNFC_USERDATA_EEPROM_OFFSET = 0x02BCU;                    \
91       nfcFL._PHDNLDNFC_USERDATA_EEPROM_LEN = 0x0C00U;                       \
92       nfcFL._FW_MOBILE_MAJOR_NUMBER = FW_MOBILE_MAJOR_NUMBER_PN551;         \
93                                                                             \
94     }                                                                       \
95   }
96 #define STRCPY_FW_LIB(str) {                                                \
97   nfcFL._FW_LIB_PATH.clear();                                               \
98   nfcFL._FW_LIB_PATH.append(FW_LIB_ROOT_DIR);                               \
99   nfcFL._FW_LIB_PATH.append(str);                                           \
100   nfcFL._FW_LIB_PATH.append(FW_LIB_EXTENSION);                              \
101 }
102 #define STRCPY_FW_BIN(str) {                                                \
103   nfcFL._FW_BIN_PATH.clear();                                               \
104   nfcFL._FW_BIN_PATH.append(FW_BIN_ROOT_DIR);                               \
105   nfcFL._FW_BIN_PATH.append(str);                                           \
106   nfcFL._FW_BIN_PATH.append(FW_BIN_EXTENSION);                              \
107 }
108 #endif
109