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 UART Driver

Overview

The Smart Card UART driver uses a standard UART peripheral which supports the ISO-7816 standard. The driver supports transmission functionality in the CPU mode. The driver also supports non-blocking (asynchronous) type of data transfers. The blocking (synchronous) transfer is supported only by the RTOS adaptation layer.

Files

file  fsl_smartcard_uart.h
 

Macros

#define SMARTCARD_EMV_RX_NACK_THRESHOLD   (5u)
 EMV RX NACK interrupt generation threshold.
 
#define SMARTCARD_EMV_TX_NACK_THRESHOLD   (3u)
 EMV TX NACK interrupt generation threshold.
 
#define SMARTCARD_EMV_RX_TO_TX_GUARD_TIME_T0   (0x0u)
 EMV TX & RX GUART TIME default value.
 

Functions

void SMARTCARD_UART_GetDefaultConfig (smartcard_card_params_t *cardParams)
 Fill in smartcard_card_params structure with default values according EMV 4.3 specification. More...
 
status_t SMARTCARD_UART_Init (UART_Type *base, smartcard_context_t *context, uint32_t srcClock_Hz)
 Initializes an UART peripheral for smart card/ISO-7816 operation. More...
 
void SMARTCARD_UART_Deinit (UART_Type *base)
 This function disables the UART interrupts, disables the transmitter and receiver, and flushes the FIFOs (for modules that support FIFOs) and gates UART clock in SIM. More...
 
int32_t SMARTCARD_UART_GetTransferRemainingBytes (UART_Type *base, smartcard_context_t *context)
 Returns whether the previous UART transfer has finished. More...
 
status_t SMARTCARD_UART_AbortTransfer (UART_Type *base, smartcard_context_t *context)
 Terminates an asynchronous UART transfer early. More...
 
status_t SMARTCARD_UART_TransferNonBlocking (UART_Type *base, smartcard_context_t *context, smartcard_xfer_t *xfer)
 Transfer data using interrupts. More...
 
status_t SMARTCARD_UART_Control (UART_Type *base, smartcard_context_t *context, smartcard_control_t control, uint32_t param)
 Controls UART module as per different user request. More...
 
void SMARTCARD_UART_IRQHandler (UART_Type *base, smartcard_context_t *context)
 Interrupt handler for UART. More...
 
void SMARTCARD_UART_ErrIRQHandler (UART_Type *base, smartcard_context_t *context)
 Error Interrupt handler for UART. More...
 
void SMARTCARD_UART_TSExpiryCallback (UART_Type *base, smartcard_context_t *context)
 Handles initial TS character timer time-out event. More...
 

Function Documentation

void SMARTCARD_UART_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_UART_Init ( UART_Type *  base,
smartcard_context_t context,
uint32_t  srcClock_Hz 
)

This function Un-gate UART 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 UART 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_UART_Deinit ( UART_Type *  base)
Parameters
baseThe UART peripheral base address.
int32_t SMARTCARD_UART_GetTransferRemainingBytes ( UART_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, by reading xSize of smart card context structure.

Parameters
baseThe UART peripheral base address.
contextA pointer to a smart card driver context structure.
Returns
The number of bytes not transferred.
status_t SMARTCARD_UART_AbortTransfer ( UART_Type *  base,
smartcard_context_t context 
)

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

Parameters
baseThe UART peripheral base address.
contextA pointer to a smart card driver context structure.
Return values
kStatus_SMARTCARD_SuccessThe transfer abort was successful.
kStatus_SMARTCARD_NoTransmitInProgressNo transmission is currently in progress.
status_t SMARTCARD_UART_TransferNonBlocking ( UART_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 UART 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_UART_Control ( UART_Type *  base,
smartcard_context_t context,
smartcard_control_t  control,
uint32_t  param 
)
Parameters
baseThe UART peripheral base address.
contextA pointer to a smart card driver context structure.
controlSmart card command type.
paramInteger value of specific to control command.

return An kStatus_SMARTCARD_OtherError in case of error return kStatus_SMARTCARD_Success in success

void SMARTCARD_UART_IRQHandler ( UART_Type *  base,
smartcard_context_t context 
)

This handler uses the buffers stored in the smartcard_context_t structures to transfer data. Smart card driver requires this function to call when UART interrupt occurs.

Parameters
baseThe UART peripheral base address.
contextA pointer to a smart card driver context structure.
void SMARTCARD_UART_ErrIRQHandler ( UART_Type *  base,
smartcard_context_t context 
)

This function handles error conditions during transfer.

Parameters
baseThe UART peripheral base address.
contextA pointer to a smart card driver context structure.
void SMARTCARD_UART_TSExpiryCallback ( UART_Type *  base,
smartcard_context_t context 
)
Parameters
baseThe UART peripheral base address.
contextA pointer to a smart card driver context structure.