aboutsummaryrefslogtreecommitdiffstats
path: root/src/nfc/include/nfc_api.h
blob: cb185f037fb26f98c2820597e6c8b67894bccb1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
/******************************************************************************
 *
 *  Copyright (C) 2009-2014 Broadcom Corporation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/
/******************************************************************************
 *
 *  The original Work has been changed by NXP Semiconductors.
 *
 *  Copyright (C) 2015-2019 NXP Semiconductors
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/

/******************************************************************************
 *
 *  This file contains the Near Field Communication (NFC) API function
 *  external definitions.
 *
 ******************************************************************************/

#ifndef NFC_API_H
#define NFC_API_H

#include "nfc_target.h"
#include "nci_defs.h"
#include "nfc_hal_api.h"
#include "gki.h"
#include "vendor_cfg.h"

/* NFC application return status codes */
/* Command succeeded    */
#define NFC_STATUS_OK NCI_STATUS_OK
/* Command is rejected. */
#define NFC_STATUS_REJECTED NCI_STATUS_REJECTED
/* Message is corrupted */
#define NFC_STATUS_MSG_CORRUPTED NCI_STATUS_MESSAGE_CORRUPTED
/* buffer full          */
#define NFC_STATUS_BUFFER_FULL NCI_STATUS_BUFFER_FULL
/* failed               */
#define NFC_STATUS_FAILED NCI_STATUS_FAILED
/* not initialized      */
#define NFC_STATUS_NOT_INITIALIZED NCI_STATUS_NOT_INITIALIZED
/* Syntax error         */
#define NFC_STATUS_SYNTAX_ERROR NCI_STATUS_SYNTAX_ERROR
/* Semantic error       */
#define NFC_STATUS_SEMANTIC_ERROR NCI_STATUS_SEMANTIC_ERROR
/* Unknown NCI Group ID */
#define NFC_STATUS_UNKNOWN_GID NCI_STATUS_UNKNOWN_GID
/* Unknown NCI Opcode   */
#define NFC_STATUS_UNKNOWN_OID NCI_STATUS_UNKNOWN_OID
/* Invalid Parameter    */
#define NFC_STATUS_INVALID_PARAM NCI_STATUS_INVALID_PARAM
/* Message size too big */
#define NFC_STATUS_MSG_SIZE_TOO_BIG NCI_STATUS_MSG_SIZE_TOO_BIG
/* Already started      */
#define NFC_STATUS_ALREADY_STARTED NCI_STATUS_ALREADY_STARTED
/* Activation Failed    */
#define NFC_STATUS_ACTIVATION_FAILED NCI_STATUS_ACTIVATION_FAILED
/* Tear Down Error      */
#define NFC_STATUS_TEAR_DOWN NCI_STATUS_TEAR_DOWN
/* RF transmission error*/
#define NFC_STATUS_RF_TRANSMISSION_ERR NCI_STATUS_RF_TRANSMISSION_ERR
/* RF protocol error    */
#define NFC_STATUS_RF_PROTOCOL_ERR NCI_STATUS_RF_PROTOCOL_ERR
/* RF Timeout           */
#define NFC_STATUS_TIMEOUT NCI_STATUS_TIMEOUT
/* EE Intf activate err */
#define NFC_STATUS_EE_INTF_ACTIVE_FAIL NCI_STATUS_EE_INTF_ACTIVE_FAIL
/* EE transmission error*/
#define NFC_STATUS_EE_TRANSMISSION_ERR NCI_STATUS_EE_TRANSMISSION_ERR
/* EE protocol error    */
#define NFC_STATUS_EE_PROTOCOL_ERR NCI_STATUS_EE_PROTOCOL_ERR
/* EE Timeout           */
#define NFC_STATUS_EE_TIMEOUT NCI_STATUS_EE_TIMEOUT

#if (NXP_EXTNS == TRUE)
#define NFC_STATUS_WIRED_SESSION_ABORTED \
  NCI_STATUS_WIRED_SESSION_ABORTED /* WIRED_SESSION_ABORT error */
#define NFC_STATUS_DWP_APDU_DROPPPED \
  NCI_STATUS_DWP_APDU_DROPPPED /* FW dropped the APDU because UICC switch */
#define NFC_STATUS_ALREADY_INITIALIZED NCI_STATUS_ALREADY_INITIALIZED
/*Operation not permitted*/
#define NFC_STATUS_EPERM NCI_STATUS_EPERM
// DTA API for MW Version need to change according to release
#define NXP_EN_PN547C2 0
#define NXP_EN_PN65T 0
#define NXP_EN_PN548C2 0
#define NXP_EN_PN66T 0
#define NXP_EN_PN551 0
#define NXP_EN_PN67T 0
#define NXP_EN_PN553 1
#define NXP_EN_PN80T 1
#define NXP_EN_PN553_MR1 0
#define NXP_EN_PN81A     0
#define NXP_EN_PN553_MR2 0
#define NXP_EN_PN557     1
#define NXP_EN_PN81T     1
#define NXP_ANDROID_VER (10U)        /* NXP android version */
#define NFC_NXP_MW_VERSION_MAJ (0x01) /* MW Major Version */
#define NFC_NXP_MW_VERSION_MIN (0x01) /* MW Minor Version */
#define NFC_NXP_MW_CUSTOMER_ID (0x00) /* MW Customer Id */
#endif
/* 0xE0 ~0xFF are proprietary status codes */
/* Command started successfully                     */
#define NFC_STATUS_CMD_STARTED 0xE3
#if (NXP_EXTNS == TRUE)
/* changed from 0xE4 (as 0xE4 is defined for STATUS_EMVCO_PCD_COLLISOIN
                                             NFCC Timeout in responding to an
   NCI command     */
#define NFC_STATUS_HW_TIMEOUT 0xEC
#else
/* NFCC Timeout in responding to an NCI command     */
#define NFC_STATUS_HW_TIMEOUT 0xE4
#endif
/* More (same) event to follow                      */
#define NFC_STATUS_CONTINUE 0xE5
/* API is called to perform illegal function        */
#define NFC_STATUS_REFUSED 0xE6
/* Wrong format of R-APDU, CC file or NDEF file     */
#define NFC_STATUS_BAD_RESP 0xE7
/* 7816 Status Word is not command complete(0x9000) */
#define NFC_STATUS_CMD_NOT_CMPLTD 0xE8
/* Out of GKI buffers                               */
#define NFC_STATUS_NO_BUFFERS 0xE9
/* Protocol mismatch between API and activated one  */
#define NFC_STATUS_WRONG_PROTOCOL 0xEA
/* Another Tag command is already in progress       */
#define NFC_STATUS_BUSY 0xEB

/* Link Loss                  */
#define NFC_STATUS_LINK_LOSS 0xFC
/* data len exceeds MIU       */
#define NFC_STATUS_BAD_LENGTH 0xFD
/* invalid handle             */
#define NFC_STATUS_BAD_HANDLE 0xFE
/* congested                  */
#define NFC_STATUS_CONGESTED 0xFF
typedef uint8_t tNFC_STATUS;
#if (NXP_EXTNS == TRUE)
#define NFC_NFCC_INIT_MAX_RETRY 2
#define NFC_NORMAL_BOOT_MODE 0
#define NFC_FAST_BOOT_MODE 1
#define NFC_OSU_BOOT_MODE 2
#define UICC1_HOST ((unsigned char)0x02)
#define UICC2_HOST ((unsigned char)0x81)
#define DH_HOST ((unsigned char)0x00)
#define ESE_HOST ((unsigned char)0xC0)
#define NXP_FEATURE_ENABLED \
  ((unsigned char)0x01) /* flag to indicate NXP feature is enabled*/
#define NXP_FEATURE_DISABLED \
  ((unsigned char)0x00) /* flag to indicate NXP feature is enabled*/
#define NXP_NFC_PARAM_SWP_SESSIONID_INT2 ((unsigned char)0xEB)
#define NXP_NFC_PARAM_SWP_SESSION_ID_LEN 8
#define NXP_NFC_PROP_MAX_CMD_BUF_SIZE ((unsigned char)0x40)
#define NXP_NFC_SET_MSB(x) (x |= 0x80)
#define NXP_NFC_RESET_MSB(x) (x &= 0x7F)
#define NXP_NFC_ESE_CONN_PIPE_STATUS  ((unsigned char)0x22)
#define NXP_NFC_ESE_APDU_PIPE_STATUS  ((unsigned char)0x23)
/**********************************************
 * NFC Config Parameter IDs defined by NXP NFC
 **********************************************/
#define NXP_NFC_SET_CONFIG_PARAM_EXT \
  ((unsigned char)0xA0) /* NXP NFC set config extension ID*/
#define NXP_NFC_PARAM_ID_SWP1                \
  ((unsigned char)0xEC) /* SWP1 parameter ID \
                           UICC*/
#define NXP_NFC_PARAM_ID_SWP2                     \
  ((unsigned char)0xED) /* SWP1 parameter ID  ESE \
                           */
#define NXP_NFC_PARAM_ID_SWP1A \
  ((unsigned char)0xD4) /* SWP1 parameter ID  UICC2 */
#define NXP_NFC_PARAM_ID_NDEF_NFCEE \
  ((unsigned char)0x95) /* SWP1 parameter ID  NDEF NFCEE */
#define NXP_NFC_PARAM_ID_RF_PARAM_UICC \
  ((unsigned char)0xEF) /* UICC CE RF parameter  */
#define NXP_NFC_PARAM_ID_RF_PARAM_ESE \
  ((unsigned char)0xF0) /* ESE RF parameter   */
#define NXP_NFC_PARAM_ID_NFCC_RF_CONFIG \
  ((unsigned char)0x9B) /* NFCC RF config parameter*/
#define NXP_NFC_EMVCO_PCD_COLLISION_DETECTED \
  ((unsigned char)0xE4) /* Core generic error for EMVCO collision detected */
