phStatus_t phalMfc_Int_Value( void * pPalMifareDataParams, uint8_t bCmdCode, uint8_t bBlockNo, uint8_t * pValue ) { phStatus_t PH_MEMLOC_REM status; phStatus_t PH_MEMLOC_REM statusTmp; uint8_t PH_MEMLOC_REM aCommand[2]; uint8_t * PH_MEMLOC_REM pRxBuffer; uint16_t PH_MEMLOC_REM wRxLength; /* build command frame */ aCommand[0] = bCmdCode; aCommand[1] = bBlockNo; /* transmit the command frame (first part) */ PH_CHECK_SUCCESS_FCT(statusTmp, phpalMifare_ExchangeL3( pPalMifareDataParams, PH_EXCHANGE_DEFAULT, aCommand, 2, &pRxBuffer, &wRxLength )); /* transmit the data (second part) */ status = phpalMifare_ExchangeL3( pPalMifareDataParams, PH_EXCHANGE_DEFAULT, pValue, PHAL_MFC_VALUE_BLOCK_LENGTH, &pRxBuffer, &wRxLength ); /* there should be no response in case of successful operation */ if ((status & PH_ERR_MASK) != PH_ERR_IO_TIMEOUT) { /* Resolve NAK Code */ PH_CHECK_SUCCESS(status); /* ACK means protocol error */ return PH_ADD_COMPCODE(PH_ERR_PROTOCOL_ERROR, PH_COMP_AL_MFC); } return PH_ADD_COMPCODE(PH_ERR_SUCCESS, PH_COMP_AL_MFC); }
phStatus_t phalMful_Int_CompatibilityWrite( void * pPalMifareDataParams, uint8_t bAddress, uint8_t * pData ) { phStatus_t PH_MEMLOC_REM status; phStatus_t PH_MEMLOC_REM statusTmp; uint8_t PH_MEMLOC_REM bCommand[2]; uint8_t * PH_MEMLOC_REM pRxBuffer; uint16_t PH_MEMLOC_REM wRxLength; /* build command frame */ bCommand[0] = PHAL_MFUL_CMD_COMPWRITE; bCommand[1] = bAddress; /* send the first part */ status = phpalMifare_ExchangeL3( pPalMifareDataParams, PH_EXCHANGE_DEFAULT, bCommand, 2, &pRxBuffer, &wRxLength); /* Either ACK (newer UL cards) or TO (older UL cards) is expected */ if ((status & PH_ERR_MASK) != PH_ERR_IO_TIMEOUT) { PH_CHECK_SUCCESS(status); } /* buffer the data */ PH_CHECK_SUCCESS_FCT(statusTmp, phpalMifare_ExchangeL3( pPalMifareDataParams, PH_EXCHANGE_DEFAULT, pData, PHAL_MFUL_COMPWRITE_BLOCK_LENGTH, &pRxBuffer, &wRxLength)); return PH_ADD_COMPCODE(PH_ERR_SUCCESS, PH_COMP_AL_MFUL); }
phStatus_t phalMful_Int_Write( void * pPalMifareDataParams, uint8_t bAddress, uint8_t * pData ) { phStatus_t PH_MEMLOC_REM statusTmp; uint8_t PH_MEMLOC_REM bCommand[2]; uint8_t * PH_MEMLOC_REM pRxBuffer; uint16_t PH_MEMLOC_REM wRxLength; /* build command frame */ bCommand[0] = PHAL_MFUL_CMD_WRITE; bCommand[1] = bAddress; /* buffer the command frame */ PH_CHECK_SUCCESS_FCT(statusTmp, phpalMifare_ExchangeL3( pPalMifareDataParams, PH_EXCHANGE_BUFFER_FIRST, bCommand, 2, &pRxBuffer, &wRxLength )); /* transmit the data */ PH_CHECK_SUCCESS_FCT(statusTmp, phpalMifare_ExchangeL3( pPalMifareDataParams, PH_EXCHANGE_BUFFER_LAST, pData, PHAL_MFUL_WRITE_BLOCK_LENGTH, &pRxBuffer, &wRxLength )); return PH_ADD_COMPCODE(PH_ERR_SUCCESS, PH_COMP_AL_MFUL); }
phStatus_t phalMfc_Sw_Write( phalMfc_Sw_DataParams_t * pDataParams, uint8_t bBlockNo, uint8_t * pBlockData ) { phStatus_t PH_MEMLOC_REM statusTmp; uint8_t PH_MEMLOC_REM aCommand[2]; uint8_t * PH_MEMLOC_REM pRxBuffer; uint16_t PH_MEMLOC_REM wRxLength; /* build command frame */ aCommand[0] = PHAL_MFC_CMD_WRITE; aCommand[1] = bBlockNo; /* transmit the command frame (first part) */ PH_CHECK_SUCCESS_FCT(statusTmp, phpalMifare_ExchangeL3( pDataParams->pPalMifareDataParams, PH_EXCHANGE_DEFAULT, aCommand, 2, &pRxBuffer, &wRxLength )); /* transmit the data (second part) */ PH_CHECK_SUCCESS_FCT(statusTmp, phpalMifare_ExchangeL3( pDataParams->pPalMifareDataParams, PH_EXCHANGE_DEFAULT, pBlockData, PHAL_MFC_DATA_BLOCK_LENGTH, &pRxBuffer, &wRxLength )); return PH_ADD_COMPCODE(PH_ERR_SUCCESS, PH_COMP_AL_MFC); }
phStatus_t phalMfc_Int_Transfer( void * pPalMifareDataParams, uint8_t bBlockNo ) { uint8_t PH_MEMLOC_REM aCommand[2]; uint8_t * PH_MEMLOC_REM pRxBuffer; uint16_t PH_MEMLOC_REM wRxLength; /* build command frame */ aCommand[0] = PHAL_MFC_CMD_TRANSFER; aCommand[1] = bBlockNo; /* transmit the command frame */ return phpalMifare_ExchangeL3( pPalMifareDataParams, PH_EXCHANGE_DEFAULT, aCommand, 2, &pRxBuffer, &wRxLength ); }
phStatus_t phalMfc_Sw_PersonalizeUid( phalMfc_Sw_DataParams_t * pDataParams, uint8_t bUidType ) { uint8_t PH_MEMLOC_REM aCommand[2]; uint8_t PH_MEMLOC_REM * pRecv; uint16_t PH_MEMLOC_REM wRxlen; /* build command frame */ aCommand[0] = PHAL_MFC_CMD_PERSOUID; aCommand[1] = bUidType; /* transmit the command frame */ return phpalMifare_ExchangeL3( pDataParams->pPalMifareDataParams, PH_EXCHANGE_DEFAULT, aCommand, 2, &pRecv, &wRxlen ); }
phStatus_t phalMful_Int_Read( void * pPalMifareDataParams, uint8_t bAddress, uint8_t * pData ) { phStatus_t PH_MEMLOC_REM statusTmp; uint8_t PH_MEMLOC_REM bCommand[2]; uint8_t * PH_MEMLOC_REM pRxBuffer; uint16_t PH_MEMLOC_REM wRxLength; /* build command frame */ bCommand[0] = PHAL_MFUL_CMD_READ; bCommand[1] = bAddress; /* transmit the command frame */ PH_CHECK_SUCCESS_FCT(statusTmp, phpalMifare_ExchangeL3( pPalMifareDataParams, PH_EXCHANGE_DEFAULT, bCommand, 2, &pRxBuffer, &wRxLength )); /* check received length */ if (wRxLength != PHAL_MFUL_READ_BLOCK_LENGTH) { return PH_ADD_COMPCODE(PH_ERR_PROTOCOL_ERROR, PH_COMP_AL_MFUL); } /* copy received data block */ memcpy(pData, pRxBuffer, wRxLength); /* PRQA S 3200 */ return PH_ADD_COMPCODE(PH_ERR_SUCCESS, PH_COMP_AL_MFUL); }
phStatus_t phalMfc_Sw_Read( phalMfc_Sw_DataParams_t * pDataParams, uint8_t bBlockNo, uint8_t * pBlockData ) { phStatus_t PH_MEMLOC_REM statusTmp; uint8_t PH_MEMLOC_REM aCommand[2]; uint8_t * PH_MEMLOC_REM pRxBuffer; uint16_t PH_MEMLOC_REM wRxLength; /* build command frame */ aCommand[0] = PHAL_MFC_CMD_READ; aCommand[1] = bBlockNo; /* transmit the command frame */ PH_CHECK_SUCCESS_FCT(statusTmp, phpalMifare_ExchangeL3( pDataParams->pPalMifareDataParams, PH_EXCHANGE_DEFAULT, aCommand, 2, &pRxBuffer, &wRxLength )); /* check received length */ if (wRxLength != PHAL_MFC_DATA_BLOCK_LENGTH) { return PH_ADD_COMPCODE(PH_ERR_PROTOCOL_ERROR, PH_COMP_AL_MFC); } /* copy received data block */ memcpy(pBlockData, pRxBuffer, wRxLength); /* PRQA S 3200 */ return PH_ADD_COMPCODE(PH_ERR_SUCCESS, PH_COMP_AL_MFC); }