[Mod] 更新至版本:NxpNfcRdLib_Linux_v07.10.00_PUB
This commit is contained in:
123
Examples/Nfcrdlib_SimplifiedAPI_ISO/src/phApp_PN7462AU_Init.c
Normal file
123
Examples/Nfcrdlib_SimplifiedAPI_ISO/src/phApp_PN7462AU_Init.c
Normal file
@ -0,0 +1,123 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright 2020 NXP */
|
||||
/* */
|
||||
/* NXP Confidential. This software is owned or controlled by NXP and may only */
|
||||
/* be used strictly in accordance with the applicable license terms. */
|
||||
/* By expressly accepting such terms or by downloading, installing, */
|
||||
/* activating and/or otherwise using the software, you are agreeing that you */
|
||||
/* have read, and that you agree to comply with and are bound by, such */
|
||||
/* license terms. If you do not agree to be bound by the applicable license */
|
||||
/* terms, then you may not retain, install, activate or otherwise use the */
|
||||
/* software. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \file
|
||||
* Example Source abstracting component data structure and code initialization and code specific to HW used in the examples
|
||||
* This file shall be present in all examples. A customer does not need to touch/modify this file. This file
|
||||
* purely depends on the phNxpBuild_Lpc.h or phNxpBuild_App.h
|
||||
* The phAppInit.h externs the component data structures initialized here that is in turn included by the core examples.
|
||||
* The core example shall not use any other variable defined here except the RdLib component data structures(as explained above)
|
||||
* The RdLib component initialization requires some user defined data and function pointers.
|
||||
* These are defined in the respective examples and externed here.
|
||||
*
|
||||
* Keystore and Crypto initialization needs to be handled by application.
|
||||
*
|
||||
* $Author$
|
||||
* $Revision$ (v07.10.00)
|
||||
* $Date$
|
||||
*
|
||||
*/
|
||||
|
||||
/* Status header */
|
||||
#include <ph_Status.h>
|
||||
|
||||
#include "phApp_Init.h"
|
||||
|
||||
#ifdef NXPBUILD__PHHAL_HW_PN7462AU
|
||||
|
||||
#include <phOsal.h>
|
||||
|
||||
#include <phFlashBoot.h>
|
||||
#include <phhalTimer.h>
|
||||
|
||||
/*******************************************************************************
|
||||
** Function Declarations
|
||||
*******************************************************************************/
|
||||
void phApp_CPU_Init(void);
|
||||
|
||||
/*******************************************************************************
|
||||
** Global Variable Declaration
|
||||
*******************************************************************************/
|
||||
phhalHw_PN7462AU_DataParams_t * pHal;
|
||||
|
||||
#ifdef NXPBUILD__PHHAL_HW_TARGET
|
||||
/* Parameters for L3 activation during Autocoll */
|
||||
extern uint8_t sens_res[2] ;
|
||||
extern uint8_t nfc_id1[3] ;
|
||||
extern uint8_t sel_res ;
|
||||
extern uint8_t nfc_id3 ;
|
||||
extern uint8_t poll_res[18] ;
|
||||
#endif /* NXPBUILD__PHHAL_HW_TARGET */
|
||||
|
||||
/*******************************************************************************
|
||||
** Function Definitions
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* This function will initialize NXP NFC Controller.
|
||||
*/
|
||||
void phApp_CPU_Init(void)
|
||||
{
|
||||
phFlashBoot_Main();
|
||||
|
||||
phhalTimer_Init();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will initialize Hal Target Config
|
||||
*/
|
||||
phStatus_t phApp_HALConfigAutoColl(void)
|
||||
{
|
||||
#ifdef NXPBUILD__PHHAL_HW_TARGET
|
||||
phStatus_t wStatus;
|
||||
uint8_t bSystemCode[] = {0xFF, 0xFF};
|
||||
|
||||
/* Set Listen Parameters in HAL Buffer used during Autocoll */
|
||||
wStatus = phhalHw_PN7462AU_SetListenParam(
|
||||
pHal,
|
||||
&sens_res[0],
|
||||
&nfc_id1[0],
|
||||
sel_res,
|
||||
(poll_res[0] == 0x02 ? PH_ON : PH_OFF),
|
||||
&poll_res[2],
|
||||
&poll_res[8],
|
||||
bSystemCode);
|
||||
CHECK_SUCCESS(wStatus);
|
||||
#endif /* NXPBUILD__PHHAL_HW_TARGET */
|
||||
|
||||
return PH_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
/* Configure LPCD (for PN7462AU) */
|
||||
phStatus_t phApp_ConfigureLPCD(void)
|
||||
{
|
||||
phStatus_t status;
|
||||
uint16_t wLpcdValue;
|
||||
|
||||
wLpcdValue = 0;
|
||||
|
||||
status = phhalHw_GetConfig(pHal, PHHAL_HW_CONFIG_PN7462AU_LPCD_NEW_VALUE, &wLpcdValue);
|
||||
CHECK_SUCCESS(status);
|
||||
|
||||
if (wLpcdValue != 0x00)
|
||||
{
|
||||
status = phhalHw_SetConfig(pHal, PHHAL_HW_CONFIG_PN7462AU_LPCD_REF_VALUE, wLpcdValue);
|
||||
CHECK_SUCCESS(status);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
#endif /* NXPBUILD__PHHAL_HW_PN7462AU */
|
||||
|
||||
/******************************************************************************
|
||||
** End Of File
|
||||
******************************************************************************/
|
||||
195
Examples/Nfcrdlib_SimplifiedAPI_ISO/src/phApp_PN76XX_Init.c
Normal file
195
Examples/Nfcrdlib_SimplifiedAPI_ISO/src/phApp_PN76XX_Init.c
Normal file
@ -0,0 +1,195 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright 2021-2023 NXP */
|
||||
/* */
|
||||
/* NXP Confidential. This software is owned or controlled by NXP and may only */
|
||||
/* be used strictly in accordance with the applicable license terms. */
|
||||
/* By expressly accepting such terms or by downloading, installing, */
|
||||
/* activating and/or otherwise using the software, you are agreeing that you */
|
||||
/* have read, and that you agree to comply with and are bound by, such */
|
||||
/* license terms. If you do not agree to be bound by the applicable license */
|
||||
/* terms, then you may not retain, install, activate or otherwise use the */
|
||||
/* software. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \file
|
||||
* Example Source abstracting component data structure and code initialization and code specific to HW used in the examples
|
||||
* This file shall be present in all examples. A customer does not need to touch/modify this file. This file
|
||||
* purely depends on the phNxpBuild_Lpc.h or phNxpBuild_App.h
|
||||
* The phAppInit.h externs the component data structures initialized here that is in turn included by the core examples.
|
||||
* The core example shall not use any other variable defined here except the RdLib component data structures(as explained above)
|
||||
* The RdLib component initialization requires some user defined data and function pointers.
|
||||
* These are defined in the respective examples and externed here.
|
||||
*
|
||||
* Keystore and Crypto initialization needs to be handled by application.
|
||||
*
|
||||
* $Author: NXP $
|
||||
* $Revision: $ (v07.10.00)
|
||||
* $Date: $
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ph_Status.h>
|
||||
|
||||
#include "phApp_Init.h"
|
||||
|
||||
#ifdef NXPBUILD__PHHAL_HW_PN76XX
|
||||
#include "phOsal.h"
|
||||
|
||||
#include "PN76xx.h"
|
||||
|
||||
#include "PN76_Eeprom.h"
|
||||
#include "Clif.h"
|
||||
|
||||
/*********************************************************************************************************************/
|
||||
/* LOCAL DEFINES */
|
||||
/*********************************************************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
** Function Declarations
|
||||
*******************************************************************************/
|
||||
void phApp_CPU_Init(void);
|
||||
|
||||
/*******************************************************************************
|
||||
** Global Variable Declaration
|
||||
*******************************************************************************/
|
||||
phhalHw_Pn76xx_DataParams_t * pHal;
|
||||
|
||||
#ifdef NXPBUILD__PHHAL_HW_TARGET
|
||||
/* Parameters for L3 activation during Autocoll */
|
||||
extern uint8_t sens_res[2U] ;
|
||||
extern uint8_t nfc_id1[3U] ;
|
||||
extern uint8_t sel_res ;
|
||||
extern uint8_t nfc_id3 ;
|
||||
extern uint8_t poll_res[18U] ;
|
||||
#endif /* NXPBUILD__PHHAL_HW_TARGET */
|
||||
|
||||
/*******************************************************************************
|
||||
** Function Definitions
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
* This function will initialize NXP NFC Controller.
|
||||
*/
|
||||
void phApp_CPU_Init(void)
|
||||
{
|
||||
#ifdef SEGGER_RTT_ENABLE
|
||||
/* SEGGER RTT Init */
|
||||
memset((uint8_t *)PN76_SEGGER_RTT_MEMORY_ALLOCATION_ADDRESS, 0, 0x4b8);
|
||||
SEGGER_RTT_ConfigUpBuffer(0, NULL, NULL, 0, SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL);
|
||||
#endif
|
||||
/* To enable NS RF IRQ */
|
||||
NVIC_EnableIRQ(CLIF_RF_IRQn);
|
||||
|
||||
/* To enable NS TIMER IRQ */
|
||||
NVIC_EnableIRQ(TIMER_IRQn);
|
||||
|
||||
/* Initialize PMU */
|
||||
PMU_Init();
|
||||
|
||||
/* Initialize SMU */
|
||||
Smu_Init();
|
||||
|
||||
/* Initialize CLKGEN */
|
||||
CLKGEN_Init();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will initialize Hal Target Config
|
||||
*/
|
||||
phStatus_t phApp_HALConfigAutoColl(void)
|
||||
{
|
||||
#ifdef NXPBUILD__PHHAL_HW_TARGET
|
||||
phStatus_t wStatus;
|
||||
uint8_t baDynamicUidConfig[1U] = { 1U }; /* Enable Dynamic UID feature on PN76XX. */
|
||||
uint8_t baReadEepromConfig[24U] = { 0U };
|
||||
|
||||
/* Read Set Listen Parameters data from EEPROM */
|
||||
wStatus = (PN76_Status_t)PN76_ReadEeprom(
|
||||
baReadEepromConfig,
|
||||
PHHAL_HW_PN76XX_SET_LISTEN_EEPROM_ADDR,
|
||||
PHHAL_HW_PN76XX_SET_LISTEN_LEN
|
||||
#ifdef NXPBUILD__PHHAL_HW_PN7642
|
||||
, E_PN76_EEPROM_SECURE_LIB_CONFIG
|
||||
#endif /* NXPBUILD__PHHAL_HW_PN7642 */
|
||||
);
|
||||
CHECK_SUCCESS(wStatus);
|
||||
|
||||
/* Verify EEPROM data and configure Set Listen Parameters if EEPROM data is not correct. */
|
||||
if ((memcmp(&baReadEepromConfig[0U], sens_res, 2U) != 0x00) ||
|
||||
(memcmp(&baReadEepromConfig[2U], nfc_id1, 3U) != 0x00) ||
|
||||
(memcmp(&baReadEepromConfig[5U], &sel_res, 1U) != 0x00) ||
|
||||
(memcmp(&baReadEepromConfig[6U], poll_res, 18U) != 0x00))
|
||||
{
|
||||
/* Configure Set Listen Parameters. */
|
||||
wStatus = phhalHw_Pn76xx_SetListenParameters(
|
||||
pHal,
|
||||
&sens_res[0],
|
||||
&nfc_id1[0],
|
||||
sel_res,
|
||||
&poll_res[0],
|
||||
nfc_id3);
|
||||
CHECK_SUCCESS(wStatus);
|
||||
}
|
||||
|
||||
/* Read Dynamic UID configuration from EEPROM */
|
||||
wStatus = (PN76_Status_t)PN76_ReadEeprom(
|
||||
baReadEepromConfig,
|
||||
PHHAL_HW_PN76XX_DYNAMIC_UID_CONFG_ADDR,
|
||||
0x01U
|
||||
#ifdef NXPBUILD__PHHAL_HW_PN7642
|
||||
, E_PN76_EEPROM_SECURE_LIB_CONFIG
|
||||
#endif /* NXPBUILD__PHHAL_HW_PN7642 */
|
||||
);
|
||||
CHECK_SUCCESS(wStatus);
|
||||
|
||||
/* Verify EEPROM data and perform Dynamic UID configuration if EEPROM data is not correct. */
|
||||
if (baReadEepromConfig[0] != baDynamicUidConfig[0])
|
||||
{
|
||||
/* Configure Dynamic UID */
|
||||
wStatus = PN76_WriteEeprom(
|
||||
baDynamicUidConfig,
|
||||
PHHAL_HW_PN76XX_DYNAMIC_UID_CONFG_ADDR,
|
||||
0x01
|
||||
#ifdef NXPBUILD__PHHAL_HW_PN7642
|
||||
, E_PN76_EEPROM_SECURE_LIB_CONFIG
|
||||
#endif /* NXPBUILD__PHHAL_HW_PN7642 */
|
||||
);
|
||||
CHECK_SUCCESS(wStatus);
|
||||
}
|
||||
#endif /* NXPBUILD__PHHAL_HW_TARGET */
|
||||
return PH_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
/* Configure LPCD (for PN76XX) */
|
||||
phStatus_t phApp_ConfigureLPCD(void)
|
||||
{
|
||||
#ifdef NXPBUILD__PHHAL_HW_PN7642
|
||||
phStatus_t status = PH_ERR_SUCCESS;
|
||||
|
||||
status = phhalHw_Pn76xx_LPCD_SetConfig(pHal, PHHAL_HW_CONFIG_SET_LPCD_WAKEUPTIME_MS, 100U);
|
||||
CHECK_SUCCESS(status);
|
||||
|
||||
status = phhalHw_Pn76xx_LPCD_SetConfig(pHal, PHHAL_HW_CONFIG_LPCD_MODE, PHHAL_HW_PN76XX_LPCD_MODE_DEFAULT);
|
||||
CHECK_SUCCESS(status);
|
||||
|
||||
status = phhalHw_Lpcd(pHal);
|
||||
CHECK_SUCCESS(status);
|
||||
|
||||
status = phhalHw_Pn76xx_LPCD_SetConfig(pHal, PHHAL_HW_CONFIG_SET_LPCD_WAKEUPTIME_MS, 330U);
|
||||
CHECK_SUCCESS(status);
|
||||
|
||||
status = phhalHw_Pn76xx_LPCD_SetConfig(pHal, PHHAL_HW_CONFIG_LPCD_MODE, PHHAL_HW_PN76XX_LPCD_MODE_POWERDOWN);
|
||||
CHECK_SUCCESS(status);
|
||||
|
||||
return status;
|
||||
#endif /* NXPBUILD__PHHAL_HW_PN7642 */
|
||||
|
||||
#ifdef NXPBUILD__PHHAL_HW_PN7640
|
||||
return PH_ERR_UNSUPPORTED_COMMAND;
|
||||
#endif /* NXPBUILD__PHHAL_HW_PN7640 */
|
||||
}
|
||||
#endif /* NXPBUILD__PHHAL_HW_PN76XX */
|
||||
|
||||
/******************************************************************************
|
||||
** End Of File
|
||||
******************************************************************************/
|
||||
107
Examples/Nfcrdlib_SimplifiedAPI_ISO/src/phApp_RC663_Init.c
Normal file
107
Examples/Nfcrdlib_SimplifiedAPI_ISO/src/phApp_RC663_Init.c
Normal file
@ -0,0 +1,107 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright 2020 NXP */
|
||||
/* */
|
||||
/* NXP Confidential. This software is owned or controlled by NXP and may only */
|
||||
/* be used strictly in accordance with the applicable license terms. */
|
||||
/* By expressly accepting such terms or by downloading, installing, */
|
||||
/* activating and/or otherwise using the software, you are agreeing that you */
|
||||
/* have read, and that you agree to comply with and are bound by, such */
|
||||
/* license terms. If you do not agree to be bound by the applicable license */
|
||||
/* terms, then you may not retain, install, activate or otherwise use the */
|
||||
/* software. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \file
|
||||
* Example Source abstracting component data structure and code initialization and code specific to HW used in the examples
|
||||
* This file shall be present in all examples. A customer does not need to touch/modify this file. This file
|
||||
* purely depends on the phNxpBuild_Lpc.h or phNxpBuild_App.h
|
||||
* The phAppInit.h externs the component data structures initialized here that is in turn included by the core examples.
|
||||
* The core example shall not use any other variable defined here except the RdLib component data structures(as explained above)
|
||||
* The RdLib component initialization requires some user defined data and function pointers.
|
||||
* These are defined in the respective examples and externed here.
|
||||
*
|
||||
* Keystore and Crypto initialization needs to be handled by application.
|
||||
*
|
||||
* $Author$
|
||||
* $Revision$ (v07.10.00)
|
||||
* $Date$
|
||||
*
|
||||
*/
|
||||
|
||||
/* Status header */
|
||||
#include <ph_Status.h>
|
||||
|
||||
#include "phApp_Init.h"
|
||||
|
||||
#ifdef NXPBUILD__PHHAL_HW_RC663
|
||||
|
||||
#include "BoardSelection.h"
|
||||
/*******************************************************************************
|
||||
** Function Declarations
|
||||
*******************************************************************************/
|
||||
|
||||
#ifdef PH_PLATFORM_HAS_ICFRONTEND
|
||||
void CLIF_IRQHandler(void);
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
** Global Variable Declaration
|
||||
*******************************************************************************/
|
||||
phbalReg_Type_t sBalParams;
|
||||
phhalHw_Rc663_DataParams_t * pHal;
|
||||
|
||||
/*******************************************************************************
|
||||
** Function Definitions
|
||||
*******************************************************************************/
|
||||
|
||||
/* Configure LPCD (for CLRC663) */
|
||||
phStatus_t phApp_ConfigureLPCD(void)
|
||||
{
|
||||
phStatus_t status;
|
||||
uint8_t bValueI;
|
||||
uint8_t bValueQ;
|
||||
|
||||
/* Configure LPCD calibration standby time (T4) and RF ON time (T3). */
|
||||
status = phhalHw_Rc663_Cmd_Lpcd_SetConfig(
|
||||
pHal,
|
||||
PHHAL_HW_RC663_CMD_LPCD_MODE_DEFAULT,
|
||||
0,
|
||||
0,
|
||||
PH_NFCRDLIB_EXAMPLE_LPCD_GUARDTIME,
|
||||
PH_NFCRDLIB_EXAMPLE_LPCD_RFON_TIME);
|
||||
|
||||
/* Perform LPCD calibration to get I and Q values. */
|
||||
status = phhalHw_Rc663_Cmd_Lpcd_GetConfig(pHal, &bValueI, &bValueQ);
|
||||
CHECK_SUCCESS(status);
|
||||
|
||||
/* Configure I and Q values for LPCD detection cycle. */
|
||||
status = phhalHw_Rc663_Cmd_Lpcd_SetConfig(
|
||||
pHal,
|
||||
PHHAL_HW_RC663_CMD_LPCD_MODE_POWERDOWN,
|
||||
bValueI,
|
||||
bValueQ,
|
||||
PH_NFCRDLIB_EXAMPLE_LPCD_GUARDTIME,
|
||||
PH_NFCRDLIB_EXAMPLE_LPCD_RFON_TIME);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void CLIF_IRQHandler(void)
|
||||
{
|
||||
/* Read the interrupt status of external interrupt attached to the reader IC IRQ pin */
|
||||
if (phDriver_PinRead(PHDRIVER_PIN_IRQ, PH_DRIVER_PINFUNC_INTERRUPT))
|
||||
{
|
||||
phDriver_PinClearIntStatus(PHDRIVER_PIN_IRQ);
|
||||
|
||||
/* Call application registered callback. */
|
||||
if (pHal->pRFISRCallback != NULL)
|
||||
{
|
||||
pHal->pRFISRCallback(pHal);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* NXPBUILD__PHHAL_HW_RC663 */
|
||||
|
||||
/******************************************************************************
|
||||
** End Of File
|
||||
******************************************************************************/
|
||||
Reference in New Issue
Block a user