#define NXP_NFC_PARAM_ID_RF_PARAM_UICC2 \
  ((unsigned char)0xE8) /* UICC2 CE RF parameter  */
#define NXP_NFC_PARAM_SWP_SESSIONID_INT2 \
  ((unsigned char)0xEB) /* param for retrieveing HCI session ID for ESE */
#define NXP_NFC_PARAM_SWP_SESSIONID_INT1 \
  ((unsigned char)0xEA) /* param for retrieveing HCI session ID for UICC */
#define NXP_NFC_PARAM_SWP_SESSIONID_INT1A \
  ((unsigned char)0x1E) /* param for retrieveing HCI session ID for UICC2 */

/**********************************************
 * NFC self test Parameter IDs defined by NXP NFC
 **********************************************/
#define NXP_NFC_NCI_PACM_BIT_RATE 0x68
#endif

/**********************************************
 * NFC Config Parameter IDs defined by NCI
 **********************************************/
#define NFC_PMID_TOTAL_DURATION NCI_PARAM_ID_TOTAL_DURATION
#define NFC_PMID_PF_RC NCI_PARAM_ID_PF_RC
#define NFC_PMID_ATR_REQ_GEN_BYTES NCI_PARAM_ID_ATR_REQ_GEN_BYTES
#define NFC_PMID_LA_HIST_BY NCI_PARAM_ID_LA_HIST_BY
#define NFC_PMID_LA_NFCID1 NCI_PARAM_ID_LA_NFCID1
#define NFC_PMID_LA_BIT_FRAME_SDD NCI_PARAM_ID_LA_BIT_FRAME_SDD
#define NFC_PMID_LA_PLATFORM_CONFIG NCI_PARAM_ID_LA_PLATFORM_CONFIG
#define NFC_PMID_LA_SEL_INFO NCI_PARAM_ID_LA_SEL_INFO
#define NFC_PMID_LB_SENSB_INFO NCI_PARAM_ID_LB_SENSB_INFO
#define NFC_PMID_LB_H_INFO NCI_PARAM_ID_LB_H_INFO_RSP
#define NFC_PMID_LB_NFCID0 NCI_PARAM_ID_LB_NFCID0
#define NFC_PMID_LB_APPDATA NCI_PARAM_ID_LB_APPDATA
#define NFC_PMID_LB_SFGI NCI_PARAM_ID_LB_SFGI
#define NFC_PMID_LB_ADC_FO NCI_PARAM_ID_LB_ADC_FO
#define NFC_PMID_LF_T3T_ID1 NCI_PARAM_ID_LF_T3T_ID1
#define NFC_PMID_LF_PROTOCOL NCI_PARAM_ID_LF_PROTOCOL
#define NFC_PMID_LF_T3T_PMM NCI_PARAM_ID_LF_T3T_PMM
#define NFC_PMID_LF_T3T_FLAGS2 NCI_PARAM_ID_LF_T3T_FLAGS2
#define NFC_PMID_FWI NCI_PARAM_ID_FWI
#define NFC_PMID_LF_CON_BITR_F NCI_PARAM_ID_LF_CON_BITR_F
#define NFC_PMID_WT NCI_PARAM_ID_WT
#define NFC_PMID_ATR_RES_GEN_BYTES NCI_PARAM_ID_ATR_RES_GEN_BYTES
#define NFC_PMID_ATR_RSP_CONFIG NCI_PARAM_ID_ATR_RSP_CONFIG
#define NFC_PMID_RF_FIELD_INFO NCI_PARAM_ID_RF_FIELD_INFO

/* Technology based routing  */
#define NFC_ROUTE_TAG_TECH NCI_ROUTE_TAG_TECH
/* Protocol based routing  */
#define NFC_ROUTE_TAG_PROTO NCI_ROUTE_TAG_PROTO
#define NFC_ROUTE_TAG_AID NCI_ROUTE_TAG_AID /* AID routing */
#define NFC_ROUTE_TAG_APDU NCI_ROUTE_TAG_APDU /* APDU routing*/
#define NFC_ROUTE_TAG_SYSCODE NCI_ROUTE_TAG_SYSCODE /* System Code routing*/

/* For routing */
#define NFC_DH_ID NCI_DH_ID /* for DH */
/* To identify the loopback test */
/* use a proprietary range */
#define NFC_TEST_ID NCI_TEST_ID

#define NFC_TL_SIZE 2
#define NFC_SAVED_CMD_SIZE 2

typedef tNCI_DISCOVER_MAPS tNFC_DISCOVER_MAPS;
typedef tNCI_DISCOVER_PARAMS tNFC_DISCOVER_PARAMS;

/* all NFC Manager Callback functions have prototype like void (cback) (uint8_t
 * event, void *p_data)
 * tNFC_DATA_CBACK uses connection id as the first parameter; range 0x00-0x0F.
 * tNFC_DISCOVER_CBACK uses tNFC_DISCOVER_EVT; range  0x4000 ~
 * tNFC_RESPONSE_CBACK uses tNFC_RESPONSE_EVT; range  0x5000 ~
 */

#define NFC_FIRST_DEVT 0x4000
#define NFC_FIRST_REVT 0x5000
#define NFC_FIRST_CEVT 0x6000
#define NFC_FIRST_TEVT 0x8000
#if (NXP_EXTNS == TRUE)
  void nfc_ncif_onWiredModeHold_timeout();
  void nfc_ncif_allow_dwp_transmission();
  void nfc_ncif_modeSet_Ntf_timeout();
  void nfc_ncif_modeSet_rsp_timeout();
  void nfc_ncif_resume_dwp_wired_mode();
  void nfc_ncif_pwr_link_rsp_timeout();

/**********************************************
 * NFC self test Parameter IDs defined by NXP NFC
 **********************************************/
enum {
  NFC_CMD_TYPE_SWP           =  0x00,
  NFC_CMD_TYPE_PRBS_START,
  NFC_CMD_TYPE_PRBS_STOP,
  NFC_CMD_TYPE_CORE_RESET,
  NFC_CMD_TYPE_CORE_INIT,
  NFC_CMD_TYPE_ACT_PROP_EXTN,
  NFC_CMD_TYPE_RF_ON,
  NFC_CMD_TYPE_RF_OFF,
  NFC_CMD_TYPE_TRANSAC_A,
  NFC_CMD_TYPE_TRANSAC_B,
  NFC_CMD_TYPE_DISC_MAP,
  NFC_CMD_TYPE_DEACTIVATE,
  NFC_CMD_TYPE_NFCC_STANDBY_ON,
  NFC_CMD_TYPE_NFCC_STANDBY_OFF,
  NFC_CMD_TYPE_TYPE_NONE     = 0xFF
};

enum NFCCSELFTESTTYPE {
  TEST_TYPE_RF_ON = 0x00,
  TEST_TYPE_RF_OFF,
  TEST_TYPE_TRANSAC_A,
  TEST_TYPE_TRANSAC_B,
  TEST_TYPE_NONE = 0xFF
};
#endif
/* the events reported on tNFC_RESPONSE_CBACK */
enum {
  NFC_ENABLE_REVT = NFC_FIRST_REVT, /* 0  Enable event                  */
  NFC_DISABLE_REVT,                 /* 1  Disable event                 */
  NFC_SET_CONFIG_REVT,              /* 2  Set Config Response           */
  NFC_GET_CONFIG_REVT,              /* 3  Get Config Response           */
  NFC_NFCEE_DISCOVER_REVT,          /* 4  Discover NFCEE response       */
  NFC_NFCEE_INFO_REVT,              /* 5  Discover NFCEE Notification   */
  NFC_NFCEE_MODE_SET_REVT,          /* 6  NFCEE Mode Set response       */
  NFC_RF_FIELD_REVT,                /* 7  RF Field information          */
  NFC_EE_ACTION_REVT,               /* 8  EE Action notification        */
  NFC_EE_DISCOVER_REQ_REVT,         /* 9  EE Discover Req notification  */
  NFC_SET_ROUTING_REVT,             /* 10 Configure Routing response    */
  NFC_GET_ROUTING_REVT,             /* 11 Retrieve Routing response     */
  NFC_RF_COMM_PARAMS_UPDATE_REVT,   /* 12 RF Communication Param Update */
  NFC_GEN_ERROR_REVT,               /* 13 generic error notification    */
  NFC_NFCC_RESTART_REVT,            /* 14 NFCC has been re-initialized  */
  NFC_NFCC_TIMEOUT_REVT,            /* 15 NFCC is not responding        */
  NFC_NFCC_TRANSPORT_ERR_REVT,      /* 16 NCI Tranport error            */
  NFC_NFCC_POWER_OFF_REVT,          /* 17 NFCC turned off               */
  NFC_SET_POWER_SUB_STATE_REVT,     /* 18 Set power sub state response  */
  NFC_NFCEE_PL_CONTROL_REVT,              /* NFCEE Power/Link Ctrl response*/
  NFC_NFCEE_PWR_LNK_CTRL_REVT, /* PWR LINK CTRL Event for Wired Mode standby */
  NFC_NFCEE_STATUS_REVT                  /* NFCEE Status Notification     */
#if (NXP_EXTNS == TRUE)
  ,
  NFC_NFCEE_MODE_SET_INFO /*  NFCEE Mode Set Notification*/
#endif
};
typedef uint16_t tNFC_RESPONSE_EVT;

enum {
  NFC_CONN_CREATE_CEVT = NFC_FIRST_CEVT, /* 0  Conn Create Response          */
  NFC_CONN_CLOSE_CEVT,                   /* 1  Conn Close Response           */
  NFC_DEACTIVATE_CEVT,                   /* 2  Deactivate response/notificatn*/
  NFC_DATA_CEVT,                         /* 3  Data                          */
  NFC_ERROR_CEVT,                        /* 4  generic or interface error    */
  NFC_DATA_START_CEVT, /* 5  received the first fragment on RF link */
#if (NXP_EXTNS == TRUE)
  NFC_RF_WTX_CEVT, /* 6  received rf wtx */
#endif
  NFC_RF_TRANSMISSION_ERROR, /* 7 CE Error events */
  NFC_HCI_RESTART_TIMER
};

