AT-NFC 2.1 (win) AT-NFC kernel set

Functions
HAL Card Reader API

HAL Card Reader EMV L1 Interface. More...

## Functions
KER_BOOL | hal_emvl1_reset_card (KER_CTX_PARAM KER_BYTE btResetType, KER_BYTE *pbtATR, KER_BYTE *pbtATRLen, KER_BYTE btATRLenMax)
| Reset command to the card reader. More...
KER_BOOL | hal_emvl1_exchange_apdu (KER_CTX_PARAM KER_BYTE btProtocol, KER_BYTE btApduCase, KER_BYTE btCLA, KER_BYTE btINS, KER_BYTE btP1, KER_BYTE btP2, KER_INT16U usLc, const KER_BYTE *pbtDataIn, KER_INT16U usLe, KER_BYTE *pbtDataOut, KER_INT16U *pusDataOut, KER_INT16U usDataOutSize, KER_INT16U *pusSW1SW2)
| Send APDU requset and obtain APDU response from card. More...
#define | KER_EMVL1_PROTOCOL_T0 0x00
#define | KER_EMVL1_PROTOCOL_T1 0x01
#define | KER_EMVL1_RESET_SMART 0x00
#define | KER_EMVL1_RESET_AUTO 0x01
#define | KER_EMVL1_RESET_COLD 0x02
#define | KER_EMVL1_RESET_WARM 0x03
#define | KER_EMVL1_LE_MAX 0x0000
#define | KER_EMVL1_LE_NULL 0xFFFF
#define | KER_EMVL1_APDU_CASE1 0x01
#define | KER_EMVL1_APDU_CASE2 0x02
#define | KER_EMVL1_APDU_CASE3 0x03
#define | KER_EMVL1_APDU_CASE4 0x04

## Detailed Description

HAL Card Reader EMV L1 Interface.

This functions should be implemented by terminal application

## Macro Definition Documentation

## ◆ KER_EMVL1_APDU_CASE1

#define KER_EMVL1_APDU_CASE1 0x01

Exchange APDU Case 1 - Command Data: NO Expected Response Data: NO
C-APDU = {CLA INS P1 P2}

## ◆ KER_EMVL1_APDU_CASE2

#define KER_EMVL1_APDU_CASE2 0x02

Exchange APDU Case 2 - Command Data: NO Expected Response Data: YES
C-APDU = {CLA INS P1 P2 Le}

## ◆ KER_EMVL1_APDU_CASE3

#define KER_EMVL1_APDU_CASE3 0x03

Exchange APDU Case 3 - Command Data: YES Expected Response Data: NO
C-APDU = {CLA INS P1 P2 Lc [sDataIn(Lc)]}

## ◆ KER_EMVL1_APDU_CASE4

#define KER_EMVL1_APDU_CASE4 0x04

Exchange APDU Case 4 - Command Data: YES Expected Response Data: YES
C-APDU = {CLA INS P1 P2 Lc [sDataIn(Lc)] Le}

## ◆ KER_EMVL1_LE_MAX

#define KER_EMVL1_LE_MAX 0x0000

expected response length is unknown (card may respond with any length available)

## ◆ KER_EMVL1_LE_NULL

#define KER_EMVL1_LE_NULL 0xFFFF

no response data is expected (Le parameter should not be sent to the card)

## ◆ KER_EMVL1_PROTOCOL_T0

#define KER_EMVL1_PROTOCOL_T0 0x00

EMV Level 1 protcol T0

## ◆ KER_EMVL1_PROTOCOL_T1

#define KER_EMVL1_PROTOCOL_T1 0x01

EMV Level 1 protcol T1

## ◆ KER_EMVL1_RESET_AUTO

#define KER_EMVL1_RESET_AUTO 0x01

Send cold reset firstly, if any of TB1 TB2 in ATR present and have non-zero value - send warm reset next

## ◆ KER_EMVL1_RESET_COLD

#define KER_EMVL1_RESET_COLD 0x02

EMV Level 1 cold reset - optional implementation for external usage only

## ◆ KER_EMVL1_RESET_SMART

#define KER_EMVL1_RESET_SMART 0x00

Obtain ATR w/o reset if no apdu issued since last reset, otherwise - as KER_EMVL1_RESET_AUTO

## ◆ KER_EMVL1_RESET_WARM

#define KER_EMVL1_RESET_WARM 0x03

EMV Level 1 warm reset - optional implementation for external usage only

## Function Documentation

## ◆ hal_emvl1_exchange_apdu()

KER_BOOL hal_emvl1_exchange_apdu | ( | KER_CTX_PARAM KER_BYTE | btProtocol,
|  | KER_BYTE | btApduCase,
|  | KER_BYTE | btCLA,
|  | KER_BYTE | btINS,
|  | KER_BYTE | btP1,
|  | KER_BYTE | btP2,
|  | KER_INT16U | usLc,
|  | const KER_BYTE * | pbtDataIn,
|  | KER_INT16U | usLe,
|  | KER_BYTE * | pbtDataOut,
|  | KER_INT16U * | pusDataOut,
|  | KER_INT16U | usDataOutSize,
|  | KER_INT16U * | pusSW1SW2
| ) |  |

Send APDU requset and obtain APDU response from card.

Parameters

  [in] | btProtocol | Chip protocol type KER_EMVL1_PROTOCOL_T0 or KER_EMVL1_PROTOCOL_T1
  [in] | btApduCase | APDU request type - KER_EMVL1_APDU_CASE1, KER_EMVL1_APDU_CASE2, KER_EMVL1_APDU_CASE3 or KER_EMVL1_APDU_CASE4
  [in] | btCLA | Class of Instruction
  [in] | btINS | Instruction Code
  [in] | btP1 | Instruction Parameter 1
  [in] | btP2 | Instruction Parameter 2
  [in] | usLc | The pbtDataIn data length
  [in] | pbtDataIn | The data to send to the card
  [in] | usLe | Expected length of response data from card (if known), or KER_EMVL1_LE_MAX or KER_EMVL1_LE_NULL
  [out] | pbtDataOut | Buffer to obtain command response data sent by the card
  [out] | pusDataOut | Length of data placed in pbtDataOut
  [in] | usDataOutSize | pbtDataOut buffer size
  [out] | pusSW1SW2 | card response status bytes

Returns
  KER_TRUE Success.
  KER_FALSE Failure. Execution failed due to invalid param or reader error.

## ◆ hal_emvl1_reset_card()

KER_BOOL hal_emvl1_reset_card | ( | KER_CTX_PARAM KER_BYTE | btResetType,
|  | KER_BYTE * | pbtATR,
|  | KER_BYTE * | pbtATRLen,
|  | KER_BYTE | btATRLenMax
| ) |  |

Reset command to the card reader.

Parameters

  [in] | btResetType | Card reset type KER_EMVL1_RESET_COLD or KER_EMVL1_RESET_WARM or KER_EMVL1_RESET_SMART
  [out] | pbtATR | Buffer to obtain ATR (answer to reset) sent by the card
  [out] | pbtATRLen | Length of data placed in btATR
  [in] | btATRLenMax | pbtDataOut buffer size

Returns
  KER_TRUE Success.
  KER_FALSE Failure. Execution failed due to invalid param or reader error.