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_DevMgmt.c *
23 * \brief HCI PN544 Device Management Gate Routines. *
26 * Project: NFC-FRI-1.1 *
28 * $Date: Fri Mar 12 10:21:54 2010 $ *
29 * $Author: ing04880 $ *
31 * $Aliases: NFC_FRI1.1_WK1007_R33_3,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ *
33 * =========================================================================== *
37 ***************************** Header File Inclusion ****************************
39 #include <phNfcConfig.h>
40 #include <phNfcCompId.h>
41 #include <phHciNfc_Pipe.h>
42 #include <phHciNfc_DevMgmt.h>
43 #include <phHciNfc_Emulation.h>
44 #include <phOsalNfc.h>
47 ****************************** Macro Definitions *******************************
50 /* Commands for System Management module */
51 #define NXP_RF_CHECK_SETTINGS 0x10U
52 #define NXP_RF_UPDATE_SETTINGS 0x11U
54 /* Self Test Commands */
55 #define NXP_SELF_TEST_ANTENNA 0x20U
56 #define NXP_SELF_TEST_SWP 0x21U
57 #define NXP_SELF_TEST_NFCWI 0x22U
58 #define NXP_SELF_TEST_PRBS 0x25U
60 /* System Management propreitary control */
61 #define NXP_DBG_READ 0x3EU
62 #define NXP_DBG_WRITE 0x3FU
64 /* System Management Events */
65 #define NXP_EVT_SET_AUTONOMOUS 0x01U
66 #define NXP_EVT_CLF_WAKEUP 0x02U
68 /* System Management Information Events */
69 #define NXP_EVT_INFO_TXLDO_OVERCUR 0x10U
70 #define NXP_EVT_INFO_PMUVCC 0x11U
71 #define NXP_EVT_INFO_EXT_RF_FIELD 0x12U
72 #define NXP_EVT_INFO_MEM_VIOLATION 0x13U
73 #define NXP_EVT_INFO_TEMP_OVERHEAT 0x14U
74 #define NXP_EVT_INFO_LLC_ERROR 0x15U
76 #define NFC_DEV_TXLDO_MASK 0x03U
80 *************************** Structure and Enumeration ***************************
84 /** \defgroup grp_hci_nfc HCI PN544 Device Management Component
89 typedef enum phHciNfc_DevMgmt_Seq{
90 DEV_MGMT_PIPE_OPEN = 0x00U,
91 DEV_MGMT_SET_PWR_STATUS,
92 DEV_MGMT_SET_INFO_EVT,
93 DEV_MGMT_GET_EEPROM_INFO,
100 DEV_MGMT_IFC_TO_TX_L,
101 DEV_MGMT_ANAIRQ_CONF,
105 DEV_MGMT_UICC_PWR_REQUEST,
106 DEV_MGMT_ACTIVE_GUARD_TO,
107 DEV_MGMT_MAX_ACT_TO_LOW,
108 DEV_MGMT_MAX_ACT_TO_HIGH,
109 DEV_MGMT_UICC_CE_A_ACCESS,
110 DEV_MGMT_UICC_CE_B_ACCESS,
111 DEV_MGMT_UICC_CE_BP_ACCESS,
112 DEV_MGMT_UICC_CE_F_ACCESS,
113 DEV_MGMT_UICC_RD_A_ACCESS,
114 DEV_MGMT_UICC_RD_B_ACCESS,
115 DEV_MGMT_UICC_BIT_RATE,
116 DEV_MGMT_UICC_RX_ERR_CNT,
117 DEV_MGMT_UICC_TX_ERR_CNT,
118 DEV_MGMT_LLC_GRD_TO_H,
119 DEV_MGMT_LLC_GRD_TO_L,
120 DEV_MGMT_LLC_ACK_TO_H,
121 DEV_MGMT_LLC_ACK_TO_L,
123 DEV_MGMT_EVT_AUTONOMOUS,
125 } phHciNfc_DevMgmt_Seq_t;
128 typedef struct phHciNfc_DevMgmt_Info{
129 phHciNfc_DevMgmt_Seq_t current_seq;
130 phHciNfc_DevMgmt_Seq_t next_seq;
131 phHciNfc_Pipe_Info_t *p_pipe_info;
135 uint8_t pmuvcc_status;
136 uint8_t overheat_status;
139 phNfc_sData_t test_result;
141 } phHciNfc_DevMgmt_Info_t;
145 *************************** Static Function Declaration **************************
150 phHciNfc_DevMgmt_InfoUpdate(
151 phHciNfc_sContext_t *psHciContext,
152 phHal_sHwReference_t *pHwRef,
160 phHciNfc_Recv_DevMgmt_Response(
173 phHciNfc_Recv_DevMgmt_Event(
187 phHciNfc_Send_DevMgmt_Command (
188 phHciNfc_sContext_t *psHciContext,
196 phHciNfc_Send_DevMgmt_Event (
197 phHciNfc_sContext_t *psHciContext,
204 *************************** Function Definitions ***************************
209 phHciNfc_DevMgmt_Init_Resources(
210 phHciNfc_sContext_t *psHciContext
213 NFCSTATUS status = NFCSTATUS_SUCCESS;
214 phHciNfc_DevMgmt_Info_t *p_device_mgmt_info=NULL;
216 if( NULL == psHciContext )
218 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
222 if(( NULL == psHciContext->p_device_mgmt_info ) &&
223 (phHciNfc_Allocate_Resource((void **)(&p_device_mgmt_info),
224 sizeof(phHciNfc_DevMgmt_Info_t))== NFCSTATUS_SUCCESS))
226 psHciContext->p_device_mgmt_info = p_device_mgmt_info;
227 p_device_mgmt_info->current_seq = DEV_MGMT_PIPE_OPEN;
228 p_device_mgmt_info->next_seq = DEV_MGMT_PIPE_OPEN;
229 p_device_mgmt_info->p_pipe_info = NULL;
233 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INSUFFICIENT_RESOURCES);
241 phHciNfc_DevMgmt_Get_PipeID(
242 phHciNfc_sContext_t *psHciContext,
246 NFCSTATUS status = NFCSTATUS_SUCCESS;
248 if( (NULL != psHciContext)
249 && ( NULL != ppipe_id )
250 && ( NULL != psHciContext->p_device_mgmt_info )
253 phHciNfc_Pipe_Info_t *p_pipe_info = NULL;
254 p_pipe_info = ((phHciNfc_DevMgmt_Info_t *)
255 psHciContext->p_device_mgmt_info)->p_pipe_info ;
256 if (NULL != p_pipe_info)
258 *ppipe_id = p_pipe_info->pipe.pipe_id ;
262 *ppipe_id = (uint8_t)HCI_UNKNOWN_PIPE_ID;
268 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION);
275 phHciNfc_DevMgmt_Get_Test_Result(
276 phHciNfc_sContext_t *psHciContext,
277 phNfc_sData_t *p_test_result
280 NFCSTATUS status = NFCSTATUS_SUCCESS;
282 if( (NULL != psHciContext)
283 && ( NULL != p_test_result )
284 && ( NULL != psHciContext->p_device_mgmt_info )
287 phHciNfc_DevMgmt_Info_t *p_device_mgmt_info=NULL;
288 p_device_mgmt_info = (phHciNfc_DevMgmt_Info_t *)
289 psHciContext->p_device_mgmt_info ;
290 p_test_result->buffer = p_device_mgmt_info->test_result.buffer;
291 p_test_result->length = p_device_mgmt_info->test_result.length;
296 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION);
304 phHciNfc_DevMgmt_Set_Test_Result(
305 phHciNfc_sContext_t *psHciContext,
309 NFCSTATUS status = NFCSTATUS_SUCCESS;
311 if( (NULL != psHciContext)
312 && ( NULL != psHciContext->p_device_mgmt_info )
315 phHciNfc_DevMgmt_Info_t *p_device_mgmt_info=NULL;
316 p_device_mgmt_info = (phHciNfc_DevMgmt_Info_t *)
317 psHciContext->p_device_mgmt_info ;
318 p_device_mgmt_info->test_status = test_status;
323 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION);
332 phHciNfc_DevMgmt_Update_PipeInfo(
333 phHciNfc_sContext_t *psHciContext,
335 phHciNfc_Pipe_Info_t *pPipeInfo
338 NFCSTATUS status = NFCSTATUS_SUCCESS;
340 if( NULL == psHciContext )
342 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
344 else if(NULL == psHciContext->p_device_mgmt_info)
346 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
350 phHciNfc_DevMgmt_Info_t *p_device_mgmt_info=NULL;
351 p_device_mgmt_info = (phHciNfc_DevMgmt_Info_t *)
352 psHciContext->p_device_mgmt_info ;
353 /* Update the pipe_info of the Device Management Gate obtained
354 * from HCI Response */
355 p_device_mgmt_info->p_pipe_info = pPipeInfo;
356 if (( NULL != pPipeInfo)
357 && ((uint8_t)HCI_UNKNOWN_PIPE_ID != pipeID)
360 /* Update the Response Receive routine of the Device
362 pPipeInfo->recv_resp = &phHciNfc_Recv_DevMgmt_Response;
363 pPipeInfo->recv_event = &phHciNfc_Recv_DevMgmt_Event;
372 phHciNfc_DevMgmt_Configure (
373 phHciNfc_sContext_t *psHciContext,
379 NFCSTATUS status = NFCSTATUS_SUCCESS;
380 phHciNfc_Pipe_Info_t *p_pipe_info = NULL;
381 uint8_t pipe_id = (uint8_t)HCI_UNKNOWN_PIPE_ID;
385 if( (NULL == psHciContext) || (NULL == pHwRef) )
387 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
389 else if( NULL == psHciContext->p_device_mgmt_info )
391 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION);
395 p_pipe_info = ((phHciNfc_DevMgmt_Info_t *)
396 psHciContext->p_device_mgmt_info)->p_pipe_info ;
398 if(NULL == p_pipe_info )
400 status = PHNFCSTVAL(CID_NFC_HCI,
401 NFCSTATUS_INVALID_HCI_SEQUENCE);
405 pipe_id = p_pipe_info->pipe.pipe_id ;
407 params[i++] = (uint8_t)(address >> BYTE_SIZE);
408 params[i++] = (uint8_t)address;
410 p_pipe_info->param_info = ¶ms;
411 p_pipe_info->param_length = i ;
412 status = phHciNfc_Send_DevMgmt_Command( psHciContext, pHwRef,
413 pipe_id, (uint8_t)NXP_DBG_WRITE );
421 phHciNfc_DevMgmt_Get_Info (
422 phHciNfc_sContext_t *psHciContext,
428 NFCSTATUS status = NFCSTATUS_SUCCESS;
429 phHciNfc_Pipe_Info_t *p_pipe_info = NULL;
430 uint8_t pipe_id = (uint8_t)HCI_UNKNOWN_PIPE_ID;
434 if( (NULL == psHciContext) || (NULL == pHwRef) )
436 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
438 else if( NULL == psHciContext->p_device_mgmt_info )
440 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION);
444 p_pipe_info = ((phHciNfc_DevMgmt_Info_t *)
445 psHciContext->p_device_mgmt_info)->p_pipe_info ;
447 if(NULL == p_pipe_info )
449 status = PHNFCSTVAL(CID_NFC_HCI,
450 NFCSTATUS_INVALID_HCI_SEQUENCE);
454 ((phHciNfc_DevMgmt_Info_t *)
455 psHciContext->p_device_mgmt_info)->p_val = p_val;
456 pipe_id = p_pipe_info->pipe.pipe_id ;
458 params[i++] = (uint8_t)(address >> BYTE_SIZE);
459 params[i++] = (uint8_t) address;
460 p_pipe_info->param_info = ¶ms;
461 p_pipe_info->param_length = i ;
462 status = phHciNfc_Send_DevMgmt_Command( psHciContext, pHwRef,
463 pipe_id, (uint8_t)NXP_DBG_READ );
471 * \brief Initialisation of PN544 Device Managment Gate.
473 * This function initialses the PN544 Device Management gate and
474 * populates the PN544 Device Management Information Structure
479 phHciNfc_DevMgmt_Initialise(
480 phHciNfc_sContext_t *psHciContext,
484 NFCSTATUS status = NFCSTATUS_SUCCESS;
485 phHciNfc_Pipe_Info_t *p_pipe_info = NULL;
486 phHciNfc_DevMgmt_Info_t *p_device_mgmt_info=NULL;
487 static uint8_t config = 0x10;
489 if( ( NULL == psHciContext )
493 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
495 else if (NULL == psHciContext->p_device_mgmt_info)
497 status = PHNFCSTVAL(CID_NFC_HCI,
498 NFCSTATUS_INVALID_HCI_INFORMATION);
499 }/* End of the PN544 Device Info Memory Check */
502 p_device_mgmt_info = (phHciNfc_DevMgmt_Info_t *)
503 psHciContext->p_device_mgmt_info ;
504 p_pipe_info = p_device_mgmt_info->p_pipe_info;
506 if (NULL == p_pipe_info)
508 status = PHNFCSTVAL(CID_NFC_HCI,
509 NFCSTATUS_INVALID_HCI_SEQUENCE);
513 switch(p_device_mgmt_info->current_seq )
515 /* PN544 Device Mgmt pipe open sequence */
516 case DEV_MGMT_PIPE_OPEN:
518 status = phHciNfc_Open_Pipe( psHciContext,
519 pHwRef, p_pipe_info );
520 if(status == NFCSTATUS_SUCCESS)
522 p_device_mgmt_info->next_seq =
524 status = NFCSTATUS_PENDING;
528 case DEV_MGMT_GET_EEPROM_INFO:
530 p_pipe_info->reg_index = DEVICE_INFO_EEPROM_INDEX;
531 status = phHciNfc_Send_Generic_Cmd( psHciContext,
532 pHwRef, (uint8_t)p_pipe_info->pipe.pipe_id,
533 (uint8_t)ANY_GET_PARAMETER);
534 if(NFCSTATUS_PENDING == status )
536 #if ( NXP_NFC_IFC_TIMEOUT & 0x01 )
537 p_device_mgmt_info->next_seq =
538 DEV_MGMT_IFC_TO_TX_H;
540 p_device_mgmt_info->next_seq =
542 #endif /* #if ( NXP_NFC_IFC_TIMEOUT & 0x01 ) */
546 case DEV_MGMT_GPIO_PDIR:
549 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
550 NFC_ADDRESS_GPIO_PDIR , config );
551 if(NFCSTATUS_PENDING == status )
553 p_device_mgmt_info->next_seq =
558 case DEV_MGMT_GPIO_PEN:
560 config = NXP_NFC_GPIO_MASK(NXP_DOWNLOAD_GPIO)| 0x03 ;
561 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
562 NFC_ADDRESS_GPIO_PEN , config );
563 if(NFCSTATUS_PENDING == status )
565 #if ( NXP_NFC_IFC_TIMEOUT & 0x01 )
566 p_device_mgmt_info->next_seq =
567 DEV_MGMT_IFC_TO_TX_H;
569 p_device_mgmt_info->next_seq =
571 #endif /* #if ( NXP_NFC_IFC_TIMEOUT & 0x01 ) */
575 case DEV_MGMT_FELICA_RC:
578 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
579 NFC_FELICA_RC_ADDR , config );
580 if(NFCSTATUS_PENDING == status )
583 if ((HCI_SELF_TEST == psHciContext->init_mode )
584 || (HCI_NFC_DEVICE_TEST == psHciContext->init_mode ))
586 p_device_mgmt_info->next_seq =
591 p_device_mgmt_info->next_seq =
592 DEV_MGMT_GET_EEPROM_INFO;
598 #if ( NXP_NFC_IFC_TIMEOUT & 0x01 )
600 case DEV_MGMT_IFC_TO_TX_H:
603 ( NXP_NFC_IFC_CONFIG_DEFAULT >> BYTE_SIZE ) /* 0x03 */;
604 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
605 NFC_ADDRESS_IFC_TO_TX_H , config );
606 if(NFCSTATUS_PENDING == status )
608 p_device_mgmt_info->next_seq =
609 DEV_MGMT_IFC_TO_TX_L;
613 case DEV_MGMT_IFC_TO_TX_L:
616 ( NXP_NFC_IFC_CONFIG_DEFAULT & BYTE_MASK ) /* 0xE8 */;
617 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
618 NFC_ADDRESS_IFC_TO_TX_L , config );
619 if(NFCSTATUS_PENDING == status )
621 #if ( NXP_NFC_IFC_TIMEOUT & 0x02 )
622 p_device_mgmt_info->next_seq =
623 DEV_MGMT_IFC_TO_RX_H;
625 p_device_mgmt_info->next_seq =
627 #endif /* #if ( NXP_NFC_IFC_TIMEOUT & 0x02 ) */
631 case DEV_MGMT_IFC_TO_RX_H:
634 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
635 NFC_ADDRESS_IFC_TO_RX_H , config );
636 if(NFCSTATUS_PENDING == status )
638 p_device_mgmt_info->next_seq =
639 DEV_MGMT_IFC_TO_RX_L;
643 case DEV_MGMT_IFC_TO_RX_L:
646 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
647 NFC_ADDRESS_IFC_TO_RX_L , config );
648 if(NFCSTATUS_PENDING == status )
650 p_device_mgmt_info->next_seq =
656 #endif /* #if ( NXP_NFC_IFC_TIMEOUT & 0x01 ) */
657 case DEV_MGMT_TX_LDO:
659 #if ( NXP_HAL_VERIFY_EEPROM_CRC & 0x01U )
660 if (0 != p_device_mgmt_info->eeprom_crc)
662 status = NFCSTATUS_FAILED;
667 config = (NFC_DEV_HWCONF_DEFAULT |
668 (NXP_DEFAULT_TX_LDO & NFC_DEV_TXLDO_MASK));
669 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
670 NFC_ADDRESS_HW_CONF , config );
671 if(NFCSTATUS_PENDING == status )
673 #if ( SW_TYPE_RF_TUNING_BF & 0x01)
674 p_device_mgmt_info->next_seq = DEV_MGMT_ANAIRQ_CONF;
676 p_device_mgmt_info->next_seq = DEV_MGMT_CLK_REQ;
678 /* status = NFCSTATUS_SUCCESS; */
683 #if ( SW_TYPE_RF_TUNING_BF & 0x01)
684 /* The Analogue IRQ Configuartion */
685 case DEV_MGMT_ANAIRQ_CONF:
688 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
689 NFC_ADDRESS_ANAIRQ_CONF , config );
690 if(NFCSTATUS_PENDING == status )
692 p_device_mgmt_info->next_seq =
694 /* status = NFCSTATUS_SUCCESS; */
698 /* The PMOS Modulation Index */
699 case DEV_MGMT_PMOS_MOD:
701 config = NFC_DEV_PMOS_MOD_DEFAULT;
702 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
703 NFC_ADDRESS_PMOS_MOD , config );
704 if(NFCSTATUS_PENDING == status )
706 p_device_mgmt_info->next_seq =
708 /* status = NFCSTATUS_SUCCESS; */
712 #endif /* #if ( SW_TYPE_RF_TUNING_BF & 0x01) */
713 case DEV_MGMT_CLK_REQ:
715 config = ((phHal_sHwConfig_t *)
716 psHciContext->p_config_params)->clk_req ;
717 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
718 NFC_ADDRESS_CLK_REQ , config );
719 if(NFCSTATUS_PENDING == status )
721 p_device_mgmt_info->next_seq =
723 /* status = NFCSTATUS_SUCCESS; */
727 case DEV_MGMT_INPUT_CLK:
729 config = ((phHal_sHwConfig_t *)
730 psHciContext->p_config_params)->input_clk;
731 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
732 NFC_ADDRESS_CLK_INPUT , config );
733 if(NFCSTATUS_PENDING == status )
735 p_device_mgmt_info->next_seq =
736 DEV_MGMT_UICC_PWR_REQUEST;
740 case DEV_MGMT_UICC_PWR_REQUEST:
742 config = NXP_UICC_PWR_REQUEST;
743 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
744 NFC_ADDRESS_SWP_PWR_REQ , config );
745 if(NFCSTATUS_PENDING == status )
747 p_device_mgmt_info->next_seq =
748 DEV_MGMT_UICC_RD_A_ACCESS;
752 case DEV_MGMT_UICC_RD_A_ACCESS:
754 #if ( NXP_UICC_RD_RIGHTS & 0x01 )
755 config = (uint8_t) phHciNfc_RFReaderAGate;
758 #endif /* #if ( NXP_UICC_RD_RIGHTS & 0x01 ) */
759 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
760 NFC_ADDRESS_UICC_RD_A_ACCESS , config );
761 if(NFCSTATUS_PENDING == status )
763 p_device_mgmt_info->next_seq =
764 DEV_MGMT_UICC_RD_B_ACCESS;
768 case DEV_MGMT_UICC_RD_B_ACCESS:
770 #if ( NXP_UICC_RD_RIGHTS & 0x02 )
771 config = (uint8_t) phHciNfc_RFReaderBGate;
774 #endif /* #if ( NXP_UICC_RD_RIGHTS & 0x02 ) */
775 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
776 NFC_ADDRESS_UICC_RD_B_ACCESS , config );
777 if(NFCSTATUS_PENDING == status )
779 p_device_mgmt_info->next_seq =
780 DEV_MGMT_UICC_CE_A_ACCESS;
784 case DEV_MGMT_UICC_CE_A_ACCESS:
786 #if defined(HOST_EMULATION) || ( NXP_UICC_CE_RIGHTS & 0x01 )
787 config = (uint8_t) phHciNfc_CETypeAGate;
790 #endif /* #if ( NXP_UICC_CE_RIGHTS & 0x01 ) */
791 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
792 NFC_ADDRESS_UICC_CE_A_ACCESS , config );
793 if(NFCSTATUS_PENDING == status )
795 p_device_mgmt_info->next_seq =
796 DEV_MGMT_UICC_CE_B_ACCESS;
800 case DEV_MGMT_UICC_CE_B_ACCESS:
802 #if defined(HOST_EMULATION) || ( NXP_UICC_CE_RIGHTS & 0x02 )
803 config = (uint8_t) phHciNfc_CETypeBGate;
806 #endif /* #if ( NXP_UICC_CE_RIGHTS & 0x02 ) */
807 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
808 NFC_ADDRESS_UICC_CE_B_ACCESS , config );
809 if(NFCSTATUS_PENDING == status )
811 p_device_mgmt_info->next_seq =
812 DEV_MGMT_UICC_CE_BP_ACCESS;
816 case DEV_MGMT_UICC_CE_BP_ACCESS:
818 #if defined(HOST_EMULATION) || ( NXP_UICC_CE_RIGHTS & 0x04 )
819 config = (uint8_t) phHciNfc_CETypeBPrimeGate;
822 #endif /* #if ( NXP_UICC_CE_RIGHTS & 0x04 ) */
823 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
824 NFC_ADDRESS_UICC_CE_BP_ACCESS , config );
825 if(NFCSTATUS_PENDING == status )
827 p_device_mgmt_info->next_seq =
828 DEV_MGMT_UICC_CE_F_ACCESS;
832 case DEV_MGMT_UICC_CE_F_ACCESS:
834 #if defined(HOST_EMULATION) || ( NXP_UICC_CE_RIGHTS & 0x08 )
835 config = (uint8_t) phHciNfc_CETypeFGate;
838 #endif /* #if ( NXP_UICC_CE_RIGHTS & 0x08 ) */
839 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
840 NFC_ADDRESS_UICC_CE_F_ACCESS , config );
841 if(NFCSTATUS_PENDING == status )
843 p_device_mgmt_info->next_seq =
844 DEV_MGMT_UICC_BIT_RATE;
848 case DEV_MGMT_UICC_BIT_RATE:
850 config = NXP_UICC_BIT_RATE;
851 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
852 NFC_ADDRESS_SWP_BITRATE , config );
853 if(NFCSTATUS_PENDING == status )
855 #if defined (CFG_PWR_STATUS)
856 p_device_mgmt_info->next_seq =
857 DEV_MGMT_SET_PWR_STATUS;
859 p_device_mgmt_info->next_seq =
860 DEV_MGMT_SET_INFO_EVT;
865 #ifdef CFG_PWR_STATUS
866 case DEV_MGMT_SET_PWR_STATUS:
868 config = NXP_SYSTEM_PWR_STATUS;
869 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
870 NFC_ADDRESS_PWR_STATUS , config );
871 if(NFCSTATUS_PENDING == status )
873 p_device_mgmt_info->next_seq =
874 DEV_MGMT_SET_INFO_EVT;
879 case DEV_MGMT_SET_INFO_EVT:
881 config = NXP_SYSTEM_EVT_INFO;
882 status = phHciNfc_Set_Param(psHciContext, pHwRef,
883 p_pipe_info, DEVICE_INFO_EVT_INDEX,
884 (uint8_t *)&config, sizeof(config) );
885 if(NFCSTATUS_PENDING == status )
887 #if ( HOST_LINK_TIMEOUT & 0x01 )
888 p_device_mgmt_info->next_seq =
889 DEV_MGMT_LLC_GRD_TO_H;
891 p_device_mgmt_info->next_seq =
892 DEV_MGMT_EVT_AUTONOMOUS;
893 status = NFCSTATUS_SUCCESS;
894 #endif /* #if ( HOST_LINK_TIMEOUT & 0x01 ) */
898 #if ( HOST_LINK_TIMEOUT & 0x01 )
900 case DEV_MGMT_LLC_GRD_TO_H:
903 ( NXP_NFC_LINK_GRD_CFG_DEFAULT >> BYTE_SIZE ) /* 0x00 */;
904 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
905 NFC_ADDRESS_LLC_GRD_TO_H , config );
906 if(NFCSTATUS_PENDING == status )
908 p_device_mgmt_info->next_seq =
909 DEV_MGMT_LLC_GRD_TO_L;
913 case DEV_MGMT_LLC_GRD_TO_L:
916 ( NXP_NFC_LINK_GRD_CFG_DEFAULT & BYTE_MASK ) /* 0x32 */;
917 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
918 NFC_ADDRESS_LLC_GRD_TO_L , config );
919 if(NFCSTATUS_PENDING == status )
921 #if ( HOST_LINK_TIMEOUT & 0x02 )
922 p_device_mgmt_info->next_seq =
923 DEV_MGMT_LLC_ACK_TO_H;
925 p_device_mgmt_info->next_seq =
926 DEV_MGMT_EVT_AUTONOMOUS;
927 status = NFCSTATUS_SUCCESS;
928 #endif /* #if ( HOST_LINK_TIMEOUT & 0x02 ) */
932 case DEV_MGMT_LLC_ACK_TO_H:
935 ( NXP_NFC_LINK_ACK_CFG_DEFAULT >> BYTE_SIZE )/* 0x00 */;
936 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
937 NFC_ADDRESS_LLC_ACK_TO_H , config );
938 if(NFCSTATUS_PENDING == status )
940 p_device_mgmt_info->next_seq =
941 DEV_MGMT_LLC_ACK_TO_L;
945 case DEV_MGMT_LLC_ACK_TO_L:
948 ( NXP_NFC_LINK_ACK_CFG_DEFAULT & BYTE_MASK ) /* 0x00 */;;
949 status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
950 NFC_ADDRESS_LLC_ACK_TO_L , config );
951 if(NFCSTATUS_PENDING == status )
953 p_device_mgmt_info->next_seq =
954 DEV_MGMT_EVT_AUTONOMOUS;
955 status = NFCSTATUS_SUCCESS;
960 #endif /* #if ( HOST_LINK_TIMEOUT & 0x01 ) */
963 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_SEQUENCE);
967 }/* End of the Sequence Switch */
970 } /* End of Null Context Check */
976 * \brief Releases the resources allocated the PN544 Device Management.
978 * This function Releases the resources allocated the PN544 Device Management
979 * and resets the hardware to the reset state.
983 phHciNfc_DevMgmt_Release(
984 phHciNfc_sContext_t *psHciContext,
988 NFCSTATUS status = NFCSTATUS_SUCCESS;
989 phHciNfc_Pipe_Info_t *p_pipe_info = NULL;
990 phHciNfc_DevMgmt_Info_t *p_device_mgmt_info=NULL;
992 if( (NULL == psHciContext) || (NULL == pHwRef) )
994 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
998 if( NULL != psHciContext->p_device_mgmt_info )
1000 p_device_mgmt_info = (phHciNfc_DevMgmt_Info_t *)
1001 psHciContext->p_device_mgmt_info ;
1002 switch(p_device_mgmt_info->current_seq)
1005 /* PN544 Device pipe close sequence */
1006 case DEV_MGMT_EVT_AUTONOMOUS:
1008 p_pipe_info = p_device_mgmt_info->p_pipe_info;
1010 p_pipe_info->param_info = NULL;
1011 p_pipe_info->param_length = HCP_ZERO_LEN;
1013 status = phHciNfc_Send_DevMgmt_Event(psHciContext, pHwRef,
1014 p_pipe_info->pipe.pipe_id, NXP_EVT_SET_AUTONOMOUS);
1015 if(status == NFCSTATUS_PENDING)
1017 p_device_mgmt_info->next_seq = DEV_MGMT_PIPE_OPEN;
1018 status = NFCSTATUS_SUCCESS;
1022 /* PN544 Device pipe close sequence */
1023 case DEV_MGMT_PIPE_CLOSE:
1025 p_pipe_info = p_device_mgmt_info->p_pipe_info;
1027 status = phHciNfc_Close_Pipe( psHciContext,
1028 pHwRef, p_pipe_info );
1029 if(status == NFCSTATUS_SUCCESS)
1031 p_device_mgmt_info->next_seq = DEV_MGMT_PIPE_OPEN;
1032 /* status = NFCSTATUS_PENDING; */
1038 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_SEQUENCE);
1042 }/* End of the Sequence Switch */
1044 }/* End of the PN544 Device Info Memory Check */
1046 } /* End of Null Context Check */
1052 phHciNfc_DevMgmt_Update_Sequence(
1053 phHciNfc_sContext_t *psHciContext,
1054 phHciNfc_eSeqType_t DevMgmt_seq
1057 NFCSTATUS status = NFCSTATUS_SUCCESS;
1058 phHciNfc_DevMgmt_Info_t *p_device_mgmt_info=NULL;
1059 if( NULL == psHciContext )
1061 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
1063 else if ( NULL == psHciContext->p_device_mgmt_info )
1065 status = PHNFCSTVAL(CID_NFC_HCI,
1066 NFCSTATUS_INVALID_HCI_INFORMATION);
1070 p_device_mgmt_info = (phHciNfc_DevMgmt_Info_t *)
1071 psHciContext->p_device_mgmt_info ;
1077 p_device_mgmt_info->current_seq = DEV_MGMT_PIPE_OPEN;
1078 p_device_mgmt_info->next_seq = DEV_MGMT_PIPE_OPEN ;
1083 p_device_mgmt_info->current_seq = p_device_mgmt_info->next_seq;
1089 p_device_mgmt_info->current_seq = DEV_MGMT_EVT_AUTONOMOUS;
1090 p_device_mgmt_info->next_seq = DEV_MGMT_EVT_AUTONOMOUS ;
1097 }/* End of Update Sequence Switch */
1106 * \brief Perform the System Management Tests
1107 * provided by the corresponding peripheral device.
1109 * This function performs the System Management Tests provided by the NFC
1110 * Peripheral device.
1114 phHciNfc_DevMgmt_Test(
1118 phNfc_sData_t *test_param
1121 phHciNfc_sContext_t *psHciContext =
1122 (phHciNfc_sContext_t *)psContext ;
1123 NFCSTATUS status = NFCSTATUS_SUCCESS;
1124 phHciNfc_Pipe_Info_t *p_pipe_info = NULL;
1125 uint8_t pipe_id = (uint8_t)HCI_UNKNOWN_PIPE_ID;
1127 if( (NULL == psHciContext) || (NULL == pHwRef) )
1129 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
1131 else if( NULL == psHciContext->p_device_mgmt_info )
1133 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION);
1137 phHciNfc_DevMgmt_Info_t *p_device_mgmt_info = (phHciNfc_DevMgmt_Info_t *)
1138 psHciContext->p_device_mgmt_info ;
1139 p_pipe_info = ((phHciNfc_DevMgmt_Info_t *)
1140 psHciContext->p_device_mgmt_info)->p_pipe_info ;
1143 case NXP_SELF_TEST_ANTENNA:
1144 case NXP_SELF_TEST_SWP:
1145 case NXP_SELF_TEST_PRBS:
1146 /* case NXP_SELF_TEST_NFCWI: */
1148 if (NULL != p_pipe_info)
1150 pipe_id = p_pipe_info->pipe.pipe_id ;
1151 if ( NULL != test_param )
1153 p_pipe_info->param_info = test_param->buffer;
1154 p_pipe_info->param_length = (uint8_t)test_param->length;
1156 p_device_mgmt_info->test_result.buffer = NULL;
1157 p_device_mgmt_info->test_result.length = 0;
1159 phHciNfc_Send_DevMgmt_Command( psHciContext, pHwRef,
1160 pipe_id, (uint8_t)test_type );
1164 status = PHNFCSTVAL(CID_NFC_HCI,
1165 NFCSTATUS_INVALID_HCI_INFORMATION);
1171 status = PHNFCSTVAL(CID_NFC_HCI,
1172 NFCSTATUS_FEATURE_NOT_SUPPORTED);
1183 * \brief Receives the HCI Response from the corresponding peripheral device.
1185 * This function receives the HCI Command Response from the connected NFC
1186 * Peripheral device.
1190 phHciNfc_Recv_DevMgmt_Response(
1201 phHciNfc_sContext_t *psHciContext =
1202 (phHciNfc_sContext_t *)psContext ;
1203 phHciNfc_DevMgmt_Info_t *p_device_mgmt_info=NULL;
1204 NFCSTATUS status = NFCSTATUS_SUCCESS;
1205 uint8_t prev_cmd = ANY_GET_PARAMETER;
1207 if( (NULL == psHciContext) || (NULL == pHwRef) )
1209 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
1211 else if( NULL == psHciContext->p_device_mgmt_info )
1213 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
1217 p_device_mgmt_info = (phHciNfc_DevMgmt_Info_t *)
1218 psHciContext->p_device_mgmt_info ;
1219 prev_cmd = p_device_mgmt_info->p_pipe_info->prev_msg ;
1222 case ANY_GET_PARAMETER:
1224 status = phHciNfc_DevMgmt_InfoUpdate(psHciContext,
1225 (phHal_sHwReference_t *)pHwRef,
1226 p_device_mgmt_info->p_pipe_info->reg_index,
1227 &pResponse[HCP_HEADER_LEN],
1228 (uint8_t)(length - HCP_HEADER_LEN));
1231 case ANY_SET_PARAMETER:
1239 case ANY_CLOSE_PIPE:
1241 phOsalNfc_FreeMemory(p_device_mgmt_info->p_pipe_info);
1242 p_device_mgmt_info->p_pipe_info = NULL;
1243 psHciContext->p_pipe_list[PIPETYPE_STATIC_LINK] = NULL;
1250 if( NULL != p_device_mgmt_info->p_val )
1252 *p_device_mgmt_info->p_val = (uint8_t)( length > HCP_HEADER_LEN ) ?
1253 pResponse[HCP_HEADER_LEN]: 0;
1254 p_device_mgmt_info->p_val = NULL;
1258 /* Self Test Commands */
1259 case NXP_SELF_TEST_ANTENNA:
1260 case NXP_SELF_TEST_SWP:
1261 case NXP_SELF_TEST_NFCWI:
1262 case NXP_SELF_TEST_PRBS:
1264 p_device_mgmt_info->test_status = (uint8_t) ( length > HCP_HEADER_LEN ) ?
1265 pResponse[HCP_HEADER_LEN]: 0;
1266 p_device_mgmt_info->test_result.buffer = (uint8_t)( length > HCP_HEADER_LEN ) ?
1267 &pResponse[HCP_HEADER_LEN]: NULL;
1268 p_device_mgmt_info->test_result.length = ( length - HCP_HEADER_LEN );
1273 status = PHNFCSTVAL(CID_NFC_HCI,
1274 NFCSTATUS_INVALID_HCI_RESPONSE);
1278 if( NFCSTATUS_SUCCESS == status )
1280 if( NULL != p_device_mgmt_info->p_pipe_info)
1282 p_device_mgmt_info->p_pipe_info->prev_status = NFCSTATUS_SUCCESS;
1284 p_device_mgmt_info->current_seq = p_device_mgmt_info->next_seq;
1292 * \brief Receives the HCI Event from the corresponding peripheral device.
1294 * This function receives the HCI Event from the connected NFC
1295 * Peripheral device.
1300 phHciNfc_Recv_DevMgmt_Event(
1311 phHciNfc_sContext_t *psHciContext =
1312 (phHciNfc_sContext_t *)psContext ;
1313 phHciNfc_DevMgmt_Info_t *p_device_mgmt_info=NULL;
1314 phHciNfc_HCP_Packet_t *hcp_packet = NULL;
1315 phHciNfc_HCP_Message_t *hcp_message = NULL;
1316 NFCSTATUS status = NFCSTATUS_SUCCESS;
1317 phHal_sEventInfo_t event_info;
1318 uint8_t event = (uint8_t) HCP_MSG_INSTRUCTION_INVALID;
1320 if( (NULL == psHciContext) || (NULL == pHwRef) )
1322 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
1324 else if( NULL == psHciContext->p_device_mgmt_info )
1326 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
1330 p_device_mgmt_info = (phHciNfc_DevMgmt_Info_t *)
1331 psHciContext->p_device_mgmt_info ;
1332 hcp_packet = (phHciNfc_HCP_Packet_t *)pEvent;
1333 hcp_message = &hcp_packet->msg.message;
1335 /* Get the Event instruction bits from the Message Header */
1336 event = (uint8_t) GET_BITS8( hcp_message->msg_header,
1337 HCP_MSG_INSTRUCTION_OFFSET, HCP_MSG_INSTRUCTION_LEN);
1338 event_info.eventHost = phHal_eHostController ;
1339 event_info.eventSource = phHal_ePCD_DevType;
1343 /* Information Events */
1344 case NXP_EVT_INFO_TXLDO_OVERCUR:
1346 event_info.eventType = NFC_INFO_TXLDO_OVERCUR;
1349 case NXP_EVT_INFO_PMUVCC:
1351 p_device_mgmt_info->pmuvcc_status = (uint8_t) ( length > HCP_HEADER_LEN ) ?
1352 pEvent[HCP_HEADER_LEN]: 0;
1355 case NXP_EVT_INFO_EXT_RF_FIELD:
1357 event_info.eventSource = phHal_ePICC_DevType ;
1358 p_device_mgmt_info->rf_status = (uint8_t) ( length > HCP_HEADER_LEN ) ?
1359 pEvent[HCP_HEADER_LEN]: 0;
1360 #ifdef EVT_INFO_EXT_EVT_DIRECT
1361 event_info.eventType = ( CE_EVT_NFC_FIELD_ON ==
1362 (p_device_mgmt_info->rf_status & 0x1FU))?
1363 NFC_EVT_FIELD_ON : NFC_EVT_FIELD_OFF;
1365 event_info.eventType = (TRUE == p_device_mgmt_info->rf_status)?
1366 NFC_EVT_FIELD_ON : NFC_EVT_FIELD_OFF;
1370 case NXP_EVT_INFO_MEM_VIOLATION:
1372 event_info.eventType = NFC_INFO_MEM_VIOLATION;
1373 LOGW("Your NFC controller is kinda hosed, take it to npelly@ to fix");
1376 case NXP_EVT_INFO_TEMP_OVERHEAT:
1378 p_device_mgmt_info->overheat_status = (uint8_t)( length > HCP_HEADER_LEN ) ?
1379 pEvent[HCP_HEADER_LEN]: 0;
1380 event_info.eventType = NFC_INFO_TEMP_OVERHEAT;
1381 event_info.eventInfo.overheat_status =
1382 p_device_mgmt_info->overheat_status;
1385 case NXP_EVT_INFO_LLC_ERROR:
1387 event_info.eventType = NFC_INFO_LLC_ERROR;
1392 status = PHNFCSTVAL(CID_NFC_HCI,
1393 NFCSTATUS_INVALID_HCI_RESPONSE);
1397 if( NFCSTATUS_SUCCESS == status )
1399 if( NULL != p_device_mgmt_info->p_pipe_info)
1401 p_device_mgmt_info->p_pipe_info->prev_status =
1404 p_device_mgmt_info->current_seq =
1405 p_device_mgmt_info->next_seq;
1406 phHciNfc_Notify_Event(psHciContext, pHwRef,
1407 NFC_NOTIFY_EVENT, &event_info);
1416 phHciNfc_DevMgmt_InfoUpdate(
1417 phHciNfc_sContext_t *psHciContext,
1418 phHal_sHwReference_t *pHwRef,
1424 phHciNfc_DevMgmt_Info_t *p_device_mgmt_info=NULL;
1425 NFCSTATUS status = NFCSTATUS_SUCCESS;
1428 PHNFC_UNUSED_VARIABLE(pHwRef);
1429 if( (NULL == psHciContext)
1430 || (NULL == reg_value)
1431 || (reg_length == 0)
1434 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
1436 else if ( NULL == psHciContext->p_device_mgmt_info )
1438 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION);
1442 p_device_mgmt_info = (phHciNfc_DevMgmt_Info_t *)
1443 psHciContext->p_device_mgmt_info ;
1447 case DEVICE_INFO_EEPROM_INDEX:
1449 p_device_mgmt_info->eeprom_crc = reg_value[i];
1458 } /* End of Context and the PN544 Device information validity check */
1466 * \brief Sends the RF Settings HCI Additonal Commands to the connected
1469 * This function Sends the RF Settings HCI Command frames in the HCP packet
1470 * format to the connected reader device.
1474 phHciNfc_Send_DevMgmt_Command (
1475 phHciNfc_sContext_t *psHciContext,
1481 phHciNfc_HCP_Packet_t *hcp_packet = NULL;
1482 phHciNfc_HCP_Message_t *hcp_message = NULL;
1483 phHciNfc_Pipe_Info_t *p_pipe_info = NULL;
1486 NFCSTATUS status = NFCSTATUS_SUCCESS;
1488 if( (NULL == psHciContext)
1489 || ( pipe_id > PHHCINFC_MAX_PIPE)
1490 ||(NULL == psHciContext->p_pipe_list[pipe_id])
1493 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
1494 HCI_DEBUG("%s: Invalid Arguments passed \n",
1495 "phHciNfc_Send_DevMgmt_Command");
1499 p_pipe_info = (phHciNfc_Pipe_Info_t *)
1500 psHciContext->p_pipe_list[pipe_id];
1501 psHciContext->tx_total = 0 ;
1502 length += HCP_HEADER_LEN ;
1505 /* Self Test Commands */
1506 case NXP_SELF_TEST_ANTENNA:
1507 case NXP_SELF_TEST_SWP:
1508 case NXP_SELF_TEST_NFCWI:
1509 case NXP_SELF_TEST_PRBS:
1510 /* Internal Properietary Commands */
1515 hcp_packet = (phHciNfc_HCP_Packet_t *) psHciContext->send_buffer;
1516 /* Construct the HCP Frame */
1517 phHciNfc_Build_HCPFrame(hcp_packet,HCP_CHAINBIT_DEFAULT,
1518 (uint8_t) pipe_id, HCP_MSG_TYPE_COMMAND, cmd);
1519 hcp_message = &(hcp_packet->msg.message);
1520 /* Append the RF Setting Parameter also the optional Value */
1521 phHciNfc_Append_HCPFrame((uint8_t *)hcp_message->payload,
1522 i, p_pipe_info->param_info,
1523 p_pipe_info->param_length);
1524 length =(uint8_t)(length + i + p_pipe_info->param_length);
1529 status = PHNFCSTVAL( CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED );
1530 HCI_DEBUG("%s: Statement Should Not Occur \n",
1531 "phHciNfc_Send_DevMgmt_Command");
1535 if( NFCSTATUS_SUCCESS == status )
1537 p_pipe_info->sent_msg_type = HCP_MSG_TYPE_COMMAND;
1538 p_pipe_info->prev_msg = cmd;
1539 psHciContext->tx_total = length;
1540 psHciContext->response_pending = TRUE ;
1542 /* Send the Constructed HCP packet to the lower layer */
1543 status = phHciNfc_Send_HCP( psHciContext, pHwRef );
1544 p_pipe_info->prev_status = NFCSTATUS_PENDING;
1554 * \brief Sends the RF Settings HCI Additonal Events to the connected
1557 * This function Sends the RF Settings HCI Events frames in the HCP packet
1558 * format to the connected reader device.
1563 phHciNfc_Send_DevMgmt_Event (
1564 phHciNfc_sContext_t *psHciContext,
1570 phHciNfc_HCP_Packet_t *hcp_packet = NULL;
1571 phHciNfc_HCP_Message_t *hcp_message = NULL;
1572 phHciNfc_Pipe_Info_t *p_pipe_info = NULL;
1575 NFCSTATUS status = NFCSTATUS_SUCCESS;
1577 if( (NULL == psHciContext)
1578 || ( pipe_id > PHHCINFC_MAX_PIPE)
1579 ||(NULL == psHciContext->p_pipe_list[pipe_id])
1582 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
1583 HCI_DEBUG("%s: Invalid Arguments passed \n",
1584 "phHciNfc_Send_DevMgmt_Event");
1588 p_pipe_info = (phHciNfc_Pipe_Info_t *)
1589 psHciContext->p_pipe_list[pipe_id];
1590 psHciContext->tx_total = 0 ;
1591 length += HCP_HEADER_LEN ;
1592 if( NXP_EVT_SET_AUTONOMOUS == event )
1595 hcp_packet = (phHciNfc_HCP_Packet_t *) psHciContext->send_buffer;
1596 /* Construct the HCP Frame */
1597 phHciNfc_Build_HCPFrame(hcp_packet,HCP_CHAINBIT_DEFAULT,
1598 (uint8_t) pipe_id, HCP_MSG_TYPE_EVENT, event);
1599 hcp_message = &(hcp_packet->msg.message);
1600 /* Append the RF Setting Parameter also the optional Value */
1601 phHciNfc_Append_HCPFrame((uint8_t *)hcp_message->payload,
1602 i, p_pipe_info->param_info,
1603 p_pipe_info->param_length);
1604 length =(uint8_t)(length + i + p_pipe_info->param_length);
1608 status = PHNFCSTVAL( CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED );
1609 HCI_DEBUG("%s: Statement Should Not Occur \n",
1610 "phHciNfc_Send_DevMgmt_Event");
1612 if( NFCSTATUS_SUCCESS == status )
1614 p_pipe_info->sent_msg_type = HCP_MSG_TYPE_EVENT;
1615 p_pipe_info->prev_msg = event;
1616 psHciContext->tx_total = length;
1618 /* Send the Constructed HCP packet to the lower layer */
1619 status = phHciNfc_Send_HCP( psHciContext, pHwRef );
1620 p_pipe_info->prev_status = NFCSTATUS_PENDING;