2 * Copyright (C) 2010 NXP Semiconductors
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * =========================================================================== *
22 * \file phHciNfc_Sequence.c *
23 * \brief State Machine Implementation for the HCI Management and *
24 * and the Function Sequence for a particular State *
27 * Project: NFC-FRI-1.1 *
29 * $Date: Tue Jun 8 09:33:46 2010 $ *
30 * $Author: ing04880 $ *
32 * $Aliases: NFC_FRI1.1_WK1023_R35_1 $
34 * =========================================================================== *
38 ################################################################################
39 ***************************** Header File Inclusion ****************************
40 ################################################################################
43 #include <phNfcCompId.h>
44 #include <phNfcConfig.h>
46 #include <phHciNfc_Sequence.h>
47 #include <phHciNfc_AdminMgmt.h>
48 #include <phHciNfc_IDMgmt.h>
49 #include <phHciNfc_LinkMgmt.h>
50 #include <phHciNfc_DevMgmt.h>
51 #include <phHciNfc_PollingLoop.h>
52 #include <phHciNfc_RFReader.h>
53 #include <phHciNfc_RFReaderA.h>
54 #include <phHciNfc_Emulation.h>
56 #include <phHciNfc_NfcIPMgmt.h>
58 #include <phHciNfc_SWP.h>
59 #include <phHciNfc_WI.h>
60 #include <phOsalNfc.h>
63 ################################################################################
64 ****************************** Macro Definitions *******************************
65 ################################################################################
68 /* Address Definitions for HAL Configuration */
69 #define NFC_ADDRESS_HAL_CONF 0x9FD0U
73 ################################################################################
74 ********************** Structure/Enumeration Definitions ***********************
75 ################################################################################
81 typedef struct phHciNfc_sFsm
83 phHciNfc_eState_t from_state;
84 phHciNfc_eState_t to_state;
88 static phHciNfc_sFsm_t phHciNfc_Valid_Fsm[] = {
89 {hciState_Reset, hciState_Initialise , TRUE},
90 /* {hciState_Reset, hciState_Config, FALSE}, */
91 {hciState_Initialise, hciState_Config, TRUE},
92 {hciState_Initialise, hciState_Release, TRUE},
93 {hciState_Config, hciState_Connect, TRUE},
94 {hciState_Config, hciState_Release, TRUE},
95 {hciState_Connect, hciState_Activate, TRUE},
96 {hciState_Connect, hciState_Transact, TRUE},
97 {hciState_Connect, hciState_Disconnect, TRUE},
98 {hciState_Disconnect, hciState_Config, TRUE},
99 /* {hciState_Disconnect, hciState_Release, TRUE}, */
100 {hciState_Reset, hciState_Initialise, TRUE},
107 ################################################################################
108 ************************* Function Prototype Declaration ***********************
109 ################################################################################
115 phHciNfc_Config_Sequence(
116 phHciNfc_sContext_t *psHciContext,
122 * \ingroup grp_hci_nfc
124 * The phHciNfc_Connect_Sequence function sequence selects the
125 * discovered target for performing the transaction.
127 * \param[in] psHciContext psHciContext is the context of
129 * \param[in] pHwRef pHwRef is the Information of
130 * the Device Interface Link .
132 * \retval NFCSTATUS_SUCCESS HCI target selection sequence successful.
133 * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters
134 * could not be interpreted properly.
135 * \retval Other errors Other related errors
141 phHciNfc_Transact_Sequence(
142 phHciNfc_sContext_t *psHciContext,
147 * \ingroup grp_hci_nfc
149 * The phHciNfc_Info_Sequence function sequence selects the
150 * discovered target for performing the transaction.
152 * \param[in] psHciContext psHciContext is the context of
154 * \param[in] pHwRef pHwRef is the Information of
155 * the Device Interface Link .
157 * \retval NFCSTATUS_SUCCESS HCI target selection sequence successful.
158 * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters
159 * could not be interpreted properly.
160 * \retval Other errors Other related errors
166 phHciNfc_Info_Sequence(
167 phHciNfc_sContext_t *psHciContext,
173 phHciNfc_Test_Sequence(
174 phHciNfc_sContext_t *psHciContext,
176 NFCSTATUS test_status,
186 phHciNfc_sContext_t *psHciContext
193 phHciNfc_IO_Sequence(
194 phHciNfc_sContext_t *psHciContext,
196 NFCSTATUS test_status,
203 phHciNfc_Pending_Sequence(
204 phHciNfc_sContext_t *psHciContext,
210 ################################################################################
211 ***************************** Function Definitions *****************************
212 ################################################################################
216 phHciNfc_FSM_Validate(
217 phHciNfc_sContext_t *psHciContext,
218 phHciNfc_eState_t state,
219 uint8_t validate_type
222 NFCSTATUS status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_STATE);
223 phHciNfc_eState_t cur_state = (phHciNfc_eState_t)
224 psHciContext->hci_state.cur_state;
226 switch(validate_type)
228 case NFC_FSM_CURRENT:
230 if( cur_state == (uint8_t) state )
232 status = NFCSTATUS_SUCCESS;
238 phHciNfc_eState_t next_state = state;
245 /* Specifies the Starting of the init Sequence */
246 case hciState_Initialise:
247 /* Initialise to Perform Test on
248 the Antenna/SWP Link */
251 status = NFCSTATUS_SUCCESS;
259 case hciState_Initialise:
263 /* Discovery Resume after connect failure */
264 case hciState_Initialise:
265 /* Configuring the Discovery/Emulation */
266 case hciState_Config:
267 /* Configuring the Memory */
269 /* Occurence of the Tag Discovered Event */
270 case hciState_Select:
271 /* Occurence of the Target Activated Event */
272 case hciState_Listen:
273 /* Specifies the Starting of the Release Sequence */
274 case hciState_Release:
276 status = NFCSTATUS_SUCCESS;
286 if ((hciState_Test == next_state )
287 || (hciState_IO == next_state)
288 || (hciState_Release == next_state))
290 /* Next Test/Reset Sequence */
291 status = NFCSTATUS_SUCCESS;
295 case hciState_Select:
299 /* Restart the Wheel */
300 case hciState_Initialise:
301 /* Select the next Tag in the Field or
302 * already Selected Tag Again
304 /* Configuring the Memory */
306 case hciState_Select:
307 /* Configuring the Discovery/Emulation */
308 case hciState_Config:
309 /* Re-Activate the Target or
310 * Discover the next target
312 case hciState_Reactivate:
313 /* Connect the Discovered Target */
314 case hciState_Connect:
315 /* Specifies the Starting of the Release Sequence */
316 case hciState_Release:
318 status = NFCSTATUS_SUCCESS;
326 case hciState_Connect:
330 /* Disabling the Tag Discovery */
331 case hciState_Initialise:
332 /* Configuring the Discovery/Emulation */
333 /* This should not be allowed if the target
336 /* Configuring the Memory */
338 case hciState_Config:
339 /* Re-Activate the Target or
340 * Discover the next target
342 case hciState_Reactivate:
343 /* Intermediate Transceive State */
344 case hciState_Transact:
345 /* Intermediate Presence Check State */
346 case hciState_Presence:
347 /* Disconnect the Target Connected */
348 case hciState_Disconnect:
349 /* Specifies the Starting of the Release Sequence */
350 case hciState_Release:
352 status = NFCSTATUS_SUCCESS;
360 case hciState_Listen:
364 /* Releasing from the Emulation/Target Mode */
365 case hciState_Initialise:
366 /* Occurence of the Tag Discovered Event
367 * after the Disconnect Operation
369 case hciState_Select:
370 /* Configuring the Memory */
372 /* Configuring the Discovery/Emulation */
373 case hciState_Config:
374 /* Intermediate Transceive State */
375 case hciState_Transact:
376 /* Specifies the Starting of the Release Sequence */
377 case hciState_Release:
379 status = NFCSTATUS_SUCCESS;
387 case hciState_Reactivate:
391 /* Restart/Discovery after the Target is removed
392 * after Reactivation.
394 /* case hciState_Initialise: */
395 /* Re-Connect the Re-Activated Target */
396 case hciState_Connect:
397 /* Configuring the Memory */
399 /* Configuring the Discovery/Emulation */
400 case hciState_Config:
401 /* Specifies the Starting of the Release Sequence */
402 case hciState_Release:
404 status = NFCSTATUS_SUCCESS;
412 case hciState_Disconnect:
416 /* Discovery Resume after connect failure
417 after the disconnect */
418 case hciState_Initialise:
419 /* Configuring the Memory */
421 /* Configuring the Discovery/Emulation */
422 case hciState_Config:
423 /* Occurence of the Tag Discovered Event
424 * after the Disconnect Operation
426 case hciState_Select:
427 /* Occurence of the Target Activated Event */
428 case hciState_Listen:
429 /* Specifies the Starting of the Release Sequence */
430 case hciState_Release:
432 status = NFCSTATUS_SUCCESS;
443 case hciState_Presence:
444 case hciState_Transact:
445 case hciState_Release:
450 /* case phHciNfc_Unknown: */
453 /* status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_STATE); */
456 } /* End of State Validation Switch */
457 if( NFC_FSM_IN_PROGRESS == psHciContext->hci_state.transition )
459 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_STATE);
465 HCI_DEBUG("State Validate Type:%x is Unknown/Incorrect \n",
475 phHciNfc_sContext_t *psHciContext,
476 phHciNfc_eState_t next_state
479 NFCSTATUS status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_STATE);
481 HCI_DEBUG(" HCI: Current State --> %02u \n",
482 psHciContext->hci_state.cur_state );
483 HCI_DEBUG(" HCI: Transition Before FSM Update --> %02u \n",
484 psHciContext->hci_state.transition );
485 HCI_DEBUG(" HCI: Next State Before FSM Update --> %02u \n",
486 psHciContext->hci_state.next_state );
488 status = phHciNfc_FSM_Validate(psHciContext, next_state, NFC_FSM_NEXT );
489 if(NFCSTATUS_SUCCESS == status)
491 psHciContext->hci_state.next_state = (uint8_t) next_state;
492 psHciContext->hci_state.transition = NFC_FSM_IN_PROGRESS;
493 psHciContext->response_pending = FALSE;
494 HCI_DEBUG(" HCI: Next State After FSM Update --> %02u \n",
495 psHciContext->hci_state.next_state );
499 HCI_DEBUG(" HCI: FSM - Invalid next state --> %02u \n",
508 phHciNfc_FSM_Complete(
509 phHciNfc_sContext_t *psHciContext
512 NFCSTATUS status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_STATE);
514 HCI_DEBUG("HCI: In Function: %s \n", __FUNCTION__);
516 HCI_DEBUG(" HCI: Transition Before FSM Complete --> %02u \n",
517 psHciContext->hci_state.transition );
519 HCI_DEBUG(" HCI: Current State Before FSM Complete --> %02u \n",
520 psHciContext->hci_state.cur_state );
522 HCI_DEBUG(" HCI: Next State Before FSM Complete --> %02u \n",
523 psHciContext->hci_state.next_state );
525 if( (NFC_FSM_IN_PROGRESS == psHciContext->hci_state.transition)
528 psHciContext->hci_state.cur_state =
529 psHciContext->hci_state.next_state ;
530 psHciContext->hci_state.transition = NFC_FSM_COMPLETE ;
531 psHciContext->hci_state.next_state = (uint8_t) hciState_Unknown ;
532 /* Reset the HCI Sequence */
533 psHciContext->response_pending = FALSE;
534 psHciContext->hci_seq = HCI_INVALID_SEQ;
535 status = NFCSTATUS_SUCCESS;
538 HCI_DEBUG(" HCI: Current State After FSM Complete --> %02u \n",
539 psHciContext->hci_state.cur_state );
545 phHciNfc_FSM_Rollback(
546 phHciNfc_sContext_t *psHciContext
550 HCI_DEBUG("HCI: %s: transition=%02u, cur_state=%02u, next_state=%02u\n",
552 psHciContext->hci_state.transition,
553 psHciContext->hci_state.cur_state,
554 psHciContext->hci_state.next_state);
561 if( (NFC_FSM_IN_PROGRESS == psHciContext->hci_state.transition)
564 psHciContext->hci_state.transition = NFC_FSM_COMPLETE ;
565 psHciContext->hci_state.next_state = (uint8_t) hciState_Unknown ;
566 /* Reset the HCI Sequence */
567 psHciContext->hci_seq = HCI_INVALID_SEQ;
568 psHciContext->response_pending = FALSE;
576 phHciNfc_sContext_t *psHciContext
580 if( (hciState_Reset != psHciContext->hci_state.cur_state )
583 psHciContext->hci_state.cur_state = (uint8_t) hciState_Initialise ;
584 psHciContext->hci_state.transition = NFC_FSM_COMPLETE ;
585 psHciContext->hci_state.next_state = (uint8_t) hciState_Unknown ;
586 /* Reset the HCI Sequence */
587 psHciContext->hci_seq = HCI_INVALID_SEQ;
597 phHciNfc_Pending_Sequence(
598 phHciNfc_sContext_t *psHciContext,
602 NFCSTATUS status = NFCSTATUS_SUCCESS;
604 PHNFC_UNUSED_VARIABLE(status);
606 HCI_DEBUG("HCI: psHciContext->target_release --> %s \n",
607 (psHciContext->target_release)?"TRUE":"FALSE");
608 if(TRUE == psHciContext->target_release)
610 #ifdef SW_RELEASE_TARGET
611 status = phHciNfc_ReaderMgmt_Deselect(
612 psHciContext, pHwRef, phHal_eISO14443_A_PICC, TRUE);
613 if(NFCSTATUS_PENDING == status )
615 psHciContext->target_release = FALSE ;
620 status = psHciContext->error_status;
622 psHciContext->target_release = FALSE ;
631 phHciNfc_Error_Sequence(
634 NFCSTATUS error_status,
639 NFCSTATUS status = NFCSTATUS_SUCCESS;
640 phHciNfc_sContext_t *psHciContext = (phHciNfc_sContext_t *)psContext;
642 PHNFC_UNUSED_VARIABLE(status);
644 HCI_DEBUG("HCI: In Function: %s \n",
647 HCI_DEBUG ("HCI : Error Status : %04X\n", error_status);
649 HCI_DEBUG(" HCI: Current HCI State --> %02u \n",
650 psHciContext->hci_state.cur_state );
651 HCI_DEBUG(" HCI: Next HCI State --> %02u \n",
652 psHciContext->hci_state.next_state );
655 if ( NFC_FSM_IN_PROGRESS == psHciContext->hci_state.transition )
657 switch(psHciContext->hci_state.next_state)
659 case hciState_Initialise:
661 if (hciState_Reset == psHciContext->hci_state.cur_state)
663 phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
665 phHciNfc_Release_Lower( psHciContext, pHwRef );
666 /* Release all the resources and
667 * Notify the Receive Error Scenario to the Upper Layer
669 comp_info.status = error_status ;
670 phHciNfc_Release_Notify (psHciContext, pHwRef,
671 NFC_NOTIFY_INIT_FAILED, &comp_info);
673 else if (hciState_Config == psHciContext->hci_state.cur_state)
675 /* Notify the Poll/Emulation Configure failure to the upper layer */
677 phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
679 comp_info.status = error_status ;
681 psHciContext->error_status = error_status;
682 status = phHciNfc_Pending_Sequence(psHciContext, pHwRef );
683 /* Rollback the FSM as the Poll/Emulation configuration Failed */
684 phHciNfc_FSM_Rollback(psHciContext);
685 psHciContext->error_status = NFCSTATUS_SUCCESS;
686 phHciNfc_Notify(psHciContext->p_upper_notify,
687 psHciContext->p_upper_context, pHwRef,
688 NFC_NOTIFY_CONFIG_ERROR, &comp_info);
693 /* Notify the Poll Configure failure to the upper layer */
694 phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
697 psHciContext->error_status = error_status;
698 status = phHciNfc_Pending_Sequence(psHciContext, pHwRef );
699 /* Rollback the FSM as the Poll Disable Failed */
700 phHciNfc_FSM_Rollback(psHciContext);
701 comp_info.status = error_status ;
702 psHciContext->error_status = NFCSTATUS_SUCCESS;
703 phHciNfc_Notify(psHciContext->p_upper_notify,
704 psHciContext->p_upper_context, pHwRef,
705 NFC_NOTIFY_ERROR, &comp_info);
711 status = phHciNfc_Test_Sequence( psHciContext, pHwRef , error_status,
712 (uint8_t *)pdata, length );
717 status = phHciNfc_IO_Sequence( psHciContext, pHwRef , error_status,
718 (uint8_t *)pdata, length );
721 case hciState_Config:
723 /* Notify the Configure failure to the upper layer */
724 phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
726 psHciContext->error_status = error_status;
727 status = phHciNfc_Pending_Sequence(psHciContext, pHwRef );
728 /* Rollback the FSM as the Poll Failed */
729 phHciNfc_FSM_Rollback(psHciContext);
730 comp_info.status = psHciContext->error_status ;
731 psHciContext->error_status = NFCSTATUS_SUCCESS;
732 phHciNfc_Notify(psHciContext->p_upper_notify,
733 psHciContext->p_upper_context, pHwRef,
734 NFC_NOTIFY_CONFIG_ERROR, &comp_info);
737 case hciState_Select:
739 /* Notify the Configure failure to the upper layer */
740 phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
742 /* Rollback the FSM as the Target Discovery Failed */
743 phHciNfc_FSM_Rollback(psHciContext);
744 status = phHciNfc_ReaderMgmt_Update_Sequence(
745 psHciContext, INFO_SEQ );
746 comp_info.status = error_status ;
747 phHciNfc_Notify(psHciContext->p_upper_notify,
748 psHciContext->p_upper_context, pHwRef,
749 NFC_NOTIFY_DISCOVERY_ERROR, &comp_info);
752 /* Polling Wheel will be restarted by the upper layer
753 * to Rediscover again */
754 if(NFCSTATUS_SUCCESS == status)
756 status = phHciNfc_ReaderMgmt_Deselect(
757 psHciContext, pHwRef, phHal_eISO14443_A_PICC, FALSE);
759 phHciNfc_FSM_Rollback(psHciContext);
763 case hciState_Transact:
764 /* Notify the Transceive failure to the upper layer */
766 phNfc_sTransactionInfo_t transact_info={FALSE,0,NULL,NULL,0};
768 /* Rollback the FSM as the Transceive Failed */
769 phHciNfc_FSM_Rollback(psHciContext);
770 transact_info.status = error_status;
771 transact_info.buffer = NULL;
772 transact_info.length = FALSE;
773 psHciContext->p_xchg_info = NULL ;
774 phHciNfc_Notify(psHciContext->p_upper_notify,
775 psHciContext->p_upper_context, pHwRef,
776 NFC_NOTIFY_TRANSCEIVE_ERROR, &transact_info);
780 case hciState_Connect:
782 /* Notify the General failure to the upper layer */
783 phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
785 /* psHciContext->host_rf_type = phHal_eUnknown_DevType; */
786 status = phHciNfc_ReaderMgmt_Update_Sequence(
787 psHciContext, INFO_SEQ );
788 psHciContext->p_target_info = NULL;
789 psHciContext->hci_state.cur_state = hciState_Select;
790 phHciNfc_FSM_Rollback(psHciContext);
791 comp_info.status = error_status ;
792 phHciNfc_Notify(psHciContext->p_upper_notify,
793 psHciContext->p_upper_context, pHwRef,
794 NFC_NOTIFY_CONNECT_FAILED, &comp_info);
797 case hciState_Reactivate:
799 /* Notify the General failure to the upper layer */
800 phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
802 /* psHciContext->host_rf_type = phHal_eUnknown_DevType;
803 status = phHciNfc_ReaderMgmt_Update_Sequence(
804 psHciContext, INFO_SEQ );
805 psHciContext->p_target_info = NULL;
806 psHciContext->hci_state.cur_state = hciState_Select; */
807 phHciNfc_FSM_Rollback(psHciContext);
808 comp_info.status = error_status ;
809 phHciNfc_Notify(psHciContext->p_upper_notify,
810 psHciContext->p_upper_context, pHwRef,
811 NFC_NOTIFY_CONNECT_FAILED, &comp_info);
814 case hciState_Presence:
816 phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
818 /* Roll Back to Connect State as Presence Check is Complete */
819 phHciNfc_FSM_Rollback(psHciContext);
821 /* Initialisation Complete Notification to the Upper Layer */
822 comp_info.status = error_status;
823 phHciNfc_Notify(psHciContext->p_upper_notify,
824 psHciContext->p_upper_context, pHwRef,
825 NFC_NOTIFY_ERROR, &comp_info);
826 HCI_PRINT(" HCI Remote Target Removed from the Field. \n");
829 /* Notify the Connect or Disconnect failure to the upper layer */
830 case hciState_Disconnect:
832 /* Notify the General failure to the upper layer */
833 phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
835 phHciNfc_FSM_Rollback(psHciContext);
836 comp_info.status = error_status ;
837 phHciNfc_Notify(psHciContext->p_upper_notify,
838 psHciContext->p_upper_context, pHwRef,
839 NFC_NOTIFY_DISCONNECT_FAILED, &comp_info);
842 case hciState_Release:
844 #ifdef NXP_HCI_SHUTDOWN_OVERRIDE
845 status = phHciNfc_Release_Sequence(psHciContext ,pHwRef);
847 phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
849 phHciNfc_Release_Lower( psHciContext, pHwRef );
850 /* Release all the resources and
851 * Notify the Receive Error Scenario to the Upper Layer
853 comp_info.status = error_status ;
854 phHciNfc_Release_Notify (psHciContext, pHwRef,
855 NFC_NOTIFY_DEINIT_FAILED, &comp_info);
861 /* Notify the General failure to the upper layer */
862 phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
864 phHciNfc_FSM_Rollback(psHciContext);
865 comp_info.status = error_status ;
866 psHciContext->error_status = error_status;
867 status = phHciNfc_Pending_Sequence(psHciContext, pHwRef );
868 if (NFCSTATUS_PENDING != status)
870 psHciContext->error_status = NFCSTATUS_SUCCESS;
871 phHciNfc_Notify(psHciContext->p_upper_notify,
872 psHciContext->p_upper_context, pHwRef,
873 NFC_NOTIFY_ERROR, &comp_info);
878 } /* End of the Processing of HCI State*/
882 /* Notify the General failure to the upper layer */
883 phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
884 phHciNfc_FSM_Rollback(psHciContext);
885 comp_info.status = error_status ;
886 /* Disable the Notification to the Upper Layer */
887 if(NFCSTATUS_BOARD_COMMUNICATION_ERROR
888 == PHNFCSTATUS(error_status))
890 phHciNfc_Notify(psHciContext->p_upper_notify,
891 psHciContext->p_upper_context, pHwRef,
892 NFC_NOTIFY_ERROR, &comp_info);
896 psHciContext->error_status = error_status;
897 status = phHciNfc_Pending_Sequence(psHciContext, pHwRef );
898 if (NFCSTATUS_PENDING != status)
900 psHciContext->error_status = NFCSTATUS_SUCCESS;
910 phHciNfc_Resume_Sequence(
911 phHciNfc_sContext_t *psHciContext,
915 NFCSTATUS status = NFCSTATUS_SUCCESS;
917 HCI_DEBUG("HCI: %s: cur_state=%02u, next_state=%02u",
919 psHciContext->hci_state.cur_state,
920 psHciContext->hci_state.next_state);
925 switch(psHciContext->hci_state.next_state)
927 /* Process the Admin Gate Response based on the HCI State */
928 case hciState_Initialise:
930 switch (psHciContext->hci_state.cur_state)
932 /* Initialise State after Power on */
935 status = phHciNfc_Initialise_Sequence(psHciContext ,pHwRef);
938 /* Initialise State after Power on */
939 case hciState_Config:
941 status = phHciNfc_Config_Sequence(psHciContext ,pHwRef);
944 /* Discovery Resume after connect failure */
945 case hciState_Initialise:
946 case hciState_Select:
947 case hciState_Connect:
949 phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
951 /* Update to the Intialise state as the discovery wheel is
954 status = phHciNfc_FSM_Complete(psHciContext);
956 psHciContext->host_rf_type = phHal_eUnknown_DevType;
957 psHciContext->p_target_info = NULL;
958 psHciContext->p_xchg_info = NULL;
960 /* Initialisation Complete Notification to the Upper Layer */
961 comp_info.status = status;
962 phHciNfc_Notify(psHciContext->p_upper_notify,
963 psHciContext->p_upper_context, pHwRef,
964 NFC_NOTIFY_POLL_RESTARTED , &comp_info);
965 HCI_PRINT(" HCI Remote Target Still Present in the Field. \n");
970 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_STATE);
976 case hciState_Release:
978 status = phHciNfc_Release_Sequence(psHciContext ,pHwRef);
981 case hciState_Config:
983 status = phHciNfc_Config_Sequence(psHciContext ,pHwRef);
986 case hciState_Listen:
987 case hciState_Select:
989 status = phHciNfc_Info_Sequence( psHciContext, pHwRef );
992 case hciState_Reactivate:
993 case hciState_Connect:
995 status = phHciNfc_Connect_Sequence( psHciContext, pHwRef );
998 case hciState_Transact:
1000 status = phHciNfc_Transact_Sequence(
1001 psHciContext, pHwRef );
1004 case hciState_Presence:
1006 phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
1008 /* Roll Back to Connect State as Presence Check is Complete */
1009 phHciNfc_FSM_Rollback(psHciContext);
1011 /* Initialisation Complete Notification to the Upper Layer */
1012 comp_info.status = NFCSTATUS_SUCCESS;
1013 phHciNfc_Notify(psHciContext->p_upper_notify,
1014 psHciContext->p_upper_context, pHwRef,
1015 NFC_NOTIFY_TARGET_PRESENT , &comp_info);
1016 HCI_PRINT(" HCI Remote Target Still Present in the Field. \n");
1019 case hciState_Disconnect:
1021 status = phHciNfc_Disconnect_Sequence( psHciContext, pHwRef );
1026 status = phHciNfc_Test_Sequence( psHciContext, pHwRef , status, NULL, 0 );
1031 status = phHciNfc_IO_Sequence( psHciContext, pHwRef , status, NULL, 0 );
1034 case hciState_Unknown:
1040 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_STATE);
1043 } /* End of the Processing of HCI State*/
1050 phHciNfc_Initialise_Sequence(
1051 phHciNfc_sContext_t *psHciContext,
1055 NFCSTATUS status = NFCSTATUS_SUCCESS;
1056 static uint8_t config = 0;
1058 PHNFC_UNUSED_VARIABLE(config);
1060 switch(psHciContext->hci_seq)
1062 case ADMIN_INIT_SEQ:
1064 status = phHciNfc_Admin_Initialise( psHciContext,pHwRef );
1065 if(NFCSTATUS_SUCCESS == status)
1067 #ifdef ESTABLISH_SESSION
1068 if( hciMode_Session == psHciContext->hci_mode)
1070 /* TODO: Initialise Link Management
1072 NFCSTATUS info_status = NFCSTATUS_SUCCESS;
1073 PHNFC_UNUSED_VARIABLE(info_status);
1074 info_status = phHciNfc_IDMgmt_Update_Sequence(
1075 psHciContext, INFO_SEQ );
1077 if(NFCSTATUS_SUCCESS == info_status)
1079 psHciContext->hci_seq = PL_STOP_SEQ;
1083 psHciContext->hci_seq = HCI_END_SEQ;
1084 status = PHNFCSTVAL(CID_NFC_HCI,
1085 NFCSTATUS_INVALID_HCI_SEQUENCE);
1091 psHciContext->hci_seq = LINK_MGMT_INIT_SEQ;
1096 case LINK_MGMT_INIT_SEQ:
1098 status = phHciNfc_LinkMgmt_Initialise( psHciContext,pHwRef );
1099 if(NFCSTATUS_SUCCESS == status)
1101 psHciContext->hci_seq = IDENTITY_INIT_SEQ;
1105 case IDENTITY_INIT_SEQ:
1107 status = phHciNfc_IDMgmt_Initialise( psHciContext,pHwRef );
1108 if(NFCSTATUS_SUCCESS == status)
1110 psHciContext->hci_seq = DEV_INIT_SEQ;
1116 status = phHciNfc_DevMgmt_Initialise( psHciContext,pHwRef );
1117 if(NFCSTATUS_SUCCESS == status)
1119 if (HCI_SELF_TEST != psHciContext->init_mode)
1121 psHciContext->hci_seq = PL_INIT_SEQ;
1125 #if defined( ESTABLISH_SESSION )
1126 NFCSTATUS info_status = NFCSTATUS_SUCCESS;
1127 PHNFC_UNUSED_VARIABLE(info_status);
1128 info_status = phHciNfc_IDMgmt_Update_Sequence(
1129 psHciContext, INFO_SEQ );
1131 if(NFCSTATUS_SUCCESS == info_status)
1133 #if ( NXP_HAL_MEM_INFO_SIZE > 0x00U )
1134 psHciContext->hci_seq = DEV_HAL_INFO_SEQ;
1136 psHciContext->hci_seq = IDENTITY_INFO_SEQ;
1137 #endif /* #if ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) */
1141 psHciContext->hci_seq = HCI_END_SEQ;
1142 status = PHNFCSTVAL(CID_NFC_HCI,
1143 NFCSTATUS_INVALID_HCI_SEQUENCE);
1145 #elif ( NXP_HAL_MEM_INFO_SIZE > 0x00U )
1146 psHciContext->hci_seq = DEV_HAL_INFO_SEQ;
1148 psHciContext->hci_seq = HCI_END_SEQ;
1149 #endif /* #ifdef ESTABLISH_SESSION */
1157 status = phHciNfc_PollLoop_Initialise( psHciContext,pHwRef );
1158 if(NFCSTATUS_SUCCESS == status)
1160 NFCSTATUS reset_status = NFCSTATUS_SUCCESS;
1161 PHNFC_UNUSED_VARIABLE(reset_status);
1162 reset_status = phHciNfc_ReaderMgmt_Update_Sequence(
1163 psHciContext, RESET_SEQ );
1164 psHciContext->hci_seq = READER_MGMT_INIT_SEQ;
1168 case READER_MGMT_INIT_SEQ:
1170 status = phHciNfc_ReaderMgmt_Initialise( psHciContext,pHwRef );
1171 if(NFCSTATUS_SUCCESS == status)
1173 NFCSTATUS reset_status = NFCSTATUS_SUCCESS;
1174 PHNFC_UNUSED_VARIABLE(reset_status);
1175 reset_status = phHciNfc_EmuMgmt_Update_Seq(
1176 psHciContext, RESET_SEQ );
1177 psHciContext->hci_seq = EMULATION_INIT_SEQ;
1181 case EMULATION_INIT_SEQ:
1183 status = phHciNfc_EmuMgmt_Initialise( psHciContext,pHwRef );
1184 if(NFCSTATUS_SUCCESS == status)
1186 #if defined( ESTABLISH_SESSION )
1187 psHciContext->hci_seq = ADMIN_SESSION_SEQ;
1188 #elif ( NXP_HAL_MEM_INFO_SIZE > 0x00U )
1189 psHciContext->hci_seq = DEV_HAL_INFO_SEQ;
1191 psHciContext->hci_seq = HCI_END_SEQ;
1196 #ifdef ESTABLISH_SESSION
1197 case ADMIN_SESSION_SEQ:
1199 status = phHciNfc_Admin_Initialise( psHciContext,pHwRef );
1200 if(NFCSTATUS_SUCCESS == status)
1202 #if ( NXP_HAL_MEM_INFO_SIZE > 0x00U )
1203 psHciContext->hci_seq = DEV_HAL_INFO_SEQ;
1205 psHciContext->hci_seq = IDENTITY_INFO_SEQ;
1206 #endif /* #if ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) */
1212 status = phHciNfc_ReaderMgmt_Disable_Discovery(
1213 psHciContext, pHwRef );
1214 if(NFCSTATUS_SUCCESS == status)
1216 #if defined( SW_AUTO_ACTIVATION )
1217 psHciContext->hci_seq = READER_SW_AUTO_SEQ;
1218 #elif ( NXP_HAL_MEM_INFO_SIZE > 0x00U )
1219 psHciContext->hci_seq = DEV_HAL_INFO_SEQ;
1221 psHciContext->hci_seq = IDENTITY_INFO_SEQ;
1222 #endif /* #if ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) */
1226 #ifdef SW_AUTO_ACTIVATION
1227 case READER_SW_AUTO_SEQ:
1229 uint8_t activate_enable = FALSE;
1230 uint8_t rdr_enable = TRUE;
1232 status = phHciNfc_ReaderA_Update_Info(
1233 psHciContext, HCI_READER_A_ENABLE,
1235 if(status == NFCSTATUS_SUCCESS)
1237 status = phHciNfc_ReaderA_Auto_Activate( psHciContext,
1238 pHwRef, activate_enable );
1239 if(status == NFCSTATUS_SUCCESS)
1241 psHciContext->hci_seq = IDENTITY_INFO_SEQ;
1248 case IDENTITY_INFO_SEQ:
1250 status = phHciNfc_IDMgmt_Info_Sequence( psHciContext,pHwRef );
1251 if(NFCSTATUS_SUCCESS == status)
1253 if ((HCI_SELF_TEST != psHciContext->init_mode)
1254 /* && ( TRUE == ((phHal_sHwReference_t *)pHwRef)->se_detect ) */
1255 && (HCI_CUSTOM_INIT != psHciContext->init_mode)
1256 && (HCI_NFC_DEVICE_TEST != psHciContext->init_mode))
1258 NFCSTATUS info_status = NFCSTATUS_SUCCESS;
1259 PHNFC_UNUSED_VARIABLE(info_status);
1260 info_status = phHciNfc_EmuMgmt_Update_Seq(
1261 psHciContext, INFO_SEQ );
1263 if(NFCSTATUS_SUCCESS == info_status)
1265 psHciContext->hci_seq = EMULATION_SWP_SEQ;
1270 psHciContext->hci_seq = HCI_END_SEQ;
1275 case EMULATION_SWP_SEQ:
1277 status = phHciNfc_EmuMgmt_Initialise( psHciContext,pHwRef );
1278 if(NFCSTATUS_SUCCESS == status)
1280 psHciContext->hci_seq = HCI_END_SEQ;
1284 #endif /* #ifdef ESTABLISH_SESSION */
1286 #if ( NXP_HAL_MEM_INFO_SIZE > 0x00U )
1287 case DEV_HAL_INFO_SEQ:
1289 static uint8_t mem_index = 0;
1290 status = phHciNfc_DevMgmt_Get_Info(psHciContext, pHwRef,
1291 (NFC_ADDRESS_HAL_CONF + mem_index),
1292 (psHciContext->hal_mem_info + mem_index));
1293 if(NFCSTATUS_PENDING == status)
1296 if (NXP_HAL_MEM_INFO_SIZE <= mem_index )
1298 NFCSTATUS info_status = NFCSTATUS_SUCCESS;
1299 PHNFC_UNUSED_VARIABLE(info_status);
1300 info_status = phHciNfc_IDMgmt_Update_Sequence(
1301 psHciContext, INFO_SEQ );
1303 psHciContext->hci_seq = IDENTITY_INFO_SEQ;
1304 /* psHciContext->hci_seq =
1305 (HCI_SELF_TEST != psHciContext->init_mode)?
1306 IDENTITY_INFO_SEQ : HCI_END_SEQ; */
1311 #endif /* #if ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) */
1314 phHal_sMemInfo_t *p_mem_info =
1315 (phHal_sMemInfo_t *) ( psHciContext->hal_mem_info );
1317 (HCI_SELF_TEST == psHciContext->init_mode )
1318 || (HCI_NFC_DEVICE_TEST == psHciContext->init_mode )
1321 psHciContext->hci_state.next_state
1322 = (uint8_t) hciState_Test;
1324 status = phHciNfc_FSM_Complete ( psHciContext );
1325 #ifdef UICC_CONNECTIVITY_PATCH
1326 phHciNfc_Uicc_Connectivity( psHciContext, pHwRef );
1327 #endif /* #ifdef UICC_CONNECTIVITY_PATCH */
1329 #if ( NXP_HAL_MEM_INFO_SIZE > 0x00U )
1330 if(NXP_FW_UPLOAD_SUCCESS != p_mem_info->fw_magic )
1332 status = PHNFCSTVAL( CID_NFC_HCI, NFCSTATUS_FAILED );
1334 #endif /* #if ( NXP_HAL_MEM_INFO_SIZE > 0x00U ) */
1336 /* Initialisation Complete Notification to the Upper Layer */
1337 if(NFCSTATUS_SUCCESS == status)
1339 phNfc_sCompletionInfo_t comp_info={FALSE,0, NULL};
1341 comp_info.status = status;
1342 phHciNfc_Notify(psHciContext->p_upper_notify,
1343 psHciContext->p_upper_context, pHwRef,
1344 NFC_NOTIFY_INIT_COMPLETED, &comp_info);
1345 HCI_PRINT("HCI Initialisation Completed \n");
1349 pphNfcIF_Notification_CB_t p_upper_notify = psHciContext->p_upper_notify;
1350 void *pcontext = psHciContext->p_upper_context;
1351 phNfc_sCompletionInfo_t comp_info;
1354 phHciNfc_Release_Lower( psHciContext, pHwRef );
1355 phHciNfc_Release_Resources( &psHciContext );
1356 /* Notify the Failure to the Upper Layer */
1357 comp_info.status = status;
1358 phHciNfc_Notify( p_upper_notify, pcontext, pHwRef,
1359 NFC_NOTIFY_INIT_FAILED, &comp_info);
1360 HCI_PRINT("HCI FSM Initialisation Error \n");
1373 phHciNfc_Release_Sequence(
1374 phHciNfc_sContext_t *psHciContext,
1378 NFCSTATUS status = NFCSTATUS_SUCCESS;
1380 switch(psHciContext->hci_seq)
1384 status = phHciNfc_ReaderMgmt_Disable_Discovery(
1385 psHciContext, pHwRef );
1386 if(NFCSTATUS_SUCCESS == status)
1388 (void)phHciNfc_EmuMgmt_Update_Seq(
1389 psHciContext, REL_SEQ );
1390 psHciContext->hci_seq = EMULATION_REL_SEQ;
1391 status = NFCSTATUS_PENDING;
1395 case EMULATION_REL_SEQ:
1397 status = phHciNfc_EmuMgmt_Release( psHciContext,pHwRef );
1398 if(NFCSTATUS_SUCCESS == status)
1400 (void)phHciNfc_DevMgmt_Update_Sequence(
1401 psHciContext, REL_SEQ );
1402 psHciContext->hci_seq = ADMIN_REL_SEQ;
1403 status = NFCSTATUS_PENDING;
1409 NFCSTATUS info_status = NFCSTATUS_SUCCESS;
1410 PHNFC_UNUSED_VARIABLE(info_status);
1411 info_status = phHciNfc_DevMgmt_Update_Sequence(
1412 psHciContext, REL_SEQ );
1413 status = phHciNfc_DevMgmt_Release( psHciContext, pHwRef );
1414 if(NFCSTATUS_SUCCESS == status)
1416 psHciContext->hci_seq = HCI_END_SEQ;
1417 status = NFCSTATUS_PENDING;
1421 case READER_MGMT_REL_SEQ:
1423 status = phHciNfc_ReaderMgmt_Release( psHciContext,pHwRef );
1424 if(NFCSTATUS_SUCCESS == status)
1426 psHciContext->hci_seq = PL_REL_SEQ;
1427 status = NFCSTATUS_PENDING;
1433 status = phHciNfc_PollLoop_Release( psHciContext,pHwRef );
1434 if(NFCSTATUS_SUCCESS == status)
1436 psHciContext->hci_seq = IDENTITY_REL_SEQ;
1437 status = NFCSTATUS_PENDING;
1441 case IDENTITY_REL_SEQ:
1443 status = phHciNfc_IDMgmt_Release( psHciContext,pHwRef );
1444 if(NFCSTATUS_SUCCESS == status)
1446 psHciContext->hci_seq = LINK_MGMT_REL_SEQ;
1447 status = NFCSTATUS_PENDING;
1451 case LINK_MGMT_REL_SEQ:
1453 status = phHciNfc_LinkMgmt_Release( psHciContext,pHwRef );
1454 if(NFCSTATUS_SUCCESS == status)
1456 psHciContext->hci_seq = ADMIN_REL_SEQ;
1457 status = NFCSTATUS_PENDING;
1463 /* Admin Management Release Sequence */
1464 status = phHciNfc_Admin_Release( psHciContext,pHwRef, phHciNfc_TerminalHostID );
1465 if(NFCSTATUS_SUCCESS == status)
1467 psHciContext->hci_seq = DEV_REL_SEQ;
1468 status = NFCSTATUS_PENDING;
1474 pphNfcIF_Notification_CB_t p_upper_notify =
1475 psHciContext->p_upper_notify;
1476 phNfc_sLowerIF_t *plower_if =
1477 &(psHciContext->lower_interface);
1479 psHciContext->p_upper_context;
1480 phNfc_sCompletionInfo_t comp_info;
1483 status = plower_if->release((void *)plower_if->pcontext,
1486 phHciNfc_Release_Resources( &psHciContext );
1487 /* De-Initialisation Complete Notification to the Upper Layer */
1488 comp_info.status = status;
1489 phHciNfc_Notify(p_upper_notify, pcontext, pHwRef,
1490 NFC_NOTIFY_DEINIT_COMPLETED, &comp_info);
1492 HCI_PRINT("HCI Release Completed \n");
1497 /* psHciContext->hci_seq = HCI_END_SEQ; */
1508 phHciNfc_Config_Sequence(
1509 phHciNfc_sContext_t *psHciContext,
1513 NFCSTATUS status = NFCSTATUS_SUCCESS;
1514 phNfc_sCompletionInfo_t comp_info = {FALSE,0,NULL};
1516 switch(psHciContext->config_type)
1520 status = phHciNfc_PollLoop_Sequence( psHciContext, pHwRef );
1525 status = phHciNfc_SmartMx_Mode_Sequence( psHciContext, pHwRef );
1529 case NFC_GENERAL_CFG:
1531 if(TARGET_GENERAL_SEQ == psHciContext->hci_seq)
1533 status = phHciNfc_NfcIP_SetATRInfo( psHciContext,
1534 pHwRef, NFCIP_TARGET,
1535 psHciContext->p_config_params);
1536 if( NFCSTATUS_PENDING != status )
1538 /* Roll Back the State Machine to its Original State */
1539 phHciNfc_FSM_Rollback ( psHciContext );
1543 psHciContext->hci_seq = HCI_END_SEQ;
1548 status = phHciNfc_Pending_Sequence(psHciContext, pHwRef );
1549 if (NFCSTATUS_PENDING != status)
1551 /* Roll Back to its Current State as Configuration is Complete */
1552 phHciNfc_FSM_Rollback(psHciContext);
1554 HCI_PRINT(" NFC-IP(P2P) Configuration Completed. \n");
1555 comp_info.status = status;
1556 psHciContext->error_status = NFCSTATUS_SUCCESS;
1557 phHciNfc_Notify(psHciContext->p_upper_notify,
1558 psHciContext->p_upper_context, pHwRef,
1559 NFC_NOTIFY_CONFIG_SUCCESS , &comp_info);
1565 case SWP_PROTECT_CFG:
1569 /* Roll Back to its Current State as Configuration is Complete */
1570 phHciNfc_FSM_Rollback(psHciContext);
1572 HCI_DEBUG(" %s Configuration Completed. \n",
1573 ((SMX_WI_CFG == psHciContext->config_type)?
1574 "SmartMX" : "SWP Event/Protection"));
1576 comp_info.status = status;
1577 phHciNfc_Notify(psHciContext->p_upper_notify,
1578 psHciContext->p_upper_context, pHwRef,
1579 NFC_NOTIFY_CONFIG_SUCCESS, &comp_info);
1582 case NFC_TARGET_CFG:
1584 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
1590 phHal_sEmulationCfg_t *p_emulation_cfg =
1591 (phHal_sEmulationCfg_t * )
1592 psHciContext->p_config_params;
1593 if (NULL != p_emulation_cfg)
1595 phHal_sUiccEmuCfg_t *uicc_config =
1596 &p_emulation_cfg->config.uiccEmuCfg;
1597 if( TRUE == uicc_config->enableUicc )
1599 status = phHciNfc_Uicc_Connect_Status(psHciContext,pHwRef);
1600 if( NFCSTATUS_PENDING == status )
1603 } /* Or Else Fall through to notify the above layer */
1612 status = phHciNfc_EmulationCfg_Sequence( psHciContext, pHwRef );
1617 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_SEQUENCE);
1627 phHciNfc_PollLoop_Sequence(
1628 phHciNfc_sContext_t *psHciContext,
1632 NFCSTATUS status = NFCSTATUS_SUCCESS;
1633 phHal_sADD_Cfg_t *p_poll_config = (phHal_sADD_Cfg_t * )
1634 psHciContext->p_config_params;
1635 if (NULL != p_poll_config)
1638 p_poll_config->NfcIP_Mode;
1639 switch(psHciContext->hci_seq)
1641 case PL_DURATION_SEQ:
1643 status = phHciNfc_PollLoop_Cfg( psHciContext, pHwRef,
1644 (uint8_t)PL_DURATION , NULL);
1645 if(NFCSTATUS_SUCCESS == status)
1647 #if defined (ENABLE_P2P) && defined (TARGET_SPEED)
1648 psHciContext->hci_seq = TARGET_SPEED_SEQ;
1649 #elif defined (ENABLE_P2P) && defined (INITIATOR_SPEED)
1650 psHciContext->hci_seq = INITIATOR_SPEED_SEQ;
1651 #elif defined (ENABLE_P2P) && defined (NFCIP_TGT_DISABLE_CFG)
1652 psHciContext->hci_seq = PL_TGT_DISABLE_SEQ;
1654 psHciContext->hci_seq = PL_CONFIG_PHASE_SEQ;
1657 status = NFCSTATUS_PENDING;
1661 #if defined (ENABLE_P2P) && defined (TARGET_SPEED)
1662 case TARGET_SPEED_SEQ:
1664 #define NFCIP_ACTIVE_SHIFT 0x03U
1665 #define NFCIP_PASSIVE_MASK 0x07U
1666 uint8_t mode = ( NXP_NFCIP_ACTIVE_DEFAULT << NFCIP_ACTIVE_SHIFT ) |
1667 ( DEFAULT_NFCIP_TARGET_MODE_SUPPORT & NFCIP_PASSIVE_MASK );
1669 phHciNfc_NfcIP_SetMode( psHciContext, pHwRef, NFCIP_TARGET,
1671 if(NFCSTATUS_PENDING == status)
1673 #if defined (INITIATOR_SPEED)
1674 psHciContext->hci_seq = INITIATOR_SPEED_SEQ;
1675 #elif defined (NFCIP_TGT_DISABLE_CFG)
1676 psHciContext->hci_seq = PL_TGT_DISABLE_SEQ;
1678 psHciContext->hci_seq = PL_CONFIG_PHASE_SEQ;
1680 status = NFCSTATUS_PENDING;
1685 #if defined (ENABLE_P2P) && defined (INITIATOR_SPEED)
1686 case INITIATOR_SPEED_SEQ:
1689 phHciNfc_NfcIP_SetMode( psHciContext, pHwRef, NFCIP_INITIATOR,
1690 (uint8_t) (speed & DEFAULT_NFCIP_INITIATOR_MODE_SUPPORT));
1691 if(NFCSTATUS_PENDING == status)
1693 #if defined (NFCIP_TGT_DISABLE_CFG)
1694 psHciContext->hci_seq = PL_TGT_DISABLE_SEQ;
1696 psHciContext->hci_seq = PL_CONFIG_PHASE_SEQ;
1698 status = NFCSTATUS_PENDING;
1703 #if defined (ENABLE_P2P) && defined (NFCIP_TGT_DISABLE_CFG)
1704 case PL_TGT_DISABLE_SEQ:
1706 /* Configure the Polling Loop Target Disable Parameter */
1707 status = phHciNfc_PollLoop_Cfg( psHciContext, pHwRef,
1708 (uint8_t)PL_DISABLE_TARGET, &p_poll_config->NfcIP_Tgt_Disable );
1709 if(NFCSTATUS_SUCCESS == status)
1711 psHciContext->hci_seq = PL_CONFIG_PHASE_SEQ;
1712 status = NFCSTATUS_PENDING;
1717 case PL_CONFIG_PHASE_SEQ:
1719 phHal_sPollDevInfo_t *p_poll_info =
1720 &(p_poll_config->PollDevInfo.PollCfgInfo);
1722 p_poll_info->EnableIso14443A =
1723 ( (p_poll_info->EnableIso14443A)
1724 || ( speed & (uint8_t)phHal_ePassive106 )
1726 p_poll_info->EnableFelica212 =
1727 ( (p_poll_info->EnableFelica212)
1728 || ( speed & (uint8_t)phHal_ePassive212 )
1730 p_poll_info->EnableFelica424 =
1731 ( (p_poll_info->EnableFelica424)
1732 || ( speed & (uint8_t)phHal_ePassive424 )
1734 /* Configure the Polling Loop Gate Parameters */
1735 status = phHciNfc_PollLoop_Cfg( psHciContext, pHwRef,
1736 (uint8_t)PL_RD_PHASES, NULL );
1737 if(NFCSTATUS_SUCCESS == status)
1739 if(((~(PL_RD_PHASES_DISABLE)) &
1740 p_poll_config->PollDevInfo.PollEnabled)!= 0)
1742 psHciContext->hci_seq = READER_ENABLE_SEQ;
1746 /* psHciContext->hci_seq = READER_DISABLE_SEQ; */
1747 psHciContext->hci_seq = HCI_END_SEQ;
1749 status = NFCSTATUS_PENDING;
1753 case READER_ENABLE_SEQ:
1756 phHciNfc_ReaderMgmt_Enable_Discovery(
1757 psHciContext, pHwRef );
1758 if(NFCSTATUS_SUCCESS == status)
1760 /* psHciContext->hci_seq = PL_CONFIG_PHASE_SEQ; */
1761 psHciContext->hci_seq = HCI_END_SEQ;
1762 status = NFCSTATUS_PENDING;
1766 case READER_DISABLE_SEQ:
1768 status = phHciNfc_ReaderMgmt_Disable_Discovery(
1769 psHciContext, pHwRef );
1771 if(NFCSTATUS_SUCCESS == status)
1773 if((~(PL_RD_PHASES_DISABLE) &
1774 p_poll_config->PollDevInfo.PollEnabled)!= 0)
1776 psHciContext->hci_seq = PL_DURATION_SEQ;
1780 #if defined (ENABLE_P2P) && defined (INITIATOR_SPEED)
1781 psHciContext->hci_seq = INITIATOR_SPEED_SEQ;
1782 #elif defined (ENABLE_P2P) && defined (NFCIP_TGT_DISABLE_CFG)
1783 psHciContext->hci_seq = PL_TGT_DISABLE_SEQ;
1785 psHciContext->hci_seq = PL_CONFIG_PHASE_SEQ;
1787 /* psHciContext->hci_seq = HCI_END_SEQ; */
1789 status = NFCSTATUS_PENDING;
1795 phNfc_sCompletionInfo_t comp_info;
1796 status = phHciNfc_Pending_Sequence(psHciContext, pHwRef );
1797 if (NFCSTATUS_PENDING != status)
1799 /* status = phHciNfc_FSM_Complete ( psHciContext );*/
1800 phHciNfc_FSM_Rollback ( psHciContext );
1801 /* Poll Configuration Notification to the Upper Layer */
1802 if((~(PL_RD_PHASES_DISABLE) &
1803 p_poll_config->PollDevInfo.PollEnabled)!= 0)
1805 comp_info.status = status;
1806 phHciNfc_Notify(psHciContext->p_upper_notify,
1807 psHciContext->p_upper_context, pHwRef,
1808 NFC_NOTIFY_POLL_ENABLED, &comp_info);
1812 comp_info.status = status;
1813 phHciNfc_Notify(psHciContext->p_upper_notify,
1814 psHciContext->p_upper_context, pHwRef,
1815 NFC_NOTIFY_POLL_DISABLED, &comp_info);
1817 HCI_PRINT("HCI Discovery Configuration Completed \n");
1823 /* psHciContext->hci_seq = HCI_END_SEQ; */
1826 }/* End of the Poll Sequence Switch */
1827 }/* End of the Poll Config info Check */
1834 phHciNfc_EmulationCfg_Sequence(
1835 phHciNfc_sContext_t *psHciContext,
1839 NFCSTATUS status = NFCSTATUS_SUCCESS;
1840 static phNfc_sCompletionInfo_t comp_info = {FALSE,0,NULL};
1841 #if defined(HOST_EMULATION)
1842 phHciNfc_GateID_t ce_gate = phHciNfc_UnknownGate;
1843 #endif /* #ifdef HOST_EMULATION */
1844 phHal_sEmulationCfg_t *p_emulation_cfg = (phHal_sEmulationCfg_t * )
1845 psHciContext->p_config_params;
1846 #ifdef UICC_SESSION_RESET
1847 uint8_t uicc_clear_pipes = FALSE;
1851 if (NULL != p_emulation_cfg)
1853 #if defined(HOST_EMULATION)
1854 if(NFC_HOST_CE_A_EMULATION == p_emulation_cfg->emuType)
1856 psHciContext->config_type = NFC_CE_A_CFG;
1857 if (NULL == psHciContext->p_ce_a_info)
1859 ce_gate = phHciNfc_CETypeAGate;
1862 else if (NFC_HOST_CE_B_EMULATION == p_emulation_cfg->emuType)
1864 psHciContext->config_type = NFC_CE_B_CFG;
1865 if (NULL == psHciContext->p_ce_b_info)
1867 ce_gate = phHciNfc_CETypeBGate;
1870 #ifdef UICC_SESSION_RESET
1871 else if ((NFC_UICC_EMULATION == p_emulation_cfg->emuType)
1872 &&(FALSE == p_emulation_cfg->config.uiccEmuCfg.enableUicc)
1875 uicc_clear_pipes = TRUE;
1882 #endif /* #ifdef HOST_EMULATION */
1884 switch(psHciContext->hci_seq)
1886 #if defined(HOST_EMULATION)
1889 if(phHciNfc_UnknownGate != ce_gate)
1891 status = phHciNfc_Admin_CE_Init(psHciContext, pHwRef, ce_gate);
1895 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_NOT_ALLOWED);
1898 if(NFCSTATUS_SUCCESS == status)
1900 psHciContext->hci_seq = EMULATION_CONFIG_SEQ;
1901 /* psHciContext->hci_seq = HCI_END_SEQ; */
1902 status = NFCSTATUS_PENDING;
1907 case EMULATION_CONFIG_SEQ:
1909 status = phHciNfc_Emulation_Cfg(psHciContext, pHwRef,
1910 psHciContext->config_type);
1911 if(NFCSTATUS_SUCCESS == status)
1913 /* psHciContext->hci_seq = PL_CONFIG_PHASE_SEQ; */
1914 #ifdef UICC_SESSION_RESET
1915 if(UICC_SWP_CFG == psHciContext->config_type)
1917 psHciContext->hci_seq = ADMIN_REL_SEQ;
1920 #endif /* UICC_SESSION_RESET */
1922 psHciContext->hci_seq = HCI_END_SEQ;
1924 status = NFCSTATUS_PENDING;
1928 #ifdef UICC_SESSION_RESET
1931 if (TRUE == uicc_clear_pipes)
1933 /* Admin Management UICC Release Sequence */
1934 status = phHciNfc_Admin_Release( psHciContext,pHwRef, phHciNfc_UICCHostID );
1935 if(NFCSTATUS_SUCCESS == status)
1937 psHciContext->hci_seq = HCI_END_SEQ;
1938 if (UICC_SWP_CFG == psHciContext->config_type)
1940 (void)phHciNfc_SWP_Update_Sequence(psHciContext,
1943 status = NFCSTATUS_PENDING;
1948 #endif /* UICC_SESSION_RESET */
1952 phHciNfc_FSM_Rollback(psHciContext);
1954 HCI_PRINT(" Emulation Configuration Completed. \n");
1956 comp_info.status = status;
1957 phHciNfc_Notify(psHciContext->p_upper_notify,
1958 psHciContext->p_upper_context, pHwRef,
1959 NFC_NOTIFY_CONFIG_SUCCESS, &comp_info);
1964 /* psHciContext->hci_seq = HCI_END_SEQ; */
1972 }/* End of the Emulation Config info Check */
1979 phHciNfc_SmartMx_Mode_Sequence(
1980 phHciNfc_sContext_t *psHciContext,
1984 NFCSTATUS status = NFCSTATUS_SUCCESS;
1985 phHal_sADD_Cfg_t *p_poll_config = (phHal_sADD_Cfg_t * )
1986 psHciContext->p_config_params;
1987 phNfc_sCompletionInfo_t comp_info = {FALSE,0,NULL};
1988 if (NULL != p_poll_config)
1990 switch(psHciContext->hci_seq)
1992 case READER_DISABLE_SEQ:
1994 status = phHciNfc_ReaderMgmt_Disable_Discovery(
1995 psHciContext, pHwRef );
1996 if(NFCSTATUS_SUCCESS == status)
1998 psHciContext->hci_seq = EMULATION_CONFIG_SEQ;
1999 /* psHciContext->hci_seq = HCI_END_SEQ; */
2000 status = NFCSTATUS_PENDING;
2004 case EMULATION_CONFIG_SEQ:
2006 status = phHciNfc_WI_Configure_Mode(
2007 psHciContext, pHwRef,psHciContext->smx_mode );
2008 if(NFCSTATUS_SUCCESS == status)
2010 psHciContext->hci_seq = PL_CONFIG_PHASE_SEQ;
2011 /* psHciContext->hci_seq = HCI_END_SEQ; */
2012 status = NFCSTATUS_PENDING;
2016 case PL_CONFIG_PHASE_SEQ:
2018 /* Configure the Polling Loop Gate Parameters */
2019 status = phHciNfc_PollLoop_Cfg( psHciContext, pHwRef,
2020 (uint8_t)PL_RD_PHASES, NULL );
2021 if(NFCSTATUS_SUCCESS == status)
2023 psHciContext->hci_seq = READER_ENABLE_SEQ;
2024 status = NFCSTATUS_PENDING;
2028 case READER_ENABLE_SEQ:
2031 phHciNfc_ReaderMgmt_Enable_Discovery(
2032 psHciContext, pHwRef );
2033 if(NFCSTATUS_SUCCESS == status)
2035 /* psHciContext->hci_seq = PL_CONFIG_PHASE_SEQ; */
2036 psHciContext->hci_seq = HCI_END_SEQ;
2037 status = NFCSTATUS_PENDING;
2043 status = phHciNfc_Pending_Sequence(psHciContext, pHwRef );
2044 if (NFCSTATUS_PENDING != status)
2046 /* status = phHciNfc_FSM_Complete ( psHciContext );*/
2047 phHciNfc_FSM_Rollback ( psHciContext );
2048 if( hciState_Disconnect == psHciContext->hci_state.cur_state)
2050 psHciContext->host_rf_type = phHal_eUnknown_DevType;
2051 psHciContext->p_target_info = NULL;
2052 psHciContext->p_xchg_info = NULL;
2054 /* Poll Configuration Notification to the Upper Layer */
2055 if((~(PL_RD_PHASES_DISABLE) &
2056 p_poll_config->PollDevInfo.PollEnabled)!= 0)
2058 comp_info.status = status;
2059 phHciNfc_Notify(psHciContext->p_upper_notify,
2060 psHciContext->p_upper_context, pHwRef,
2061 NFC_NOTIFY_POLL_ENABLED, &comp_info);
2065 comp_info.status = status;
2066 phHciNfc_Notify(psHciContext->p_upper_notify,
2067 psHciContext->p_upper_context, pHwRef,
2068 NFC_NOTIFY_POLL_DISABLED, &comp_info);
2070 HCI_PRINT("HCI Discovery Configuration Completed \n");
2076 /* psHciContext->hci_seq = HCI_END_SEQ; */
2079 }/* End of the Poll Sequence Switch */
2080 }/* End of the Poll Config info Check */
2087 phHciNfc_Connect_Sequence(
2088 phHciNfc_sContext_t *psHciContext,
2092 NFCSTATUS status = NFCSTATUS_SUCCESS;
2093 static phNfc_sCompletionInfo_t comp_info = {FALSE,0,NULL};
2094 phHal_eRemDevType_t target_type = phHal_eUnknown_DevType;
2096 if( NULL != psHciContext->p_target_info )
2099 target_type = psHciContext->p_target_info->RemDevType;
2100 switch(psHciContext->hci_seq)
2102 case READER_REACTIVATE_SEQ:
2104 /* Complete the Reactivate Sequence and notify the HAL */
2105 status = phHciNfc_FSM_Complete ( psHciContext );
2106 /* Reactivate Complete Notification to the Upper Layer */
2107 if(NFCSTATUS_SUCCESS == status)
2109 comp_info.status = status;
2110 phHciNfc_Notify(psHciContext->p_upper_notify,
2111 psHciContext->p_upper_context, pHwRef,
2112 NFC_NOTIFY_TARGET_REACTIVATED , &comp_info);
2113 HCI_PRINT(" HCI Remote Target Reactivated. \n");
2117 comp_info.status = status;
2118 phHciNfc_FSM_Rollback ( psHciContext );
2119 phHciNfc_Notify(psHciContext->p_upper_notify,
2120 psHciContext->p_upper_context, pHwRef,
2121 NFC_NOTIFY_ERROR , &comp_info);
2122 HCI_PRINT("HCI FSM Invalid Selection State \n");
2123 HCI_PRINT("HCI Remote Target Reactivation Failed \n");
2127 case READER_SELECT_SEQ:
2129 /* If the Target is Mifare then it should fall through */
2130 if(( phHal_eMifare_PICC != target_type )
2131 &&(phHal_eISO14443_3A_PICC != target_type)
2133 && ( phHal_eISO14443_B_PICC != target_type )
2134 && ( phHal_eISO14443_4B_PICC != target_type )
2137 && ( phHal_eFelica_PICC != target_type )
2140 && ( phHal_eJewel_PICC != target_type )
2141 #endif /* #ifdef TYPE_JEWEL */
2142 #ifdef TYPE_ISO15693
2143 && ( phHal_eISO15693_PICC != target_type )
2144 #endif /* #ifdef TYPE_ISO15693 */
2148 status = phHciNfc_ReaderMgmt_Info_Sequence( psHciContext, pHwRef );
2149 if(NFCSTATUS_SUCCESS == status)
2151 psHciContext->hci_seq = HCI_END_SEQ;
2152 status = NFCSTATUS_PENDING;
2160 /* Complete the Connect Sequence and notify the HAL */
2161 status = phHciNfc_FSM_Complete ( psHciContext );
2162 /* Connection Complete Notification to the Upper Layer */
2163 if(NFCSTATUS_SUCCESS == status)
2165 /* Invalidate the previously polled RF Reader Type */
2166 /* psHciContext->host_rf_type = phHal_eInvalidRFType;*/
2167 comp_info.status = status;
2168 phHciNfc_Notify(psHciContext->p_upper_notify,
2169 psHciContext->p_upper_context, pHwRef,
2170 NFC_NOTIFY_TARGET_CONNECTED , &comp_info);
2171 HCI_PRINT(" HCI Remote Target Selected for Transaction. \n");
2175 comp_info.status = status;
2176 /* phHciNfc_FSM_Rollback ( psHciContext ); */
2177 phHciNfc_Notify(psHciContext->p_upper_notify,
2178 psHciContext->p_upper_context, pHwRef,
2179 NFC_NOTIFY_ERROR , &comp_info);
2180 HCI_PRINT("HCI FSM Invalid Selection State \n");
2181 HCI_PRINT("HCI Remote Target Selection Failed \n");
2187 HCI_PRINT("\t Invalid HCI Connect Sequence \n");
2188 /* psHciContext->hci_seq = HCI_END_SEQ; */
2191 }/* End of the Connect Sequence Switch */
2199 phHciNfc_Disconnect_Sequence(
2200 phHciNfc_sContext_t *psHciContext,
2204 NFCSTATUS status = NFCSTATUS_SUCCESS;
2205 static phNfc_sCompletionInfo_t comp_info = {FALSE, 0 , NULL};
2206 phHal_eRemDevType_t target_type = phHal_eUnknown_DevType;
2207 uint8_t re_poll = 0;
2209 if( NULL != psHciContext->p_target_info )
2212 target_type = psHciContext->p_target_info->RemDevType;
2213 switch(psHciContext->hci_seq)
2215 case READER_UICC_DISPATCH_SEQ:
2217 status = phHciNfc_ReaderMgmt_UICC_Dispatch(
2218 psHciContext, pHwRef, target_type );
2219 psHciContext->hci_seq = READER_DESELECT_SEQ;
2220 if(NFCSTATUS_PENDING == status)
2226 case READER_DESELECT_SEQ:
2228 re_poll = (uint8_t) ( NULL != psHciContext->p_config_params )?
2229 *((uint8_t *)psHciContext->p_config_params):FALSE;
2230 status = phHciNfc_ReaderMgmt_Deselect(
2231 psHciContext, pHwRef, target_type, re_poll);
2232 if(NFCSTATUS_PENDING == status)
2234 psHciContext->hci_seq = HCI_END_SEQ;
2235 psHciContext->p_config_params = NULL;
2241 /* Complete the Disconnect Sequence and notify the HAL */
2242 status = phHciNfc_FSM_Complete ( psHciContext );
2243 /* Disconnect Notification to the Upper Layer */
2244 if(NFCSTATUS_SUCCESS == status)
2246 /* Invalidate the previously polled RF Reader Type */
2247 psHciContext->host_rf_type = phHal_eUnknown_DevType;
2248 psHciContext->p_target_info = NULL;
2249 psHciContext->p_xchg_info = NULL;
2250 comp_info.status = status;
2251 phHciNfc_Notify(psHciContext->p_upper_notify,
2252 psHciContext->p_upper_context, pHwRef,
2253 NFC_NOTIFY_TARGET_DISCONNECTED , &comp_info);
2254 HCI_PRINT(" HCI Remote Target De-Selected. \n");
2258 comp_info.status = status;
2259 /* phHciNfc_FSM_Rollback ( psHciContext ); */
2260 phHciNfc_Notify(psHciContext->p_upper_notify,
2261 psHciContext->p_upper_context, pHwRef,
2262 NFC_NOTIFY_ERROR , &comp_info);
2263 HCI_PRINT("HCI FSM Invalid De-Selection State \n");
2264 HCI_PRINT("HCI Remote Target De-Selection Failed \n");
2271 HCI_PRINT("\t Invalid HCI Connect Sequence \n");
2272 /* psHciContext->hci_seq = HCI_END_SEQ; */
2275 }/* End of the Connect Sequence Switch */
2284 phHciNfc_Transact_Sequence(
2285 phHciNfc_sContext_t *psHciContext,
2289 static phNfc_sTransactionInfo_t transact_info = {FALSE,0,NULL,NULL,0};
2291 pphNfcIF_Notification_CB_t p_upper_notify = psHciContext->p_upper_notify;
2292 void *pcontext = psHciContext->p_upper_context;
2293 uint8_t transact_result = NFC_NOTIFY_ERROR;
2295 /* Roll Back to Connect State as Transceive is Complete */
2296 phHciNfc_FSM_Rollback(psHciContext);
2298 switch (psHciContext->host_rf_type)
2300 case phHal_eISO14443_A_PCD:
2302 case phHal_eISO14443_B_PCD:
2304 case phHal_eISO14443_BPrime_PCD:
2306 case phHal_eFelica_PCD:
2308 #ifdef TYPE_ISO15693
2309 case phHal_eISO15693_PCD:
2312 if(ZERO != psHciContext->rx_index)
2314 transact_info.status = NFCSTATUS_SUCCESS;
2315 transact_info.buffer =
2316 &psHciContext->recv_buffer[psHciContext->rx_index];
2317 transact_info.length =
2318 psHciContext->rx_total - psHciContext->rx_index;
2319 transact_result = NFC_NOTIFY_TRANSCEIVE_COMPLETED;
2323 transact_info.status = NFCSTATUS_FAILED;
2324 transact_result = NFC_NOTIFY_TRANSCEIVE_ERROR;
2326 HCI_PRINT(" HCI Transceive operation Completed. \n");
2327 psHciContext->p_xchg_info = NULL ;
2332 case phHal_eJewel_PCD:
2335 transact_info.status = NFCSTATUS_SUCCESS;
2336 transact_info.buffer =
2337 &psHciContext->recv_buffer[psHciContext->rx_index];
2338 transact_info.length =
2339 psHciContext->rx_total - psHciContext->rx_index;
2340 transact_result = NFC_NOTIFY_TRANSCEIVE_COMPLETED;
2341 HCI_PRINT(" HCI Transceive operation Completed. \n");
2342 psHciContext->p_xchg_info = NULL ;
2345 #if defined(ENABLE_P2P)
2346 case phHal_eNfcIP1_Initiator:
2347 case phHal_eNfcIP1_Target:
2350 HCI_PRINT(" HCI Send operation Completed. \n");
2351 transact_info.status = NFCSTATUS_SUCCESS;
2352 transact_result = NFC_NOTIFY_SEND_COMPLETED;
2355 case phHal_eUnknown_DevType:
2358 transact_info.status =
2359 PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
2364 /* Notify the Transceive Completion to the Upper layer */
2365 phHciNfc_Notify( p_upper_notify, pcontext , pHwRef,
2366 transact_result, &transact_info);
2368 return (NFCSTATUS)NFCSTATUS_SUCCESS;
2373 phHciNfc_Info_Sequence(
2374 phHciNfc_sContext_t *psHciContext,
2378 NFCSTATUS status = NFCSTATUS_SUCCESS;
2380 HCI_DEBUG(" HCI: Info Sequence Entry --> Reader Type : %02X \n",
2381 psHciContext->host_rf_type);
2382 switch (psHciContext->host_rf_type)
2384 case phHal_eISO14443_A_PCD:
2386 case phHal_eISO14443_B_PCD:
2388 case phHal_eISO14443_BPrime_PCD:
2390 case phHal_eFelica_PCD:
2393 case phHal_eJewel_PCD:
2395 #ifdef TYPE_ISO15693
2396 case phHal_eISO15693_PCD:
2399 /* To update the select sequence to retrieve
2400 * the target information using the reader type.
2402 status = phHciNfc_ReaderMgmt_Info_Sequence( psHciContext, pHwRef );
2405 #if defined(ENABLE_P2P)
2406 case phHal_eNfcIP1_Initiator:
2407 case phHal_eNfcIP1_Target:
2409 status = phHciNfc_NfcIP_Info_Sequence( psHciContext, pHwRef );
2413 case phHal_eUnknown_DevType:
2417 PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
2427 phHciNfc_Test_Sequence(
2428 phHciNfc_sContext_t *psHciContext,
2430 NFCSTATUS test_status,
2435 NFCSTATUS status = NFCSTATUS_SUCCESS;
2436 static phNfc_sCompletionInfo_t comp_info = {0};
2437 static phNfc_sData_t test_result= {NULL,0};
2439 /* Complete the Test Sequence and notify the HAL */
2440 status = phHciNfc_FSM_Complete ( psHciContext );
2441 /* Test Results to the Upper Layer */
2442 if(NFCSTATUS_SUCCESS == status)
2444 comp_info.status = test_status;
2445 if ( (NULL != pdata) && (length >= HCP_HEADER_LEN) )
2447 test_result.buffer = ( pdata + HCP_HEADER_LEN);
2448 test_result.length = length - HCP_HEADER_LEN;
2452 status = phHciNfc_DevMgmt_Get_Test_Result(
2453 psHciContext, &test_result );
2455 comp_info.info = &test_result;
2456 phHciNfc_Notify(psHciContext->p_upper_notify,
2457 psHciContext->p_upper_context, pHwRef,
2458 NFC_NOTIFY_RESULT , &comp_info);
2459 HCI_DEBUG(" HCI System Test Completed : Status = %u\n", test_status);
2463 comp_info.status = status;
2464 phHciNfc_FSM_Rollback ( psHciContext );
2465 phHciNfc_Notify(psHciContext->p_upper_notify,
2466 psHciContext->p_upper_context, pHwRef,
2467 NFC_NOTIFY_ERROR , &comp_info);
2468 HCI_PRINT("HCI FSM Invalid Test State \n");
2476 phHciNfc_IO_Sequence(
2477 phHciNfc_sContext_t *psHciContext,
2479 NFCSTATUS io_status,
2484 NFCSTATUS status = NFCSTATUS_SUCCESS;
2485 static phNfc_sCompletionInfo_t comp_info = {0};
2487 /* To remove "warning (VS 4100) : unreferenced formal parameter" */
2488 PHNFC_UNUSED_VARIABLE(pdata);
2489 PHNFC_UNUSED_VARIABLE(length);
2490 /* Complete the Test Sequence and notify the HAL */
2491 phHciNfc_FSM_Rollback ( psHciContext );
2492 /* Test Results to the Upper Layer */
2493 comp_info.status = io_status;
2494 status = phHciNfc_Pending_Sequence(psHciContext, pHwRef );
2495 if(NFCSTATUS_SUCCESS == io_status)
2497 phHciNfc_Notify(psHciContext->p_upper_notify,
2498 psHciContext->p_upper_context, pHwRef,
2499 NFC_IO_SUCCESS , &comp_info);
2500 HCI_PRINT(" HCI System IO Successful. \n");
2504 phHciNfc_Notify(psHciContext->p_upper_notify,
2505 psHciContext->p_upper_context, pHwRef,
2506 NFC_IO_ERROR , &comp_info);
2507 HCI_PRINT("HCI IO Error \n");
2517 phHciNfc_Activate_Sequence(
2518 phHciNfc_sContext_t *psHciContext,
2522 NFCSTATUS status = NFCSTATUS_SUCCESS;