typedef enum {
    NFC_INTF_REQ_SRC_SPI,
    NFC_INTF_REQ_SRC_DWP
} tNFC_INTF_REQ_SRC;

typedef uint16_t tNFC_CONN_EVT;

#define NFC_NFCC_INFO_LEN 4
#ifndef NFC_NFCC_MAX_NUM_VS_INTERFACE
#define NFC_NFCC_MAX_NUM_VS_INTERFACE 5
#endif
typedef struct {
  tNFC_STATUS status;                   /* The event status.                */
  uint8_t nci_version;                  /* the NCI version of NFCC          */
  uint8_t max_conn;                     /* max number of connections by NFCC*/
  uint32_t nci_features;                /* the NCI features of NFCC         */
  uint16_t nci_interfaces;              /* the NCI interfaces of NFCC       */
  uint16_t max_ce_table;                /* the max routing table size       */
  uint16_t max_param_size;              /* Max Size for Large Parameters    */
  uint8_t manufacture_id;               /* the Manufacture ID for NFCC      */
  uint8_t nfcc_info[NFC_NFCC_INFO_LEN]; /* the Manufacture Info for NFCC      */
  uint8_t vs_interface
      [NFC_NFCC_MAX_NUM_VS_INTERFACE]; /* the NCI VS interfaces of NFCC    */
  uint8_t hci_packet_size;             /*HCI payload size*/
  uint8_t hci_conn_credits;            /*max number of HCI credits*/
  uint16_t max_nfc_v_size;             /* maximum frame size for NFC-V*/
} tNFC_ENABLE_REVT;

#define NFC_MAX_NUM_IDS 125
/* the data type associated with NFC_SET_CONFIG_REVT */
typedef struct {
  tNFC_STATUS status;                 /* The event status.                */
  uint8_t num_param_id;               /* Number of rejected NCI Param ID  */
  uint8_t param_ids[NFC_MAX_NUM_IDS]; /* NCI Param ID          */
} tNFC_SET_CONFIG_REVT;

/* the data type associated with NFC_GET_CONFIG_REVT */
typedef struct {
  tNFC_STATUS status;    /* The event status.    */
  uint16_t tlv_size;     /* The length of TLV    */
  uint8_t* p_param_tlvs; /* TLV                  */
} tNFC_GET_CONFIG_REVT;

#if (NXP_EXTNS == TRUE)
typedef struct {
  tNFC_STATUS status;
  uint8_t nfcee_id;
} tNFC_NFCEE_MODE_SET_INFO;

#define ESE_STATE_JCOP_DWNLD                                      \
  0x8000 /* Depicts the state of Jcop download to be matched with \
            P61_STATE_JCP_DWNLD                                   \
            under p61_access_state_t inside pn553.h(NFCC driver header) */

typedef enum jcop_dwnld_state {
  JCP_DWNLD_IDLE = ESE_STATE_JCOP_DWNLD, /* jcop dwnld is not ongoing*/
  JCP_DWNLD_INIT = 0x8010,               /* jcop dwonload init state*/
  JCP_DWNLD_START = 0x8020,              /* download started */
  JCP_SPI_DWNLD_COMPLETE = 0x8040, /* jcop download complete in spi interface*/
  JCP_DWP_DWNLD_COMPLETE = 0x8080, /* jcop download complete */
} jcop_dwnld_state_t;
#endif

/* the data type associated with NFC_NFCEE_DISCOVER_REVT */
typedef struct {
  tNFC_STATUS status; /* The event status.    */
  uint8_t num_nfcee;  /* The number of NFCEE  */
} tNFC_NFCEE_DISCOVER_REVT;

#define NFC_NFCEE_INTERFACE_APDU NCI_NFCEE_INTERFACE_APDU
#define NFC_NFCEE_INTERFACE_HCI_ACCESS NCI_NFCEE_INTERFACE_HCI_ACCESS
#define NFC_NFCEE_INTERFACE_T3T NCI_NFCEE_INTERFACE_T3T
#define NFC_NFCEE_INTERFACE_TRANSPARENT NCI_NFCEE_INTERFACE_TRANSPARENT
#define NFC_NFCEE_INTERFACE_PROPRIETARY NCI_NFCEE_INTERFACE_PROPRIETARY

#define NFC_NFCEE_TAG_HW_ID NCI_NFCEE_TAG_HW_ID
#define NFC_NFCEE_TAG_ATR_BYTES NCI_NFCEE_TAG_ATR_BYTES
#define NFC_NFCEE_TAG_T3T_INFO NCI_NFCEE_TAG_T3T_INFO
#define NFC_NFCEE_TAG_HCI_HOST_ID NCI_NFCEE_TAG_HCI_HOST_ID
#if (NXP_EXTNS == TRUE)
typedef uint16_t tNFC_NFCEE_TAG;
#else
typedef uint8_t tNFC_NFCEE_TAG;
#endif
/* additional NFCEE Info */
typedef struct {
  tNFC_NFCEE_TAG tag;
  uint8_t len;
  uint8_t info[NFC_MAX_EE_INFO];
} tNFC_NFCEE_TLV;

/* NFCEE unrecoverable error */
#define NFC_NFCEE_STATUS_UNRECOVERABLE_ERROR NCI_NFCEE_STS_UNRECOVERABLE_ERROR
/* NFCEE connected and inactive */
#define NFC_NFCEE_STATUS_INACTIVE NCI_NFCEE_STS_CONN_INACTIVE
/* NFCEE connected and active   */
#define NFC_NFCEE_STATUS_ACTIVE NCI_NFCEE_STS_CONN_ACTIVE
/* NFCEE removed                */
#define NFC_NFCEE_STATUS_REMOVED NCI_NFCEE_STS_REMOVED
/* the data type associated with NFC_NFCEE_INFO_REVT */

typedef struct {
  tNFC_STATUS status;    /* The event status - place holder  */
  uint8_t nfcee_id;      /* NFCEE ID                         */
  uint8_t ee_status;     /* The NFCEE status.                */
  uint8_t num_interface; /* number of NFCEE interfaces       */
  uint8_t ee_interface[NFC_MAX_EE_INTERFACE]; /* NFCEE interface       */
  uint8_t num_tlvs;                       /* number of TLVs                   */
  tNFC_NFCEE_TLV ee_tlv[NFC_MAX_EE_TLVS]; /* The TLVs associated with NFCEE   */
  bool  nfcee_power_ctrl;       /* 1, if NFCC has control of NFCEE Power Supply */
} tNFC_NFCEE_INFO_REVT;

#define NFC_MODE_ACTIVATE NCI_NFCEE_MD_ACTIVATE
#define NFC_MODE_DEACTIVATE NCI_NFCEE_MD_DEACTIVATE
typedef uint8_t tNFC_NFCEE_MODE;
/* the data type associated with NFC_NFCEE_MODE_SET_REVT */
typedef struct {
  tNFC_STATUS status;   /* The event status.*/
  uint8_t nfcee_id;     /* NFCEE ID         */
  tNFC_NFCEE_MODE mode; /* NFCEE mode       */
} tNFC_NFCEE_MODE_SET_REVT;

#if (NXP_EXTNS == TRUE || APPL_DTA_MODE == TRUE)
/* This data type is for FW Version */
typedef struct {
  uint8_t rom_code_version; /* ROM code Version  */
  uint8_t major_version;    /* Major Version */
  uint8_t minor_version;    /* Minor Version  */
} tNFC_FW_VERSION;
#endif
typedef struct {
  tNFC_STATUS status; /* The event status.*/
  uint8_t nfcee_id;   /* NFCEE ID         */
} tNFC_NFCEE_EE_PWR_LNK_REVT;

#define NFC_MAX_AID_LEN NCI_MAX_AID_LEN /* 16 */
#define NFC_MIN_APDU_DATA_LEN NCI_MIN_APDU_DATA_LEN
#define NFC_MIN_APDU_MASK_LEN NCI_MIN_APDU_MASK_LEN
#define NFC_MAX_APDU_DATA_LEN NCI_MAX_APDU_DATA_LEN
#define NFC_MAX_APDU_MASK_LEN NCI_MAX_APDU_MASK_LEN
/* the data type associated with NFC_CE_GET_ROUTING_REVT */

/* Max payload size  */
#define NFC_MAX_GET_ROUTING_PLD_SIZE 255

typedef struct {
  tNFC_STATUS status; /* The event status                 */
  uint8_t nfcee_id;   /* NFCEE ID                         */
  uint8_t num_tlvs;   /* number of TLVs                   */
  uint8_t tlv_size;   /* the total len of all TLVs        */
  uint8_t param_tlvs[NFC_MAX_GET_ROUTING_PLD_SIZE]; /* the TLVs*/
} tNFC_GET_ROUTING_REVT;

/* the data type associated with NFC_CONN_CREATE_CEVT */
typedef struct {
  tNFC_STATUS status; /* The event status                 */
  uint8_t dest_type;  /* the destination type             */
  uint8_t id;         /* NFCEE ID  or RF Discovery ID     */
  uint8_t buff_size;  /* The max buffer size              */
  uint8_t num_buffs;  /* The number of buffers            */
} tNFC_CONN_CREATE_CEVT;

/* the data type associated with NFC_CONN_CLOSE_CEVT */
typedef struct {
  tNFC_STATUS status; /* The event status                 */
} tNFC_CONN_CLOSE_CEVT;

/* the data type associated with NFC_DATA_CEVT */
typedef struct {
  tNFC_STATUS status; /* The event status                 */
  NFC_HDR* p_data;    /* The received Data                */
} tNFC_DATA_CEVT;

/* the data type associated with NFC_NFCEE_PL_CONTROL_REVT */
typedef struct
{
    tNFC_STATUS             status;                 /* The event status.*/
    uint8_t                   nfcee_id;               /* NFCEE ID         */
    tNCI_NFCEE_PL_CONFIG    pl_control;             /* Power/Link Control Config of the original command */
} tNFC_NFCEE_PL_CONTROL_REVT;

