NXP NFC Reader Library v4.040.05.011646

Data Structures | Typedefs | Enumerations | Functions
Tools
Common

This component implements tools that are necessary for many different software modules. More...

Collaboration diagram for Tools:

## Data Structures
struct | phTools_Q
| Queue structure of Message Queue. More...

## Typedefs
typedef struct phTools_Q | phTools_Q_t
| Queue structure of Message Queue.

## Enumerations
enum | phTools_Q_Type_t { PH_TOOLS_Q_DATA_TO_BE_SENT = 0x01, PH_TOOLS_Q_RX_DATA }
| Type of Queue Message. More...

## Functions
phStatus_t | phTools_EncodeParity (uint8_t bOption, uint8_t *pInBuffer, uint16_t wInBufferLength, uint8_t bInBufferBits, uint16_t wOutBufferSize, uint8_t *pOutBuffer, uint16_t *pOutBufferLength, uint8_t *pOutBufferBits)
| Calculate even or odd parity. More...
phStatus_t | phTools_DecodeParity (uint8_t bOption, uint8_t *pInBuffer, uint16_t wInBufferLength, uint8_t bInBufferBits, uint16_t wOutBufferSize, uint8_t *pOutBuffer, uint16_t *pOutBufferLength, uint8_t *pOutBufferBits)
| Verify and Remove even or odd parity. More...
phStatus_t | phTools_CalculateCrc5 (uint8_t bOption, uint8_t bPreset, uint8_t bPolynom, uint8_t *pData, uint16_t wDataLength, uint8_t *pCrc)
| Calculate a CRC 5. More...
phStatus_t | phTools_CalculateCrc8 (uint8_t bOption, uint8_t bPreset, uint8_t bPolynom, uint8_t *pData, uint16_t wDataLength, uint8_t *pCrc)
| Calculate a CRC 8. More...
phStatus_t | phTools_CalculateCrc16 (uint8_t bOption, uint16_t wPreset, uint16_t wPolynom, uint8_t *pData, uint16_t wDataLength, uint16_t *pCrc)
| Calculate a CRC 16. More...
phStatus_t | phTools_CalculateCrc32 (uint8_t bOption, uint32_t dwPreset, uint32_t dwPolynom, uint8_t *pData, uint16_t wDataLength, uint32_t *pCrc)
| Calculate a CRC 32. More...
phStatus_t | phTools_ComputeCrc_B (uint8_t *pData, uint32_t dwLength, uint8_t *pCrc)
| Calculate a CRC_B. More...
phStatus_t | phTools_GetVersion (uint8_t *pProductVer, uint16_t *pMajor, uint8_t *pMinor, uint16_t *pPatch_Dev, uint8_t *pVersionString, uint16_t *pVersionStringLen)
| The function gets the Version of the Firmware of DUT. More...
phStatus_t | phTools_Q_Init (void)
| To initialize the Queue manager. More...
phTools_Q_t * | phTools_Q_Get (uint32_t dwBlockTime, uint8_t bPriority)
| To get a empty Queue from a Free Pool. More...
phStatus_t | phTools_Q_Send (phTools_Q_t *psMsgQueue, uint32_t dwBlockTime, uint16_t wFrameOpt)
| Queue a message to last of the Message send queue list. More...
phStatus_t | phTools_Q_SendFront (phTools_Q_t *psMsgQueue, uint32_t dwBlockTime, uint16_t wFrameOpt)
| Queue a message to front of the Message send queue list. More...
phTools_Q_t * | phTools_Q_Receive (uint32_t dwBlockTime)
| To get a filled message queue from the send queue list. More...
phStatus_t | phTools_Q_Release (phTools_Q_t *psMsgQueue, uint32_t dwBlockTime)
| Returns a freed message queue back to the free message pool. More...
void | phTools_Q_DeInit (void)
| To release the memory resources used by the Message queue manager.

