Kinetis SDK v.2.0 API Reference Manual  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Smart Card EMVSIM Driver

Overview

The SmartCard EMVSIM driver covers the transmission functionality in the CPU mode. The driver supports non-blocking (asynchronous) type of data transfers. The blocking (synchronous) transfer is supported only by the RTOS adaptation layer.

Files

file  fsl_smartcard_emvsim.h
 

Macros

#define SMARTCARD_EMV_RX_NACK_THRESHOLD   (5u)
 EMV RX NACK interrupt generation threshold.
 
#define SMARTCARD_EMV_TX_NACK_THRESHOLD   (5u)
 EMV TX NACK interrupt generation threshold.
 
#define SMARTCARD_WWT_ADJUSTMENT   (180u)
 Smart card Word Wait Timer adjustment value.
 
#define SMARTCARD_CWT_ADJUSTMENT   (3u)
 Smart card Character Wait Timer adjustment value.
 

Enumerations

enum  emvsim_gpc_clock_select_t {
  kEMVSIM_GPCClockDisable = 0u,
  kEMVSIM_GPCCardClock = 1u,
  kEMVSIM_GPCRxClock = 2u,
  kEMVSIM_GPCTxClock = 3u
}
 General Purpose Counter clock selections. More...
 
enum  emvsim_presence_detect_edge_t {
  kEMVSIM_DetectOnFallingEdge = 0u,
  kEMVSIM_DetectOnRisingEdge = 1u
}
 EMVSIM card presence detection edge control. More...
 
enum  emvsim_presence_detect_status_t {
  kEMVSIM_DetectPinIsLow = 0u,
  kEMVSIM_DetectPinIsHigh = 1u
}
 EMVSIM card presence detection status. More...
 

Smart card EMVSIM Driver

void SMARTCARD_EMVSIM_GetDefaultConfig (smartcard_card_params_t *cardParams)
 Fill in smartcard_card_params structure with default values according EMV 4.3 specification. More...
 
status_t SMARTCARD_EMVSIM_Init (EMVSIM_Type *base, smartcard_context_t *context, uint32_t srcClock_Hz)
 Initializes an EMVSIM peripheral for smart card/ISO-7816 operation. More...
 
void SMARTCARD_EMVSIM_Deinit (EMVSIM_Type *base)
 This function disables the EMVSIM interrupts, disables the transmitter and receiver, flushes the FIFOs and gates EMVSIM clock in SIM. More...
 
int32_t SMARTCARD_EMVSIM_GetTransferRemainingBytes (EMVSIM_Type *base, smartcard_context_t *context)
 Returns whether the previous EMVSIM transfer has finished. More...
 
status_t SMARTCARD_EMVSIM_AbortTransfer (EMVSIM_Type *base, smartcard_context_t *context)
 Terminates an asynchronous EMVSIM transfer early. More...
 
status_t SMARTCARD_EMVSIM_TransferNonBlocking (EMVSIM_Type *base, smartcard_context_t *context, smartcard_xfer_t *xfer)
 Transfer data using interrupts. More...
 
status_t SMARTCARD_EMVSIM_Control (EMVSIM_Type *base, smartcard_context_t *context, smartcard_control_t control, uint32_t param)
 Controls EMVSIM module as per different user request. More...
 
void SMARTCARD_EMVSIM_IRQHandler (EMVSIM_Type *base, smartcard_context_t *context)
 Handles EMVSIM module interrupts. More...
 

Enumeration Type Documentation

Enumerator
kEMVSIM_GPCClockDisable 

disabled

kEMVSIM_GPCCardClock 

card clock

kEMVSIM_GPCRxClock 

receive clock

kEMVSIM_GPCTxClock 

transmit ETU clock

Enumerator
kEMVSIM_DetectOnFallingEdge 

presence detect on falling edge

kEMVSIM_DetectOnRisingEdge 

presence detect on rising edge

Enumerator
kEMVSIM_DetectPinIsLow 

presence detect pin is logic low

kEMVSIM_DetectPinIsHigh 

presence detect pin is logic high

Function Documentation

void SMARTCARD_EMVSIM_GetDefaultConfig ( smartcard_card_params_t cardParams)
Parameters
cardParamsThe configuration structure of type smartcard_interface_config_t. Function fill in members: Fi = 372; Di = 1; currentD = 1; WI = 0x0A; GTN = 0x00; with default values.
status_t SMARTCARD_EMVSIM_Init ( EMVSIM_Type *  base,
smartcard_context_t context,
uint32_t  srcClock_Hz 
)

This function Un-gate EMVSIM clock, initializes the module to EMV default settings, configures the IRQ, enables the module-level interrupt to the core and initialize driver context.

Parameters
baseThe EMVSIM peripheral base address.
contextA pointer to a smart card driver context structure.
srcClock_HzSmart card clock generation module source clock.
Returns
An error code or kStatus_SMARTCARD_Success.
void SMARTCARD_EMVSIM_Deinit ( EMVSIM_Type *  base)
Parameters
baseThe EMVSIM module base address.
int32_t SMARTCARD_EMVSIM_GetTransferRemainingBytes ( EMVSIM_Type *  base,
smartcard_context_t context 
)

When performing an async transfer, call this function to ascertain the context of the current transfer: in progress (or busy) or complete (success). If the transfer is still in progress, the user can obtain the number of words that have not been transferred.

Parameters
baseThe EMVSIM module base address.
contextA pointer to a smart card driver context structure.
Returns
The number of bytes not transferred.
status_t SMARTCARD_EMVSIM_AbortTransfer ( EMVSIM_Type *  base,
smartcard_context_t context 
)

During an async EMVSIM transfer, the user can terminate the transfer early if the transfer is still in progress.

Parameters
baseThe EMVSIM peripheral address.
contextA pointer to a smart card driver context structure.
Return values
kStatus_SMARTCARD_SuccessThe transmit abort was successful.
kStatus_SMARTCARD_NoTransmitInProgressNo transmission is currently in progress.
status_t SMARTCARD_EMVSIM_TransferNonBlocking ( EMVSIM_Type *  base,
smartcard_context_t context,
smartcard_xfer_t xfer 
)

A non-blocking (also known as asynchronous) function means that the function returns immediately after initiating the transfer function. The application has to get the transfer status to see when the transfer is complete. In other words, after calling non-blocking (asynchronous) transfer function, the application must get the transfer status to check if transmit is completed or not.

Parameters
baseThe EMVSIM peripheral base address.
contextA pointer to a smart card driver context structure.
xferA pointer to smart card transfer structure where are linked buffers and sizes.
Returns
An error code or kStatus_SMARTCARD_Success.
status_t SMARTCARD_EMVSIM_Control ( EMVSIM_Type *  base,
smartcard_context_t context,
smartcard_control_t  control,
uint32_t  param 
)
Parameters
baseThe EMVSIM peripheral base address.
contextA pointer to a smart card driver context structure.
controlControl type
paramInteger value of specific to control command.

return kStatus_SMARTCARD_Success in success. return kStatus_SMARTCARD_OtherError in case of error.

void SMARTCARD_EMVSIM_IRQHandler ( EMVSIM_Type *  base,
smartcard_context_t context 
)
Parameters
baseThe EMVSIM peripheral base address.
contextA pointer to a smart card driver context structure.