Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Smart Card Service

The smart card service provides functions for cards supporting ISO7816 protocol.

asfdoc_sam0_iso7816_qs.

Modules

 Quick Start Guide(s)
 In this section you can find a list of all Quick Start guides related to the Smart Card Service.
 

Macros

#define CASE1   1
 Case for APDU commands. More...
 
#define CASE2   2
 
#define CASE3   3
 
#define ISO_NULL_VAL   0x60
 NULL byte to restart byte procedure. More...
 
#define RST_WAIT_TIME   120
 Reset wait time. More...
 
#define RX_TIMEOUT   12000
 Receive timeout. More...
 

Functions

void iso7816_cold_reset (void)
 Cold reset. More...
 
void iso7816_data_block_atr (uint8_t *p_atr, uint8_t *p_length)
 Answer To Reset (ATR). More...
 
void iso7816_decode_atr (uint8_t *p_atr)
 Decode ATR trace. More...
 
static enum status_code iso7816_get_char (uint8_t *p_char_received)
 Get a character from ISO7816. More...
 
bool iso7816_get_reset_statuts (void)
 Pin status for ISO7816 RESET PIN. More...
 
static void iso7816_icc_power_off (void)
 ISO7816 ICC power off. More...
 
static void iso7816_icc_power_on (void)
 ISO7816 ICC power on. More...
 
void iso7816_init (struct usart_module *const module, uint32_t pin_rst, uint32_t clock_get_hz)
 Initializes a ISO7816 interface device. More...
 
static enum status_code iso7816_send_char (uint8_t uc_char)
 Send a char to ISO7816. More...
 
void iso7816_warm_reset (void)
 Warm reset. More...
 
uint16_t iso7816_xfr_block_tpdu_t0 (const uint8_t *p_apdu, uint8_t *p_message, uint16_t us_length)
 Transfer Block TPDU T = 0. More...
 

Variables

volatile uint32_t iso7816_gs_frequency
 Generator source frequency of smart card usart. More...
 
static uint32_t iso7816_pin_rst
 Smart Card reset PIN. More...
 
static struct usart_moduleiso7816_usart_module
 
static uint8_t iso7816_usart_status = ISO7816_USART_RCV
 Variable for state of send and receive from USART. More...
 

#define CASE1   1

Case for APDU commands.

Referenced by iso7816_xfr_block_tpdu_t0().

#define CASE2   2
#define CASE3   3
#define ISO_NULL_VAL   0x60

NULL byte to restart byte procedure.

Referenced by iso7816_xfr_block_tpdu_t0().

#define RST_WAIT_TIME   120

Reset wait time.

Referenced by iso7816_cold_reset(), and iso7816_warm_reset().

#define RX_TIMEOUT   12000

Receive timeout.

Referenced by iso7816_get_char().

void iso7816_cold_reset ( void  )

Cold reset.

References i, iso7816_icc_power_on(), and RST_WAIT_TIME.

void iso7816_data_block_atr ( uint8_t *  p_atr,
uint8_t *  p_length 
)

Answer To Reset (ATR).

Parameters
[in]p_atrPointer to ATR buffer.
[in]p_lengthPointer for store the ATR length.

References Assert, i, iso7816_get_char(), and j.

void iso7816_decode_atr ( uint8_t *  p_atr)

Decode ATR trace.

Parameters
[in]p_atrPinter on ATR buffer.

References i, and j.

static enum status_code iso7816_get_char ( uint8_t *  p_char_received)
static

Get a character from ISO7816.

Parameters
[in]p_char_receivedPointer for store the received char.
Returns
Status of the operation.
Return values
STATUS_OKIf the operation was completed
STATUS_ERR_TIMEOUTIf operation was not completed, due to USART module timing out

References ISO7816_USART_RCV, ISO7816_USART_SEND, RX_TIMEOUT, STATUS_ERR_TIMEOUT, STATUS_OK, and usart_read_wait().

Referenced by iso7816_data_block_atr(), and iso7816_xfr_block_tpdu_t0().

bool iso7816_get_reset_statuts ( void  )

Pin status for ISO7816 RESET PIN.

Returns
Status of ISO7816 RESET PIN output buffer.

References port_pin_get_output_level().

static void iso7816_icc_power_off ( void  )
static

ISO7816 ICC power off.

References ISO7816_PIN_POWER_OFF, and port_pin_set_output_level().

Referenced by iso7816_warm_reset().

static void iso7816_icc_power_on ( void  )
static

ISO7816 ICC power on.

References ISO7816_PIN_POWER_ON, and port_pin_set_output_level().

Referenced by iso7816_cold_reset(), and iso7816_warm_reset().

void iso7816_init ( struct usart_module *const  module,
uint32_t  pin_rst,
uint32_t  clock_get_hz 
)

Initializes a ISO7816 interface device.

Parameters
[out]modulePointer to USART device
[in]pin_rstControl smart card RST pin index
[in]clock_get_hzGenerator source frequency of smart card usart

References Assert.

static enum status_code iso7816_send_char ( uint8_t  uc_char)
static

Send a char to ISO7816.

Parameters
[in]uc_charChar to be sent.
Returns
Status of the operation.

References ISO7816_USART_RCV, ISO7816_USART_SEND, and usart_write_wait().

Referenced by iso7816_xfr_block_tpdu_t0().

void iso7816_warm_reset ( void  )
uint16_t iso7816_xfr_block_tpdu_t0 ( const uint8_t *  p_apdu,
uint8_t *  p_message,
uint16_t  us_length 
)

Transfer Block TPDU T = 0.

Parameters
[in]p_apduPointer to APDU buffer.
[in]p_messagePointer to message buffer.
[in]us_lengthBlock length.
Returns
Message index.

References Assert, CASE1, CASE2, CASE3, iso7816_get_char(), iso7816_send_char(), and ISO_NULL_VAL.

volatile uint32_t iso7816_gs_frequency

Generator source frequency of smart card usart.

uint32_t iso7816_pin_rst
static

Smart Card reset PIN.

struct usart_module* iso7816_usart_module
static
uint8_t iso7816_usart_status = ISO7816_USART_RCV
static

Variable for state of send and receive from USART.