## ToolsConfigs
#define | PH_TOOLS_CRC16_PRESET_ISO14443A 0x6363U
| CRC16 Preset for ISO14443-A. More...
#define | PH_TOOLS_CRC16_PRESET_ISO14443B 0xFFFFU
| CRC16 Preset for ISO14443-B. More...
#define | PH_TOOLS_CRC16_PRESET_FELICA 0x0000U
| CRC16 Preset for Felica. More...
#define | PH_TOOLS_CRC16_POLY_ISO14443 0x8408U
| CRC16 Polynom for ISO14443. More...
#define | PH_TOOLS_CRC32_PRESET_DF8 0xFFFFFFFFU
| CRC32 Preset for DesFire. More...
#define | PH_TOOLS_CRC32_POLY_DF8 0xEDB88320U
| CRC32 Polynom for DesFire. More...
#define | PH_TOOLS_CRC8_PRESET_EPC 0xFFU
| Preset value for EPC CRC-8 generation. More...
#define | PH_TOOLS_CRC8_PRESET_UID 0xFDU
| Preset value for UID CRC-8 generation. More...
#define | PH_TOOLS_CRC8_POLY_EPCUID 0x1DU
| Polynomial for EPC/UID CRC-8 generation: x^8 + x^4 + x^3 + x^2 + 1 (MSB first). More...
#define | PH_TOOLS_CRC16_PRESET_EPCUID 0xFFFFU
| Preset value for EPC/UID CRC-16 generation. More...
#define | PH_TOOLS_CRC16_POLY_EPCUID 0x1021U
| Polynomial for EPC/UID CRC-16 generation: x^16 + x^12 + x^5 + 1 (MSB first). More...
#define | PH_TOOLS_CRC5_PRESET_I18000P3 0x09U
| Preset value for ISO18000-3 CRC-5 generation. More...
#define | PH_TOOLS_CRC5_POLY_I18000P3 0x09U
| Polynomial for ISO18000-3 CRC-5 generation: x^5 + x^3 + 1 (LSB first). More...
#define | PH_TOOLS_CRC16_PRESET_I18000P3 0xFFFFU
| Preset value for ISO18000-3 CRC-16 generation. More...
#define | PH_TOOLS_CRC16_POLY_I18000P3 0x8408U
| Polynomial for ISO18000-3 CRC-16 generation: x^16 + x^12 + x^5 + 1 (LSB first). More...
#define | PH_TOOLS_CRC16_POLY_FELICA 0x1021U
| Polynomial for Felica CRC-16 generation: x^16 + x^12 + x^5 + 1 (MSB first). More...
#define | PH_TOOLS_PARITY_OPTION_EVEN 0x00U
| Encode/Decode even parity bits. More...
#define | PH_TOOLS_PARITY_OPTION_ODD 0x01U
| Encode/Decode odd parity bits. More...
#define | PH_TOOLS_CRC16_POLY_PN7462AU_TESTOS 0x1021U
| Polynomial for TestOS CRC-16 generation: x^16 + x^12 + x^5 + 1 (MSB first). More...
#define | PH_TOOLS_CRC_OPTION_DEFAULT 0x00U
| Default CRC operation. More...
#define | PH_TOOLS_CRC_OPTION_OUPUT_INVERTED 0x01U
| Inverts the bits after calculation. More...
#define | PH_TOOLS_CRC_OPTION_MSB_FIRST 0x02U
| Calculates CRC with MSB(it) first. More...
#define | PH_TOOLS_CRC_OPTION_BITWISE 0x04U
| Bitwise CRC, `wDataLength` represents the Bitlength. More...
#define | PH_TOOLS_CRC_OPTION_MASK 0x07U
| Mask of valid option bits. More...

## Q Configs
#define | PH_TOOLS_Q_MAX_ELEMENTS 10 /* Indicates maximum elements in the Q pool */
#define | PH_TOOLS_Q_RESERVED_ELEMENTS 2 /* Indicates reserved elements in the Q pool for high priority tasks. */

