The smart card service provides functions for cards supporting ISO7816 protocol.
Macros | |
#define | CASE1 1 |
Checking board configuration of the ISO7816 handler. 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... | |
#define | USART_RCV 1 |
#define | USART_SEND 0 |
Flip flop for send and receive char. 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 uint32_t | iso7816_get_char (uint8_t *p_char_received) |
Get a character from ISO7816. More... | |
uint8_t | iso7816_get_reset_statuts (void) |
Pin status for ISO7816 RESET PIN. More... | |
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 (const usart_iso7816_opt_t *p_usart_opt, uint32_t ul_mck, uint32_t ul_rst_pin_idx) |
Initializes a ISO7816 interface device. More... | |
static uint32_t | 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 | g_ul_clk |
Define the main clock of the system. More... | |
static uint8_t | gs_uc_state = USART_RCV |
Variable for state of send and receive from USART. More... | |
uint32_t | gs_ul_rst_pin_idx |
Card reset PIN. More... | |
#define CASE1 1 |
Checking board configuration of the ISO7816 handler.
Case for APDU commands.
Referenced by iso7816_xfr_block_tpdu_t0().
#define CASE2 2 |
Referenced by iso7816_xfr_block_tpdu_t0().
#define CASE3 3 |
Referenced by iso7816_xfr_block_tpdu_t0().
#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().
#define USART_RCV 1 |
Referenced by iso7816_get_char(), and iso7816_send_char().
#define USART_SEND 0 |
Flip flop for send and receive char.
Referenced by iso7816_get_char(), and iso7816_send_char().
void iso7816_cold_reset | ( | void | ) |
Cold reset.
References iso7816_icc_power_on(), ISO7816_USART, RST_WAIT_TIME, usart_read(), usart_reset_iterations(), usart_reset_nack(), and usart_reset_status().
void iso7816_data_block_atr | ( | uint8_t * | p_atr, |
uint8_t * | p_length | ||
) |
Answer To Reset (ATR).
p_atr | Pointer to ATR buffer. |
p_length | Pointer for store the ATR length. |
References iso7816_get_char().
Referenced by main().
void iso7816_decode_atr | ( | uint8_t * | p_atr | ) |
|
static |
Get a character from ISO7816.
p_char_received | Pointer for store the received char. |
References ISO7816_USART, RX_TIMEOUT, usart_get_status(), USART_RCV, usart_read(), usart_reset_iterations(), usart_reset_nack(), usart_reset_status(), and USART_SEND.
Referenced by iso7816_data_block_atr(), and iso7816_xfr_block_tpdu_t0().
uint8_t iso7816_get_reset_statuts | ( | void | ) |
Pin status for ISO7816 RESET PIN.
References ioport_get_pin_level(), and IOPORT_PIN_LEVEL_HIGH.
void iso7816_icc_power_off | ( | void | ) |
ISO7816 ICC power off.
References IOPORT_PIN_LEVEL_LOW, and ioport_set_pin_level().
Referenced by iso7816_warm_reset().
|
static |
ISO7816 ICC power on.
References IOPORT_PIN_LEVEL_HIGH, and ioport_set_pin_level().
Referenced by iso7816_cold_reset(), and iso7816_warm_reset().
void iso7816_init | ( | const usart_iso7816_opt_t * | p_usart_opt, |
uint32_t | ul_mck, | ||
uint32_t | ul_rst_pin_idx | ||
) |
Initializes a ISO7816 interface device.
p_usart_opt | Pointer to an ISO7816 instance. |
ul_mck | USART module input clock frequency. |
ul_rst_pin_idx | Control smart card RST pin index. |
References IOPORT_PIN_LEVEL_LOW, ioport_set_pin_level(), ISO7816_USART, usart_disable_interrupt(), usart_enable_rx(), usart_enable_tx(), usart_init_iso7816(), and usart_set_tx_timeguard().
Referenced by main().
|
static |
Send a char to ISO7816.
uc_char | Char to be sent. |
There are errors happened, reset the status bit.
References ISO7816_USART, usart_get_status(), USART_RCV, usart_reset_iterations(), usart_reset_nack(), usart_reset_status(), USART_SEND, and usart_write().
Referenced by iso7816_xfr_block_tpdu_t0().
void iso7816_warm_reset | ( | void | ) |
Warm reset.
References iso7816_icc_power_off(), iso7816_icc_power_on(), ISO7816_USART, RST_WAIT_TIME, usart_read(), usart_reset_iterations(), usart_reset_nack(), and usart_reset_status().
Referenced by main().
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.
p_apdu | Pointer to APDU buffer. |
p_message | Pointer to message buffer. |
us_length | Block length. |
References CASE1, CASE2, CASE3, iso7816_get_char(), iso7816_send_char(), and ISO_NULL_VAL.
Referenced by send_receive_cmd().
volatile uint32_t g_ul_clk |
Define the main clock of the system.
|
static |
Variable for state of send and receive from USART.
uint32_t gs_ul_rst_pin_idx |
Card reset PIN.