/* the data type associated with NFC_NFCEE_STATUS_REVT */
typedef struct
{
    tNFC_STATUS             status;                 /* The event status.*/
    uint8_t                   nfcee_id;               /* NFCEE ID         */
    tNCI_EE_NTF_STATUS      nfcee_status;           /* NFCEE status     */
} tNFC_NFCEE_STATUS_REVT;

/* RF Field Status */
typedef uint8_t tNFC_RF_STS;

/* RF Field Technologies */
#define NFC_RF_TECHNOLOGY_A NCI_RF_TECHNOLOGY_A
#define NFC_RF_TECHNOLOGY_B NCI_RF_TECHNOLOGY_B
#define NFC_RF_TECHNOLOGY_F NCI_RF_TECHNOLOGY_F
typedef uint8_t tNFC_RF_TECH;


extern uint8_t NFC_GetNCIVersion();

/* Supported Protocols */
#define NFC_PROTOCOL_UNKNOWN NCI_PROTOCOL_UNKNOWN /* Unknown */
/* Type1Tag    - NFC-A            */
#define NFC_PROTOCOL_T1T NCI_PROTOCOL_T1T
/* Type2Tag    - NFC-A            */
#define NFC_PROTOCOL_T2T NCI_PROTOCOL_T2T
/* Type3Tag    - NFC-F            */
#define NFC_PROTOCOL_T3T NCI_PROTOCOL_T3T
/* Type5Tag    - NFC-V/ISO15693*/
#define NFC_PROTOCOL_T5T NFC_PROTOCOL_T5T_(NFC_GetNCIVersion())
#define NFC_PROTOCOL_T5T_(x) \
  (((x) == NCI_VERSION_2_0) ? NCI_PROTOCOL_T5T : NCI_PROTOCOL_15693)
/* Type 4A,4B  - NFC-A or NFC-B   */
#define NFC_PROTOCOL_ISO_DEP NCI_PROTOCOL_ISO_DEP
/* NFCDEP/LLCP - NFC-A or NFC-F       */
#define NFC_PROTOCOL_NFC_DEP NCI_PROTOCOL_NFC_DEP
#define NFC_PROTOCOL_MIFARE NCI_PROTOCOL_MIFARE
#if (NXP_EXTNS == TRUE)
#define NFC_PROTOCOL_ISO7816 \
  NCI_PROTOCOL_ISO7816 /*ISO7816 -AID default Routing */
#define NFC_PROTOCOL_T3BT NCI_PROTOCOL_T3BT
#endif
#define NFC_PROTOCOL_B_PRIME NCI_PROTOCOL_B_PRIME
#define NFC_PROTOCOL_ISO15693 NCI_PROTOCOL_15693
#define NFC_PROTOCOL_KOVIO NCI_PROTOCOL_KOVIO
typedef uint8_t tNFC_PROTOCOL;

/* Discovery Types/Detected Technology and Mode */
#define NFC_DISCOVERY_TYPE_POLL_A NCI_DISCOVERY_TYPE_POLL_A
#define NFC_DISCOVERY_TYPE_POLL_B NCI_DISCOVERY_TYPE_POLL_B
#define NFC_DISCOVERY_TYPE_POLL_F NCI_DISCOVERY_TYPE_POLL_F
#define NFC_DISCOVERY_TYPE_POLL_A_ACTIVE NCI_DISCOVERY_TYPE_POLL_A_ACTIVE
#define NFC_DISCOVERY_TYPE_POLL_F_ACTIVE NCI_DISCOVERY_TYPE_POLL_F_ACTIVE
#define NFC_DISCOVERY_TYPE_POLL_ACTIVE NCI_DISCOVERY_TYPE_POLL_ACTIVE
#define NFC_DISCOVERY_TYPE_POLL_V NCI_DISCOVERY_TYPE_POLL_V
#define NFC_DISCOVERY_TYPE_POLL_B_PRIME NCI_DISCOVERY_TYPE_POLL_B_PRIME
#define NFC_DISCOVERY_TYPE_POLL_KOVIO NCI_DISCOVERY_TYPE_POLL_KOVIO
#define NFC_DISCOVERY_TYPE_LISTEN_A NCI_DISCOVERY_TYPE_LISTEN_A
#define NFC_DISCOVERY_TYPE_LISTEN_B NCI_DISCOVERY_TYPE_LISTEN_B
#define NFC_DISCOVERY_TYPE_LISTEN_F NCI_DISCOVERY_TYPE_LISTEN_F
#define NFC_DISCOVERY_TYPE_LISTEN_A_ACTIVE NCI_DISCOVERY_TYPE_LISTEN_A_ACTIVE
#define NFC_DISCOVERY_TYPE_LISTEN_F_ACTIVE NCI_DISCOVERY_TYPE_LISTEN_F_ACTIVE
#define NFC_DISCOVERY_TYPE_LISTEN_ACTIVE NCI_DISCOVERY_TYPE_LISTEN_ACTIVE
#define NFC_DISCOVERY_TYPE_LISTEN_ISO15693 NCI_DISCOVERY_TYPE_LISTEN_ISO15693
#define NFC_DISCOVERY_TYPE_LISTEN_B_PRIME NCI_DISCOVERY_TYPE_LISTEN_B_PRIME
#if (NXP_EXTNS == TRUE)
#define NFC_DISCOVERY_TYPE_FIELD_DETECT NCI_DISCOVERY_TYPE_FIELD_DETECT
#endif
typedef uint8_t tNFC_DISCOVERY_TYPE;
typedef uint8_t tNFC_RF_TECH_N_MODE;

/* Select Response codes */
#define NFC_SEL_RES_NFC_FORUM_T2T 0x00
#define NFC_SEL_RES_MF_CLASSIC 0x08

#define  NCI_CALCULATE_ACK(a,v) {(a) &=  ((1 << (v)) -1);}
#define  MAX_NUM_VALID_BITS_FOR_ACK      0x07
/* Bit Rates */
#define NFC_BIT_RATE_212 NCI_BIT_RATE_212   /* 212 kbit/s */
#define NFC_BIT_RATE_424 NCI_BIT_RATE_424   /* 424 kbit/s */
typedef uint8_t tNFC_BIT_RATE;

/**********************************************
 * Interface Types
 **********************************************/
#define NFC_INTERFACE_EE_DIRECT_RF NCI_INTERFACE_EE_DIRECT_RF
#define NFC_INTERFACE_FRAME NCI_INTERFACE_FRAME
#define NFC_INTERFACE_ISO_DEP NCI_INTERFACE_ISO_DEP
#define NFC_INTERFACE_NFC_DEP NCI_INTERFACE_NFC_DEP
#define NFC_INTERFACE_MIFARE NCI_INTERFACE_VS_MIFARE
typedef tNCI_INTF_TYPE tNFC_INTF_TYPE;

/**********************************************
 *  Deactivation Type
 **********************************************/
#define NFC_DEACTIVATE_TYPE_IDLE NCI_DEACTIVATE_TYPE_IDLE
#define NFC_DEACTIVATE_TYPE_SLEEP NCI_DEACTIVATE_TYPE_SLEEP
#define NFC_DEACTIVATE_TYPE_SLEEP_AF NCI_DEACTIVATE_TYPE_SLEEP_AF
#define NFC_DEACTIVATE_TYPE_DISCOVERY NCI_DEACTIVATE_TYPE_DISCOVERY
typedef uint8_t tNFC_DEACT_TYPE;

/**********************************************
 *  Deactivation Reasons
 **********************************************/
#define NFC_DEACTIVATE_REASON_DH_REQ_FAILED NCI_DEACTIVATE_REASON_DH_REQ_FAILED
typedef uint8_t tNFC_DEACT_REASON;

/* the data type associated with NFC_RF_FIELD_REVT */
typedef struct {
  tNFC_STATUS status;   /* The event status - place holder. */
  tNFC_RF_STS rf_field; /* RF Field Status                  */
} tNFC_RF_FIELD_REVT;

#define NFC_MAX_APP_DATA_LEN 40
typedef struct {
  uint8_t len_aid;              /* length of application id */
  uint8_t aid[NFC_MAX_AID_LEN]; /* application id           */
} tNFC_AID;
typedef struct {
  uint8_t len_aid;                    /* length of application id */
  uint8_t aid[NFC_MAX_AID_LEN];       /* application id           */
  uint8_t len_data;                   /* len of application data  */
  uint8_t data[NFC_MAX_APP_DATA_LEN]; /* application data    */
} tNFC_APP_INIT;

/* ISO 7816-4 SELECT command */
#define NFC_EE_TRIG_SELECT NCI_EE_TRIG_7816_SELECT
/* RF Protocol changed       */
#define NFC_EE_TRIG_RF_PROTOCOL NCI_EE_TRIG_RF_PROTOCOL
/* RF Technology changed     */
#define NFC_EE_TRIG_RF_TECHNOLOGY NCI_EE_TRIG_RF_TECHNOLOGY
/* Application initiation    */
#define NFC_EE_TRIG_APP_INIT NCI_EE_TRIG_APP_INIT
typedef uint8_t tNFC_EE_TRIGGER;
typedef struct {
  tNFC_EE_TRIGGER trigger; /* the trigger of this event        */
  union {
    tNFC_PROTOCOL protocol;
    tNFC_RF_TECH technology;
    tNFC_AID aid;
    tNFC_APP_INIT app_init;
  } param; /* Discovery Type specific parameters */
} tNFC_ACTION_DATA;

/* the data type associated with NFC_EE_ACTION_REVT */
typedef struct {
  tNFC_STATUS status;        /* The event status - place holder  */
  uint8_t nfcee_id;          /* NFCEE ID                         */
  tNFC_ACTION_DATA act_data; /* data associated /w the action    */
} tNFC_EE_ACTION_REVT;

