Thank you for your reply, I have already initiated the spi channel:
RESET_PeripheralReset(kHSLSPI_RST_SHIFT_RSTn);
const spi_master_config_t FC8_SPI_NFC_config = {
.enableLoopback = false,
.enableMaster = true,
.polarity = kSPI_ClockPolarityActiveHigh,
.phase = kSPI_ClockPhaseFirstEdge,
.direction = kSPI_MsbFirst,
.baudRate_Bps = 1200000UL,
.dataWidth = kSPI_Data8Bits,
.sselNum = kSPI_Ssel0,
.sselPol = kSPI_SpolActiveAllLow,
.txWatermark = kSPI_TxFifo0,
.rxWatermark = kSPI_RxFifo1,
.delayConfig = {
.preDelay = 0U,
.postDelay = 0U,
.frameDelay = 0U,
.transferDelay = 0U
}
};
static void FC8_SPI_NFC_init(void) {
/* Initialization function */
SPI_MasterInit(FC8_SPI_NFC_PERIPHERAL, &FC8_SPI_NFC_config, FC8_SPI_NFC_CLOCK_SOURCE);
}
I can read out the pn5190 firmware version via spi using the library function as below:
phhalHw_Pn5190_Version_t _pVersion;
status = phhalHw_Pn5190_Instr_GetVersion(
&gphNfcLib_Params.sHal, /**< [In] Pointer to this layer's parameter structure. */
&_pVersion /**< [InOut] structure pointer for, 4 byte Version Information read from PN5190. */
);
if(status == PH_ERR_SUCCESS)
{
PRINTF("phhalHw_Pn5190_Instr_GetVersion bHw_Version %x bROM_Version %x wFW_Version %x\n", _pVersion.bHw_Version, _pVersion.bROM_Version, _pVersion.wFW_Version);
}else
{
PRINTF("phhalHw_Pn5190_Instr_GetVersion %x\n",status);
return 1;
}
=>> GOT: phhalHw_Pn5190_Instr_GetVersion bHw_Version 52 bROM_Version 2 wFW_Version 205
I think the problem is the phbalReg_Exchange. This is the original one from the library for LCP1769:
phStatus_t phbalReg_Exchange(
void * pDataParams,
uint16_t wOption,
uint8_t * pTxBuffer,
uint16_t wTxLength,
uint16_t wRxBufSize,
uint8_t * pRxBuffer,
uint16_t * pRxLength
)
{
uint16_t xferLen;
Chip_SSP_DATA_SETUP_T xferConfig;
xferConfig.length = wTxLength;
xferConfig.rx_data = pRxBuffer;
xferConfig.tx_data = pTxBuffer;
xferConfig.rx_cnt = 0;
xferConfig.tx_cnt = 0;
/* data exchange */
if ( wRxBufSize == 0 )
{
Chip_SSP_WriteFrames_Blocking(LPC_SSP, pTxBuffer, wTxLength);
xferLen = wTxLength; /* Fake as a full duplex */
}
else
{
if ( wTxLength == 0 )
{
xferLen = Chip_SSP_ReadFrames_Blocking(LPC_SSP, pRxBuffer, wRxBufSize);
}
else
{
xferLen = Chip_SSP_RWFrames_Blocking(LPC_SSP, &xferConfig);
}
}
if ( wTxLength !=0 && wRxBufSize != 0 )
{
if (xferLen != wTxLength)
{
return (PH_DRIVER_FAILURE | PH_COMP_DRIVER);
}
}
if ( pRxLength != NULL)
*pRxLength = xferLen;
return PH_DRIVER_SUCCESS;
}
Could you check if my porting code is correct?