• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012-2014 NXP Semiconductors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifdef NXP_HW_SELF_TEST
18 
19 
20 #include <phNxpNciHal_SelfTest.h>
21 #include <phNxpLog.h>
22 #include <pthread.h>
23 #include <phOsalNfc_Timer.h>
24 
25 #define HAL_WRITE_RSP_TIMEOUT   (2000)   /* Timeout value to wait for response from PN54X */
26 #define HAL_WRITE_MAX_RETRY     (10)
27 
28 /******************* Structures and definitions *******************************/
29 
30 typedef uint8_t (*st_validator_t)(nci_data_t *exp, phTmlNfc_TransactInfo_t *act);
31 
32 phAntenna_St_Resp_t phAntenna_resp;
33 
34 typedef struct nci_test_data
35 {
36     nci_data_t cmd;
37     nci_data_t exp_rsp;
38     nci_data_t exp_ntf;
39     st_validator_t rsp_validator;
40     st_validator_t ntf_validator;
41 
42 }nci_test_data_t;
43 
44 /******************* Global variables *****************************************/
45 
46 static int thread_running = 0;
47 static uint32_t timeoutTimerId = 0;
48 static int hal_write_timer_fired = 0;
49 
50 /* TML Context */
51 extern phTmlNfc_Context_t *gpphTmlNfc_Context;
52 
53 /* Global HAL Ref */
54 extern phNxpNciHal_Control_t nxpncihal_ctrl;
55 
56 /* Driver parameters */
57 phLibNfc_sConfig_t   gDrvCfg;
58 
59 NFCSTATUS gtxldo_status = NFCSTATUS_FAILED;
60 NFCSTATUS gagc_value_status = NFCSTATUS_FAILED;
61 NFCSTATUS gagc_nfcld_status = NFCSTATUS_FAILED;
62 NFCSTATUS gagc_differential_status = NFCSTATUS_FAILED;
63 
64 
65 static uint8_t st_validator_testEquals(nci_data_t *exp, phTmlNfc_TransactInfo_t *act);
66 static uint8_t st_validator_null(nci_data_t *exp, phTmlNfc_TransactInfo_t *act);
67 static uint8_t st_validator_testSWP1_vltg(nci_data_t *exp, phTmlNfc_TransactInfo_t *act);
68 static uint8_t st_validator_testAntenna_Txldo(nci_data_t *exp, phTmlNfc_TransactInfo_t *act);
69 static uint8_t st_validator_testAntenna_AgcVal(nci_data_t *exp, phTmlNfc_TransactInfo_t *act);
70 static uint8_t st_validator_testAntenna_AgcVal_FixedNfcLd(nci_data_t *exp, phTmlNfc_TransactInfo_t *act);
71 static uint8_t st_validator_testAntenna_AgcVal_Differential(nci_data_t *exp, phTmlNfc_TransactInfo_t *act);
72 
73 #if(NFC_NXP_CHIP_TYPE != PN547C2)
74 NFCSTATUS phNxpNciHal_getPrbsCmd (phNxpNfc_PrbsType_t prbs_type, phNxpNfc_PrbsHwType_t hw_prbs_type,
75         uint8_t tech, uint8_t bitrate, uint8_t *prbs_cmd, uint8_t prbs_cmd_len);
76 #else
77 NFCSTATUS phNxpNciHal_getPrbsCmd (uint8_t tech, uint8_t bitrate, uint8_t *prbs_cmd, uint8_t prbs_cmd_len);
78 #endif
79 /* Test data to validate SWP line 2*/
80 static nci_test_data_t swp2_test_data[] = {
81     {
82         {
83             0x04, {0x20,0x00,0x01,0x01} /* cmd */
84         },
85         {
86 #if(NFC_NXP_CHIP_TYPE != PN547C2)
87             0x06, {0x40,0x00,0x03,0x00,0x11,0x01} /* exp_rsp */
88 #else
89             0x06, {0x40,0x00,0x03,0x00,0x10,0x01} /* exp_rsp */
90 #endif
91         },
92         {
93             0x00, {0x00} /* ext_ntf */
94         },
95         st_validator_testEquals, /* validator */
96         st_validator_null
97     },
98     {
99         {
100 #if(NFC_NXP_CHIP_TYPE != PN547C2)
101             0x05, {0x20,0x01,0x02,0x00,0x00} /* cmd */
102 #else
103             0x03, {0x20,0x01,0x00}
104 #endif
105         },
106         {
107 #if(NFC_NXP_CHIP_TYPE != PN547C2)
108             0x4, {0x40,0x01,0x19,0x00 } /* exp_rsp */
109 #else
110             0x4, {0x40,0x01,0x17,0x00 }
111 #endif
112         },
113         {
114             0x00, {0x00} /* ext_ntf */
115         },
116         st_validator_testEquals, /* validator */
117         st_validator_null
118     },
119     {
120         {
121             0x03, {0x2F,0x02,0x00} /* cmd */
122         },
123         {
124             0x04, {0x4F,0x02,0x05,0x00} /* exp_rsp */
125         },
126         {
127             0x00, {0x00} /* ext_ntf */
128         },
129         st_validator_testEquals, /* validator */
130         st_validator_null
131     },
132     {
133         {
134             0x04, {0x2F,0x3E,0x01,0x01} /* cmd */
135         },
136         {
137             0x04, {0x4F,0x3E,0x01,0x00} /* exp_rsp */
138         },
139         {
140             0x04, {0x6F,0x3E,0x02,0x00} /* ext_ntf */
141         },
142         st_validator_testEquals, /* validator */
143         st_validator_testEquals
144     },
145 
146 };
147 
148 /* Test data to validate SWP line 1*/
149 static nci_test_data_t swp1_test_data[] = {
150 
151     {
152         {
153             0x04, {0x20,0x00,0x01,0x01} /* cmd */
154         },
155         {
156 #if(NFC_NXP_CHIP_TYPE != PN547C2)
157             0x06, {0x40,0x00,0x03,0x00,0x11,0x01} /* exp_rsp */
158 #else
159             0x06, {0x40,0x00,0x03,0x00,0x10,0x01} /* exp_rsp */
160 #endif
161         },
162         {
163             0x00, {0x00} /* ext_ntf */
164         },
165         st_validator_testEquals, /* validator */
166         st_validator_null
167     },
168     {
169         {
170 #if(NFC_NXP_CHIP_TYPE != PN547C2)
171             0x05, {0x20,0x01,0x02,0x00,0x00} /* cmd */
172 #else
173             0x03, {0x20,0x01,0x00}
174 #endif
175         },
176         {
177 #if(NFC_NXP_CHIP_TYPE != PN547C2)
178             0x4, {0x40,0x01,0x19,0x00 } /* exp_rsp */
179 #else
180             0x4, {0x40,0x01,0x17,0x00 }
181 #endif
182         },
183         {
184             0x00, {0x00} /* ext_ntf */
185         },
186         st_validator_testEquals, /* validator */
187         st_validator_null
188     },
189     {
190         {
191             0x03, {0x2F,0x02,0x00} /* cmd */
192         },
193         {
194             0x04, {0x4F,0x02,0x05,0x00} /* exp_rsp */
195         },
196         {
197             0x00, {0x00} /* ext_ntf */
198         },
199         st_validator_testEquals, /* validator */
200         st_validator_null
201     },
202     {
203         {
204             0x04, {0x2F,0x3E,0x01,0x00} /* cmd */
205         },
206         {
207             0x04, {0x4F,0x3E,0x01,0x00} /* exp_rsp */
208         },
209         {
210             0x04, {0x6F,0x3E,0x02,0x00} /* ext_ntf */
211         },
212 
213         st_validator_testEquals, /* validator */
214         st_validator_testSWP1_vltg
215     },
216 };
217 
218 static nci_test_data_t prbs_test_data[] = {
219     {
220         {
221             0x04, {0x20,0x00,0x01,0x00} /* cmd */
222         },
223         {
224 #if(NFC_NXP_CHIP_TYPE != PN547C2)
225             0x06, {0x40,0x00,0x03,0x00,0x11,0x00} /* exp_rsp */
226 #else
227             0x06, {0x40,0x00,0x03,0x00,0x10,0x00} /* exp_rsp */
228 #endif
229         },
230         {
231             0x00, {0x00} /* ext_ntf */
232         },
233         st_validator_testEquals, /* validator */
234         st_validator_null
235     },
236     {
237         {
238 #if(NFC_NXP_CHIP_TYPE != PN547C2)
239             0x05, {0x20,0x01,0x02,0x00,0x00} /* cmd */
240 #else
241             0x03, {0x20,0x01,0x00} /* cmd */
242 #endif
243         },
244         {
245 #if(NFC_NXP_CHIP_TYPE != PN547C2)
246             0x4, {0x40,0x01,0x19,0x00 } /* exp_rsp */
247 #else
248             0x4, {0x40,0x01,0x17,0x00 } /* exp_rsp */
249 #endif
250         },
251         {
252             0x00, {0x00} /* ext_ntf */
253         },
254         st_validator_testEquals, /* validator */
255         st_validator_null
256 #if(NFC_NXP_CHIP_TYPE != PN547C2)
257     },
258     {
259         {
260             0x04, {0x2F,0x00,0x01,0x00} /* cmd */
261         },
262         {
263             0x04, {0x4F,0x00,0x01,0x00} /* exp_rsp */
264         },
265         {
266             0x00, {0x00} /* ext_ntf */
267         },
268         st_validator_testEquals, /* validator */
269         st_validator_null
270 #endif
271     }
272 };
273 
274 /* for rf field test, first requires to disable the standby mode */
275 static nci_test_data_t rf_field_on_test_data[] = {
276     {
277         {
278             0x04, {0x20,0x00,0x01,0x00} /* cmd */
279         },
280         {
281 #if(NFC_NXP_CHIP_TYPE != PN547C2)
282             0x06, {0x40,0x00,0x03,0x00,0x11,0x00} /* exp_rsp */
283 #else
284             0x06, {0x40,0x00,0x03,0x00,0x10,0x00} /* exp_rsp */
285 #endif
286         },
287         {
288             0x00, {0x00} /* ext_ntf */
289         },
290         st_validator_testEquals, /* validator */
291         st_validator_null
292     },
293     {
294         {
295 #if(NFC_NXP_CHIP_TYPE != PN547C2)
296             0x05, {0x20,0x01,0x02,0x00,0x00} /* cmd */
297 #else
298             0x03, {0x20,0x01,0x00} /* cmd */
299 #endif
300         },
301         {
302 #if(NFC_NXP_CHIP_TYPE != PN547C2)
303             0x4, {0x40,0x01,0x19,0x00 } /* exp_rsp */
304 #else
305             0x4, {0x40,0x01,0x17,0x00 } /* exp_rsp */
306 #endif
307         },
308         {
309             0x00, {0x00} /* ext_ntf */
310         },
311         st_validator_testEquals, /* validator */
312         st_validator_null
313     },
314 #if(NFC_NXP_CHIP_TYPE != PN547C2)
315     {
316          {
317             0x03, {0x2F,0x02,0x00} /* cmd */
318          },
319          {
320             0x04, {0x4F,0x02,0x05,0x00} /* exp_rsp */
321          },
322          {
323             0x00, {0x00} /* ext_ntf */
324          },
325          st_validator_testEquals, /* validator */
326          st_validator_null
327     },
328     {
329          {
330             0x04, {0x2F,0x00,0x01,0x00} /* cmd */
331          },
332          {
333             0x04, {0x4F,0x00,0x01,0x00} /* exp_rsp */
334          },
335          {
336             0x00, {0x00} /* ext_ntf */
337          },
338          st_validator_testEquals, /* validator */
339          st_validator_null
340     },
341 #endif
342     {
343         {
344 #if(NFC_NXP_CHIP_TYPE != PN547C2)
345             0x05, {0x2F,0x3D,0x02,0x20,0x01} /* cmd */
346 #else
347             0x08, {0x2F,0x3D,0x05,0x20,0x01,0x00,0x00,0x00} /* cmd */
348 #endif
349         },
350         {
351             0x04, {0x4F,0x3D,0x05,0x00} /* exp_rsp */
352         },
353         {
354             0x00, {0x00} /* ext_ntf */
355         },
356         st_validator_testEquals, /* validator */
357         st_validator_null
358 #if(NFC_NXP_CHIP_TYPE != PN547C2)
359     },
360     {
361         {
362             0x04, {0x2F,0x00,0x01,0x01} /* cmd */
363         },
364         {
365             0x04, {0x4F,0x00,0x01,0x00} /* exp_rsp */
366         },
367         {
368             0x00, {0x00} /* ext_ntf */
369         },
370         st_validator_testEquals, /* validator */
371         st_validator_null
372 #endif
373     }
374 };
375 
376 static nci_test_data_t rf_field_off_test_data[] = {
377     {
378         {
379             0x04, {0x20,0x00,0x01,0x00} /* cmd */
380         },
381         {
382 #if(NFC_NXP_CHIP_TYPE != PN547C2)
383             0x06, {0x40,0x00,0x03,0x00,0x11,0x00} /* exp_rsp */
384 #else
385             0x06, {0x40,0x00,0x03,0x00,0x10,0x00} /* exp_rsp */
386 #endif
387         },
388         {
389             0x00, {0x00} /* ext_ntf */
390         },
391         st_validator_testEquals, /* validator */
392         st_validator_null
393     },
394     {
395         {
396 #if(NFC_NXP_CHIP_TYPE != PN547C2)
397             0x05, {0x20,0x01,0x02,0x00,0x00} /* cmd */
398 #else
399             0x03, {0x20,0x01,0x00} /* cmd */
400 #endif
401         },
402         {
403 #if(NFC_NXP_CHIP_TYPE != PN547C2)
404             0x4, {0x40,0x01,0x19,0x00 } /* exp_rsp */
405 #else
406             0x4, {0x40,0x01,0x17,0x00 } /* exp_rsp */
407 #endif
408         },
409         {
410             0x00, {0x00} /* ext_ntf */
411         },
412         st_validator_testEquals, /* validator */
413         st_validator_null
414     },
415 #if(NFC_NXP_CHIP_TYPE != PN547C2)
416     {
417         {
418             0x03, {0x2F,0x02,0x00} /* cmd */
419         },
420         {
421             0x04, {0x4F,0x02,0x05,0x00} /* exp_rsp */
422         },
423         {
424             0x00, {0x00} /* ext_ntf */
425         },
426         st_validator_testEquals, /* validator */
427         st_validator_null
428      },
429      {
430         {
431              0x04, {0x2F,0x00,0x01,0x00} /* cmd */
432         },
433         {
434              0x04, {0x4F,0x00,0x01,0x00} /* exp_rsp */
435         },
436         {
437              0x00, {0x00} /* ext_ntf */
438         },
439         st_validator_testEquals, /* validator */
440         st_validator_null
441      },
442 #endif
443      {
444         {
445 #if(NFC_NXP_CHIP_TYPE != PN547C2)
446             0x05, {0x2F,0x3D,0x02,0x20,0x00} /* cmd */
447 #else
448             0x08, {0x2F,0x3D,0x05,0x20,0x00,0x00,0x00,0x00} /* cmd */
449 #endif
450         },
451         {
452             0x04, {0x4F,0x3D,0x05,0x00} /* exp_rsp */
453         },
454         {
455             0x00, {0x00} /* ext_ntf */
456         },
457         st_validator_testEquals, /* validator */
458         st_validator_null
459 #if(NFC_NXP_CHIP_TYPE != PN547C2)
460      },
461      {
462         {
463             0x04, {0x2F,0x00,0x01,0x01} /* cmd */
464         },
465         {
466             0x04, {0x4F,0x00,0x01,0x00} /* exp_rsp */
467         },
468         {
469             0x00, {0x00} /* ext_ntf */
470         },
471         st_validator_testEquals, /* validator */
472         st_validator_null
473 #endif
474      }
475 };
476 
477 /* Download pin test data 1 */
478 static nci_test_data_t download_pin_test_data1[] = {
479     {
480         {
481             0x04, {0x20,0x00,0x01,0x01} /* cmd */
482         },
483         {
484 #if(NFC_NXP_CHIP_TYPE != PN547C2)
485             0x06, {0x40,0x00,0x03,0x00,0x11,0x01} /* exp_rsp */
486 #else
487             0x06, {0x40,0x00,0x03,0x00,0x10,0x01} /* exp_rsp */
488 #endif
489         },
490         {
491             0x00, {0x00} /* ext_ntf */
492         },
493         st_validator_testEquals, /* validator */
494         st_validator_null
495     },
496 };
497 
498 /* Download pin test data 2 */
499 static nci_test_data_t download_pin_test_data2[] = {
500     {
501         {
502             0x08, {0x00, 0x04, 0xD0, 0x11, 0x00, 0x00, 0x5B, 0x46} /* cmd */
503         },
504         {
505             0x08, {0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x87, 0x16} /* exp_rsp */
506         },
507         {
508             0x00, {0x00} /* ext_ntf */
509         },
510         st_validator_testEquals, /* validator */
511         st_validator_null
512     },
513 };
514 /* Antenna self test data*/
515 static nci_test_data_t antenna_self_test_data[] = {
516     {
517         {
518             0x04, {0x20,0x00,0x01,0x00} /* cmd */
519         },
520         {
521 #if(NFC_NXP_CHIP_TYPE != PN547C2)
522             0x06, {0x40,0x00,0x03,0x00,0x11,0x00} /* exp_rsp */
523 #else
524             0x06, {0x40,0x00,0x03,0x00,0x10,0x00} /* exp_rsp */
525 #endif
526         },
527         {
528             0x00, {0x00} /* ext_ntf */
529         },
530         st_validator_testEquals, /* validator */
531         st_validator_null
532     },
533     {
534         {
535 #if(NFC_NXP_CHIP_TYPE != PN547C2)
536             0x05, {0x20,0x01,0x02,0x00,0x00} /* cmd */
537 #else
538             0x03, {0x20,0x01,0x00} /* cmd */
539 #endif
540         },
541         {
542 #if(NFC_NXP_CHIP_TYPE != PN547C2)
543             0x4, {0x40,0x01,0x19,0x00 } /* exp_rsp */
544 #else
545             0x4, {0x40,0x01,0x17,0x00 } /* exp_rsp */
546 #endif
547         },
548         {
549             0x00, {0x00} /* ext_ntf */
550         },
551         st_validator_testEquals, /* validator */
552         st_validator_null
553     },
554     {
555         {
556             0x03, {0x2F,0x02,0x00} /* cmd */
557         },
558         {
559             0x04, {0x4F,0x02,0x05,0x00} /* exp_rsp */
560         },
561         {
562             0x00, {0x00} /* ext_ntf */
563         },
564         st_validator_testEquals, /* validator */
565         st_validator_null
566     },
567 #if(NFC_NXP_CHIP_TYPE != PN547C2)
568     {
569         {
570             0x04, {0x2F,0x00,0x01,0x00} /* cmd */
571         },
572         {
573             0x04, {0x4F,0x00,0x01,0x00} /* exp_rsp */
574         },
575         {
576             0x00, {0x00} /* ext_ntf */
577         },
578         st_validator_testEquals, /* validator */
579         st_validator_null
580     },
581 #endif
582     {
583         {
584             0x05, {0x2F, 0x3D, 0x02, 0x01, 0x80} /* TxLDO cureent measurement cmd */
585         },
586         {
587             0x03, {0x4F, 0x3D, 05} /* exp_rsp */
588         },
589         {
590             0x00, {0x00} /* ext_ntf */
591         },
592         st_validator_testAntenna_Txldo,
593         st_validator_null
594     },
595     {
596         {
597 #if(NFC_NXP_CHIP_TYPE != PN547C2)
598             0x07, {0x2F, 0x3D, 0x04, 0x02, 0xC8, 0x60, 0x03} /* AGC measurement cmd */
599 #else
600             0x07, {0x2F, 0x3D, 0x04, 0x02, 0xCD, 0x60, 0x03} /* AGC measurement cmd */
601 #endif
602         },
603         {
604             0x03, {0x4F, 0x3D, 05} /* exp_rsp */
605         },
606         {
607             0x00, {0x00} /* ext_ntf */
608         },
609         st_validator_testAntenna_AgcVal,
610         st_validator_null
611     },
612     {
613         {
614             0x07, {0x2F, 0x3D, 0x04, 0x04, 0x20, 0x08, 0x20} /* AGC with NFCLD measurement cmd */
615         },
616         {
617             0x03, {0x4F, 0x3D, 05} /* exp_rsp */
618         },
619         {
620             0x00, {0x00} /* ext_ntf */
621         },
622         st_validator_testAntenna_AgcVal_FixedNfcLd,
623         st_validator_null
624     },
625     {
626         {
627             0x07, {0x2F, 0x3D, 0x04, 0x08, 0x8C, 0x60, 0x03} /* AGC with NFCLD measurement cmd */
628         },
629         {
630             0x03, {0x4F, 0x3D, 05} /* exp_rsp */
631         },
632         {
633             0x00, {0x00} /* ext_ntf */
634         },
635         st_validator_testAntenna_AgcVal_Differential,
636         st_validator_null
637 #if(NFC_NXP_CHIP_TYPE != PN547C2)
638     },
639     {
640         {
641             0x04, {0x2F,0x00,0x01,0x01} /* cmd */
642         },
643         {
644             0x04, {0x4F,0x00,0x01,0x00} /* exp_rsp */
645         },
646         {
647             0x00, {0x00} /* ext_ntf */
648         },
649         st_validator_testEquals, /* validator */
650         st_validator_null
651 #endif
652     }
653 };
654 
655 
656 /************** Self test functions ***************************************/
657 
658 static uint8_t st_validator_testEquals(nci_data_t *exp, phTmlNfc_TransactInfo_t *act);
659 static void hal_write_cb(void *pContext, phTmlNfc_TransactInfo_t *pInfo);
660 static void hal_write_rsp_timeout_cb(uint32_t TimerId, void *pContext);
661 static void hal_read_cb(void *pContext, phTmlNfc_TransactInfo_t *pInfo);
662 
663 /*******************************************************************************
664 **
665 ** Function         st_validator_null
666 **
667 ** Description      Null Validator
668 **
669 ** Returns          One
670 **
671 *******************************************************************************/
672 static uint8_t st_validator_null(nci_data_t *exp, phTmlNfc_TransactInfo_t *act)
673 {
674     UNUSED(exp);
675     UNUSED(act);
676     return 1;
677 }
678 
679 /*******************************************************************************
680 **
681 ** Function         st_validator_testSWP1_vltg
682 **
683 ** Description      Validator function to validate swp1 connection.
684 **
685 ** Returns          One if successful otherwise Zero.
686 **
687 *******************************************************************************/
688 static uint8_t st_validator_testSWP1_vltg(nci_data_t *exp, phTmlNfc_TransactInfo_t *act)
689 {
690     uint8_t result = 0;
691 
692     if(NULL == exp || NULL == act)
693     {
694         return result;
695     }
696 
697     if( (act->wLength == 0x05) &&
698             (memcmp(exp->p_data,act->pBuff,exp->len) == 0))
699     {
700         if(act->pBuff[4] == 0x01 || act->pBuff[4] == 0x02)
701         {
702             result = 1;
703         }
704     }
705 
706     return result;
707 }
708 
709 /*******************************************************************************
710 **
711 ** Function         st_validator_testAntenna_Txldo
712 **
713 ** Description      Validator function to validate Antenna TxLDO current measurement.
714 **
715 ** Returns          One if successful otherwise Zero.
716 **
717 *******************************************************************************/
718 static uint8_t st_validator_testAntenna_Txldo(nci_data_t *exp, phTmlNfc_TransactInfo_t *act)
719 {
720     uint8_t result = 0;
721     uint8_t mesuredrange =0;
722     long measured_val = 0;
723     int tolerance = 0;
724 
725     if(NULL == exp || NULL == act)
726     {
727         return result;
728     }
729 
730     NXPLOG_NCIHAL_D("st_validator_testAntenna_Txldo = 0x%x", act->pBuff[3]);
731     if (0x05 == act->pBuff[2])
732     {
733         if (NFCSTATUS_SUCCESS == act->pBuff[3])
734         {
735             result = 1;
736             NXPLOG_NCIHAL_D("Antenna: TxLDO current measured raw value in mA : 0x%x", act->pBuff[4]);
737             if(0x00 == act->pBuff[5])
738             {
739                 NXPLOG_NCIHAL_D("Measured range : 0x00 = 50 - 100 mA");
740                 measured_val = ((0.40 * act->pBuff[4]) + 50);
741                 NXPLOG_NCIHAL_D("TxLDO current absolute value in mA = %ld", measured_val);
742             }
743             else
744             {
745                 NXPLOG_NCIHAL_D("Measured range : 0x01 = 20 - 70 mA");
746                 measured_val = ((0.40 * act->pBuff[4]) + 20);
747                 NXPLOG_NCIHAL_D("TxLDO current absolute value in mA = %ld", measured_val);
748             }
749 
750             tolerance = (phAntenna_resp.wTxdoMeasuredRangeMax  *
751                          phAntenna_resp.wTxdoMeasuredTolerance)/100;
752             if ((measured_val <= phAntenna_resp.wTxdoMeasuredRangeMax + tolerance))
753             {
754                 tolerance = (phAntenna_resp.wTxdoMeasuredRangeMin *
755                              phAntenna_resp.wTxdoMeasuredTolerance)/100;
756                 if((measured_val >= phAntenna_resp.wTxdoMeasuredRangeMin - tolerance))
757                 {
758                     gtxldo_status = NFCSTATUS_SUCCESS;
759                     NXPLOG_NCIHAL_E("Test Antenna Response for TxLDO measurement PASS");
760                 }
761                 else
762                 {
763                     gtxldo_status = NFCSTATUS_FAILED;
764                     NXPLOG_NCIHAL_E("Test Antenna Response for TxLDO measurement FAIL");
765                 }
766             }
767             else
768             {
769                 gtxldo_status = NFCSTATUS_FAILED;
770                 NXPLOG_NCIHAL_E("Test Antenna Response for TxLDO measurement FAIL");
771             }
772         }
773         else
774         {
775             gtxldo_status = NFCSTATUS_FAILED;
776             NXPLOG_NCIHAL_E("Test Antenna Response for TxLDO measurement failed: Invalid status");
777         }
778 
779     }
780     else
781     {
782         gtxldo_status = NFCSTATUS_FAILED;
783         NXPLOG_NCIHAL_E("Test Antenna Response for TxLDO measurement failed: Invalid payload length");
784     }
785 
786     return result;
787 }
788 
789 /*******************************************************************************
790 **
791 ** Function         st_validator_testAntenna_AgcVal
792 **
793 ** Description      Validator function reads AGC value of antenna and print the info
794 **
795 ** Returns          One if successful otherwise Zero.
796 **
797 *******************************************************************************/
798 static uint8_t st_validator_testAntenna_AgcVal(nci_data_t *exp, phTmlNfc_TransactInfo_t *act)
799 {
800     uint8_t result = 0;
801     int agc_tolerance = 0;
802     long agc_val = 0;
803 
804     if(NULL == exp || NULL == act)
805     {
806         return result;
807     }
808 
809     if (0x05 == act->pBuff[2])
810     {
811         if (NFCSTATUS_SUCCESS == act->pBuff[3])
812         {
813             result = 1;
814             agc_tolerance = (phAntenna_resp.wAgcValue * phAntenna_resp.wAgcValueTolerance)/100;
815             agc_val =  ((act->pBuff[5] << 8) | (act->pBuff[4]));
816             NXPLOG_NCIHAL_D("AGC value : %ld", agc_val);
817             if(((phAntenna_resp.wAgcValue - agc_tolerance) <= agc_val) &&
818                (agc_val <= (phAntenna_resp.wAgcValue + agc_tolerance)))
819             {
820                 gagc_value_status = NFCSTATUS_SUCCESS;
821                 NXPLOG_NCIHAL_E("Test Antenna Response for AGC Values  PASS");
822             }
823             else
824             {
825                 gagc_value_status = NFCSTATUS_FAILED;
826                 NXPLOG_NCIHAL_E("Test Antenna Response for AGC Values  FAIL");
827             }
828         }
829         else
830         {
831             gagc_value_status = NFCSTATUS_FAILED;
832             NXPLOG_NCIHAL_E("Test Antenna Response for AGC Values  FAIL");
833         }
834     }
835     else
836     {
837         gagc_value_status = NFCSTATUS_FAILED;
838         NXPLOG_NCIHAL_E("Test Antenna Response for AGC value failed: Invalid payload length");
839     }
840 
841     return result;
842 }
843 /*******************************************************************************
844 **
845 ** Function         st_validator_testAntenna_AgcVal_FixedNfcLd
846 **
847 ** Description      Validator function reads and print AGC value of
848 **                  antenna with fixed NFCLD
849 **
850 ** Returns          One if successful otherwise Zero.
851 **
852 *******************************************************************************/
853 static uint8_t st_validator_testAntenna_AgcVal_FixedNfcLd(nci_data_t *exp, phTmlNfc_TransactInfo_t *act)
854 {
855     uint8_t result = 0;
856     int agc_nfcld_tolerance = 0;
857     long agc_nfcld = 0;
858 
859     if(NULL == exp || NULL == act)
860     {
861         return result;
862     }
863 
864     if(0x05 == act->pBuff[2])
865     {
866         if(NFCSTATUS_SUCCESS == act->pBuff[3])
867         {
868             result = 1;
869             agc_nfcld_tolerance = (phAntenna_resp.wAgcValuewithfixedNFCLD *
870                                    phAntenna_resp.wAgcValuewithfixedNFCLDTolerance)/100;
871             agc_nfcld =  ((act->pBuff[5] << 8) | (act->pBuff[4]));
872             NXPLOG_NCIHAL_D("AGC value with Fixed Nfcld  : %ld", agc_nfcld);
873 
874             if(((phAntenna_resp.wAgcValuewithfixedNFCLD - agc_nfcld_tolerance) <= agc_nfcld) &&
875               (agc_nfcld <= (phAntenna_resp.wAgcValuewithfixedNFCLD + agc_nfcld_tolerance)))
876             {
877                 gagc_nfcld_status = NFCSTATUS_SUCCESS;
878                 NXPLOG_NCIHAL_E("Test Antenna Response for AGC value with fixed NFCLD PASS");
879             }
880             else
881             {
882                 gagc_nfcld_status =  NFCSTATUS_FAILED;
883                 NXPLOG_NCIHAL_E("Test Antenna Response for AGC value with fixed NFCLD FAIL");
884             }
885         }
886         else
887         {
888             gagc_nfcld_status =  NFCSTATUS_FAILED;
889             NXPLOG_NCIHAL_E("Test Antenna Response for AGC value with fixed NFCLD failed: Invalid status");
890         }
891     }
892     else
893     {
894         gagc_nfcld_status =  NFCSTATUS_FAILED;
895         NXPLOG_NCIHAL_E("Test Antenna Response for AGC value with fixed NFCLD failed: Invalid payload length");
896     }
897 
898     return result;
899 }
900 
901 /*******************************************************************************
902 **
903 ** Function         st_validator_testAntenna_AgcVal_Differential
904 **
905 ** Description      Reads the AGC value with open/short RM from buffer and print
906 **
907 ** Returns          One if successful otherwise Zero.
908 **
909 *******************************************************************************/
910 static uint8_t st_validator_testAntenna_AgcVal_Differential(nci_data_t *exp, phTmlNfc_TransactInfo_t *act)
911 {
912     uint8_t result = 0;
913     int agc_toleranceopne1 = 0;
914     int agc_toleranceopne2 = 0;
915     long agc_differentialOpne1 = 0;
916     long agc_differentialOpne2 = 0;
917 
918     if(NULL == exp || NULL == act)
919     {
920         return result;
921     }
922 
923     if (0x05 == act->pBuff[2])
924     {
925         if (NFCSTATUS_SUCCESS == act->pBuff[3])
926         {
927             result = 1;
928             agc_toleranceopne1=(phAntenna_resp.wAgcDifferentialWithOpen1 *
929                                 phAntenna_resp.wAgcDifferentialWithOpenTolerance1)/100;
930             agc_toleranceopne2=(phAntenna_resp.wAgcDifferentialWithOpen2 *
931                                 phAntenna_resp.wAgcDifferentialWithOpenTolerance2)/100;
932             agc_differentialOpne1 =  ((act->pBuff[5] << 8) | (act->pBuff[4]));
933             agc_differentialOpne2 =  ((act->pBuff[7] << 8) | (act->pBuff[6]));
934             NXPLOG_NCIHAL_D("AGC value differential Opne 1  : %ld", agc_differentialOpne1);
935             NXPLOG_NCIHAL_D("AGC value differentialOpne  2 : %ld", agc_differentialOpne2);
936 
937             if(((agc_differentialOpne1 >= phAntenna_resp.wAgcDifferentialWithOpen1 - agc_toleranceopne1) &&
938                (agc_differentialOpne1 <= phAntenna_resp.wAgcDifferentialWithOpen1 + agc_toleranceopne1)) &&
939                ((agc_differentialOpne2 >= phAntenna_resp.wAgcDifferentialWithOpen2 - agc_toleranceopne2) &&
940                (agc_differentialOpne2 <= phAntenna_resp.wAgcDifferentialWithOpen2 + agc_toleranceopne2)))
941             {
942                 gagc_differential_status = NFCSTATUS_SUCCESS;
943                 NXPLOG_NCIHAL_E("Test Antenna Response for AGC Differential Open PASS");
944             }
945             else
946             {
947                 gagc_differential_status = NFCSTATUS_FAILED;
948                 NXPLOG_NCIHAL_E("Test Antenna Response for AGC Differential Open  FAIL");
949             }
950         }
951         else
952         {
953             NXPLOG_NCIHAL_E("Test Antenna Response for AGC Differential failed: Invalid status");
954             gagc_differential_status = NFCSTATUS_FAILED;
955         }
956 
957     }
958     else
959     {
960         NXPLOG_NCIHAL_E("Test Antenna Response for AGC Differential failed: Invalid payload length");
961         gagc_differential_status = NFCSTATUS_FAILED;
962     }
963 
964     return result;
965 }
966 /*******************************************************************************
967 **
968 ** Function         st_validator_testEquals
969 **
970 ** Description      Validator function to validate for equality between actual
971 **                  and expected values.
972 **
973 ** Returns          One if successful otherwise Zero.
974 **
975 *******************************************************************************/
976 static uint8_t st_validator_testEquals(nci_data_t *exp, phTmlNfc_TransactInfo_t *act)
977 {
978     uint8_t result = 0;
979 
980     if(NULL == exp || NULL == act)
981     {
982         return result;
983     }
984     if(exp->len <= act->wLength &&
985             (memcmp(exp->p_data,act->pBuff,exp->len) == 0))
986     {
987         result = 1;
988     }
989 
990     return result;
991 }
992 
993 /*******************************************************************************
994 **
995 ** Function         hal_write_rsp_timeout_cb
996 **
997 ** Description      Callback function for hal write response timer.
998 **
999 ** Returns          None
1000 **
1001 *******************************************************************************/
1002 static void hal_write_rsp_timeout_cb(uint32_t timerId, void *pContext)
1003 {
1004     UNUSED(timerId);
1005     NXPLOG_NCIHAL_E("hal_write_rsp_timeout_cb - write timeout!!!");
1006     hal_write_timer_fired = 1;
1007     hal_read_cb(pContext,NULL);
1008 }
1009 
1010 /*******************************************************************************
1011 **
1012 ** Function         hal_write_cb
1013 **
1014 ** Description      Callback function for hal write.
1015 **
1016 ** Returns          None
1017 **
1018 *******************************************************************************/
1019 static void hal_write_cb(void *pContext, phTmlNfc_TransactInfo_t *pInfo)
1020 {
1021     phNxpNciHal_Sem_t *p_cb_data = (phNxpNciHal_Sem_t*) pContext;
1022 
1023     if (pInfo->wStatus == NFCSTATUS_SUCCESS)
1024     {
1025         NXPLOG_NCIHAL_D("write successful status = 0x%x", pInfo->wStatus);
1026     }
1027     else
1028     {
1029         NXPLOG_NCIHAL_E("write error status = 0x%x", pInfo->wStatus);
1030     }
1031 
1032     p_cb_data->status = pInfo->wStatus;
1033     SEM_POST(p_cb_data);
1034 
1035     return;
1036 }
1037 
1038 /*******************************************************************************
1039 **
1040 ** Function         hal_read_cb
1041 **
1042 ** Description      Callback function for hal read.
1043 **
1044 ** Returns          None
1045 **
1046 *******************************************************************************/
1047 static void hal_read_cb(void *pContext, phTmlNfc_TransactInfo_t *pInfo)
1048 {
1049     phNxpNciHal_Sem_t *p_cb_data = (phNxpNciHal_Sem_t*) pContext;
1050     NFCSTATUS status;
1051     if(hal_write_timer_fired == 1)
1052     {
1053         NXPLOG_NCIHAL_D("hal_read_cb - response timeout occurred");
1054 
1055         hal_write_timer_fired = 0;
1056         p_cb_data->status = NFCSTATUS_RESPONSE_TIMEOUT;
1057         status = phTmlNfc_ReadAbort();
1058     }
1059     else
1060     {
1061         NFCSTATUS status = phOsalNfc_Timer_Stop(timeoutTimerId);
1062 
1063         if (NFCSTATUS_SUCCESS == status)
1064         {
1065             NXPLOG_NCIHAL_D("Response timer stopped");
1066         }
1067         else
1068         {
1069             NXPLOG_NCIHAL_E("Response timer stop ERROR!!!");
1070             p_cb_data->status  = NFCSTATUS_FAILED;
1071         }
1072 
1073         if (pInfo->wStatus == NFCSTATUS_SUCCESS)
1074         {
1075             NXPLOG_NCIHAL_D("hal_read_cb successful status = 0x%x", pInfo->wStatus);
1076             p_cb_data->status = NFCSTATUS_SUCCESS;
1077         }
1078         else
1079         {
1080             NXPLOG_NCIHAL_E("hal_read_cb error status = 0x%x", pInfo->wStatus);
1081             p_cb_data->status = NFCSTATUS_FAILED;
1082         }
1083 
1084         p_cb_data->status = pInfo->wStatus;
1085 
1086         nci_test_data_t *test_data = (nci_test_data_t*) p_cb_data->pContext;
1087 
1088         if(test_data->exp_rsp.len == 0)
1089         {
1090             /* Compare the actual notification with expected notification.*/
1091             if( test_data->ntf_validator(&(test_data->exp_ntf),pInfo) == 1 )
1092             {
1093                 p_cb_data->status = NFCSTATUS_SUCCESS;
1094             }
1095             else
1096             {
1097                 p_cb_data->status = NFCSTATUS_FAILED;
1098 
1099             }
1100         }
1101 
1102         /* Compare the actual response with expected response.*/
1103         else if( test_data->rsp_validator(&(test_data->exp_rsp),pInfo) == 1)
1104         {
1105             p_cb_data->status = NFCSTATUS_SUCCESS;
1106         }
1107         else
1108         {
1109             p_cb_data->status = NFCSTATUS_FAILED;
1110         }
1111         test_data->exp_rsp.len = 0;
1112     }
1113 
1114     SEM_POST(p_cb_data);
1115 
1116     return;
1117 }
1118 
1119 /*******************************************************************************
1120 **
1121 ** Function         phNxpNciHal_test_rx_thread
1122 **
1123 ** Description      Thread to fetch and process messages from message queue.
1124 **
1125 ** Returns          NULL
1126 **
1127 *******************************************************************************/
1128 static void *phNxpNciHal_test_rx_thread(void *arg)
1129 {
1130     phLibNfc_Message_t msg;
1131     UNUSED(arg);
1132     NXPLOG_NCIHAL_D("Self test thread started");
1133 
1134     thread_running = 1;
1135 
1136     while (thread_running == 1)
1137     {
1138         /* Fetch next message from the NFC stack message queue */
1139         if (phDal4Nfc_msgrcv(gDrvCfg.nClientId,
1140                 &msg, 0, 0) == -1)
1141         {
1142             NXPLOG_NCIHAL_E("Received bad message");
1143             continue;
1144         }
1145 
1146         if(thread_running == 0)
1147         {
1148             break;
1149         }
1150 
1151         switch (msg.eMsgType)
1152         {
1153             case PH_LIBNFC_DEFERREDCALL_MSG:
1154             {
1155                 phLibNfc_DeferredCall_t *deferCall =
1156                         (phLibNfc_DeferredCall_t *) (msg.pMsgData);
1157 
1158                 REENTRANCE_LOCK();
1159                 deferCall->pCallback(deferCall->pParameter);
1160                 REENTRANCE_UNLOCK();
1161 
1162                 break;
1163             }
1164         }
1165     }
1166 
1167     NXPLOG_NCIHAL_D("Self test thread stopped");
1168 
1169     return NULL;
1170 }
1171 
1172 /*******************************************************************************
1173 **
1174 ** Function         phNxpNciHal_readLocked
1175 **
1176 ** Description      Reads response and notification from NFCC and waits for
1177 **                  read completion, for a definitive timeout value.
1178 **
1179 ** Returns          NFCSTATUS_SUCCESS if successful,otherwise NFCSTATUS_FAILED,
1180 **                  NFCSTATUS_RESPONSE_TIMEOUT in case of timeout.
1181 **
1182 *******************************************************************************/
1183 static NFCSTATUS phNxpNciHal_readLocked(nci_test_data_t *pData )
1184 {
1185     NFCSTATUS status = NFCSTATUS_SUCCESS;
1186     phNxpNciHal_Sem_t cb_data;
1187     uint16_t read_len = 16;
1188     /* RX Buffer */
1189     uint32_t rx_data[NCI_MAX_DATA_LEN];
1190 
1191     /* Create the local semaphore */
1192     if (phNxpNciHal_init_cb_data(&cb_data, pData) != NFCSTATUS_SUCCESS)
1193     {
1194         NXPLOG_NCIHAL_D("phTmlNfc_Read Create cb data failed");
1195         status = NFCSTATUS_FAILED;
1196         goto clean_and_return;
1197     }
1198 
1199     /* call read pending */
1200     status = phTmlNfc_Read(
1201             (uint8_t *) rx_data,
1202             (uint16_t) read_len,
1203             (pphTmlNfc_TransactCompletionCb_t) &hal_read_cb,
1204             &cb_data);
1205 
1206     if (status != NFCSTATUS_PENDING)
1207     {
1208         NXPLOG_NCIHAL_E("TML Read status error status = %x", status);
1209         status = NFCSTATUS_FAILED;
1210         goto clean_and_return;
1211     }
1212 
1213     status = phOsalNfc_Timer_Start(timeoutTimerId,
1214             HAL_WRITE_RSP_TIMEOUT,
1215             &hal_write_rsp_timeout_cb,
1216             &cb_data);
1217 
1218     if (NFCSTATUS_SUCCESS == status)
1219     {
1220         NXPLOG_NCIHAL_D("Response timer started");
1221     }
1222     else
1223     {
1224         NXPLOG_NCIHAL_E("Response timer not started");
1225         status = NFCSTATUS_FAILED;
1226         goto clean_and_return;
1227     }
1228 
1229     /* Wait for callback response */
1230     if (SEM_WAIT(cb_data))
1231     {
1232         NXPLOG_NCIHAL_E("phTmlNfc_Read semaphore error");
1233         status = NFCSTATUS_FAILED;
1234         goto clean_and_return;
1235     }
1236 
1237     if(cb_data.status == NFCSTATUS_RESPONSE_TIMEOUT)
1238     {
1239         NXPLOG_NCIHAL_E("Response timeout!!!");
1240         status = NFCSTATUS_RESPONSE_TIMEOUT;
1241         goto clean_and_return;
1242 
1243     }
1244 
1245     if (cb_data.status != NFCSTATUS_SUCCESS)
1246     {
1247         NXPLOG_NCIHAL_E("phTmlNfc_Read failed  ");
1248         status = NFCSTATUS_FAILED;
1249         goto clean_and_return;
1250     }
1251 
1252     clean_and_return:
1253     phNxpNciHal_cleanup_cb_data(&cb_data);
1254 
1255     return status;
1256 }
1257 
1258 /*******************************************************************************
1259 **
1260 ** Function         phNxpNciHal_writeLocked
1261 **
1262 ** Description      Send command to NFCC and waits for cmd write completion, for
1263 **                  a definitive timeout value.
1264 **
1265 ** Returns          NFCSTATUS_SUCCESS if successful,otherwise NFCSTATUS_FAILED,
1266 **                  NFCSTATUS_RESPONSE_TIMEOUT in case of timeout.
1267 **
1268 *******************************************************************************/
1269 static NFCSTATUS phNxpNciHal_writeLocked(nci_test_data_t *pData )
1270 {
1271     NFCSTATUS status = NFCSTATUS_SUCCESS;
1272 
1273     phNxpNciHal_Sem_t cb_data;
1274     int retryCnt = 0;
1275 
1276     /* Create the local semaphore */
1277     if (phNxpNciHal_init_cb_data(&cb_data, NULL) != NFCSTATUS_SUCCESS)
1278     {
1279         NXPLOG_NCIHAL_D("phTmlNfc_Write Create cb data failed");
1280         goto clean_and_return;
1281     }
1282 
1283 retry:
1284     status = phTmlNfc_Write(pData->cmd.p_data, pData->cmd.len,
1285             (pphTmlNfc_TransactCompletionCb_t) &hal_write_cb, &cb_data);
1286 
1287     if (status != NFCSTATUS_PENDING)
1288     {
1289         NXPLOG_NCIHAL_E("phTmlNfc_Write status error");
1290         goto clean_and_return;
1291     }
1292 
1293     /* Wait for callback response */
1294     if (SEM_WAIT(cb_data))
1295     {
1296         NXPLOG_NCIHAL_E("write_unlocked semaphore error");
1297         status = NFCSTATUS_FAILED;
1298         goto clean_and_return;
1299     }
1300 
1301     if (cb_data.status != NFCSTATUS_SUCCESS && retryCnt < HAL_WRITE_MAX_RETRY)
1302     {
1303         retryCnt++;
1304         NXPLOG_NCIHAL_E("write_unlocked failed - PN54X Maybe in Standby Mode - Retry %d",retryCnt);
1305         goto retry;
1306     }
1307 
1308     status = cb_data.status;
1309 
1310 clean_and_return:
1311     phNxpNciHal_cleanup_cb_data(&cb_data);
1312 
1313     return status;
1314 }
1315 
1316 /*******************************************************************************
1317 **
1318 ** Function         phNxpNciHal_performTest
1319 **
1320 ** Description      Performs a single cycle of command,response and
1321 **                  notification.
1322 **
1323 ** Returns          NFCSTATUS_SUCCESS if successful,otherwise NFCSTATUS_FAILED,
1324 **
1325 *******************************************************************************/
1326 NFCSTATUS phNxpNciHal_performTest(nci_test_data_t *pData )
1327 {
1328     NFCSTATUS status = NFCSTATUS_SUCCESS;
1329 
1330     if(NULL == pData)
1331     {
1332         return NFCSTATUS_FAILED;
1333     }
1334 
1335     CONCURRENCY_LOCK();
1336 
1337     status = phNxpNciHal_writeLocked(pData);
1338 
1339     if(status == NFCSTATUS_RESPONSE_TIMEOUT)
1340     {
1341         goto clean_and_return;
1342     }
1343     if(status != NFCSTATUS_SUCCESS)
1344     {
1345         goto clean_and_return;
1346     }
1347 
1348     status = phNxpNciHal_readLocked(pData);
1349 
1350     if(status != NFCSTATUS_SUCCESS)
1351     {
1352         goto clean_and_return;
1353     }
1354 
1355     if(0 != pData->exp_ntf.len)
1356     {
1357         status = phNxpNciHal_readLocked(pData);
1358 
1359         if(status != NFCSTATUS_SUCCESS)
1360         {
1361             goto clean_and_return;
1362         }
1363     }
1364 
1365 clean_and_return:
1366     CONCURRENCY_UNLOCK();
1367     return status;
1368 }
1369 
1370 /*******************************************************************************
1371  **
1372  ** Function         phNxpNciHal_TestMode_open
1373  **
1374  ** Description      It opens the physical connection with NFCC (PN54X) and
1375  **                  creates required client thread for operation.
1376  **
1377  ** Returns          NFCSTATUS_SUCCESS if successful,otherwise NFCSTATUS_FAILED.
1378  **
1379  *******************************************************************************/
1380 NFCSTATUS phNxpNciHal_TestMode_open (void)
1381 {
1382     /* Thread */
1383     pthread_t test_rx_thread;
1384 
1385     phOsalNfc_Config_t tOsalConfig;
1386     phTmlNfc_Config_t tTmlConfig;
1387     NFCSTATUS status = NFCSTATUS_SUCCESS;
1388     uint16_t read_len = 255;
1389 
1390     /* initialize trace level */
1391     phNxpLog_InitializeLogLevel();
1392 
1393     if (phNxpNciHal_init_monitor() == NULL)
1394     {
1395         NXPLOG_NCIHAL_E("Init monitor failed");
1396         return NFCSTATUS_FAILED;
1397     }
1398 
1399     CONCURRENCY_LOCK();
1400 
1401     memset(&tOsalConfig, 0x00, sizeof(tOsalConfig));
1402     memset(&tTmlConfig, 0x00, sizeof(tTmlConfig));
1403 
1404     gDrvCfg.nClientId = phDal4Nfc_msgget(0, 0600);
1405     gDrvCfg.nLinkType = ENUM_LINK_TYPE_I2C;/* For PN54X */
1406     tTmlConfig.pDevName = (int8_t *) "/dev/pn54x";
1407     tOsalConfig.dwCallbackThreadId = (uintptr_t) gDrvCfg.nClientId;
1408     tOsalConfig.pLogFile = NULL;
1409     tTmlConfig.dwGetMsgThreadId = (uintptr_t) gDrvCfg.nClientId;
1410     nxpncihal_ctrl.gDrvCfg.nClientId = (uintptr_t) gDrvCfg.nClientId;
1411 
1412     /* Initialize TML layer */
1413     status = phTmlNfc_Init(&tTmlConfig);
1414     if (status != NFCSTATUS_SUCCESS)
1415     {
1416         NXPLOG_NCIHAL_E("phTmlNfc_Init Failed");
1417         goto clean_and_return;
1418     }
1419 
1420     pthread_attr_t attr;
1421     pthread_attr_init(&attr);
1422     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
1423     if (pthread_create(&test_rx_thread, &attr,
1424             phNxpNciHal_test_rx_thread, NULL) != 0)
1425     {
1426         NXPLOG_NCIHAL_E("pthread_create failed");
1427         phTmlNfc_Shutdown();
1428         goto clean_and_return;
1429     }
1430 
1431     timeoutTimerId = phOsalNfc_Timer_Create();
1432 
1433     if(timeoutTimerId == 0xFFFF)
1434     {
1435         NXPLOG_NCIHAL_E("phOsalNfc_Timer_Create failed");
1436     }
1437     else
1438     {
1439         NXPLOG_NCIHAL_D("phOsalNfc_Timer_Create SUCCESS");
1440     }
1441     CONCURRENCY_UNLOCK();
1442 
1443     return NFCSTATUS_SUCCESS;
1444 
1445 clean_and_return:
1446     CONCURRENCY_UNLOCK();
1447     phNxpNciHal_cleanup_monitor();
1448     return NFCSTATUS_FAILED;
1449 }
1450 
1451 /*******************************************************************************
1452  **
1453  ** Function         phNxpNciHal_TestMode_close
1454  **
1455  ** Description      This function close the NFCC interface and free all
1456  **                  resources.
1457  **
1458  ** Returns          None.
1459  **
1460  *******************************************************************************/
1461 
1462 void phNxpNciHal_TestMode_close ()
1463 {
1464 
1465     NFCSTATUS status = NFCSTATUS_SUCCESS;
1466 
1467     CONCURRENCY_LOCK();
1468 
1469     if (NULL != gpphTmlNfc_Context->pDevHandle)
1470     {
1471         /* Abort any pending read and write */
1472         status = phTmlNfc_ReadAbort();
1473         status = phTmlNfc_WriteAbort();
1474 
1475         phOsalNfc_Timer_Cleanup();
1476 
1477         status = phTmlNfc_Shutdown();
1478 
1479         NXPLOG_NCIHAL_D("phNxpNciHal_close return status = %d", status);
1480 
1481         thread_running = 0;
1482 
1483         phDal4Nfc_msgrelease(gDrvCfg.nClientId);
1484 
1485         status = phOsalNfc_Timer_Delete(timeoutTimerId);
1486     }
1487 
1488     CONCURRENCY_UNLOCK();
1489 
1490     phNxpNciHal_cleanup_monitor();
1491 
1492     /* Return success always */
1493     return;
1494 }
1495 
1496 /*******************************************************************************
1497  **
1498  ** Function         phNxpNciHal_SwpTest
1499  **
1500  ** Description      Test function to validate the SWP line. SWP line number is
1501  **                  is sent as parameter to the API.
1502  **
1503  ** Returns          NFCSTATUS_SUCCESS if successful,otherwise NFCSTATUS_FAILED.
1504  **
1505  *******************************************************************************/
1506 
1507 NFCSTATUS phNxpNciHal_SwpTest(uint8_t swp_line)
1508 {
1509     NFCSTATUS status = NFCSTATUS_SUCCESS;
1510     int len = 0;
1511     int cnt = 0;
1512 
1513     NXPLOG_NCIHAL_D("phNxpNciHal_SwpTest - start\n");
1514 
1515     if(swp_line == 0x01)
1516     {
1517         len = (sizeof(swp1_test_data)/sizeof(swp1_test_data[0]));
1518 
1519         for(cnt = 0; cnt < len; cnt++)
1520         {
1521             status = phNxpNciHal_performTest(&(swp1_test_data[cnt]));
1522             if(status == NFCSTATUS_RESPONSE_TIMEOUT ||
1523                     status == NFCSTATUS_FAILED
1524             )
1525             {
1526                 break;
1527             }
1528         }
1529     }
1530     else if(swp_line == 0x02)
1531     {
1532         len = (sizeof(swp2_test_data)/sizeof(swp2_test_data[0]));
1533 
1534         for(cnt = 0; cnt < len; cnt++)
1535         {
1536             status = phNxpNciHal_performTest(&(swp2_test_data[cnt]));
1537             if(status == NFCSTATUS_RESPONSE_TIMEOUT ||
1538                     status == NFCSTATUS_FAILED
1539             )
1540             {
1541                 break;
1542             }
1543         }
1544     }
1545     else
1546     {
1547         status = NFCSTATUS_FAILED;
1548     }
1549 
1550     if( status == NFCSTATUS_SUCCESS)
1551     {
1552         NXPLOG_NCIHAL_D("phNxpNciHal_SwpTest - SUCCESSS\n");
1553     }
1554     else
1555     {
1556         NXPLOG_NCIHAL_D("phNxpNciHal_SwpTest - FAILED\n");
1557     }
1558 
1559     NXPLOG_NCIHAL_D("phNxpNciHal_SwpTest - end\n");
1560 
1561     return status;
1562 }
1563 
1564 /*******************************************************************************
1565  **
1566  ** Function         phNxpNciHal_PrbsTestStart
1567  **
1568  ** Description      Test function start RF generation for RF technology and bit
1569  **                  rate. RF technology and bit rate are sent as parameter to
1570  **                  the API.
1571  **
1572  ** Returns          NFCSTATUS_SUCCESS if RF generation successful,
1573  **                  otherwise NFCSTATUS_FAILED.
1574  **
1575  *******************************************************************************/
1576 
1577 #if(NFC_NXP_CHIP_TYPE != PN547C2)
1578 NFCSTATUS phNxpNciHal_PrbsTestStart (phNxpNfc_PrbsType_t prbs_type, phNxpNfc_PrbsHwType_t hw_prbs_type,
1579         phNxpNfc_Tech_t tech, phNxpNfc_Bitrate_t bitrate)
1580 #else
1581 NFCSTATUS phNxpNciHal_PrbsTestStart (phNxpNfc_Tech_t tech, phNxpNfc_Bitrate_t bitrate)
1582 #endif
1583 {
1584     NFCSTATUS status = NFCSTATUS_FAILED;
1585 
1586     nci_test_data_t prbs_cmd_data;
1587 
1588 #if(NFC_NXP_CHIP_TYPE != PN547C2)
1589     uint8_t rsp_cmd_info[] = {0x4F, 0x30, 0x01, 0x00};
1590     prbs_cmd_data.cmd.len = 0x09;
1591 #else
1592     uint8_t rsp_cmd_info[] = {0x4F, 0x30, 0x01, 0x00};
1593     prbs_cmd_data.cmd.len = 0x07;
1594 #endif
1595 
1596     memcpy(prbs_cmd_data.exp_rsp.p_data, &rsp_cmd_info[0], sizeof(rsp_cmd_info));
1597     prbs_cmd_data.exp_rsp.len = sizeof(rsp_cmd_info);
1598 
1599     //prbs_cmd_data.exp_rsp.len = 0x00;
1600     prbs_cmd_data.exp_ntf.len = 0x00;
1601     prbs_cmd_data.rsp_validator = st_validator_testEquals;
1602     prbs_cmd_data.ntf_validator = st_validator_null;
1603 
1604     uint8_t len = 0;
1605     uint8_t cnt = 0;
1606 
1607 //    [NCI] -> [0x2F 0x30 0x04 0x00 0x00 0x01 0xFF]
1608 
1609 #if(NFC_NXP_CHIP_TYPE != PN547C2)
1610     status = phNxpNciHal_getPrbsCmd(prbs_type, hw_prbs_type, tech, bitrate,
1611             prbs_cmd_data.cmd.p_data,prbs_cmd_data.cmd.len);
1612 #else
1613     status = phNxpNciHal_getPrbsCmd(tech, bitrate,prbs_cmd_data.cmd.p_data,prbs_cmd_data.cmd.len);
1614 #endif
1615 
1616     if( status == NFCSTATUS_FAILED)
1617     {
1618         //Invalid Param.
1619         NXPLOG_NCIHAL_D("phNxpNciHal_PrbsTestStart - INVALID_PARAM\n");
1620 
1621         goto clean_and_return;
1622     }
1623 
1624     len = (sizeof(prbs_test_data)/sizeof(prbs_test_data[0]));
1625 
1626     for(cnt = 0; cnt < len; cnt++)
1627     {
1628         status = phNxpNciHal_performTest(&(prbs_test_data[cnt]));
1629         if(status == NFCSTATUS_RESPONSE_TIMEOUT ||
1630                 status == NFCSTATUS_FAILED
1631         )
1632         {
1633             break;
1634         }
1635     }
1636 
1637     /* Ignoring status, as there will be no response - Applicable till FW version 8.1.1*/
1638     status = phNxpNciHal_performTest(&prbs_cmd_data);
1639     clean_and_return:
1640 
1641     if( status == NFCSTATUS_SUCCESS)
1642     {
1643         NXPLOG_NCIHAL_D("phNxpNciHal_PrbsTestStart - SUCCESSS\n");
1644     }
1645     else
1646     {
1647         NXPLOG_NCIHAL_D("phNxpNciHal_PrbsTestStart - FAILED\n");
1648     }
1649 
1650     NXPLOG_NCIHAL_D("phNxpNciHal_PrbsTestStart - end\n");
1651 
1652     return status;
1653 }
1654 
1655 /*******************************************************************************
1656  **
1657  ** Function         phNxpNciHal_PrbsTestStop
1658  **
1659  ** Description      Test function stop RF generation for RF technology started
1660  **                  by phNxpNciHal_PrbsTestStart.
1661  **
1662  ** Returns          NFCSTATUS_SUCCESS if operation successful,
1663  **                  otherwise NFCSTATUS_FAILED.
1664  **
1665  *******************************************************************************/
1666 
1667 NFCSTATUS phNxpNciHal_PrbsTestStop ()
1668 {
1669     NXPLOG_NCIHAL_D("phNxpNciHal_PrbsTestStop - Start\n");
1670 
1671     NFCSTATUS status = NFCSTATUS_SUCCESS;
1672 
1673     status = phTmlNfc_IoCtl(phTmlNfc_e_ResetDevice);
1674 
1675     if(NFCSTATUS_SUCCESS == status)
1676     {
1677         NXPLOG_NCIHAL_D("phNxpNciHal_PrbsTestStop - SUCCESS\n");
1678     }
1679     else
1680     {
1681         NXPLOG_NCIHAL_D("phNxpNciHal_PrbsTestStop - FAILED\n");
1682 
1683     }
1684     NXPLOG_NCIHAL_D("phNxpNciHal_PrbsTestStop - end\n");
1685 
1686     return status;
1687 }
1688 
1689 /*******************************************************************************
1690 **
1691 ** Function         phNxpNciHal_getPrbsCmd
1692 **
1693 ** Description      Test function frames the PRBS command.
1694 **
1695 ** Returns          NFCSTATUS_SUCCESS if successful,otherwise NFCSTATUS_FAILED.
1696 **
1697 *******************************************************************************/
1698 #if(NFC_NXP_CHIP_TYPE != PN547C2)
1699 NFCSTATUS phNxpNciHal_getPrbsCmd (phNxpNfc_PrbsType_t prbs_type, phNxpNfc_PrbsHwType_t hw_prbs_type,
1700         uint8_t tech, uint8_t bitrate, uint8_t *prbs_cmd, uint8_t prbs_cmd_len)
1701 #else
1702 NFCSTATUS phNxpNciHal_getPrbsCmd (uint8_t tech, uint8_t bitrate, uint8_t *prbs_cmd, uint8_t prbs_cmd_len)
1703 #endif
1704 {
1705     NFCSTATUS status = NFCSTATUS_SUCCESS;
1706     int position_tech_param = 0;
1707     int position_bit_param = 0;
1708 
1709     NXPLOG_NCIHAL_D("phNxpNciHal_getPrbsCmd - tech 0x%x bitrate = 0x%x", tech, bitrate);
1710     if(NULL == prbs_cmd ||
1711 #if(NFC_NXP_CHIP_TYPE != PN547C2)
1712             prbs_cmd_len != 0x09)
1713 #else
1714             prbs_cmd_len != 0x07)
1715 #endif
1716     {
1717         return status;
1718     }
1719 
1720     prbs_cmd[0] = 0x2F;
1721     prbs_cmd[1] = 0x30;
1722 #if(NFC_NXP_CHIP_TYPE != PN547C2)
1723     prbs_cmd[2] = 0x06;
1724     prbs_cmd[3] = (uint8_t)prbs_type;
1725     //0xFF Error value used for validation.
1726     prbs_cmd[4] = (uint8_t)hw_prbs_type;
1727     prbs_cmd[5] = 0xFF;//TECH
1728     prbs_cmd[6] = 0xFF;//BITRATE
1729     prbs_cmd[7] = 0x01;
1730     prbs_cmd[8] = 0xFF;
1731     position_tech_param = 5;
1732     position_bit_param = 6;
1733 #else
1734     prbs_cmd[2] = 0x04;
1735     //0xFF Error value used for validation.
1736     prbs_cmd[3] = 0xFF;//TECH
1737     //0xFF Error value used for validation.
1738     prbs_cmd[4] = 0xFF;//BITRATE
1739     prbs_cmd[5] = 0x01;
1740     prbs_cmd[6] = 0xFF;
1741     position_tech_param = 3;
1742     position_bit_param = 4;
1743 #endif
1744 
1745     switch (tech) {
1746         case NFC_RF_TECHNOLOGY_A:
1747             NXPLOG_NCIHAL_D("phNxpNciHal_getPrbsCmd - NFC_RF_TECHNOLOGY_A");
1748             prbs_cmd[position_tech_param] = 0x00;
1749             break;
1750         case NFC_RF_TECHNOLOGY_B:
1751             NXPLOG_NCIHAL_D("phNxpNciHal_getPrbsCmd - NFC_RF_TECHNOLOGY_B");
1752             prbs_cmd[position_tech_param] = 0x01;
1753             break;
1754         case NFC_RF_TECHNOLOGY_F:
1755             NXPLOG_NCIHAL_D("phNxpNciHal_getPrbsCmd - NFC_RF_TECHNOLOGY_F");
1756             prbs_cmd[position_tech_param] = 0x02;
1757             break;
1758         default:
1759             break;
1760     }
1761 
1762     switch (bitrate)
1763     {
1764         case NFC_BIT_RATE_106:
1765             NXPLOG_NCIHAL_D("phNxpNciHal_getPrbsCmd - NFC_BIT_RATE_106");
1766             if(prbs_cmd[position_tech_param] != 0x02)
1767             {
1768                 prbs_cmd[position_bit_param] = 0x00;
1769             }
1770             break;
1771         case NFC_BIT_RATE_212:
1772             NXPLOG_NCIHAL_D("phNxpNciHal_getPrbsCmd - NFC_BIT_RATE_212");
1773             prbs_cmd[position_bit_param] = 0x01;
1774             break;
1775         case NFC_BIT_RATE_424:
1776             NXPLOG_NCIHAL_D("phNxpNciHal_getPrbsCmd - NFC_BIT_RATE_424");
1777             prbs_cmd[position_bit_param] = 0x02;
1778             break;
1779         case NFC_BIT_RATE_848:
1780             NXPLOG_NCIHAL_D("phNxpNciHal_getPrbsCmd - NFC_BIT_RATE_848");
1781             if(prbs_cmd[position_tech_param] != 0x02)
1782             {
1783                 prbs_cmd[position_bit_param] = 0x03;
1784             }
1785             break;
1786         default:
1787             break;
1788     }
1789 
1790     if(prbs_cmd[position_tech_param] == 0xFF || prbs_cmd[position_bit_param] == 0xFF)
1791     {
1792         //Invalid Param.
1793         status = NFCSTATUS_FAILED;
1794     }
1795 
1796     return status;
1797 }
1798 
1799 /*******************************************************************************
1800 **
1801 ** Function         phNxpNciHal_RfFieldTest
1802 **
1803 ** Description      Test function performs RF filed test.
1804 **
1805 ** Returns          NFCSTATUS_SUCCESS if successful,otherwise NFCSTATUS_FAILED.
1806 **
1807 *******************************************************************************/
1808 NFCSTATUS phNxpNciHal_RfFieldTest (uint8_t on)
1809 {
1810     NFCSTATUS status = NFCSTATUS_SUCCESS;
1811     int len = 0;
1812     int cnt = 0;
1813 
1814     NXPLOG_NCIHAL_D("phNxpNciHal_RfFieldTest - start %x\n",on);
1815 
1816     if(on == 0x01)
1817     {
1818         len = (sizeof(rf_field_on_test_data)/sizeof(rf_field_on_test_data[0]));
1819 
1820         for(cnt = 0; cnt < len; cnt++)
1821         {
1822             status = phNxpNciHal_performTest(&(rf_field_on_test_data[cnt]));
1823             if(status == NFCSTATUS_RESPONSE_TIMEOUT || status == NFCSTATUS_FAILED)
1824             {
1825                 break;
1826             }
1827         }
1828     }
1829     else if(on == 0x00)
1830     {
1831         len = (sizeof(rf_field_off_test_data)/sizeof(rf_field_off_test_data[0]));
1832 
1833         for(cnt = 0; cnt < len; cnt++)
1834         {
1835             status = phNxpNciHal_performTest(&(rf_field_off_test_data[cnt]));
1836             if(status == NFCSTATUS_RESPONSE_TIMEOUT || status == NFCSTATUS_FAILED)
1837             {
1838                 break;
1839             }
1840         }
1841     }
1842     else
1843     {
1844         status = NFCSTATUS_FAILED;
1845     }
1846 
1847     if( status == NFCSTATUS_SUCCESS)
1848     {
1849         NXPLOG_NCIHAL_D("phNxpNciHal_RfFieldTest - SUCCESSS\n");
1850     }
1851     else
1852     {
1853         NXPLOG_NCIHAL_D("phNxpNciHal_RfFieldTest - FAILED\n");
1854     }
1855 
1856     NXPLOG_NCIHAL_D("phNxpNciHal_RfFieldTest - end\n");
1857 
1858     return status;
1859 }
1860 
1861 /*******************************************************************************
1862  **
1863  ** Function         phNxpNciHal_AntennaTest
1864  **
1865  ** Description
1866  **
1867  ** Returns
1868  **
1869  *******************************************************************************/
1870 NFCSTATUS phNxpNciHal_AntennaTest ()
1871 {
1872     NFCSTATUS status = NFCSTATUS_FAILED;
1873 
1874     return status;
1875 }
1876 
1877 /*******************************************************************************
1878 **
1879 ** Function         phNxpNciHal_DownloadPinTest
1880 **
1881 ** Description      Test function to validate the FW download pin connection.
1882 **
1883 ** Returns          NFCSTATUS_SUCCESS if successful,otherwise NFCSTATUS_FAILED.
1884 **
1885 *******************************************************************************/
1886 NFCSTATUS phNxpNciHal_DownloadPinTest(void)
1887 {
1888     NFCSTATUS status = NFCSTATUS_FAILED;
1889     int len = 0;
1890     int cnt = 0;
1891 
1892     NXPLOG_NCIHAL_D("phNxpNciHal_DownloadPinTest - start\n");
1893 
1894     len = (sizeof(download_pin_test_data1)/sizeof(download_pin_test_data1[0]));
1895 
1896     for(cnt = 0; cnt < len; cnt++)
1897     {
1898         status = phNxpNciHal_performTest(&(download_pin_test_data1[cnt]));
1899         if(status == NFCSTATUS_RESPONSE_TIMEOUT || status == NFCSTATUS_FAILED)
1900         {
1901             break;
1902         }
1903     }
1904 
1905     if (status != NFCSTATUS_SUCCESS)
1906     {
1907         NXPLOG_NCIHAL_D("phNxpNciHal_DownloadPinTest - FAILED\n");
1908         return status;
1909     }
1910 
1911     status = NFCSTATUS_FAILED;
1912     status = phTmlNfc_IoCtl(phTmlNfc_e_EnableDownloadMode);
1913     if (NFCSTATUS_SUCCESS != status)
1914     {
1915         NXPLOG_NCIHAL_D("phNxpNciHal_DownloadPinTest - FAILED\n");
1916         return status;
1917     }
1918 
1919     status = NFCSTATUS_FAILED;
1920     len = (sizeof(download_pin_test_data2)/sizeof(download_pin_test_data2[0]));
1921 
1922      for(cnt = 0; cnt < len; cnt++)
1923      {
1924          status = phNxpNciHal_performTest(&(download_pin_test_data2[cnt]));
1925          if(status == NFCSTATUS_RESPONSE_TIMEOUT || status == NFCSTATUS_FAILED)
1926          {
1927              break;
1928          }
1929      }
1930 
1931     if( status == NFCSTATUS_SUCCESS)
1932     {
1933         NXPLOG_NCIHAL_D("phNxpNciHal_DownloadPinTest - SUCCESSS\n");
1934     }
1935     else
1936     {
1937         NXPLOG_NCIHAL_D("phNxpNciHal_DownloadPinTest - FAILED\n");
1938     }
1939 
1940     NXPLOG_NCIHAL_D("phNxpNciHal_DownloadPinTest - end\n");
1941 
1942     return status;
1943 }
1944 /*******************************************************************************
1945 **
1946 ** Function         phNxpNciHal_AntennaSelfTest
1947 **
1948 ** Description      Test function to validate the Antenna's discrete
1949 **                  components connection.
1950 **
1951 ** Returns          NFCSTATUS_SUCCESS if successful,otherwise NFCSTATUS_FAILED.
1952 **
1953 *******************************************************************************/
1954 NFCSTATUS phNxpNciHal_AntennaSelfTest(phAntenna_St_Resp_t * phAntenna_St_Resp )
1955 {
1956     NFCSTATUS status = NFCSTATUS_FAILED;
1957     NFCSTATUS antenna_st_status = NFCSTATUS_FAILED;
1958     int len = 0;
1959     int cnt = 0;
1960 
1961     NXPLOG_NCIHAL_D("phNxpNciHal_AntennaSelfTest - start\n");
1962     memcpy(&phAntenna_resp, phAntenna_St_Resp, sizeof(phAntenna_St_Resp_t));
1963     len = (sizeof(antenna_self_test_data)/sizeof(antenna_self_test_data[0]));
1964 
1965     for(cnt = 0; cnt < len; cnt++)
1966     {
1967         status = phNxpNciHal_performTest(&(antenna_self_test_data[cnt]));
1968         if(status == NFCSTATUS_RESPONSE_TIMEOUT || status == NFCSTATUS_FAILED)
1969         {
1970             NXPLOG_NCIHAL_E("phNxpNciHal_AntennaSelfTest: commnad execution - FAILED\n");
1971             break;
1972         }
1973     }
1974 
1975     if(status == NFCSTATUS_SUCCESS)
1976     {
1977         if((gtxldo_status == NFCSTATUS_SUCCESS) && (gagc_value_status == NFCSTATUS_SUCCESS) &&
1978            (gagc_nfcld_status == NFCSTATUS_SUCCESS) && (gagc_differential_status == NFCSTATUS_SUCCESS))
1979         {
1980             antenna_st_status = NFCSTATUS_SUCCESS;
1981             NXPLOG_NCIHAL_D("phNxpNciHal_AntennaSelfTest - SUCESS\n");
1982         }
1983         else
1984         {
1985             NXPLOG_NCIHAL_D("phNxpNciHal_AntennaSelfTest - FAILED\n");
1986         }
1987     }
1988     else
1989     {
1990         NXPLOG_NCIHAL_D("phNxpNciHal_AntennaSelfTest - FAILED\n");
1991     }
1992 
1993     NXPLOG_NCIHAL_D("phNxpNciHal_AntennaSelfTest - end\n");
1994 
1995     return antenna_st_status;
1996 }
1997 
1998 #endif /*#ifdef NXP_HW_SELF_TEST*/
1999