#define NFC_EE_DISC_OP_ADD 0
#define NFC_EE_DISC_OP_REMOVE 1
typedef uint8_t tNFC_EE_DISC_OP;
typedef struct {
  tNFC_EE_DISC_OP op;              /* add or remove this entry         */
  uint8_t nfcee_id;                /* NFCEE ID                         */
  tNFC_RF_TECH_N_MODE tech_n_mode; /* Discovery Technology and Mode    */
  tNFC_PROTOCOL protocol;          /* NFC protocol                     */
} tNFC_EE_DISCOVER_INFO;

#ifndef NFC_MAX_EE_DISC_ENTRIES
#define NFC_MAX_EE_DISC_ENTRIES 6
#endif
/* T, L, V(NFCEE ID, TechnMode, Protocol) */
#define NFC_EE_DISCOVER_ENTRY_LEN 5
#define NFC_EE_DISCOVER_INFO_LEN 3 /* NFCEE ID, TechnMode, Protocol */
/* the data type associated with NFC_EE_DISCOVER_REQ_REVT */
typedef struct {
  tNFC_STATUS status; /* The event status - place holder  */
  uint8_t num_info;   /* number of entries in info[]      */
  tNFC_EE_DISCOVER_INFO
      info[NFC_MAX_EE_DISC_ENTRIES]; /* discovery request from NFCEE */
} tNFC_EE_DISCOVER_REQ_REVT;

typedef union {
  tNFC_STATUS status; /* The event status. */
  tNFC_ENABLE_REVT enable;
  tNFC_SET_CONFIG_REVT set_config;
  tNFC_GET_CONFIG_REVT get_config;
  tNFC_NFCEE_DISCOVER_REVT nfcee_discover;
  tNFC_NFCEE_INFO_REVT nfcee_info;
  tNFC_NFCEE_MODE_SET_REVT mode_set;
#if (NXP_EXTNS == TRUE)
  tNFC_NFCEE_MODE_SET_INFO mode_set_info;
  tNFC_NFCEE_EE_PWR_LNK_REVT pwr_lnk_ctrl;
#endif
  tNFC_NFCEE_PL_CONTROL_REVT  pl_control;
  tNFC_NFCEE_STATUS_REVT  nfcee_status;
  tNFC_RF_FIELD_REVT rf_field;
  tNFC_STATUS cfg_routing;
  tNFC_GET_ROUTING_REVT get_routing;
  tNFC_EE_ACTION_REVT ee_action;
  tNFC_EE_DISCOVER_REQ_REVT ee_discover_req;
  void* p_vs_evt_data;
} tNFC_RESPONSE;

/*************************************
**  RESPONSE Callback Functions
**************************************/
typedef void(tNFC_RESPONSE_CBACK)(tNFC_RESPONSE_EVT event,
                                  tNFC_RESPONSE* p_data);

/* The events reported on tNFC_VS_CBACK */
/* The event is (NCI_RSP_BIT|oid) for response and (NCI_NTF_BIT|oid) for
 * notification*/

typedef uint8_t tNFC_VS_EVT;

/*************************************
**  Proprietary (Vendor Specific) Callback Functions
**************************************/
typedef void(tNFC_VS_CBACK)(tNFC_VS_EVT event, uint16_t data_len,
                            uint8_t* p_data);

/* the events reported on tNFC_DISCOVER_CBACK */
enum {
  NFC_START_DEVT = NFC_FIRST_DEVT, /* Status of NFC_DiscoveryStart     */
  NFC_MAP_DEVT,                    /* Status of NFC_DiscoveryMap       */
  NFC_RESULT_DEVT,                 /* The responses from remote device */
  NFC_SELECT_DEVT,                 /* Status of NFC_DiscoverySelect    */
  NFC_ACTIVATE_DEVT,               /* RF interface is activated        */
  NFC_DEACTIVATE_DEVT              /* Status of RF deactivation        */
};
typedef uint16_t tNFC_DISCOVER_EVT;

/* the data type associated with NFC_START_DEVT */
typedef tNFC_STATUS tNFC_START_DEVT;

typedef tNCI_RF_PA_PARAMS tNFC_RF_PA_PARAMS;
#define NFC_MAX_SENSB_RES_LEN NCI_MAX_SENSB_RES_LEN
#define NFC_NFCID0_MAX_LEN 4
#if (NXP_EXTNS == TRUE)
#define NFC_PUPIID_MAX_LEN 8
#endif
typedef struct {
  uint8_t sensb_res_len; /* Length of SENSB_RES Response (Byte 2 - Byte 12 or
                            13) Available after Technology Detection */
  uint8_t sensb_res[NFC_MAX_SENSB_RES_LEN]; /* SENSB_RES Response (ATQ) */
  uint8_t nfcid0[NFC_NFCID0_MAX_LEN];
#if (NXP_EXTNS == TRUE)
  uint8_t pupiid_len;
  uint8_t pupiid[NFC_PUPIID_MAX_LEN];
#endif
} tNFC_RF_PB_PARAMS;

#define NFC_MAX_SENSF_RES_LEN NCI_MAX_SENSF_RES_LEN
#define NFC_NFCID2_LEN NCI_NFCID2_LEN
typedef struct {
  uint8_t bit_rate;      /* NFC_BIT_RATE_212 or NFC_BIT_RATE_424 */
  uint8_t sensf_res_len; /* Length of SENSF_RES Response (Byte 2 - Byte 17 or
                            19) Available after Technology Detection */
  uint8_t sensf_res[NFC_MAX_SENSF_RES_LEN]; /* SENSB_RES Response */
  uint8_t nfcid2[NFC_NFCID2_LEN]; /* NFCID2 generated by the Local NFCC for
                                     NFC-DEP Protocol.Available for Frame
                                     Interface  */
  uint8_t mrti_check;
  uint8_t mrti_update;
} tNFC_RF_PF_PARAMS;

typedef tNCI_RF_LF_PARAMS tNFC_RF_LF_PARAMS;

#define NFC_ISO15693_UID_LEN 8
typedef struct {
  uint8_t flag;
  uint8_t dsfid;
  uint8_t uid[NFC_ISO15693_UID_LEN];
} tNFC_RF_PISO15693_PARAMS;

#ifndef NFC_KOVIO_MAX_LEN
#define NFC_KOVIO_MAX_LEN 32
#endif
typedef struct {
  uint8_t uid_len;
  uint8_t uid[NFC_KOVIO_MAX_LEN];
} tNFC_RF_PKOVIO_PARAMS;

typedef tNCI_RF_ACM_P_PARAMS tNFC_RF_ACM_P_PARAMS;

typedef union {
  tNFC_RF_PA_PARAMS pa;
  tNFC_RF_PB_PARAMS pb;
  tNFC_RF_PF_PARAMS pf;
  tNFC_RF_LF_PARAMS lf;
  tNFC_RF_PISO15693_PARAMS pi93;
  tNFC_RF_PKOVIO_PARAMS pk;
  tNFC_RF_ACM_P_PARAMS acm_p;
} tNFC_RF_TECH_PARAMU;

typedef struct {
  tNFC_DISCOVERY_TYPE mode;
  tNFC_RF_TECH_PARAMU param;
} tNFC_RF_TECH_PARAMS;

/* the data type associated with NFC_RESULT_DEVT */
typedef struct {
  tNFC_STATUS status;                /* The event status - place holder.  */
  uint8_t rf_disc_id;                /* RF Discovery ID                   */
  uint8_t protocol;                  /* supported protocol                */
  tNFC_RF_TECH_PARAMS rf_tech_param; /* RF technology parameters          */
  uint8_t more;                      /* 0: last, 1: last (limit), 2: more */
} tNFC_RESULT_DEVT;

/* the data type associated with NFC_SELECT_DEVT */
typedef tNFC_STATUS tNFC_SELECT_DEVT;

/* the data type associated with NFC_STOP_DEVT */
typedef tNFC_STATUS tNFC_STOP_DEVT;

#define NFC_MAX_ATS_LEN NCI_MAX_ATS_LEN
#define NFC_MAX_HIS_BYTES_LEN NCI_MAX_HIS_BYTES_LEN
#define NFC_MAX_GEN_BYTES_LEN NCI_MAX_GEN_BYTES_LEN

typedef struct {
  uint8_t ats_res_len;              /* Length of ATS RES                */
  uint8_t ats_res[NFC_MAX_ATS_LEN]; /* ATS RES                          */
  bool nad_used;                    /* NAD is used or not               */
  uint8_t fwi;                      /* Frame Waiting time Integer       */
  uint8_t sfgi;                     /* Start-up Frame Guard time Integer*/
  uint8_t his_byte_len;             /* len of historical bytes          */
  uint8_t his_byte[NFC_MAX_HIS_BYTES_LEN]; /* historical bytes             */
} tNFC_INTF_PA_ISO_DEP;

typedef struct { uint8_t rats; /* RATS */ } tNFC_INTF_LA_ISO_DEP;

typedef struct {
  uint8_t atr_res_len;                      /* Length of ATR_RES            */
  uint8_t atr_res[NFC_MAX_ATS_LEN];         /* ATR_RES (Byte 3 - Byte 17+n) */
  uint8_t max_payload_size;                 /* 64, 128, 192 or 254          */
  uint8_t gen_bytes_len;                    /* len of general bytes         */
  uint8_t gen_bytes[NFC_MAX_GEN_BYTES_LEN]; /* general bytes           */
  uint8_t
      waiting_time; /* WT -> Response Waiting Time RWT = (256 x 16/fC) x 2WT */
} tNFC_INTF_PA_NFC_DEP;

/* Note: keep tNFC_INTF_PA_NFC_DEP data member in the same order as
 * tNFC_INTF_LA_NFC_DEP */