## Detailed Description

This component implements tools that are necessary for many different software modules.

## Macro Definition Documentation

## § PH_TOOLS_CRC16_PRESET_ISO14443A

#define PH_TOOLS_CRC16_PRESET_ISO14443A 0x6363U

CRC16 Preset for ISO14443-A.

## § PH_TOOLS_CRC16_PRESET_ISO14443B

#define PH_TOOLS_CRC16_PRESET_ISO14443B 0xFFFFU

CRC16 Preset for ISO14443-B.

## § PH_TOOLS_CRC16_PRESET_FELICA

#define PH_TOOLS_CRC16_PRESET_FELICA 0x0000U

CRC16 Preset for Felica.

## § PH_TOOLS_CRC16_POLY_ISO14443

#define PH_TOOLS_CRC16_POLY_ISO14443 0x8408U

CRC16 Polynom for ISO14443.

## § PH_TOOLS_CRC32_PRESET_DF8

#define PH_TOOLS_CRC32_PRESET_DF8 0xFFFFFFFFU

CRC32 Preset for DesFire.

## § PH_TOOLS_CRC32_POLY_DF8

#define PH_TOOLS_CRC32_POLY_DF8 0xEDB88320U

CRC32 Polynom for DesFire.

## § PH_TOOLS_CRC8_PRESET_EPC

#define PH_TOOLS_CRC8_PRESET_EPC 0xFFU

Preset value for EPC CRC-8 generation.

## § PH_TOOLS_CRC8_PRESET_UID

#define PH_TOOLS_CRC8_PRESET_UID 0xFDU

Preset value for UID CRC-8 generation.

## § PH_TOOLS_CRC8_POLY_EPCUID

#define PH_TOOLS_CRC8_POLY_EPCUID 0x1DU

Polynomial for EPC/UID CRC-8 generation: x^8 + x^4 + x^3 + x^2 + 1 (MSB first).

## § PH_TOOLS_CRC16_PRESET_EPCUID

#define PH_TOOLS_CRC16_PRESET_EPCUID 0xFFFFU

Preset value for EPC/UID CRC-16 generation.

## § PH_TOOLS_CRC16_POLY_EPCUID

#define PH_TOOLS_CRC16_POLY_EPCUID 0x1021U

Polynomial for EPC/UID CRC-16 generation: x^16 + x^12 + x^5 + 1 (MSB first).

## § PH_TOOLS_CRC5_PRESET_I18000P3

#define PH_TOOLS_CRC5_PRESET_I18000P3 0x09U

Preset value for ISO18000-3 CRC-5 generation.

## § PH_TOOLS_CRC5_POLY_I18000P3

#define PH_TOOLS_CRC5_POLY_I18000P3 0x09U

Polynomial for ISO18000-3 CRC-5 generation: x^5 + x^3 + 1 (LSB first).

## § PH_TOOLS_CRC16_PRESET_I18000P3

#define PH_TOOLS_CRC16_PRESET_I18000P3 0xFFFFU

Preset value for ISO18000-3 CRC-16 generation.

## § PH_TOOLS_CRC16_POLY_I18000P3

#define PH_TOOLS_CRC16_POLY_I18000P3 0x8408U

Polynomial for ISO18000-3 CRC-16 generation: x^16 + x^12 + x^5 + 1 (LSB first).

## § PH_TOOLS_CRC16_POLY_FELICA

#define PH_TOOLS_CRC16_POLY_FELICA 0x1021U

Polynomial for Felica CRC-16 generation: x^16 + x^12 + x^5 + 1 (MSB first).

## § PH_TOOLS_PARITY_OPTION_EVEN

#define PH_TOOLS_PARITY_OPTION_EVEN 0x00U

Encode/Decode even parity bits.

## § PH_TOOLS_PARITY_OPTION_ODD

#define PH_TOOLS_PARITY_OPTION_ODD 0x01U

Encode/Decode odd parity bits.

