Summary of the invention
The technical problem to be solved in the present invention is, for the above-mentioned defect of prior art, provides a kind of interrupt detection apparatus and method thereof of mobile terminal, is intended to solve the not enough problem of interruption pin that existing external interrupt increase causes mobile terminal master controller.
The technical scheme that technical solution problem of the present invention adopts is as follows:
An interrupt detection apparatus for mobile terminal, for detection of the down trigger state of module with interrupt function, it comprises
Multiple external interrupt, for exporting corresponding interrupt trigger signal in the time having the module down trigger of interrupt function;
Scrambler, during for detection of multiple external interrupt output interrupt trigger signal, generates gap coding according to the order of connection of multiple external interrupt and scrambler to multiple interrupt trigger signal codings;
Down trigger module, exports enabled instruction for detection of arbitrary external interrupt while exporting effective interrupt trigger signal;
Master controller, for the order of connection of prestore multiple external interrupt and scrambler, obtains described gap coding and resolves after reception enabled instruction, identifies the external interrupt that down trigger occurs in conjunction with the order of connection;
Described multiple external interrupt connects respectively scrambler and down trigger module, and described master controller connects scrambler and down trigger module.
In the interrupt detection apparatus of described mobile terminal, described master controller comprises:
Interrupt detection module, for working according to the enabled instruction control interrupt source acquisition module receiving;
Interrupt source acquisition module, for the order of connection of prestore multiple external interrupt and scrambler, obtains described gap coding and resolves, and identifies the external interrupt of down trigger in conjunction with the order of connection;
Described interruption detection module disconnecting trigger module and interrupt source acquisition module, described interrupt source acquisition module connects scrambler.
In the interrupt detection apparatus of described mobile terminal, when described interruption detection module configure interrupt trigger pip high level is effective, described down trigger module is many inputs or door; When described interruption detection module configure interrupt trigger pip Low level effective, described down trigger module is many inputs and door.
In the interrupt detection apparatus of described mobile terminal, the coding formula of described scrambler is: Y=X
1× 2
0+ X
2× 2
1+ X
3× 2
2+ X
4× 2
3+ ... + X
n× 2
n-1, wherein, Y is gap coding, the number that n is external interrupt, X
1represent the interrupt trigger signal of the first external interrupt output, X
2represent the interrupt trigger signal of the second external interrupt output, by that analogy, X
nrepresent the interrupt trigger signal of n external interrupt output.
In the interrupt detection apparatus of described mobile terminal, described external interrupt is 4, comprise the first external interrupt, the second external interrupt, the 3rd external interrupt and the 4th external interrupt, the output terminal of described the first external interrupt connects the IN1 pin of scrambler and the in1 pin of down trigger module, the output terminal of the second external interrupt connects the IN2 pin of scrambler and the in2 pin of down trigger module, the output terminal of the 3rd external interrupt connects the IN3 pin of scrambler and the in3 pin of down trigger module, the output terminal of the 4th external interrupt connects the IN4 pin of scrambler and the in4 pin of down trigger module, the HSCL pin of the SSCL pin disconnecting source acquisition module of described scrambler, the HSDA pin of the SSDA pin disconnecting source acquisition module of scrambler, the IRQ pin of the output pin OUT disconnecting detection module of down trigger module.
An interruption detection method for mobile terminal, it comprises:
The prestore order of connection of multiple external interrupt and scrambler of A, master controller, multiple external interrupt are exported corresponding interrupt trigger signal in the time of the module down trigger with interrupt function of correspondence;
When B, scrambler detect multiple external interrupt output interrupt trigger signal, according to the order of connection of multiple external interrupt and scrambler, multiple interrupt trigger signal codings are generated to gap coding; When detecting arbitrary external interrupt output interrupt trigger signal, down trigger module exports enabled instruction;
C, master controller obtain described gap coding and resolve after receiving enabled instruction, identify the external interrupt that down trigger occurs in conjunction with the order of connection.
In described interruption detection method, in described step B, the coding formula of scrambler is: Y=X
1× 2
0+ X
2× 2
1+ X
3× 2
2+ X
4× 2
3+ ... + X
n× 2
n-1, wherein, Y is gap coding, the number that n is external interrupt, X
1represent the interrupt trigger signal of the first external interrupt output, X
2represent the interrupt trigger signal of the second external interrupt output, by that analogy, X
nrepresent the interrupt trigger signal of n external interrupt output.
Compared to prior art, the interrupt detection apparatus of mobile terminal provided by the invention and method thereof, while detecting the module down trigger with interrupt function by scrambler, the interrupt trigger signal of multiple external interrupt outputs, according to the order of connection of multiple external interrupt and scrambler, multiple interrupt trigger signal codings are generated to gap coding, down trigger module detects when arbitrary external interrupt is exported effective interrupt trigger signal, output enabled instruction control master controller obtains described gap coding and resolves, master controller can identify according to the order of connection of the multiple external interrupt that prestore and scrambler and analysis result the external interrupt that down trigger occurs, master controller only need to arrange an interrupt pin and just can detect multiple external interrupt like this, has reduced the pin number of master controller, has saved resource for mobile terminal, has improved mobile terminal work efficiency.
Embodiment
The invention provides a kind of interrupt detection apparatus and method thereof of mobile terminal, for making object of the present invention, technical scheme and advantage clearer, clear and definite, developing simultaneously referring to accompanying drawing, the present invention is described in more detail for embodiment.Should be appreciated that specific embodiment described herein, only in order to explain the present invention, is not intended to limit the present invention.
The present invention is directed to the increase of existing mobile terminal external interrupt causes primary controller interruption pin not enough, increase interruption pin and can increase area and the cost of master controller, take the problem in the space of mobile terminal, adopt the mode that external interrupt is carried out to code identification to reduce primary controller and interrupt the number setting of pin, to save the resource of mobile terminal.Refer to Fig. 1, the interrupt detection apparatus of described mobile terminal comprises multiple external interrupt, master controller 100, scrambler 200 and down trigger module 300, the input end of described multiple external interrupt connects respectively the corresponding module with interrupt function (as button, WIFI chip, touch-screen etc.), the output terminal of multiple external interrupt connects respectively the input end of scrambler 200 and the input end of down trigger module 300, and the input end of described master controller 100 connects the output terminal of scrambler 200 and the output terminal of down trigger module 300.
Wherein, multiple external interrupt comprise the first external interrupt, the second external interrupt, the 3rd external interrupt ..., n external interrupt, n is positive integer, the number of the module with interrupt function arranging in the value of n and mobile terminal is identical.An external interrupt of the corresponding connection of each module with interrupt function.In the time having the module down trigger of interrupt function, its corresponding external interrupt is exported corresponding interrupt trigger signal.Scrambler 200 detects the interrupt trigger signal of multiple external interrupt output, according to the order of connection of multiple external interrupt and scrambler 200 to multiple interrupt trigger signals (that is to say its low and high level is encoded) generation gap coding of encoding.Meanwhile, down trigger module 300 detects and when arbitrary external interrupt is exported effective interrupt trigger signal, exports enabled instruction.The order of connection of multiple external interrupt that prestore in master controller 100 and scrambler 200, obtains described gap coding and resolves after reception enabled instruction, can identify the external interrupt that down trigger occurs in conjunction with the order of connection.
In the present embodiment, described master controller 100 comprises interruption detection module 101 and interrupt source acquisition module 102, described interruption detection module 101 disconnecting trigger modules 300 and interrupt source acquisition module 102, and described interrupt source acquisition module 102 connects scrambler 200.Interrupting detection module 101 works according to the enabled instruction control interrupt source acquisition module 102 receiving.The order of connection of multiple external interrupt that prestore in interrupt source acquisition module 102 and scrambler 200, obtains described gap coding and resolves, and identifies which external interrupt be interrupted triggering in conjunction with the order of connection.
In the present embodiment, described interrupt trigger signal is divided into high level effectively and Low level effective.If high level is effective, represent external interrupt not when down trigger, interrupt trigger signal is low level; When down trigger, interrupt trigger signal becomes high level.Accordingly, described interruption detection module 101 is configured to interrupt trigger signal high level effective, described down trigger module 300 adopts many inputs or door.All external interrupt are not all when down trigger, and the interrupt trigger signal of its output is low level, now many inputs or door output low level.In the time that arbitrary external interrupt is exported the interrupt trigger signal of effective high level, input more or door be exportable high level, i.e. enabled instruction.That is to say, when interrupt trigger signal high level is effective, enabled instruction is also that high level is effective.
In like manner, if Low level effective, represent external interrupt not when down trigger, interrupt trigger signal is high level; When down trigger, interrupt trigger signal becomes low level.Accordingly, described interruption detection module 101 is configured to interrupt trigger signal Low level effective, down trigger module 300 adopts many inputs and door.All external interrupt are not all when down trigger, and the interrupt trigger signal of its output is high level, now many inputs and a door output high level.In the time of the effective low level interrupt trigger signal of arbitrary external interrupt output, many inputs get final product output low level, i.e. enabled instruction with door.That is to say, when interrupt trigger signal Low level effective, enabled instruction is also Low level effective.
In the specific implementation, the module based on having interrupt function is interrupted the uniqueness arranging, the interrupt trigger signal of its generation can not be all high level effectively or Low level effective.The present embodiment taking significant level more as main come configure interrupt detection module 101, remainingly before the output of external interrupt, carry out anti-phase processing and make significant level unified.Suppose to have 8 external interrupt, high level effectively accounts for 6, remaining 3 Low level effectives.Interruption detection module 101 is configured to high level effective, down trigger module 300 adopts many inputs or door, increases by three phase inverters.The output terminal of 3 external interrupt (Low level effective) connects respectively the input end of a phase inverter, and the output terminal of three phase inverters connects respectively the input end of scrambler 200 and the input end of many inputs or door.
After significant level setting completes, scrambler 200 can start according to the order of connection of multiple external interrupt and scrambler, multiple interrupt trigger signals to be encoded.In the present embodiment, the coding formula of scrambler 200 is: Y=X
1× 2
0+ X
2× 2
1+ X
3× 2
2+ X
4× 2
3+ ... + X
n× 2
n-1, wherein, Y is gap coding, the number that n is external interrupt.X
1represent the interrupt trigger signal of the first external interrupt output, X
2represent the interrupt trigger signal of the second external interrupt output, by that analogy, X
nrepresent the interrupt trigger signal of n external interrupt output.When interrupt trigger signal is effective, X equals 1; When interrupt trigger signal is invalid, X equals 0.Multiple external interrupt with the order of connection of scrambler 200 are: the first external interrupt is connected the first input pin of scrambler 200, and the second external interrupt connects the second input pin of scrambler 200, and by that analogy, n external interrupt connects the n input pin of scrambler 200.
In the present embodiment, described gap coding, for scrambler is according to the coding of the level state of its each input pin, and the each input pin connection of scrambler is external interrupt.That is to say, whether the gap coding that scrambler is exported is actually and triggers to encode according to each external interrupt.In the specific implementation, can also adopt other coded systems, be which external interrupt triggers as long as can make master controller identify, and its coded system and the order of connection are all in protection domain of the present invention.
Scrambler 200 carries out I2C digital communication with master controller 100, and gap coding is transferred to master controller 100.Master controller 100 is according to the described order of connection to described gap coding and resolve, and can identify is which external interrupt is interrupted triggering.
Please refer to Fig. 2, the present embodiment is taking external interrupt as 4, and interrupt trigger signal is all that high level is effective, and it is example that down trigger module 300 adopts many inputs or door.4 external interrupt are respectively the first external interrupt 401, the second external interrupt 402, the 3rd external interrupt 403 and the 4th external interrupt 404.4 external interrupt with the order of connection of scrambler are: the output terminal of described the first external interrupt 401 is connected the IN1 pin of scrambler 200 and the in1 pin of many inputs or door, the output terminal of the second external interrupt connects the IN2 pin of scrambler and the in2 pin of many inputs or door, the output terminal of the 3rd external interrupt connects the IN3 pin of scrambler and the in3 pin of many inputs or door, the output terminal of the 4th external interrupt connects the IN4 pin of scrambler and the in4 pin of many inputs or door, the HSCL pin of the SSCL pin disconnecting source acquisition module 102 of described scrambler 200, the HSDA pin of the SSDA pin disconnecting source acquisition module 102 of scrambler, the IRQ pin of the output pin OUT disconnecting detection module 101 of many inputs or door.Gap coding Y=X
1× 2
0+ X
2× 2
1+ X
3× 2
2+ X
4× 2
3, wherein, X
1represent the interrupt trigger signal of the first external interrupt output 401 on IN1 pin, X
2represent the interrupt trigger signal that on IN2 pin, the second external interrupt 402 is exported, X
3represent the interrupt trigger signal that on IN3 pin, the 3rd external interrupt 403 is exported, X
4represent the interrupt trigger signal that on IN4 pin, the 4th external interrupt 404 is exported.
Suppose X
1, X
2, X
4high level is effective, X
3for low level.Y=1 × 1+1 × 2+0 × 4+1 × 8=11.Scrambler 200 is the HSDA pin to master controller 100 by SSDA pin Transmission coding Y.It is 1101 that master controller is resolved gap coding Y, by the order of connection of from left to right distinguishing corresponding the first external interrupt ~ four external interrupt, can identify the first external interrupt, the second external interrupt, the portion's down trigger all round, and the 3rd external interrupt does not trigger.Master controller only need to arrange an interrupt pin and just can detect multiple external interrupt like this, has reduced the pin number of master controller, has saved resource for mobile terminal, has improved mobile terminal work efficiency.
Based on the interrupt detection apparatus of above-mentioned mobile terminal, the present invention also provides a kind of interruption detection method of mobile terminal, and please refer to Fig. 3, as shown in Figure 3, it comprises described interruption detection method:
The prestore order of connection of multiple external interrupt and scrambler of S100, master controller, multiple external interrupt in the time of the module down trigger with interrupt function of correspondence, export corresponding interrupt trigger signal;
S200, scrambler detect described interrupt trigger signal, according to the order of connection of multiple external interrupt and scrambler, multiple interrupt trigger signal codings are generated to gap coding; When detecting arbitrary external interrupt output interrupt trigger signal, down trigger module exports enabled instruction;
S300, master controller obtain described gap coding and resolve after receiving enabled instruction, identify the external interrupt that down trigger occurs in conjunction with the order of connection, specifically refer to above-described embodiment.
Before described steps A, also need according to effectively still Low level effective of interrupt trigger signal high level, the enabled instruction that the IRQ pin that interrupts detection module in master controller is received is configured to high level effectively or Low level effective, specifically refers to above-described embodiment.
In described step B, the coding formula of scrambler is: Y=X
1× 2
0+ X
2× 2
1+ X
3× 2
2+ X
4× 2
3+ ... + X
n× 2
n-1, wherein, Y is gap coding, the number that n is external interrupt, X
1represent the interrupt trigger signal of the first external interrupt output, X
2represent the interrupt trigger signal of the second external interrupt output, by that analogy, X
nthe interrupt trigger signal that represents the output of n external interrupt, specifically refers to above-described embodiment.
In sum, the interrupt trigger signal that the present invention exports while detecting multiple external interrupt down trigger by scrambler, according to the order of connection of multiple external interrupt and scrambler, multiple interrupt trigger signal codings are generated to gap coding, when detecting arbitrary external interrupt output interrupt trigger signal, down trigger module exports enabled instruction, interrupting detection module obtains described gap coding and resolves according to enabled instruction control interrupt source acquisition module, it is which external interrupt triggers that multiple external interrupt that master controller basis prestores and the order of connection of scrambler and analysis result can identify, master controller only need to arrange an interrupt pin and just can detect multiple external interrupt like this, has reduced the pin number of master controller, has saved resource for mobile terminal, has improved mobile terminal work efficiency.
Should be understood that, application of the present invention is not limited to above-mentioned giving an example, and for those of ordinary skills, can be improved according to the above description or convert, and all these improvement and conversion all should belong to the protection domain of claims of the present invention.