typedef struct {
  uint8_t atr_req_len;                      /* Length of ATR_REQ            */
  uint8_t atr_req[NFC_MAX_ATS_LEN];         /* ATR_REQ (Byte 3 - Byte 18+n) */
  uint8_t max_payload_size;                 /* 64, 128, 192 or 254          */
  uint8_t gen_bytes_len;                    /* len of general bytes         */
  uint8_t gen_bytes[NFC_MAX_GEN_BYTES_LEN]; /* general bytes           */
} tNFC_INTF_LA_NFC_DEP;
typedef tNFC_INTF_LA_NFC_DEP tNFC_INTF_LF_NFC_DEP;
typedef tNFC_INTF_PA_NFC_DEP tNFC_INTF_PF_NFC_DEP;

#define NFC_MAX_ATTRIB_LEN NCI_MAX_ATTRIB_LEN

typedef struct {
  uint8_t attrib_res_len;                 /* Length of ATTRIB RES      */
  uint8_t attrib_res[NFC_MAX_ATTRIB_LEN]; /* ATTRIB RES                */
  uint8_t hi_info_len;                    /* len of Higher layer Info  */
  uint8_t hi_info[NFC_MAX_GEN_BYTES_LEN]; /* Higher layer Info         */
  uint8_t mbli;                           /* Maximum buffer length.    */
} tNFC_INTF_PB_ISO_DEP;

typedef struct {
  uint8_t attrib_req_len;                 /* Length of ATTRIB REQ      */
  uint8_t attrib_req[NFC_MAX_ATTRIB_LEN]; /* ATTRIB REQ (Byte 2 - 10+k)*/
  uint8_t hi_info_len;                    /* len of Higher layer Info  */
  uint8_t hi_info[NFC_MAX_GEN_BYTES_LEN]; /* Higher layer Info         */
  uint8_t nfcid0[NFC_NFCID0_MAX_LEN];     /* NFCID0                    */
} tNFC_INTF_LB_ISO_DEP;

#ifndef NFC_MAX_RAW_PARAMS
#define NFC_MAX_RAW_PARAMS 16
#endif
#define NFC_MAX_RAW_PARAMS 16
typedef struct {
  uint8_t param_len;
  uint8_t param[NFC_MAX_RAW_PARAMS];
} tNFC_INTF_FRAME;

typedef struct {
  tNFC_INTF_TYPE type; /* Interface Type  1 Byte  See Table 67 */
  union {
    tNFC_INTF_LA_ISO_DEP la_iso;
    tNFC_INTF_PA_ISO_DEP pa_iso;
    tNFC_INTF_LB_ISO_DEP lb_iso;
    tNFC_INTF_PB_ISO_DEP pb_iso;
    tNFC_INTF_LA_NFC_DEP la_nfc;
    tNFC_INTF_PA_NFC_DEP pa_nfc;
    tNFC_INTF_LF_NFC_DEP lf_nfc;
    tNFC_INTF_PF_NFC_DEP pf_nfc;
    tNFC_INTF_FRAME frame;
  } intf_param; /* Activation Parameters   0 - n Bytes */
} tNFC_INTF_PARAMS;

/* the data type associated with NFC_ACTIVATE_DEVT */
typedef struct {
  uint8_t rf_disc_id;                /* RF Discovery ID          */
  tNFC_PROTOCOL protocol;            /* supported protocol       */
  tNFC_RF_TECH_PARAMS rf_tech_param; /* RF technology parameters */
  tNFC_DISCOVERY_TYPE data_mode;     /* for future Data Exchange */
  tNFC_BIT_RATE tx_bitrate;          /* Data Exchange Tx Bitrate */
  tNFC_BIT_RATE rx_bitrate;          /* Data Exchange Rx Bitrate */
  tNFC_INTF_PARAMS intf_param;       /* interface type and params*/
} tNFC_ACTIVATE_DEVT;

/* the data type associated with NFC_DEACTIVATE_DEVT and NFC_DEACTIVATE_CEVT */
typedef struct {
  tNFC_STATUS status;   /* The event status.        */
  tNFC_DEACT_TYPE type; /* De-activate type         */
  bool is_ntf;          /* TRUE, if deactivate notif*/
  tNFC_DEACT_REASON reason; /* De-activate reason    */
} tNFC_DEACTIVATE_DEVT;

typedef union {
  tNFC_STATUS status; /* The event status.        */
  tNFC_START_DEVT start;
  tNFC_RESULT_DEVT result;
  tNFC_SELECT_DEVT select;
  tNFC_STOP_DEVT stop;
  tNFC_ACTIVATE_DEVT activate;
  tNFC_DEACTIVATE_DEVT deactivate;
} tNFC_DISCOVER;

typedef struct {
  bool include_rf_tech_mode; /* true if including RF Tech and Mode update    */
  tNFC_RF_TECH_N_MODE rf_tech_n_mode; /* RF tech and mode */
  bool include_tx_bit_rate;  /* true if including Tx bit rate update         */
  tNFC_BIT_RATE tx_bit_rate; /* Transmit Bit Rate                            */
  bool include_rx_bit_rate;  /* true if including Rx bit rate update         */
  tNFC_BIT_RATE rx_bit_rate; /* Receive Bit Rate                             */
  bool include_nfc_b_config; /* true if including NFC-B data exchange config */
  uint8_t min_tr0;           /* Minimun TR0                                  */
  uint8_t min_tr1;           /* Minimun TR1                                  */
  uint8_t suppression_eos;   /* Suppression of EoS                           */
  uint8_t suppression_sos;   /* Suppression of SoS                           */
  uint8_t min_tr2;           /* Minimun TR1                                  */
} tNFC_RF_COMM_PARAMS;

/*************************************
**  DISCOVER Callback Functions
**************************************/
typedef void(tNFC_DISCOVER_CBACK)(tNFC_DISCOVER_EVT event,
                                  tNFC_DISCOVER* p_data);

typedef uint16_t tNFC_TEST_EVT;

/* the data type associated with NFC_LOOPBACK_TEVT */
typedef struct {
  tNFC_STATUS status; /* The event status.            */
  NFC_HDR* p_data;    /* The loop back data from NFCC */
} tNFC_LOOPBACK_TEVT;

/* the data type associated with NFC_RF_CONTROL_TEVT */
typedef tNFC_STATUS tNFC_RF_CONTROL_TEVT;

typedef union {
  tNFC_STATUS status; /* The event status.            */
  tNFC_LOOPBACK_TEVT loop_back;
  tNFC_RF_CONTROL_TEVT rf_control;
} tNFC_TEST;

/*************************************
**  TEST Callback Functions
**************************************/
typedef void(tNFC_TEST_CBACK)(tNFC_TEST_EVT event, tNFC_TEST* p_data);

typedef tNFC_DEACTIVATE_DEVT tNFC_DEACTIVATE_CEVT;
typedef union {
  tNFC_STATUS status; /* The event status. */
  tNFC_CONN_CREATE_CEVT conn_create;
  tNFC_CONN_CLOSE_CEVT conn_close;
  tNFC_DEACTIVATE_CEVT deactivate;
  tNFC_DATA_CEVT data;
} tNFC_CONN;

typedef enum {
  NFC_HCI_INIT_COMPLETE = 0x00,/* Status of HCI initialization     */
  NFC_HCI_INIT_START = 0x01
} tNFC_HCI_INIT_STATUS;
/*************************************
**  Data Callback Functions
**************************************/
typedef void(tNFC_CONN_CBACK)(uint8_t conn_id, tNFC_CONN_EVT event,
                              tNFC_CONN* p_data);
#define NFC_MAX_CONN_ID 15
#define NFC_ILLEGAL_CONN_ID 0xFF
#define NFC_RF_CONN_ID 0 /* the static connection ID for RF traffic */
#if (NXP_EXTNS == TRUE)
#define NFC_NFCEE_CONN_ID 0x03 /* the connection ID for NFCEE */
#endif
#define NFC_HCI_CONN_ID 3 /* the static connection ID for HCI transport */

/*****************************************************************************
**  EXTERNAL FUNCTION DECLARATIONS
*****************************************************************************/

/*******************************************************************************
**
** Function         NFC_Enable
**
** Description      This function enables NFC. Prior to calling NFC_Enable:
**                  - the NFCC must be powered up, and ready to receive
**                    commands.
**                  - GKI must be enabled
**                  - NFC_TASK must be started
**                  - NCIT_TASK must be started (if using dedicated NCI
**                    transport)
**
**                  This function opens the NCI transport (if applicable),
**                  resets the NFC controller, and initializes the NFC
**                  subsystems.
**
**                  When the NFC startup procedure is completed, an
**                  NFC_ENABLE_REVT is returned to the application using the
**                  tNFC_RESPONSE_CBACK.
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_Enable(tNFC_RESPONSE_CBACK* p_cback);

/*******************************************************************************
**
** Function         NFC_Disable
**
** Description      This function performs clean up routines for shutting down
**                  NFC and closes the NCI transport (if using dedicated NCI
**                  transport).
**
**                  When the NFC shutdown procedure is completed, an
**                  NFC_DISABLED_REVT is returned to the application using the
**                  tNFC_RESPONSE_CBACK.
**
** Returns          nothing
**
*******************************************************************************/
extern void NFC_Disable(void);

/*******************************************************************************
**
** Function         NFC_Init
**
** Description      This function initializes control blocks for NFC
**
** Returns          nothing
**
*******************************************************************************/
#if (NXP_EXTNS == TRUE)
extern void NFC_Init(tHAL_NFC_CONTEXT* p_hal_entry_cntxt);
#else
extern void NFC_Init(tHAL_NFC_ENTRY* p_hal_entry_tbl);
#endif

/*******************************************************************************
**
** Function         NFC_GetLmrtSize
**
** Description      Called by application wto query the Listen Mode Routing
**                  Table size supported by NFCC
**
** Returns          Listen Mode Routing Table size
**
*******************************************************************************/
extern uint16_t NFC_GetLmrtSize(void);