## § PH_TOOLS_CRC16_POLY_PN7462AU_TESTOS

#define PH_TOOLS_CRC16_POLY_PN7462AU_TESTOS 0x1021U

Polynomial for TestOS CRC-16 generation: x^16 + x^12 + x^5 + 1 (MSB first).

## § PH_TOOLS_CRC_OPTION_DEFAULT

#define PH_TOOLS_CRC_OPTION_DEFAULT 0x00U

Default CRC operation.

## § PH_TOOLS_CRC_OPTION_OUPUT_INVERTED

#define PH_TOOLS_CRC_OPTION_OUPUT_INVERTED 0x01U

Inverts the bits after calculation.

## § PH_TOOLS_CRC_OPTION_MSB_FIRST

#define PH_TOOLS_CRC_OPTION_MSB_FIRST 0x02U

Calculates CRC with MSB(it) first.

## § PH_TOOLS_CRC_OPTION_BITWISE

#define PH_TOOLS_CRC_OPTION_BITWISE 0x04U

Bitwise CRC, `wDataLength` represents the Bitlength.

## § PH_TOOLS_CRC_OPTION_MASK

#define PH_TOOLS_CRC_OPTION_MASK 0x07U

Mask of valid option bits.

## Enumeration Type Documentation

## § phTools_Q_Type_t

enum phTools_Q_Type_t

Type of Queue Message.

Enumerator
PH_TOOLS_Q_DATA_TO_BE_SENT | Message needs to be sent.
PH_TOOLS_Q_RX_DATA | Message is received.

## Function Documentation

## § phTools_EncodeParity()

phStatus_t phTools_EncodeParity | ( | uint8_t | bOption,
|  | uint8_t * | pInBuffer,
|  | uint16_t | wInBufferLength,
|  | uint8_t | bInBufferBits,
|  | uint16_t | wOutBufferSize,
|  | uint8_t * | pOutBuffer,
|  | uint16_t * | pOutBufferLength,
|  | uint8_t * | pOutBufferBits
| ) |  |

Calculate even or odd parity.

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.

Parameters

  [in] | bOption | Parity option; e.g. PH_TOOLS_PARITY_OPTION_EVEN.
  [in] | pInBuffer | Array to input data.
  [in] | wInBufferLength | Length of input data in bytes.
  [in] | bInBufferBits | Number of valid bits in last byte of pInBuffer.
  [in] | wOutBufferSize | Size of the output buffer.
  [out] | pOutBuffer | Output buffer.
  [out] | pOutBufferLength | Number of valid bytes in pOutBuffer.
  [out] | pOutBufferBits | Number of valid bits in last byte of pOutBuffer.

## § phTools_DecodeParity()

phStatus_t phTools_DecodeParity | ( | uint8_t | bOption,
|  | uint8_t * | pInBuffer,
|  | uint16_t | wInBufferLength,
|  | uint8_t | bInBufferBits,
|  | uint16_t | wOutBufferSize,
|  | uint8_t * | pOutBuffer,
|  | uint16_t * | pOutBufferLength,
|  | uint8_t * | pOutBufferBits
| ) |  |

Verify and Remove even or odd parity.

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.

Parameters

  [in] | bOption | Parity option; e.g. PH_TOOLS_PARITY_OPTION_EVEN.
  [in] | pInBuffer | Array to input data.
  [in] | wInBufferLength | Length of input data in bytes.
  [in] | bInBufferBits | Number of valid bits in last byte of pInBuffer.
  [in] | wOutBufferSize | Size of the output buffer.
  [out] | pOutBuffer | Output buffer.
  [out] | pOutBufferLength | Number of valid bytes in pOutBuffer.
  [out] | pOutBufferBits | Number of valid bits in last byte of pOutBuffer.

## § phTools_CalculateCrc5()

phStatus_t phTools_CalculateCrc5 | ( | uint8_t | bOption,
|  | uint8_t | bPreset,
|  | uint8_t | bPolynom,
|  | uint8_t * | pData,
|  | uint16_t | wDataLength,
|  | uint8_t * | pCrc
| ) |  |

