Summary of the invention
The object of the present invention is to provide a kind of interface arrangement that is used for SIM card and usim card, above-mentioned shortcoming at prior art, can be according to the residing network condition of mobile phone, can with the SIM card interface of 2G or the usim card interface of 3G, when interface was in the SIM card working method, interface arrangement was selected the byte transmission mode, when interface is in the usim card working method, select the transmission mode of byte or character block, the load mode efficient height of character block has satisfied the multiservice requirement of 3G fully.
Technical scheme of the present invention comprises:
A kind of interface arrangement that is used for SIM card and usim card wherein, comprising: bus interface module, register module, interruption processing module, clock generating module, state machine module, reception and sending module, card detection module, supply module;
Described interface arrangement is connected a side with the microprocessor of terminal, comprise: bus clock signal pclk, bus chip selection signal p_cs, bus address line padr, bus are write read control signal pwr_rd, bus write data signal pwdata, bus reading data signal prdata, reset signal prst, clock signal fclk; And dma operation request signal nreq_dma, dma operation end signal nend_dma; Interrupt request singal nirq and fast interrupt request line nfrq at a slow speed, wherein to write read control signal pwr_rd be that high level is represented write operation to bus, for low level is represented read operation; Signal reset signal prst, dma operation request signal nreq_dma, dma operation end signal nend_dma low level are effective;
The side that described interface arrangement is connected with SIM/USIM card or draw-in groove, comprise: card power supply opening/closing control signal sc_pwctrl, card reset signal sc_rst, card clock signal sc_clk, card receiving and transmitting data signals sc_io, through described supply module, other level signal of the same level of real work voltage output according to card, wherein blocking receiving and transmitting data signals sc_io is bidirectional signal line, and card reset signal sc_rst low level is effective.
Described device, wherein, the signal that described interface arrangement is connected with draw-in groove is card detection signal sc_cd, is used for test card whether in draw-in groove.
Described device, wherein, described interface arrangement partly is put into digital circuit in the digital baseband chip in the mobile phone nest plate and realizes that described digital circuit partly comprises bus interface module, register module, time processing module, interruption processing module, state machine module, transmission and receiver module, the card detection module in the interface arrangement; Artificial circuit part is put into power management module realizes that described artificial circuit part comprises the supply module in the interface arrangement.
Described device, wherein, described supply module is arranged in the Analog Baseband chip and realizes.
Described device, wherein, described bus interface module is used to finish between the microprocessor of interface arrangement and terminal and carries out exchanges data, comprise the store information of reading SIM card/usim card and from the order of issuing SIM card/usim card, control, the data message of application layer, and drive software is by the working method of the described interface arrangement of this interface configuration and the duty of monitoring interface arrangement.
Described device, wherein, described bus interface module comprises register interface, DMA interface, three parts of interrupt interface, and the microprocessor of described terminal carries out write operation, read operation by described register interface to the register in the described register module; Described DMA interface provides an efficient data load mode for interface arrangement, selects dma mode to carry out data from the data in the transceiver module buffer memory and transmits; Link to each other from the look-at-me of interface arrangement interruptable controller by the microprocessor of described interrupt interface and described terminal.
Described device, wherein, described register module comprises the register of keeping the interface arrangement operate as normal, comprise command register, status register, configuration register, interruption status/mask register, have card start-up/card work to cease and desist order, block cold reset/hot reset order, card clock suspension/recovery order in the described command register; The indication of forwards/reverse agreement state, FIFO sky/full state indication, the indication of card testing result state are arranged in the described status register; Character transmission/character block transmission configuration is arranged in the described configuration register, interface manually/configuration of interface automated manner, the configuration of card clock frequency, the configuration of rate factor DI/FI, transmission/reception deploy content; Have in described interruption status/mask register with card and detect relevant quick interruption and the interruption at a slow speed that is sent completely/finishes receiving.
Described device, wherein, described clock generating module is used to SIM card/usim card and interface arrangement that suitable clock is provided, and its clock is carried out frequency division handle.
Described device, wherein, described time processing module is used to produce the required timer of described interface arrangement, comprises that card insertion/taking-up timer, required timer, the data of reset answer send/receive required timer, clock suspension/recovery timer.
Described device, wherein, described interruption processing module is used for interrupting fast and interrupting at a slow speed; Described quick interruption is that card detects interruption through the output of nfrq signal wire; The described interruption at a slow speed through the output of nirq signal wire comprises being sent completely, finishing receiving, receiving mistake, receive time-out operation.
Described device, wherein, described card detection module is used to detect SIM card/usim card whether in draw-in groove, after card is inserted in the draw-in groove, described interface arrangement detects card and exists, and this information disappeared to tremble handle the back and notify the software of described interface arrangement with the form of quick interruption, software activates the card upper contact in proper order; If card takes out in draw-in groove, described interface arrangement detects card and does not exist, and reports in the mode of quick interruption, and produces the alarm signal that card takes out, and disconnects power supply, clock, the data-signal of card simultaneously.
Described device, wherein, described state machine module is used for the activation and the release of control card, the reset answer process of control card and protocol transmission process, the clock suspension of control card and rejuvenation, the cold reset of control card, hot reset process.
Described device, wherein, described interface arrangement is supported the clock suspension function, when not having data transmission between card and the portable terminal, described interface arrangement suspends the clock of card.
Adopt the interface arrangement that is used for SIM card and usim card of the present invention, the SIM card interface that promptly can be used for the 2G epoch also can be used for the usim card interface in 3G epoch simultaneously, reduced the research and development expense of mobile phone nest plate, when not having message exchange, interface arrangement can suspend the clock in the card, reduce power consumption like this, prolonged the stand-by time of mobile phone; Interface arrangement of the present invention not only provides the character transmission mode, also can provide the character block transmission mode, improve the data transmission efficiency between card and the interface arrangement, interface arrangement also provides the warm reset function, when unusual error of transmission appears in card, utilize the warm reset duty of quick-recovery card soon.
Embodiment
Below in conjunction with accompanying drawing, will carry out comparatively detailed explanation to each preferred embodiment of the present invention.
The interface arrangement that is used for SIM card and usim card of the present invention, as shown in Figure 1, the interface arrangement, SIM/USIM card, draw-in groove three's physical connection relation and the annexation between the interface arrangement internal module that have shown card, wherein Ka interface arrangement by bus interface module, register module, interruption processing module, clock generating module, state machine module, reception and sending module, card exist detect and disappear tremble module, supply module totally 8 partly form.
As shown in Figure 1, the input of interface arrangement of the present invention, output signal annexation are as follows:
The left signal of described interface arrangement mainly is connected with microprocessor, main signal comprises that bus clock signal (pclk), bus chip selection signal (p_cs), bus address line (paddr), bus write read control signal (pwr_rd), bus write data signal (pwdata), bus reading data signal (prdata), reset signal (prst), clock signal (fclk); Also have dma operation request signal (nreq_dma), dma operation end signal (nend_dma); And interrupt request singal (nirq) and fast interrupt request line (nfrq) at a slow speed, wherein pwr_rd is that high level is represented write operation, for low level is represented read operation, signal Prst, nreq_dma, nend_dma, low level are effective.
The right side singal of described interface arrangement mainly is connected with SIM/USIM card or draw-in groove, the signal that links to each other with card mainly comprises card power supply opening/closing control signal (sc_pwctrl), card reset signal (sc_rst), card clock signal (sc_clk), card receiving and transmitting data signals (sc_io), wherein these signals that are connected with card all will be through the supply module in the interface arrangement, real work voltage 5v/3.3v/1.8v according to card, other level signal of the same level of output, wherein said data-signal sc_io is a bidirectional signal line, and signal sc_rst low level is effective.
The signal that the right of described interface arrangement is connected with draw-in groove is card detection signal sc_cd, is used for test card whether in draw-in groove.
Be the application example of interface arrangement of the present invention in the mobile phone nest plate as shown in Figure 2, common mobile phone nest plate is made up of digital baseband chip, Analog Baseband chip, transmission and received RF chip, power management chip etc., interface arrangement of the present invention is when realizing, at first carrying out module splits, digital circuit partly is put in the digital baseband chip realizes, comprise bus interface module, register module, time processing module, interruption processing module, state machine module, transmission and receiver module, card detection module etc. in the interface arrangement; Artificial circuit part is put into power management module realizes, comprise the supply module in the interface arrangement, realize that such scheme also is feasible if supply module is put in the Analog Baseband chip.
Be the drive software structure of interface arrangement of the present invention as shown in Figure 3, layer interface is an interface hardware under the software of described interface arrangement, high-level interface is a protocol layer software, drive software operates on the operating system, be divided into " interface Interrupt Process " and " interface driving task " two parts, the function that drive software is realized is to receive data, control information from protocol layer, and send to card with the form of character or character block, be from the clamping breath of collecting mail on the other hand, and resolve these information and report protocol layer software.
The identification of the SIM card of interface arrangement of the present invention and usim card type is also finished under software control in addition, interface software at first selects a kind of Card Type to carry out reset answer and agreement communication, card also can feed back correct information to interface arrangement if selection is correct, otherwise then select remaining Card Type to carry out the agreement communication again, in case the type of interface arrangement identification card release, the type of just automatic registration card, and use the agreement communication of having chosen Card Type in the communication afterwards, till card takes out from draw-in groove.
As shown in Figure 2, the major function of the internal module of interface arrangement of the present invention and mutual relationship are as follows:
Described bus interface module is mainly used in to finish and carries out exchanges data between interface arrangement and the microprocessor, comprises the store information of reading SIM card/usim card and from the order of issuing SIM card/usim card, control, the data message of application layer, drive software also can be by the working method of this interface configuration interface arrangement of the present invention and the duty of monitoring interface arrangement in addition.
Described bus interface module comprises register interface, DMA interface, three parts of interrupt interface, and microprocessor can carry out write operation, read operation to the register in the register module by register interface; DMA interface provides a kind of efficient data load mode for interface arrangement, can select dma mode to carry out data from the data in the transceiver module buffer memory and transmit; Link to each other from the look-at-me of interface arrangement interruptable controller by interrupt interface and CPU.
Described register module mainly comprises the register of keeping the interface arrangement operate as normal, these registers have command register, status register, configuration register, interruption status/mask register etc., wherein have card start-up/card work to cease and desist order, block cold reset/hot reset order, card clock suspension/recovery order in the command register; The indication of forwards/reverse agreement state, FIFO sky/full state indication, the indication of card testing result state etc. are arranged in the status register; Character transmission/character block transmission configuration is arranged in the configuration register, interface manually/configuration of interface automated manner, the configuration of card clock frequency, the configuration of rate factor DI/FI, contents such as transmission/reception configuration; The quick interruption relevant with the card detection arranged in interruption status/mask register and be sent completely/finish receiving etc. interrupted at a slow speed.
As shown in Figure 4, described clock generating module is mainly SIM card/usim card and interface arrangement provides suitable clock, when interface arrangement is in the SIM working method, and FCLK=13Mhz; When interface arrangement is in the USIM working method, FCLK=15.36Mhz; At first FCLK being carried out frequency division handles, dividing method has four kinds to select MCLK=FCLK, MCLK=FCLK/2, MCLK=FCLK/4, MCLK=FCLK/8, the MCLK that obtains is the major clock of interface arrangement, card clock SC_CLK is the clock that equates with the MCLK frequency, and can carry out the control of opening/closing separately, ETU_CLK is adopted in the transmission of interface arrangement and reception, it is that MCLK waits until through the baud rate frequency divider, Frequency Dividing Factor commonly used has DI/FI=1/372,2/372,4/372,8/512,16/512, also support the DI that ISO/IEC7816-3 defines, FI institute might situation.
Described time processing module mainly produces the required timing unit of interface arrangement, and these timers comprise that card insertion/taking-up timer, required timer, the data of reset answer send/receive required timer, clock suspension/recovery timer.
Described interruption processing module is mainly handled two type of interrupt, interrupt fast and interrupt at a slow speed, interrupt fast through the output of nfrq signal wire, interrupt at a slow speed through the output of nirq signal wire, quick interrupt source in the interface arrangement then has only one, be that card detects interruption, when card is put in the draw-in groove or card takes out in the draw-in groove and all produces interruption fast, interrupt source at a slow speed in the interface arrangement comprises and is sent completely, finishes receiving, receives mistake, receive time-out etc., all these at a slow speed interrupt source be unified in the output of nirq signal wire after handling through " interruption processing module ".
The major function of described card detection module is to detect SIM card/usim card whether in draw-in groove, after card is inserted in the draw-in groove, interface arrangement detects card and exists, and this information disappeared to tremble handle the software of back with the form notification interface device of quick interruption, software activates the card upper contact in proper order, finish user's registration by interface arrangement after the card operate as normal, network registry success back user just can enjoy Internet resources; In case card takes out in draw-in groove, interface arrangement detects card and has not existed, and also the mode with quick interruption reports, and produces card taking-up alarm signal, disconnects power supply, clock, the data-signal of card simultaneously.
The input clock of described card detection module is clk_32khz, input signal is sc_cd, output is quick interruption, for fear of producing erroneous judgement, be necessary to exist incident, card taking-up incident to disappear and tremble processing to card, method is to adopt card insertion/taking-up timer, in the timer official hour, the incident that is consecutively detected takes place, and then judgement incident is set up, and timing is the number of cycles of configurable clock clk_32khz.
Described state machine module is the core of whole interface arrangement, interface arrangement utilizes state machine module to come the activation and the release of control card, reset answer process of control card (ATR process) and protocol transmission process (PPS process), the clock suspension of control card and rejuvenation, the cold reset of control card, hot reset process.
Control to card in state machine module has manual mode and two kinds of control modes of automatic mode, under manual mode, interface arrangement software is the timing unit in processing module service time not, required timer is provided by microprocessor, and the interface arrangement software directly interface signal line of control card is finished the activation and the releasing operation of sequence, comprise the power supply (sc_pwctrl control), the card that open and close card reset control (sc_rst control), open and close and block clock (sc_clk control), selection transmission accepting state (sc_io control).
As shown in Figure 5, automatic mode of the present invention is the state machine that comprises 16 states, the time that jump condition between the state executes from the order in the command register or this status function, each state was all finished specific function in the state machine, is described in detail as follows respectively to condition:
Idle condition: do not have SIM card/usim card in the draw-in groove this moment, the contact of Connection Card be not activated be interface arrangement and card to be connected signal condition as follows:
Interface output line SC_CLK=0
Interface output line SC_RST=0
Interface output line SC_PWCTRL=0
Interface output line SC_IO=0
Interface incoming line SC_CD=0
The card power-up state: detect card this moment and exist, beginning activates the contact in proper order, and the power supply of at first opening card is SC_PWCTRL=1.
The IO line is in accepting state: this state is configured to accepting state to bidirectional signal line SC_IO, is ready to receive data from blocking.
Open clock status: this state is opened the clock of card, promptly occurs periodic clock on the SC_CLK signal wire.
Be reset to high state: stop the cold reset to card, promptly SC_RST becomes high level by low level.
The reset answer waiting status: interface arrangement receives from first Bit data on the card, and method is an interface arrangement continuous sampling SC_IO line, if the start bit of detecting shows that then card can carry out data transmission, transfers to next state.
Forward and inverse detection state: receive from first 8 bit byte in the card, if content is 0x3B then is judged to be direct convention, if content is 0x03 then is judged to be Backward Agreement that stipulated form determines that rear port device and card just can carry out normal information interchange.
Data send accepting state: this state is that interface arrangement and SIM card/usim card carry out the normal information exchange status, and interface arrangement can send message to card, also can receive from the information in the card, otherwise also be the same concerning card.
The clock suspension state: in order to reduce power consumption, prolongs standby time, when not having message to transmit, interface arrangement can suspend the clock of card, promptly disposes SC_CLK=0.
Clock recovery state: when having message to transmit, recover the clock of card.
The hot reset state: the information interchange between interface arrangement and card repeatedly occurs when unusual, and interface arrangement can be initiated the hot reset process, forces to stick into resetting of capable duty, transfers to the reset answer waiting status after the hot reset state is finished.
Cease and desist order or the reset answer failure if receive, interface arrangement of the present invention connects the order releasing contact, relates to following state:
Be reset to low state: make signal wire SC_RST=0.
Close clock status: close the card clock and make SC_CLK=0.
The IO line is in transmit status: make signal wire SC_IO=0,
The transmission of interface arrangement of the present invention and receiver module comprise transmission and receive two parts, each part all has a buffer memory FIFO who is used for store data, the data that receive from card can be stored in to receive among the FIFO and keep in, the data that interface arrangement need send also can be put into to send among the FIFO and deposit, when data traffic is big, can adopt the mode of DMA to carry out reporting and issuing of data by bus interface module.
The transmission of described data and reception have SIM card, two kinds of working methods of usim card, when being in the SIM card working method, adopt 8 bit byte load modes, only transmit 1 byte between interface arrangement and the card at every turn, receiving end carries out parity checking to the byte that receives, if find mistake then need transmitting terminal to resend this byte; When the usim card working method, can select byte or character block load mode, the byte load mode and the SIM card of usim card are the same, when the character block load mode, can transmit a plurality of 8 bit bytes between interface arrangement and the card, verification mode adopts block check at every turn.
The supply module of interface arrangement of the present invention can be according to the voltage kind of card support, for interface signal line provides the appropriate level signal, can select 5V or 3.3v in the SIM card working method, select 3.3v or 1.8v when the usim card working method, the selection of voltage kind is by signal wire vcc_mode[1:0] realize, work as vcc_mode[1:0]=00, select 5V, vcc_mode[1:0]=01,3.3v selected, vcc_mode[1:0]=10,1.8v selected.
The above embodiment of the present invention at hardware aspect numeral, simulation separate processes, its advantage be realize simple, cost is low, clear layer aspect software is utilized operating system, can handle simultaneously a plurality of tasks, real-time good, stablize.
SIM card and the usim card interface arrangement of being used for of the present invention supported the clock suspension function, and when not having data transmission between card and the portable terminal, described interface arrangement will suspend the clock of card, so just can conserve energy, and the stand-by time that effectively prolongs mobile phone; Automatically whether test card in the mobile phone draw-in groove, when unusual contact occurring when bad, produces alarm signal.
In addition, the interface arrangement of the present invention also voltage level of support card is variable, can select 5V/3.3V or 3.3v/1.8v, supports transmission factor Di/Fi=1/372 flexibly, and 2/372,4/372,8/512,16/512 etc., support card cold reset, hot reset operation.
Should be understood that above-mentioned description at specific embodiment is comparatively detailed, can not therefore think the restriction to scope of patent protection of the present invention, scope of patent protection of the present invention should be as the criterion with claims.