Go to the documentation of this file.
39 #ifdef PREINIT_SUPPORTED
43 #ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49 #include "drv_digital_out.h"
50 #include "drv_digital_in.h"
73 #define SMARTCARD2_CMD_ICC_POWER_ON 0x62
74 #define SMARTCARD2_CMD_ICC_POWER_OFF 0x63
75 #define SMARTCARD2_CMD_GET_SLOT_STATUS 0x65
76 #define SMARTCARD2_CMD_XFR_BLOCK 0x6F
77 #define SMARTCARD2_CMD_GET_PARAMETERS 0x6C
78 #define SMARTCARD2_CMD_RESET_PARAMETERS 0x6D
79 #define SMARTCARD2_CMD_SET_PARAMETERS 0x61
80 #define SMARTCARD2_CMD_ESCAPE 0x6B
81 #define SMARTCARD2_CMD_ICC_ESCAPE 0x6E
82 #define SMARTCARD2_CMD_T0_APDU 0x6A
83 #define SMARTCARD2_CMD_SECURE 0x69
84 #define SMARTCARD2_CMD_MECHANICAL 0x71
85 #define SMARTCARD2_CMD_ABORT 0x72
86 #define SMARTCARD2_CMD_SET_DATA_RATE_CLK_FREQ 0x73
92 #define SMARTCARD2_RSP_DATA_BLOCK 0x80
93 #define SMARTCARD2_RSP_SLOT_STATUS 0x81
94 #define SMARTCARD2_RSP_PARAMETERS 0x82
95 #define SMARTCARD2_RSP_ESCAPE 0x83
96 #define SMARTCARD2_RSP_DATA_RATE_CLK_FREQ 0x84
102 #define SMARTCARD2_EVT_NOTIFY_SLOT_CHANGE 0x50
103 #define SMARTCARD2_CARD_ABSENT 0x02
104 #define SMARTCARD2_CARD_PRESENT 0x03
105 #define SMARTCARD2_EVT_HARDWARE_ERROR 0x51
106 #define SMARTCARD2_OVERCURRENT 0x01
112 #define SMARTCARD2_SYNC 0x03
113 #define SMARTCARD2_CTRL_ACK 0x06
114 #define SMARTCARD2_CTRL_NACK 0x15
115 #define SMARTCARD2_SHORT_APDU_MAX_SIZE 261
117 #define SMARTCARD2_MAX_BUF_SIZE ( SMARTCARD2_SHORT_APDU_MAX_SIZE + 13 )
118 #define SMARTCARD2_TIMEOUT_MS 5000
124 #define SMARTCARD2_CLK_STATUS_RUNNING 0x00
125 #define SMARTCARD2_CLK_STATUS_STATE_L 0x01
126 #define SMARTCARD2_CLK_STATUS_STATE_H 0x02
132 #define SMARTCARD2_POWER_SEL_AUTO 0x00
133 #define SMARTCARD2_POWER_SEL_5V 0x01
134 #define SMARTCARD2_POWER_SEL_3V 0x02
135 #define SMARTCARD2_POWER_SEL_1_8V 0x03
141 #define SMARTCARD2_ICC_ACTIVE 0
142 #define SMARTCARD2_ICC_PRESENT 1
143 #define SMARTCARD2_ICC_ABSENT 2
144 #define SMARTCARD2_ICC_STATUS_MASK 0x03
151 #define SMARTCARD2_TX_DRV_BUFFER_SIZE SMARTCARD2_MAX_BUF_SIZE
152 #define SMARTCARD2_RX_DRV_BUFFER_SIZE ( SMARTCARD2_MAX_BUF_SIZE * 2 )
170 #define SMARTCARD2_MAP_MIKROBUS( cfg, mikrobus ) \
171 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
172 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
173 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST );
188 uint8_t spec_bytes[ 3 ];
408 #endif // SMARTCARD2_H
Smart Card 2 Click context object.
Definition: smartcard2.h:199
void smartcard2_enable_device(smartcard2_t *ctx)
Smart Card 2 enable device function.
@ SMARTCARD2_ERROR
Definition: smartcard2.h:244
err_t smartcard2_icc_power_on(smartcard2_t *ctx, uint8_t power_sel)
Smart Card 2 icc power on function.
Smart Card 2 Click context object.
Definition: smartcard2.h:183
uart_data_bits_t data_bit
Definition: smartcard2.h:231
uint8_t slot_num
Definition: smartcard2.h:186
err_t smartcard2_icc_power_off(smartcard2_t *ctx)
Smart Card 2 icc power off function.
digital_out_t rst
Definition: smartcard2.h:201
uint8_t type
Definition: smartcard2.h:184
err_t smartcard2_generic_write(smartcard2_t *ctx, char *data_in, uint16_t len)
Smart Card 2 data writing function.
err_t smartcard2_read_ccid(smartcard2_t *ctx, smartcard2_ccid_t *data_out)
Smart Card 2 read ccid function.
err_t smartcard2_send_ccid(smartcard2_t *ctx, smartcard2_ccid_t *data_in)
Smart Card 2 send ccid function.
@ SMARTCARD2_CHECKSUM_ERROR
Definition: smartcard2.h:246
uint8_t seq_num
Definition: smartcard2.h:187
uart_stop_bits_t stop_bit
Definition: smartcard2.h:233
@ SMARTCARD2_OK
Definition: smartcard2.h:243
Smart Card 2 Click configuration object.
Definition: smartcard2.h:220
void smartcard2_disable_device(smartcard2_t *ctx)
Smart Card 2 disable device function.
@ SMARTCARD2_READ_ERROR
Definition: smartcard2.h:245
bool uart_blocking
Definition: smartcard2.h:230
@ SMARTCARD2_TIMEOUT_ERROR
Definition: smartcard2.h:247
#define SMARTCARD2_TX_DRV_BUFFER_SIZE
Smart Card 2 driver buffer size.
Definition: smartcard2.h:151
smartcard2_return_value_t
Smart Card 2 Click return value data.
Definition: smartcard2.h:242
uint8_t seq_num
Definition: smartcard2.h:210
pin_name_t tx_pin
Definition: smartcard2.h:223
void smartcard2_cfg_setup(smartcard2_cfg_t *cfg)
Smart Card 2 configuration object setup function.
err_t smartcard2_get_slot_status(smartcard2_t *ctx)
Smart Card 2 get slot status function.
err_t smartcard2_generic_read(smartcard2_t *ctx, char *data_out, uint16_t len)
Smart Card 2 data reading function.
uint32_t payload_size
Definition: smartcard2.h:185
#define SMARTCARD2_SHORT_APDU_MAX_SIZE
Definition: smartcard2.h:115
uart_t uart
Definition: smartcard2.h:204
uint32_t baud_rate
Definition: smartcard2.h:229
pin_name_t rst
Definition: smartcard2.h:226
uart_parity_t parity_bit
Definition: smartcard2.h:232
pin_name_t rx_pin
Definition: smartcard2.h:222
err_t smartcard2_init(smartcard2_t *ctx, smartcard2_cfg_t *cfg)
Smart Card 2 initialization function.
#define SMARTCARD2_RX_DRV_BUFFER_SIZE
Definition: smartcard2.h:152