Summary of the invention
In view of this, the embodiment of the present invention provides a kind of module identification method and terminal unit, existing to solve
The problem that many degree of the GPIO port resource caused when having in method the module identifying more than 3 take.
To achieve these goals, it is proposed that scheme as follows:
The first aspect of the embodiment of the present invention provides a kind of module identification method, is applied to terminal unit, institute
First port of CPU stating terminal unit is connected with the detection port of module, second port of described CPU
It is connected with the second port of described module;Described method includes:
The second port controlling described CPU exports high level signal and low level signal respectively;
When the second port output high level signal of described CPU, detect the test side of described module respectively
Mouthful when receiving the signal of the first port transmission of the described CPU being configured to different conditions, described mould
The output signal of the detection port of group;When the second port output low level signal of described CPU, respectively
Detect the detection port of described module at the first port receiving the described CPU being configured to different conditions
During the signal transmitted, the output signal of the detection port of described module;First port of described CPU is joined
The state put includes inputting pull-up state, input pull-down state and inputting not tension state;
In conjunction with the output signal of the second port of described CPU and the detection port of described module that detects
The type of output signal, identifies described module.
In conjunction with the first aspect of the embodiment of the present invention, in the first reality of the first aspect of the embodiment of the present invention
Execute in mode, the output signal of second port of CPU described in described combination and the described module detected
The type of the output signal of detection port, identifies described module, including:
Determine satisfied first pre-conditioned, identify the module that described module is described module detection port ground connection;
Wherein, described first pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect the detection port of described module receive be configured as input to pull-up, input drop-down
During with the signal of the first port transmission that described CPU under three kinds of states is not drawn in input, the inspection of described module
The output signal surveying port is low level signal;Further, the output signal of second port of described CPU
During for low level signal, detect the detection port of described module receive be configured as input to pull-up,
When inputting the signal of the first port transmission that described CPU under three kinds of states is not drawn in drop-down and input, described
The output signal of the detection port of module is low level signal.
In conjunction with the first aspect of the embodiment of the present invention, real at the second of the first aspect of the embodiment of the present invention
Execute in mode, the output signal of second port of CPU described in described combination and the described module detected
The type of the output signal of detection port, identifies described module, including:
Determine satisfied second pre-conditioned, identify the mould that detection port that described module is described module is unsettled
Group;
Wherein, described second pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect that the detection port of described module is receiving the described CPU being configured as input to pull-up
The signal of the first port transmission time, the output signal of the detection port of described module is high level signal,
Detect described module detection port receive be configured as input to drop-down and input do not draw described in
During the signal of first port transmission of CPU, the output signal of the detection port of described module is low level
Signal;
Further, when the output signal of second port of described CPU is low level signal, described mould is detected
The detection port of group is at the signal of the first port transmission receiving the described CPU being configured as input to pull-up
Time, the output signal of the detection port of described module is high level signal, the detection of described module detected
Port is configured as input to the letter of the first port transmission that is drop-down and that input the described CPU not drawn receiving
Number time, described module detection port output signal be low level signal.
In conjunction with the first aspect of the embodiment of the present invention, in the third reality of the first aspect of the embodiment of the present invention
Execute in mode, the output signal of second port of CPU described in described combination and the described module detected
The type of the output signal of detection port, identifies described module, including:
Determine satisfied 3rd pre-conditioned, identify that the detection port that described module is described module connects power supply
Module;
Wherein, the described 3rd pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect the detection port of described module receive be configured as input to pull-up, input drop-down
During with the signal of the first port transmission that described CPU under three kinds of states is not drawn in input, the inspection of described module
The output signal surveying port is high level signal;Further, the output signal of second port of described CPU
During for low level signal, detect the detection port of described module receive be configured as input to pull-up,
When inputting the signal of the first port transmission that described CPU under three kinds of states is not drawn in drop-down and input, described
The output signal of the detection port of module is high level signal.
In conjunction with the first aspect of the embodiment of the present invention, in the 4th kind of reality of the first aspect of the embodiment of the present invention
Execute in mode, the output signal of second port of CPU described in described combination and the described module detected
The type of the output signal of detection port, identifies described module, including:
Determine satisfied 4th pre-conditioned, identify the second port and described mould that described module is described module
The module that the detection port of group is connected;
Wherein, the described 4th pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect the detection port of described module receive be configured as input to pull-up, input drop-down
During with the signal of the first port transmission that described CPU under three kinds of states is not drawn in input, the inspection of described module
The output signal surveying port is high level signal;Further, the output signal of second port of described CPU
During for low level signal, detect the detection port of described module receive be configured as input to pull-up,
When inputting the signal of the first port transmission that described CPU under three kinds of states is not drawn in drop-down and input, described
The output signal of the detection port of module is low level signal.
In conjunction with the first embodiment of first aspect of the embodiment of the present invention, the second embodiment or
The third embodiment, in the 5th kind of embodiment of the first aspect of the embodiment of the present invention, described knot
The output letter of the detection port of the output signal closing second port of described CPU and the described module detected
Number type identification described in module, also include:
Determine satisfied 4th pre-conditioned, identify the second port and described mould that described module is described module
The module that the detection port of group is connected;
Wherein, the described 4th pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect the detection port of described module receive be configured as input to pull-up, input drop-down
During with the signal of the first port transmission that described CPU under three kinds of states is not drawn in input, the inspection of described module
The output signal surveying port is high level signal;Further, the output signal of second port of described CPU
During for low level signal, detect the detection port of described module receive be configured as input to pull-up,
When inputting the signal of the first port transmission that described CPU under three kinds of states is not drawn in drop-down and input, described
The output signal of the detection port of module is low level signal.
Second aspect in the embodiment of the present invention provides a kind of terminal unit, including: CPU and module, institute
The detection port of the first port and described module of stating CPU is connected, second port of described CPU and institute
The second port stating module is connected, wherein,
Described CPU exports high level signal and low level letter respectively for the second port controlling described CPU
Number;When the second port output high level signal of described CPU, detect the test side of described module respectively
Mouthful when receiving the signal of the first port transmission of the described CPU being configured to different conditions, described mould
The output signal of the detection port of group;When the second port output low level signal of described CPU, respectively
Detect the detection port of described module at the first port receiving the described CPU being configured to different conditions
During the signal transmitted, the output signal of the detection port of described module;And combine second end of described CPU
The output signal of mouth and the type of the output signal of the detection port of the described module detected, identify described
Module, the state that first port of described CPU is configured includes inputting pull-up state, input pull-down state
With input not tension state.
In conjunction with the second aspect of the embodiment of the present invention, in the first reality of the second aspect of the embodiment of the present invention
Executing in mode, described CPU is described in combine the output signal of the second port of described CPU and detect
The type of the output signal of the detection port of module, when identifying described module, specifically for: determine satisfied
First is pre-conditioned, identifies the module that described module is described module detection port ground connection;
Wherein, described first pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect the detection port of described module receive be configured as input to pull-up, input drop-down
During with the signal of the first port transmission that described CPU under three kinds of states is not drawn in input, the inspection of described module
The output signal surveying port is low level signal;Further, the output signal of second port of described CPU
During for low level signal, detect the detection port of described module receive be configured as input to pull-up,
When inputting the signal of the first port transmission that described CPU under three kinds of states is not drawn in drop-down and input, described
The output signal of the detection port of module is low level signal.
In conjunction with the second aspect of the embodiment of the present invention, real at the second of the second aspect of the embodiment of the present invention
Executing in mode, described CPU is described in combine the output signal of the second port of described CPU and detect
The type of the output signal of the detection port of module, when identifying described module, specifically for: determine satisfied
Second is pre-conditioned, identifies the detection unsettled module of port that described module is described module;
Wherein, described second pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect that the detection port of described module is receiving the described CPU being configured as input to pull-up
The signal of the first port transmission time, the output signal of the detection port of described module is high level signal,
Detect described module detection port receive be configured as input to drop-down and input do not draw described in
During the signal of first port transmission of CPU, the output signal of the detection port of described module is low level
Signal;
Further, when the output signal of second port of described CPU is low level signal, described mould is detected
The detection port of group is at the signal of the first port transmission receiving the described CPU being configured as input to pull-up
Time, the output signal of the detection port of described module is high level signal, the detection of described module detected
Port is configured as input to the letter of the first port transmission that is drop-down and that input the described CPU not drawn receiving
Number time, described module detection port output signal be low level signal.
In conjunction with the second aspect of the embodiment of the present invention, in the third reality of the second aspect of the embodiment of the present invention
Executing in mode, described CPU is described in combine the output signal of the second port of described CPU and detect
The type of the output signal of the detection port of module, when identifying described module, specifically for: determine satisfied
3rd is pre-conditioned, identifies that the detection port that described module is described module connects the module of power supply;
Wherein, the described 3rd pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect the detection port of described module receive be configured as input to pull-up, input drop-down
During with the signal of the first port transmission that described CPU under three kinds of states is not drawn in input, the inspection of described module
The output signal surveying port is high level signal;Further, the output signal of second port of described CPU
During for low level signal, detect the detection port of described module receive be configured as input to pull-up,
When inputting the signal of the first port transmission that described CPU under three kinds of states is not drawn in drop-down and input, described
The output signal of the detection port of module is high level signal.
In conjunction with the second aspect of the embodiment of the present invention, in the 4th kind of reality of the second aspect of the embodiment of the present invention
Executing in mode, described CPU is described in combine the output signal of the second port of described CPU and detect
The type of the output signal of the detection port of module, when identifying described module, specifically for: determine satisfied
4th is pre-conditioned, identifies the second port and the detection port of described module that described module is described module
The module being connected;
Wherein, the described 4th pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect the detection port of described module receive be configured as input to pull-up, input drop-down
During with the signal of the first port transmission that described CPU under three kinds of states is not drawn in input, the inspection of described module
The output signal surveying port is high level signal;Further, the output signal of second port of described CPU
During for low level signal, detect the detection port of described module receive be configured as input to pull-up,
When inputting the signal of the first port transmission that described CPU under three kinds of states is not drawn in drop-down and input, described
The output signal of the detection port of module is low level signal.
In conjunction with the first embodiment of second aspect of the embodiment of the present invention, the second embodiment or
The third embodiment, in the 5th kind of embodiment of the embodiment of the present invention, described CPU is combining
The output signal of the detection port of the output signal stating second port of CPU and the described module detected
Type, when identifying described module, is specifically additionally operable to: determines satisfied 4th pre-conditioned, identifies described mould
The module that the second port that group is described module is connected with the detection port of described module;
Wherein, the described 4th pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect the detection port of described module receive be configured as input to pull-up, input drop-down
During with the signal of the first port transmission that described CPU under three kinds of states is not drawn in input, the inspection of described module
The output signal surveying port is high level signal;Further, the output signal of second port of described CPU
During for low level signal, detect the detection port of described module receive be configured as input to pull-up,
When inputting the signal of the first port transmission that described CPU under three kinds of states is not drawn in drop-down and input, described
The output signal of the detection port of module is low level signal.
From above-mentioned technical scheme it can be seen that the open module identification method of the embodiment of the present invention, will be by
Second port of the module identified is connected with detection port, and the module of this type, at the second of CPU
When port transmission high level signal and low level signal, the detection port receiving area of described module is in input
The defeated during signal of second port transmission of the described CPU draw, inputted under the drop-down and state do not drawn of input
Go out signal, be different from and the detection port of the second port of described module Yu described module is not attached down
Module detection port output signal;So, dig up the roots the detection port receiving area according to described module in
Input pulls up, inputs the transmission signal of second port of described CPU that is drop-down and that input under the state do not drawn
Time output signal identify outside 3 modules, it is also possible to by described CPU second port export
When high level signal and low level signal, the output signal of the detection port of described module identifies institute
The module that the detection port of the second port and described module of stating module is connected, i.e. identifies the 4th mould
Group, owing to not increasing the GPIO port of detection, when solving the module identifying more than 3 in existing method
The problem that many degree of the GPIO port resource caused take.
Detailed description of the invention
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out
Clearly and completely describe, it is clear that described embodiment is only a part of embodiment of the present invention, and
It is not all, of embodiment.Based on the embodiment in the present invention, those of ordinary skill in the art are not making
Go out the every other embodiment obtained under creative work premise, broadly fall into the scope of protection of the invention.
The embodiment of the present invention provides a kind of module identification method, to solve to identify more than 3 in existing method
Module time the problem that takies of many degree of GPIO port resource of causing.
Herein it should be noted that module identification method disclosed in the embodiment of the present invention is applied to terminal unit,
Described terminal unit includes CPU and module, and, described module identification method is existing except identifying
Outside module, it is also possible to identify the module that the second port of module is connected with the detection port of module, its
In, described second port is any one port in described module in addition to the detection port of module, described
The detection port of module is connected with first port of described CPU, and first port of described CPU is institute
State any one GPIO port of CPU.
Further, module disclosed in the embodiment of the present invention refers to the device with communication interface, such as: photographic head,
The a series of multimedia device such as LCDs and touch screen.
See Fig. 1, a kind of module identification method disclosed in the embodiment of the present invention, including:
S101, the second port controlling described CPU export high level signal and low level signal respectively.
In the present embodiment, second port of CPU is connected with the second port of described identified module,
Described CPU is when identifying any one module being identified, and second port of described CPU is individually configured
High low with output for output, corresponding, second port output high level signal and the low level of described CPU
Second port of signal extremely described module, the signal of the second port output of described CPU is described module
Second port receive signal.
S102, described CPU second port output high level signal time, detect described module respectively
Detection port when receiving the signal of the first port transmission of the described CPU being configured to different conditions,
The output signal of the detection port of described module;When the second port output low level signal of described CPU,
The detection port detecting described module respectively is receiving the first of the described CPU being configured to different conditions
During the signal of port transmission, the output signal of the detection port of described module.
Wherein, the state that first port of described CPU is configured include input pull-up state, input drop-down
State and input not tension state.
Wherein, any one port of described module all can be as test side disclosed in the embodiment of the present invention
Mouthful, generally, using the first port of described module as the detection port of module.
Further, when second port of described CPU is configured to different states, the signal of transmission differs,
Concrete, second port of described CPU is in the state of input pull-up, and its transmission signal is high level letter
Number;Second port of described CPU is in the state that input is drop-down, and its transmission signal is low level signal;
Second port of described CPU is in the state that input is not drawn, and its transmission signal is empty.
S103, the output signal combining second port of described CPU and the detection of described module detected
The type of the output signal of port, identifies described module.
Second port of identified module is connected with detection port, the module of this type, described
When the second port transmission high level signal of CPU and low level signal, the detection port of described module receives
Second port transmission of the described CPU be in input pull-up, inputting under the drop-down and state do not drawn of input
Output signal during signal, is different from by the detection port of the second port of described module and described module not
The output signal of the detection port of the module under being attached;So, dig up the roots the test side according to described module
The second port that mouth receives and is in input pull-up, inputs described CPU that is drop-down and that input under the state do not drawn
Transmission signal time output signal identify outside 3 modules, it is also possible to by the second of described CPU
The output signal of the detection port of port output high level signal and low level signal and described module identifies
The module being connected with the detection port of described module by second port of described module, i.e. identifies the 4th
Individual module, owing to not increasing the GPIO port of detection, solves the mould identifying more than 3 in existing method
The problem that many degree of the GPIO port resource caused during group take.
Further, herein also, it should be noted second port of described CPU and first end of described CPU
Mouth is multiplexing functions, and the detection port of the second port of described module and described module is also that function is multiple
With, second port of described CPU and the second port of described module are only identified described at described CPU
During module, be used as the function identified, when after described module end of identification, second port of described CPU and
Second port of described module all can complete other work.Therefore, mould disclosed in embodiment the present embodiment
The recognition methods of group, is equivalent to only take up a GPIO port of described CPU, also occupies described
One port of module.
Another embodiment of the present invention also discloses a kind of module identification method, as in figure 2 it is shown, include step:
S201, the second port controlling described CPU export high level signal and low level signal respectively;
S202, described CPU second port output high level signal time, detect described module respectively
Detection port when receiving the signal of the first port transmission of the described CPU being configured to different conditions,
The output signal of the detection port of described module;When the second port output low level signal of described CPU,
The detection port detecting described module respectively is receiving the first of the described CPU being configured to different conditions
During the signal of port transmission, the output signal of the detection port of described module;
Wherein, the state that first port of described CPU is configured include input pull-up state, input drop-down
State and input not tension state;
S203, determine satisfied first pre-conditioned, identify that described module is that described module detects port ground connection
Module;
Wherein, described first pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect the detection port of described module receive be configured as input to pull-up, input drop-down
During with the signal of the first port transmission that described CPU under three kinds of states is not drawn in input, the inspection of described module
The output signal surveying port is low level signal;Further, the output signal of second port of described CPU
During for low level signal, detect the detection port of described module receive be configured as input to pull-up,
When inputting the signal of the first port transmission that described CPU under three kinds of states is not drawn in drop-down and input, described
The output signal of the detection port of module is low level signal.
Concrete, in the present embodiment, when the second port output high level signal of described CPU, described
The detection port of module receives respectively and is in input pull-up, inputs institute that is drop-down and that input under the state do not drawn
State the transmission signal of first port of CPU, the detection port of the most described module receive respectively high level signal,
When low level signal and spacing wave, detect the output signal of the detection port of described module, it is judged that described
The output signal of the detection port of module is low level signal.
Further, when the second port output low level signal of described CPU, the detection port of described module
The first end receive respectively and be in input pull-up, inputting described CPU that is drop-down and that input under the state do not drawn
The transmission signal of mouth, detects the output signal of the detection port of described module, it is judged that the detection of described module
The output signal of port is also low level signal, and the electricity that the second port of the most described module receives is described
The output signal of the detection port of described module is not affected, i.e. it follows that now known by ordinary mail number
Described second port and the detection port of described module in other module are not attached.
High level signal, low level signal and during spacing wave is received again due to the detection port of described module
Output signal be low level signal, then the detection port ground connection of described module is described, so, described
The output signal of the detection port of module just can be pulled low, and which the detection port of the most described module receives
Planting signal, output signal is low level signal.
Another embodiment of the present invention also discloses a kind of module identification method, sees Fig. 3, including:
S301, the second port controlling described CPU export high level signal and low level signal respectively;
S302, described CPU second port output high level signal time, detect described module respectively
Detection port when receiving the signal of the first port transmission of the described CPU being configured to different conditions,
The output signal of the detection port of described module;When the second port output low level signal of described CPU,
The detection port detecting described module respectively is receiving the first of the described CPU being configured to different conditions
During the signal of port transmission, the output signal of the detection port of described module;
Wherein, the state that first port of described CPU is configured include input pull-up state, input drop-down
State and input not tension state;
S303, determine satisfied second pre-conditioned, identify that the detection port that described module is described module hangs
Empty module;
Wherein, described second pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect that the detection port of described module is receiving the described CPU being configured as input to pull-up
The signal of the first port transmission time, the output signal of the detection port of described module is high level signal,
Detect described module detection port receive be configured as input to drop-down and input do not draw described in
During the signal of first port transmission of CPU, the output signal of the detection port of described module is low level
Signal;
Further, when the output signal of second port of described CPU is low level signal, described mould is detected
The detection port of group is at the signal of the first port transmission receiving the described CPU being configured as input to pull-up
Time, the output signal of the detection port of described module is high level signal, the inspection of described module detected
Survey port and be configured as input to first port transmission of described CPU that drop-down and input do not draws receiving
During signal, the output signal of the detection port of described module is low level signal.
Equally, in the present embodiment, at the second port output high level signal of described CPU or defeated
Going out low level signal, the detection port of described module receives high level signal, low level signal and empty letter
Number time output signal the most identical, illustrate described module second port receive described CPU the second port
The output signal of the detection port of described module is not affected by the level signal of output, is the most now identified
Module in the second port of described module and the detection port of described module do not connect.
Again due to described module detection port receive high level signal time output signal be high level letter
Number, the output signal when detection port of described module receives low level signal and spacing wave is low level
Signal, the output signal of the detection port of the most described module follows the input letter of the detection port of described module
Number, now illustrate that the detection port of described module is unsettled, the i.e. identified detection that module is described module
The module that port is unsettled.
Another embodiment of the present invention also discloses a kind of module identification method, sees Fig. 4, including:
S401, the second port controlling described CPU export high level signal and low level signal respectively;
S402, described CPU second port output high level signal time, detect described module respectively
Detection port when receiving the signal of the first port transmission of the described CPU being configured to different conditions,
The output signal of the detection port of described module;When the second port output low level signal of described CPU,
The detection port detecting described module respectively is receiving the first of the described CPU being configured to different conditions
During the signal of port transmission, the output signal of the detection port of described module;
Wherein, the state that first port of described CPU is configured include input pull-up state, input drop-down
State and input not tension state;
S403, determine satisfied 3rd pre-conditioned, identify that the detection port that described module is described module connects
The module of power supply;
Wherein, the described 3rd pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect the detection port of described module receive be configured as input to pull-up, input drop-down
During with the signal of the first port transmission that described CPU under three kinds of states is not drawn in input, the inspection of described module
The output signal surveying port is high level signal;Further, the output signal of second port of described CPU
During for low level signal, detect the detection port of described module receive be configured as input to pull-up,
When inputting the signal of the first port transmission that described CPU under three kinds of states is not drawn in drop-down and input, described
The output signal of the detection port of module is high level signal.
Equally, in the present embodiment, at the second port output high level signal of described CPU or defeated
Going out low level signal, the detection port of described module receives high level signal, low level signal and empty letter
Number time output signal the most identical, illustrate described module second port receive described CPU the second port
The output signal of the detection port of described module is not affected by the level signal of output, is the most now identified
Module in the second port of described module and the detection port of described module be not attached.
High level signal, low level signal and during spacing wave is received again due to the detection port of described module
Output signal be high level signal, the equal input high level of detection port of described module is now described,
The detection port of the most described module connects power supply, and now, no matter input signal is the detection port of described module
Which kind of signal, its output signal all can be driven high.
Another embodiment of the present invention also discloses a kind of module identification method, sees Fig. 5, including:
S501, the second port controlling described CPU export high level signal and low level signal respectively;
S502, described CPU second port output high level signal time, detect described module respectively
Detection port when receiving the signal of the first port transmission of the described CPU being configured to different conditions,
The output signal of the detection port of described module;When the second port output low level signal of described CPU,
The detection port detecting described module respectively is receiving the first of the described CPU being configured to different conditions
During the signal of port transmission, the output signal of the detection port of described module;
Wherein, the state that first port of described CPU is configured include input pull-up state, input drop-down
State and input not tension state;
S503, determine satisfied 4th pre-conditioned, identify the second port that described module is described module with
The module that the detection port of described module is connected;
Wherein, the described 4th pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect the detection port of described module receive be configured as input to pull-up, input drop-down
During with the signal of the first port transmission that described CPU under three kinds of states is not drawn in input, the inspection of described module
The output signal surveying port is high level signal;Further, the output signal of second port of described CPU
During for low level signal, detect the detection port of described module receive be configured as input to pull-up,
When inputting the signal of the first port transmission that described CPU under three kinds of states is not drawn in drop-down and input, described
The output signal of the detection port of module is low level signal.
In the present embodiment, second port of described CPU is output as high level signal and output low level signal
Time, output letter when the detection port of described module receives high level signal, low level signal and spacing wave
Number it is distinguishing, now, illustrates that the second port of described module receives the second port output of CPU
The output signal that described module is detected port by signal has an impact, and the institute of now identified module is described
The detection port of the second port and described module of stating module is connected.
Concrete, when the second port output high level signal of described CPU, due to the of described module
Two-port netwerk is connected with the detection port of described module, the input signal of the detection port of the most described module
For which kind of signal, the second port of described module receives the high level letter of the second port output of described CPU
Number all the output signal of the detection port of described module can be drawn high.
Equally, during the second port output low level signal of described CPU, due to the second end of described module
Mouth is connected with the detection port of described module, and which the input signal of the detection port of the most described module is
Planting signal, the low level signal of the second port output that the second port of described module receives described CPU is equal
The output signal of the detection port of described module can be dragged down.
Another embodiment of the present invention also discloses a kind of module identification method, sees Fig. 6, including:
S601, the second port controlling described CPU export high level signal and low level signal respectively.
S602, described CPU second port output high level signal time, detect described module respectively
Detection port when receiving the signal of the first port transmission of the described CPU being configured to different conditions,
The output signal of the detection port of described module;When the second port output low level signal of described CPU,
The detection port detecting described module respectively is receiving the first of the described CPU being configured to different conditions
During the signal of port transmission, the output signal of the detection port of described module.
Wherein, the state that first port of described CPU is configured include input pull-up state, input drop-down
State and input not tension state.
Then, in conjunction with the output signal of the second port of described CPU and the detection of described module that detects
The type of the output signal of port, it is possible to identify described module;When determine satisfied first pre-conditioned time,
Perform step 603;When determine satisfied second pre-conditioned time, perform step 604;When determining the satisfied 3rd
Time pre-conditioned, perform step 605;When determine satisfied 4th pre-conditioned time, perform step 606.
S603, identify described module be described module detection port ground connection module.
Wherein, described first pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect the detection port of described module receive be configured as input to pull-up, input drop-down
During with the signal of the first port transmission that described CPU under three kinds of states is not drawn in input, the inspection of described module
The output signal surveying port is low level signal;Further, the output signal of second port of described CPU
During for low level signal, detect the detection port of described module receive be configured as input to pull-up,
When inputting the signal of the first port transmission that described CPU under three kinds of states is not drawn in drop-down and input, described
The output signal of the detection port of module is low level signal.
S604, identify the detection unsettled module of port that described module is described module.
Wherein, described second pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect that the detection port of described module is receiving the described CPU being configured as input to pull-up
The signal of the first port transmission time, the output signal of the detection port of described module is high level signal,
Detect described module detection port receive be configured as input to drop-down and input do not draw described in
During the signal of first port transmission of CPU, the output signal of the detection port of described module is low level
Signal.
Further, when the output signal of second port of described CPU is low level signal, described mould is detected
The detection port of group is at the signal of the first port transmission receiving the described CPU being configured as input to pull-up
Time, the output signal of the detection port of described module is high level signal, the detection of described module detected
Port is configured as input to the letter of the first port transmission that is drop-down and that input the described CPU not drawn receiving
Number time, described module detection port output signal be low level signal.
S605, identify that the detection port that described module is described module connects the module of power supply.
Wherein, the described 3rd pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect the detection port of described module receive be configured as input to pull-up, input drop-down
During with the signal of the first port transmission that described CPU under three kinds of states is not drawn in input, the inspection of described module
The output signal surveying port is high level signal;Further, the output signal of second port of described CPU
During for low level signal, detect the detection port of described module receive be configured as input to pull-up,
When inputting the signal of the first port transmission that described CPU under three kinds of states is not drawn in drop-down and input, described
The output signal of the detection port of module is high level signal.
S606, identify that the second port that described module is described module is connected with the detection port of described module
The module connect;
Wherein, the described 4th pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect the detection port of described module receive be configured as input to pull-up, input drop-down
During with the signal of the first port transmission that described CPU under three kinds of states is not drawn in input, the inspection of described module
The output signal surveying port is high level signal;Further, the output signal of second port of described CPU
During for low level signal, detect the detection port of described module receive be configured as input to pull-up,
When inputting the signal of the first port transmission that described CPU under three kinds of states is not drawn in drop-down and input, described
The output signal of the detection port of module is low level signal.
Concrete, the specific works of step disclosed in the present embodiment refers to the enforcement in corresponding diagram 2-Fig. 5
Example, here is omitted.
Multimedia identification side disclosed in the embodiment of corresponding diagram 5 of the present invention is described below by way of two examples
Method.
See Fig. 7, using the P1 port of module 101 as detection port, by the P2 port of module 101
As the second port, P1 port and the P2 port of module 101 link together.
The corresponding port of central processor CPU 102 and module 101 connects, and may refer to show in Fig. 7
Content, such as: the P1 port of module 101 and the GPIO_0 port of central processor CPU 102 connect,
The P2 port of module 101 is connected with the GPIO_1 port of central processor CPU 102.
It is high low with output that the GPIO_1 port of central processor CPU 102 is configured to output, now, in
The GPIO_1 port output high level signal of central processor CPU102 and low level signal are to module 101
P2 port.
During the P2 port of module 101 receives high level signal and low level signal, central authorities process
The GPIO_0 port of device CPU102 is respectively configured as input pull-up, inputs drop-down and input the shape not drawn
State, the transmission signal of this port is separately input into the P1 port of module 101, central processor CPU 102
Obtain the output signal of the P1 port of module 101, and combine the letter inputting the P2 port to module 101
Number and the output signal of P1 port of module 101 identify module 101.
Herein it should be noted that the GPIO_0 port of central processor CPU 102 is configured as input to
Under the state drawn, the signal of this port transmission is high level signal;The GPIO-of central processor CPU 102
_ 0 port is configured as input under drop-down state, and the signal of this port transmission is low level signal;Central authorities
The GPIO_0 port of processor CPU102 is configured as input under the state do not drawn, the letter of this port transmission
Number it is spacing wave.
Concrete, the signal that the P2 port of module 101 receives is high level signal, the P1 of module 101
When port receives high level signal, low level signal and spacing wave, output signal is high level signal;
The signal that the P2 port of module 101 receives is low level signal, and the P1 port of module 101 receives high electricity
When ordinary mail number, low level signal and spacing wave, output signal is low level signal.
Equally, in another example, Fig. 8 is seen, using the P1 port of module 103 as detection port,
The P4 port of module 103 is connected to as the second port, P1 port and the P4 port of module 103
Together.
Identical with foregoing, the corresponding port of central processor CPU 102 and module 103 connects, please
See Fig. 8.
It is high low with output that the GPIO_2 port of central processor CPU 102 is configured to output, now, in
The GPIO_2 port output high level signal of central processor CPU102 and low level signal are to module 101
P4 port.
During the P4 port of module 103 receives high level signal and low level signal, module 103
P1 port receive high level signal, low level signal and spacing wave, central processor CPU 102 obtains
The output signal of the P1 port of delivery group 103, and combine the signal inputting the P4 port to module 103
Module 103 is identified with the output signal of the P1 port of module 103.
In figures 7 and 8, the port being connected with the P1 port of module differs, by detection module
Port whether have the output of output signal, it is possible to distinguish corresponding different port is connected to the P1 port of module
Module.
Receive the difference of output signal under unlike signal in conjunction with by the P1 port of module, can identify not
With the connection of P1 port, the module that the connection identification of corresponding different P1 port is different, referring specifically to
List below.
Another embodiment of the present invention also discloses a kind of terminal unit, including:
CPU and module, first port of described CPU is connected with the detection port of described module, described
Second port of CPU is connected with the second port of described module, wherein,
Described CPU exports high level signal and low level letter respectively for the second port controlling described CPU
Number;When the second port output high level signal of described CPU, detect the detection of described module respectively
Port when receiving the signal of the first port transmission of the described CPU being configured to different conditions, institute
State the output signal of the detection port of module;When the second port output low level signal of described CPU,
Detect the detection port of described module respectively and receive the of the described CPU that is configured to different conditions
During the signal that Single port transmits, the output signal of the detection port of described module;And combine described CPU
The output signal of the second port and the type of the output signal of the detection port of described module that detects,
Identifying described module, the state that first port of described CPU is configured includes inputting pull-up state, defeated
Enter pull-down state and input not tension state.
Herein it should be noted that the module that includes of terminal unit disclosed in the present embodiment is the most multiple,
Each module is identified by described CPU successively.Further, in the terminal unit disclosed in the present embodiment
Including CPU and the annexation of module, can be found in Fig. 7 and Fig. 8.
Terminal unit disclosed in the embodiment of the present invention, the module that the second port is connected with detection port, CPU
When controlling the second port transmission high level signal and the low level signal of described CPU, it is described that CPU obtains
The detection port receiving area of module pulls up in input, inputs drop-down and input described under the state do not drawn
The output signal during signal of second port transmission of CPU, be different from by the second port of described module with
The output signal of the detection port of the module detected under port is not attached of described module;So, remove
Detection port receiving area according to described module pulls up in input, inputs drop-down and input under the state do not drawn
Described CPU the second port transmission signal time output signal identify outside 3 modules, also may be used
To pass through when second port of described CPU exports high level signal and low level signal, described module
The output signal of detection port identifies the detection port of the second port of described module Yu described module
The module being connected, i.e. identifies the 4th module, owing to not increasing the GPIO port of detection, solves
The problem that many degree of the GPIO port resource caused when identifying the module of more than 3 in existing method take.
Preferably, described CPU is in the output signal of the second port combining described CPU and the institute detected
State the type of output signal of the detection port of module, identify the mode of described module specifically can include with
Any one or combination in any of lower four kinds of modes.
The first, determine satisfied first pre-conditioned, identify that described module is that described module detection port connects
The module on ground;
Wherein, described first pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect the detection port of described module receive be configured as input to pull-up, input drop-down
During with the signal of the first port transmission that described CPU under three kinds of states is not drawn in input, the inspection of described module
The output signal surveying port is low level signal;Further, the output signal of second port of described CPU
During for low level signal, detect the detection port of described module receive be configured as input to pull-up,
When inputting the signal of the first port transmission that described CPU under three kinds of states is not drawn in drop-down and input, described
The output signal of the detection port of module is low level signal.
The second, determine satisfied second pre-conditioned, identify the detection port that described module is described module
Unsettled module;
Wherein, described second pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect that the detection port of described module is receiving the described CPU being configured as input to pull-up
The signal of the first port transmission time, the output signal of the detection port of described module is high level signal,
Detect described module detection port receive be configured as input to drop-down and input do not draw described in
During the signal of first port transmission of CPU, the output signal of the detection port of described module is low level
Signal;
Further, when the output signal of second port of described CPU is low level signal, described mould is detected
The detection port of group is at the signal of the first port transmission receiving the described CPU being configured as input to pull-up
Time, the output signal of the detection port of described module is high level signal, the inspection of described module detected
Survey port and be configured as input to first port transmission of described CPU that drop-down and input do not draws receiving
During signal, the output signal of the detection port of described module is low level signal.
The third, determine satisfied 3rd pre-conditioned, identify the detection port that described module is described module
Connect the module of power supply;
Wherein, the described 3rd pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect the detection port of described module receive be configured as input to pull-up, input drop-down
During with the signal of the first port transmission that described CPU under three kinds of states is not drawn in input, the inspection of described module
The output signal surveying port is high level signal;Further, the output signal of second port of described CPU
During for low level signal, detect the detection port of described module receive be configured as input to pull-up,
When inputting the signal of the first port transmission that described CPU under three kinds of states is not drawn in drop-down and input, described
The output signal of the detection port of module is high level signal.
4th kind, determine satisfied 4th pre-conditioned, identify the second port that described module is described module
The module being connected with the detection port of described module;
Wherein, the described 4th pre-conditioned is: the output signal of second port of described CPU is high level
During signal, detect the detection port of described module receive be configured as input to pull-up, input drop-down
During with the signal of the first port transmission that described CPU under three kinds of states is not drawn in input, the inspection of described module
The output signal surveying port is high level signal;Further, the output signal of second port of described CPU
During for low level signal, detect the detection port of described module receive be configured as input to pull-up,
When inputting the signal of the first port transmission that described CPU under three kinds of states is not drawn in drop-down and input, described
The output signal of the detection port of module is low level signal.
One of ordinary skill in the art will appreciate that all or part of stream realizing in above-described embodiment method
Journey, can be by computer program and completes to instruct relevant hardware, and described program can be stored in
In computer read/write memory medium, this program is upon execution, it may include such as the embodiment of above-mentioned each method
Flow process.Wherein, described storage medium can be magnetic disc, CD, read-only store-memory body (Read-Only
Memory, ROM) or random store-memory body (Random Access Memory, RAM) etc..
Finally, in addition it is also necessary to explanation, in this article, the relational terms of such as first and second or the like
It is used merely to separate an entity or operation with another entity or operating space, and not necessarily requires
Or imply relation or the order that there is any this reality between these entities or operation.And, art
Language " includes ", " comprising " or its any other variant are intended to comprising of nonexcludability, thus
Make to include that the process of a series of key element, method, article or equipment not only include those key elements, and
Also include other key elements being not expressly set out, or also include for this process, method, article or
The key element that person's equipment is intrinsic.In the case of there is no more restriction, by statement " including ... "
The key element limited, it is not excluded that also deposit in including the process of described key element, method, article or equipment
In other identical element.
In this specification, each embodiment uses the mode gone forward one by one to describe, and each embodiment stresses
Being the difference with other embodiments, between each embodiment, identical similar portion sees mutually.
Described above to the disclosed embodiments, makes professional and technical personnel in the field be capable of or uses
The present invention.Multiple amendment to these embodiments will be aobvious and easy for those skilled in the art
See, generic principles defined herein can without departing from the spirit or scope of the present invention,
Realize in other embodiments.Therefore, the present invention is not intended to be limited to the embodiments shown herein,
And it is to fit to the widest scope consistent with principles disclosed herein and features of novelty.