Learning Linux bus drivers with cainiao: getting started with smartcard operations

Source: Internet
Author: User

Let's start with the actual objects. Let's take a look at the pin definitions of commonly used touch-point IC cards.


The interface device shall provide the following nominal power supply to the card through the contact VCC:

--
Category A: 5 V

--
Class B: 3 V

Therefore, the card and interface device should work only in Class A, or only in Class B, or in Class A and Class B (hereinafter referred to as AB ).

Class A cards should be able to operate on Class A or Class AB interface devices. The AB card should be able to operate on a, B, or AB interface device. B-type cards should be able to operate on B-type or AB-type interface equipment; B-type cards should be able to protect cards from being damaged under Class A operation conditions (as defined, the damaged card is a card that cannot be operated as required or contains incorrect data ).

 

I. Functions of each pin

1. VCC

This contact is used to provide the power supply voltage to the card. The current value in table 1 is the average value within 1 ms. Specifies the maximum current for the card. The interface device shall be able to provide the current value or a larger current value within the specified voltage range.

 

2. I/O

This contact is used as the input (receiving mode) or output (sending mode ). The following two logical States (as defined in GB/T 3453-1994) are used for information exchange through contact I/O ):

--
Status Z. If the card and interface device are in the receiving mode or the status is forced by the sender.

--
Status A, if this status is forced by the sender.

When both ends of the line are in the receiving mode, the line should be in the Z (high) state ). When the two ends of the line are in unmatched transmission mode, the logic status of the line may be uncertain. During the operation, the interface device and card should not both be in the sending mode.

When the input voltage is within the permitted range, the interface device shall be able to support the input current within the specified range. The interface device shall present an impedance to the card so that the interface device can keep the output voltage within the specified range without interfering with the card.

 

3. CLK

This contact is used to forwardCardProvides clock signals. Actual clock signal frequencyValueSpecified by F.

During stable operation, the duty cycle of the clock signal cycle should be 40% ~ 60%. When switching frequency from one value to another, ensure that there is no 40% shorter pulse in the shortest cycle allowed by the card. When the switching frequency value is used, no information is exchanged. For the switching frequency value, we recommend that you use two different times:

--
Immediately after the reset response, or

--
Perform this operation immediately after a successful PPS switch.

 

4. rst

This contact is used to provide a reset signal to the card, including cold reset and hot reset.

 

5. VPP

This contact will be retained for future use under Class B operation conditions.

Under Class A operating conditions, this contact can be used to provide the card with programming voltages required to write or erase internal non-volatile memory. Table 6 defines two activation states on the contact VPP: The pause state and the programming state. Unless the card requires a programming status, the interface device should keep the contact vpp in the paused status.

 

Ii. Card Operation Process

The circuit is activated only when the contact of the card is mechanically connected to the contact of the interface device.

The interaction between the interface device and the card should be carried out through the continuous operation as stipulated in the following terms.

--
Interface device activation circuit;

--
Information exchange between the card and the interface device always starts from the response of the card to the cold reset;

--
The interface device stops the active circuit.

The stopping sequence of the circuit should end before the mechanical disconnection of the contacts of the card and the contacts of the interface equipment.

 

1. Activation

In order to start the interaction with the mechanical connection card, the interface device should activate the circuit in the following order:

--
Set RST to state L;

--
According to the operation conditions selected by the interface device: Class A or Class B, VCC should be powered on;

--
Place the I/O on the interface device in the receiving mode;

--
In Class A conditions, Vpp should be put in the paused State; in Class B conditions, Vpp should be retained for future use;

--
The clock signal must be provided for the CLK. At least during the reset response period, the clock frequency F should be within the following range:


1 ~ 5 MHz, Class A, or


1 ~ 4 MHz, Class B.

The circuit activation sequence ends (RST is in the L state, VCC is powered on, the I/O on the interface device is in the receiving mode, and when the operation is in Class A, VPP is paused, after providing an appropriate and stable clock signal for the CLK), the card is prepared for cold reset according to the specified time sequence.

 

 

2. Information exchange

If the card supports the category of operation conditions, the card should respond to any reset. After any reset response is completed, the interface device can enable the hot reset of the card. The response to a hot reset may be different from the response to the previous reset, regardless of whether the previous reset is a cold reset or a hot reset. After a reset response indicating the negotiation method is completed, the interface device can enable PPS switching as required.

The procedure of a command depends on the transfer protocol. It mainly includes asynchronous half-duplex character transmission and asynchronous half-duplex Block Transmission Based on interface devices. When the slave card is not transmitted (equivalent to one command and the other command is started), if the card supports clock stop, the interface device can even stop the clock signal.

 

2.1 cold reset

InTaTime to apply a clock signal to the CLK. The 200 clock periods (Ta) (Time periodTaInTa) Within the range, the card should set the I/O line to the status Z. After the clock signal is applied to the CLK, by keeping the RST in the state l at least 400 clock cycles (TB) (Time periodTBInTa) To reset the card.

InTBTime, RST is placed in State H.I/OResponse onSignal on RSTRising edgeNext 400And40000Clock cycles(TC) (Time periodTCInTBAfter.

In the case that the RST is in the status H, if the response has not started for the first 40000 clock cycles, the signal on the RST should be returned to the status l, and the interface device stops the circuit.

 

2.2. Hot Reset

As shown in the figure, the interface device sets the RST to the state l at least 400 clock cycles (Time PeriodsTe) To start the hot reset, while the VCC and CLK remain stable.

InTDTime, RST is placed in State H. I/O should be promised after the rising edge of the RST SignalOf400 to 40000 clock cycles (TF) (Time periodTFInTD.

When the RST is in the state H, if the responseWeiAt the beginning of the 40000 cycle, the signal on the RST should be returned to the status l, and the interface device will stop the circuit.

 

 

2.3. Clock stopped

When the interface device considers that the slave card is not transmitted and the I/O is in the I/O holding status, the device has at least 1860 clock periods (time periods ).TG), The interface device can stop the clock on the CLK (inTeTime ).

When the clock is stopped (fromTeTimeTFTime), CLK should be in the H or l state; this state is indicated by the parameter X.

InTFTime, interface device restart clock, information exchange on I/OYesAfter at least 700 clock cycles (time periodThInTF.

 

3. Stop

When the information exchange ends or is abandoned (for example, no response is sent or the card removal is detected), the interface device should stop the active circuit in the following order as shown in the figure.

--
RST is set to state L;

--
CLKQuiltSet to status L (unless the clock has stopped in status L );

--
VPPStopped (if it has been activated );

--
I/OQuiltSet to status;

--
VCCQuiltStop.

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.