Calculate a CRC 5.

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.

Parameters

  [in] | bOption | Specifies whether the output should be inverted or not.
  [in] | bPreset | Preset used for CRC calculation, e.g. PH_TOOLS_CRC5_PRESET_I18000P3.
  [in] | bPolynom | Polynom used for reduction, e.g. PH_TOOLS_CRC5_POLY_I18000P3.
  [in] | pData | Array to input data.
  [in] | wDataLength | Length of input data.
  [out] | pCrc | Resulting CRC.

## § phTools_CalculateCrc8()

phStatus_t phTools_CalculateCrc8 | ( | uint8_t | bOption,
|  | uint8_t | bPreset,
|  | uint8_t | bPolynom,
|  | uint8_t * | pData,
|  | uint16_t | wDataLength,
|  | uint8_t * | pCrc
| ) |  |

Calculate a CRC 8.

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.

Parameters

  [in] | bOption | Specifies whether the output should be inverted or not.
  [in] | bPreset | Preset used for CRC calculation, e.g. PH_TOOLS_CRC8_PRESET_UID.
  [in] | bPolynom | Polynom used for reduction, e.g. PH_TOOLS_CRC8_POLY_EPCUID.
  [in] | pData | Array to input data.
  [in] | wDataLength | Length of input data.
  [out] | pCrc | Resulting CRC.

## § phTools_CalculateCrc16()

phStatus_t phTools_CalculateCrc16 | ( | uint8_t | bOption,
|  | uint16_t | wPreset,
|  | uint16_t | wPolynom,
|  | uint8_t * | pData,
|  | uint16_t | wDataLength,
|  | uint16_t * | pCrc
| ) |  |

Calculate a CRC 16.

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.

Parameters

  [in] | bOption | Specifies whether the output should be inverted or not.
  [in] | wPreset | Preset used for CRC calculation, e.g. PH_TOOLS_CRC16_PRESET_ISO14443A.
  [in] | wPolynom | Polynom used for reduction, e.g. PH_TOOLS_CRC16_POLY_ISO14443.
  [in] | pData | Array to input data.
  [in] | wDataLength | Length of input data.
  [out] | pCrc | Resulting CRC.

## § phTools_CalculateCrc32()

phStatus_t phTools_CalculateCrc32 | ( | uint8_t | bOption,
|  | uint32_t | dwPreset,
|  | uint32_t | dwPolynom,
|  | uint8_t * | pData,
|  | uint16_t | wDataLength,
|  | uint32_t * | pCrc
| ) |  |

Calculate a CRC 32.

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.

Parameters

  [in] | bOption | Specifies whether the output should be inverted or not.
  [in] | dwPreset | Preset used for CRC calculation, e.g. PH_TOOLS_CRC32_PRESET_DF8.
  [in] | dwPolynom | Polynom used for reduction, e.g. PH_TOOLS_CRC32_POLY_DF8.
  [in] | pData | Array to input data.
  [in] | wDataLength | Length of input data.
  [out] | pCrc | Resulting CRC.

## § phTools_ComputeCrc_B()

phStatus_t phTools_ComputeCrc_B | ( | uint8_t * | pData,
|  | uint32_t | dwLength,
|  | uint8_t * | pCrc
| ) |  |

Calculate a CRC_B.

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.

Parameters

  [in] | pData | Array to input data.
  [in] | dwLength | Length of input data.
  [out] | pCrc | Resulting Two byte CRC.

## § phTools_GetVersion()

phStatus_t phTools_GetVersion | ( | uint8_t * | pProductVer,
|  | uint16_t * | pMajor,
|  | uint8_t * | pMinor,
|  | uint16_t * | pPatch_Dev,
|  | uint8_t * | pVersionString,
|  | uint16_t * | pVersionStringLen
| ) |  |