/*******************************************************************************
**
** Function         NFC_SetConfig
**
** Description      This function is called to send the configuration parameter
**                  TLV to NFCC. The response from NFCC is reported by
**                  tNFC_RESPONSE_CBACK as NFC_SET_CONFIG_REVT.
**
** Parameters       tlv_size - the length of p_param_tlvs.
**                  p_param_tlvs - the parameter ID/Len/Value list
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_SetConfig(uint8_t tlv_size, uint8_t* p_param_tlvs);

/*******************************************************************************
**
** Function         NFC_GetConfig
**
** Description      This function is called to retrieve the parameter TLV from
**                  NFCC. The response from NFCC is reported by
**                  tNFC_RESPONSE_CBACK as NFC_GET_CONFIG_REVT.
**
** Parameters       num_ids - the number of parameter IDs
**                  p_param_ids - the parameter ID list.
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_GetConfig(uint8_t num_ids, uint8_t* p_param_ids);

/*******************************************************************************
**
** Function         NFC_NfceeDiscover
**
** Description      This function is called to enable or disable NFCEE
**                  Discovery. The response from NFCC is reported by
**                  tNFC_RESPONSE_CBACK as NFC_NFCEE_DISCOVER_REVT.
**                  The notification from NFCC is reported by
**                  tNFC_RESPONSE_CBACK as NFC_NFCEE_INFO_REVT.
**
** Parameters       discover - 1 to enable discover, 0 to disable.
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_NfceeDiscover(bool discover);

/*******************************************************************************
**
** Function         NFC_NfceeModeSet
**
** Description      This function is called to activate or de-activate an NFCEE
**                  connected to the NFCC.
**                  The response from NFCC is reported by tNFC_RESPONSE_CBACK
**                  as NFC_NFCEE_MODE_SET_REVT.
**
** Parameters       nfcee_id - the NFCEE to activate or de-activate.
**                  mode - 0 to activate NFCEE, 1 to de-activate.
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_NfceeModeSet(uint8_t nfcee_id, tNFC_NFCEE_MODE mode);

/*******************************************************************************
**
** Function         NFC_DiscoveryMap
**
** Description      This function is called to set the discovery interface
**                  mapping. The response from NFCC is reported by
**                  tNFC_DISCOVER_CBACK as. NFC_MAP_DEVT.
**
** Parameters       num - the number of items in p_params.
**                  p_maps - the discovery interface mappings
**                  p_cback - the discovery callback function
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_DiscoveryMap(uint8_t num, tNFC_DISCOVER_MAPS* p_maps,
                                    tNFC_DISCOVER_CBACK* p_cback);

/*******************************************************************************
**
** Function         NFC_DiscoveryStart
**
** Description      This function is called to start Polling and/or Listening.
**                  The response from NFCC is reported by tNFC_DISCOVER_CBACK
**                  as NFC_START_DEVT. The notification from NFCC is reported by
**                  tNFC_DISCOVER_CBACK as NFC_RESULT_DEVT.
**
** Parameters       num_params - the number of items in p_params.
**                  p_params - the discovery parameters
**                  p_cback - the discovery callback function
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_DiscoveryStart(uint8_t num_params,
                                      tNFC_DISCOVER_PARAMS* p_params,
                                      tNFC_DISCOVER_CBACK* p_cback);

/*******************************************************************************
**
** Function         NFC_DiscoverySelect
**
** Description      If tNFC_DISCOVER_CBACK reports status=NFC_MULTIPLE_PROT,
**                  the application needs to use this function to select the
**                  the logical endpoint to continue. The response from NFCC is
**                  reported by tNFC_DISCOVER_CBACK as NFC_SELECT_DEVT.
**
** Parameters       rf_disc_id - The ID identifies the remote device.
**                  protocol - the logical endpoint on the remote devide
**                  rf_interface - the RF interface to communicate with NFCC
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_DiscoverySelect(uint8_t rf_disc_id, uint8_t protocol,
                                       uint8_t rf_interface);

/*******************************************************************************
**
** Function         NFC_ConnCreate
**
** Description      This function is called to create a logical connection with
**                  NFCC for data exchange.
**                  The response from NFCC is reported in tNFC_CONN_CBACK
**                  as NFC_CONN_CREATE_CEVT.
**
** Parameters       dest_type - the destination type
**                  id   - the NFCEE ID or RF Discovery ID .
**                  protocol - the protocol
**                  p_cback - the data callback function to receive data from
**                  NFCC
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_ConnCreate(uint8_t dest_type, uint8_t id,
                                  uint8_t protocol, tNFC_CONN_CBACK* p_cback);

/*******************************************************************************
**
** Function         NFC_ConnClose
**
** Description      This function is called to close a logical connection with
**                  NFCC.
**                  The response from NFCC is reported in tNFC_CONN_CBACK
**                  as NFC_CONN_CLOSE_CEVT.
**
** Parameters       conn_id - the connection id.
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_ConnClose(uint8_t conn_id);

/*******************************************************************************
**
** Function         NFC_SetStaticRfCback
**
** Description      This function is called to update the data callback function
**                  to receive the data for the given connection id.
**
** Parameters       p_cback - the connection callback function
**
** Returns          Nothing
**
*******************************************************************************/
extern void NFC_SetStaticRfCback(tNFC_CONN_CBACK* p_cback);

/*******************************************************************************
**
** Function         NFC_SetReassemblyFlag
**
** Description      This function is called to set if nfc will reassemble
**                  nci packet as much as its buffer can hold or it should not
**                  reassemble but forward the fragmented nci packet to layer
**                  above. If nci data pkt is fragmented, nfc may send multiple
**                  NFC_DATA_CEVT with status NFC_STATUS_CONTINUE before sending
**                  NFC_DATA_CEVT with status NFC_STATUS_OK based on reassembly
**                  configuration and reassembly buffer size
**
** Parameters       reassembly - flag to indicate if nfc may reassemble or not
**
** Returns          Nothing
**
*******************************************************************************/
extern void NFC_SetReassemblyFlag(bool reassembly);

/*******************************************************************************
**
** Function         NFC_SendData
**
** Description      This function is called to send the given data packet
**                  to the connection identified by the given connection id.
**
** Parameters       conn_id - the connection id.
**                  p_data - the data packet
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_SendData(uint8_t conn_id, NFC_HDR* p_data);

/*******************************************************************************
**
** Function         NFC_FlushData
**
** Description      This function is called to discard the tx data queue of
**                  the given connection id.
**
** Parameters       conn_id - the connection id.
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_FlushData(uint8_t conn_id);

/*******************************************************************************
**
** Function         NFC_Deactivate
**
** Description      This function is called to stop the discovery process or
**                  put the listen device in sleep mode or terminate the NFC
**                  link.
**
**                  The response from NFCC is reported by tNFC_DISCOVER_CBACK
**                  as NFC_DEACTIVATE_DEVT.
**
** Parameters       deactivate_type - NFC_DEACTIVATE_TYPE_IDLE, to IDLE mode.
**                                    NFC_DEACTIVATE_TYPE_SLEEP to SLEEP mode.
**                                    NFC_DEACTIVATE_TYPE_SLEEP_AF to SLEEP_AF
**                                    mode.
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_Deactivate(tNFC_DEACT_TYPE deactivate_type);

/*******************************************************************************
**
** Function         NFC_UpdateRFCommParams
**
** Description      This function is called to update RF Communication
**                  parameters once the Frame RF Interface has been activated.
**
**                  The response from NFCC is reported by tNFC_RESPONSE_CBACK
**                  as NFC_RF_COMM_PARAMS_UPDATE_REVT.
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_UpdateRFCommParams(tNFC_RF_COMM_PARAMS* p_params);

/*******************************************************************************
**
** Function         NFC_SetPowerOffSleep
**
** Description      This function closes/opens transport and turns off/on NFCC.
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_SetPowerOffSleep(bool enable);

/*******************************************************************************
**
** Function         NFC_SetPowerSubState
**
** Description      This function is called to send the power sub state(screen
**                  state) to NFCC. The response from NFCC is reported by
**                  tNFC_RESPONSE_CBACK as NFC_SET_POWER_STATE_REVT.
**
** Parameters       scree_state
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_SetPowerSubState(uint8_t screen_state);

/*******************************************************************************
**
** Function         NFC_PowerCycleNFCC
**
** Description      This function turns off and then on NFCC.
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_PowerCycleNFCC(void);

/*******************************************************************************
**
** Function         NFC_SetRouting
**
** Description      This function is called to configure the CE routing table.
**                  The response from NFCC is reported by tNFC_RESPONSE_CBACK
**                  as NFC_SET_ROUTING_REVT.
**
** Parameters
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_SetRouting(bool more, uint8_t num_tlv, uint8_t tlv_size,
                                  uint8_t* p_param_tlvs);

/*******************************************************************************
**
** Function         NFC_GetRouting
**
** Description      This function is called to retrieve the CE routing table
**                  from NFCC. The response from NFCC is reported by
**                  tNFC_RESPONSE_CBACK as NFC_GET_ROUTING_REVT.
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_GetRouting(void);

/*******************************************************************************
**
** Function         NFC_RegVSCback
**
** Description      This function is called to register or de-register a
**                  callback function to receive Proprietary NCI response and
**                  notification events.
**                  The maximum number of callback functions allowed is
**                  NFC_NUM_VS_CBACKS
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_RegVSCback(bool is_register, tNFC_VS_CBACK* p_cback);

/*******************************************************************************
**
** Function         NFC_SendVsCommand
**
** Description      This function is called to send the given vendor specific
**                  command to NFCC. The response from NFCC is reported to the
**                  given tNFC_VS_CBACK as (oid).
**
** Parameters       oid - The opcode of the VS command.
**                  p_data - The parameters for the VS command
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_SendVsCommand(uint8_t oid, NFC_HDR* p_data,
                                     tNFC_VS_CBACK* p_cback);

/*******************************************************************************
**
** Function         NFC_SendRawVsCommand
**
** Description      This function is called to send the given raw command to
**                  NFCC. The response from NFCC is reported to the given
**                  tNFC_VS_CBACK.
**
** Parameters       p_data - The command buffer
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_SendRawVsCommand(NFC_HDR* p_data,
                                         tNFC_VS_CBACK* p_cback);

#if (NXP_EXTNS == TRUE)
/*******************************************************************************
**
** Function         NFC_SetP61Status
**
** Description      This function set the JCOP download
**                  state to pn544 driver.
**
** Returns          0 if api call success, else -1
**
*******************************************************************************/
extern int32_t NFC_SetP61Status(void* pdata, jcop_dwnld_state_t isJcopState);
#endif