The function gets the Version of the Firmware of DUT.

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Command successfully executed.
  PH_ERR_PROTOCOL_ERROR | Invalid frame or unexpected receive data length or command code mismatch.

Parameters

  [out] | pProductVer | Product Version.
  [out] | pMajor | Major Version.
  [out] | pMinor | Minor Version.
  [out] | pPatch_Dev | Development/Patch Version.
  [out] | pVersionString | Version String.
  [out] | pVersionStringLen | Version String Length.

## § phTools_Q_Init()

phStatus_t phTools_Q_Init | ( | void |  | ) |

To initialize the Queue manager.

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.
  PH_ERR_RESOURCE_ERROR | Message Queue is unavailable or OSAL returned error.

## § phTools_Q_Get()

phTools_Q_t* phTools_Q_Get | ( | uint32_t | dwBlockTime,
|  | uint8_t | bPriority
| ) |  |

To get a empty Queue from a Free Pool.

Returns a pointer to an empty Queue if available or returns NULL.

bPriority can be one of:

- PH_ON
- PH_OFF

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.
  PH_ERR_RESOURCE_ERROR | OSAL returned error.

Parameters

  [in] | dwBlockTime | The time in ticks to wait for a empty Queue to become available.
  [in] | bPriority | Used to indicate if Queue is required by high priority thread or not.

## § phTools_Q_Send()

phStatus_t phTools_Q_Send | ( | phTools_Q_t * | psMsgQueue,
|  | uint32_t | dwBlockTime,
|  | uint16_t | wFrameOpt
| ) |  |

Queue a message to last of the Message send queue list.

wFrameOpt can be one of:

- PH_TRANSMIT_DEFAULT

wFrameOpt can be combined with:

- PH_TRANSMIT_BUFFERED_BIT
- PH_TRANSMIT_LEAVE_BUFFER_BIT

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.
  PH_ERR_RESOURCE_ERROR | OSAL returned error.

Parameters

  [in] | psMsgQueue | Pointer to the Message Queue to be Queued.
  [in] | dwBlockTime | The time in ticks to wait for a empty Queue to become available.
  [in] | wFrameOpt | MAC/HAL Buffering option.

## § phTools_Q_SendFront()

phStatus_t phTools_Q_SendFront | ( | phTools_Q_t * | psMsgQueue,
|  | uint32_t | dwBlockTime,
|  | uint16_t | wFrameOpt
| ) |  |

Queue a message to front of the Message send queue list.

wFrameOpt can be one of:

- PH_TRANSMIT_DEFAULT

wFrameOpt can be combined with:

- PH_TRANSMIT_BUFFERED_BIT
- PH_TRANSMIT_LEAVE_BUFFER_BIT

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.
  PH_ERR_RESOURCE_ERROR | OSAL returned error.

Parameters

  [in] | psMsgQueue | Pointer to the Message Queue to be Queued.
  [in] | dwBlockTime | The time in ticks to wait for a empty Queue to become available.
  [in] | wFrameOpt | MAC/HAL Buffering option.

## § phTools_Q_Receive()

phTools_Q_t* phTools_Q_Receive | ( | uint32_t | dwBlockTime | ) |

To get a filled message queue from the send queue list.

Usually used by the Message Queue Manager to retrieve the queued messages waiting to be processed.

Parameters

  [in] | dwBlockTime | The time in ticks to wait for a empty Queue to become available.

## § phTools_Q_Release()

phStatus_t phTools_Q_Release | ( | phTools_Q_t * | psMsgQueue,
|  | uint32_t | dwBlockTime
| ) |  |

Returns a freed message queue back to the free message pool.

Usually used by the Message Queue Manager to return the queue to the Free pool.

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.
  PH_ERR_RESOURCE_ERROR | OSAL returned error.

Parameters

  [in] | psMsgQueue | Pointer to the Message Queue to be Queued.
  [in] | dwBlockTime | The time in ticks to wait for a empty Queue to become available.