/*******************************************************************************
**
** Function         NFC_TestLoopback
**
** Description      This function is called to send the given data packet
**                  to NFCC for loopback test.
**                  When loopback data is received from NFCC, tNFC_TEST_CBACK .
**                  reports a NFC_LOOPBACK_TEVT.
**
** Parameters       p_data - the data packet
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_TestLoopback(NFC_HDR* p_data);

/*******************************************************************************
**
** Function         NFC_ISODEPNakPresCheck
**
** Description      This function is called to send the ISO DEP nak presenc check cmd
**                  to check that the remote end point in RF field.
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_ISODEPNakPresCheck ();

/*******************************************************************************
**
** Function         NFC_GetStatusName
**
** Description      This function returns the status name.
**
** NOTE             conditionally compiled to save memory.
**
** Returns          pointer to the name
**
*******************************************************************************/
extern std::string NFC_GetStatusName(tNFC_STATUS status);

#if (NXP_EXTNS == TRUE || APPL_DTA_MODE == TRUE)
/*******************************************************************************
**
** Function         nfc_ncif_getFWVersion
**
** Description      This function sets the trace level for NFC.  If called with
**                  a value of 0xFF, it simply returns the current trace level.
**
** Returns          The new or current trace level
**
*******************************************************************************/
extern tNFC_FW_VERSION nfc_ncif_getFWVersion();
#endif

#if (NXP_EXTNS == TRUE)
/*******************************************************************************
**
** Function         nfc_ncif_storeScreenState
**
** Description      This function is called to store the last screen state
**
** Returns          void
**
*******************************************************************************/
extern void nfc_ncif_storeScreenState(uint8_t state);
extern uint8_t nfc_hal_nfcc_reset(void);
extern uint8_t nfc_hal_nfcc_init(uint8_t** pinit_rsp);
/*******************************************************************************
**
** Function         NFC_EnableDisableHalLog
**
** Description      This function is used to enable/disable
**                  HAL log level.
**
*******************************************************************************/
void NFC_EnableDisableHalLog(uint8_t type);
/*******************************************************************************
**
** Function         nfc_ncif_getMaxRoutingTableSize
**
** Description      This function is called to get the Max supported routing
*Table size.
**
** Returns           Max supported routing Table size
**
*******************************************************************************/
extern uint16_t nfc_ncif_getMaxRoutingTableSize();

/*******************************************************************************
**
** Function         NFC_Nfcee_PwrLinkCtrl
**
** Description      This function is called for NFCC which manages the power
*supply and
**                  communication links between the NFCC and its connected
*NFCEEs.
**
** Parameters       nfcee_id   - the NFCEE ID .
**                  cfg_value  - 0x00 ->Default Value(NFCC decides)
**                               0x01 ->NFCEE Power Supply always On
**                               0x03 ->NFCC to NFCEE Communication link always
**                                      active when the NFCEE is powered on
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_Nfcee_PwrLinkCtrl(uint8_t nfcee_id, uint8_t cfg_value,
                                         tNFC_INTF_REQ_SRC reqSrc);

/*******************************************************************************
**
** Function         NFC_ReqWiredAccess
**
** Description      This function request to pn54x driver to get access
**                  of P61. Status would be updated to pdata
**
** Returns          0 if api call success, else -1
**
*******************************************************************************/
int32_t NFC_ReqWiredAccess(void* pdata);
/*******************************************************************************
**
** Function         NFC_RelWiredAccess
**
** Description      This function release access
**                  of P61. Status would be updated to pdata
**
** Returns          0 if api call success, else -1
**
*******************************************************************************/
int32_t NFC_RelWiredAccess(void* pdata);
/*******************************************************************************
**
** Function         NFC_GetWiredAccess
**
** Description      This function gets the current access state
**                  of P61. Current state would be updated to pdata
**
** Returns          0 if api call success, else -1
**
*******************************************************************************/
int32_t NFC_GetP61Status(void* pdata);
/*******************************************************************************
**
** Function         NFC_DisableWired
**
** Description      This function request to pn54x driver to
**                  disable ese vdd gpio
**
** Returns          0 if api call success, else -1
**
*******************************************************************************/
int32_t NFC_DisableWired(void* pdata);

/*******************************************************************************
**
** Function         NFC_ReleaseEsePwr
**
** Description      This function request to pn553 driver to
**                  turn ese vdd gpio low
**
** Returns          0 if api call success, else -1
**
*******************************************************************************/
int32_t NFC_ReleaseEsePwr(void* pdata);

/*******************************************************************************
**
** Function         NFC_AcquireEsePwr
**
** Description      This function request to pn553 driver to
**                  turn ese vdd gpio high
**
** Returns          0 if api call success, else -1
**
*******************************************************************************/
int32_t NFC_AcquireEsePwr(void* pdata);

/*******************************************************************************
**
** Function         NFC_eSEChipReset
**
** Description      This function request to reset ESE using ISO_RST feature.
**
** Returns          0 if api call success, else -1
**
*******************************************************************************/
int32_t NFC_eSEChipReset(void* pdata);
/*******************************************************************************
**
** Function         NFC_EnableWired
**
** Description      This function request to pn54x driver to
**                  enable ese vdd gpio
**
** Returns          0 if api call success, else -1
**
*******************************************************************************/
int32_t NFC_EnableWired(void* pdata);
/*******************************************************************************
**
** Function         NFC_SetNfcServicePid
**
** Description      This function request to pn54x driver to
**                  update NFC service process ID for signalling.
**
** Returns          0 if api call success, else -1
**
*******************************************************************************/
int32_t NFC_SetNfcServicePid();
/*******************************************************************************
**
** Function         NFC_ResetNfcServicePid
**
** Description      This function request to pn54x driver to
**                  reset NFC service process ID for signalling.
**
** Returns          0 if api call success, else -1
**
*******************************************************************************/
int32_t NFC_ResetNfcServicePid();

/*******************************************************************************
**
** Function         NFC_IsLowRamDevice
**
** Description      This function provides low_ram is enabled or not
**
** Returns          true or false
**
*******************************************************************************/
bool NFC_IsLowRamDevice();

/*******************************************************************************
**
** Function         NFC_GetEseAccess
**
** Description      This function request to pn54x driver to get access
**                  of P61. it returns 0 on success. This api waits maximum
**                  defined timeout
**
** Returns          0 if api call success, else -1
**
*******************************************************************************/
int32_t NFC_GetEseAccess(void* pdata);

/*******************************************************************************
**
** Function         NFC_RelEseAccess
**
** Description      This function release access of P61.
**                  it returns 0 on success.
**
** Returns          0 if api call success, else -1
**
*******************************************************************************/
int32_t NFC_RelEseAccess(void* pdata);

/*******************************************************************************
**
** Function         NFC_RelSvddWait
**
** Description      This function release wait for svdd change
**                  of P61. Status would be updated to pdata
**
** Returns          0 if api call success, else -1
**
*******************************************************************************/
int32_t NFC_RelSvddWait(void* pdata);

/*******************************************************************************
**
** Function         NFC_GetChipType
**
** Description      Returns currently selected chip type
**
** Returns          chipType
**
*******************************************************************************/
tNFC_chipType NFC_GetChipType();

/*******************************************************************************
**
** Function         NFC_RelForceDwpOnOffWait
**
** Description      This function release wait for DWP On/Off
**                  of P73. Status would be updated to pdata
**
** Returns          0 if api call success, else -1
**
*******************************************************************************/
int32_t NFC_RelForceDwpOnOffWait (void *pdata);

/*******************************************************************************
**
** Function         NFC_Queue_Is_empty
**
** Description      This function to get NFCEE connection ID queue information
**
** Returns          1 if Queue is empty else 0
**
*******************************************************************************/
extern bool NFC_Queue_Is_empty(uint8_t conn_id);

/*******************************************************************************
 **
 ** Function         NFC_updateHciInitStatus
 **
 ** Description      Send HCI Event to nfc HAL
 **
 ** Returns          Nothing
 *******************************************************************************/
void NFC_updateHciInitStatus(tNFC_HCI_INIT_STATUS status);
#endif


/*******************************************************************************
**
** Function         NFC_NfceePLConfig
**
** Description      This function is called to set the Power and Link Control to
**                  an NFCEE connected to the NFCC.
**                  The response from NFCC is reported by tNFC_RESPONSE_CBACK
**                  as NFC_NFCEE_PL_CONTROL_REVT.
**
* Parameters       nfcee_id - the NFCEE to activate or de-activate.
**                  pl_config -
**                     NFCEE_PL_CONFIG_NFCC_DECIDES    NFCC decides (default)
**                     NFCEE_PL_CONFIG_P_ALWAYS_ON     NFCEE power supply is always on
**                     NFCEE_PL_CONFIG_L_ON_WHEN_P_ON  communication link is always active
**                                                          when NFCEE is powered on
**                     NFCEE_PL_CONFIG_PL_ALWAYS_ON    power supply and communication link are always on
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
extern tNFC_STATUS NFC_NfceePLConfig (uint8_t                 nfcee_id,
                                              tNCI_NFCEE_PL_CONFIG  pl_config);

/*******************************************************************************
**
** Function         NFC_SetStaticHciCback
**
** Description      This function is called to update the data callback function
**                  to receive the data for the static Hci connection id.
**
** Parameters       p_cback - the connection callback function
**
** Returns          Nothing
**
*******************************************************************************/
extern void NFC_SetStaticHciCback (tNFC_CONN_CBACK    *p_cback);

#endif /* NFC_API_H */