Specific embodiment
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 clear, complete
Site preparation is described, it is clear that described embodiment is a part of embodiment of the invention, rather than whole embodiments.Based on this hair
Embodiment in bright, the every other implementation that those of ordinary skill in the art are obtained under the premise of creative work is not made
Example, belongs to the scope of protection of the invention.
Referring to Fig. 1-2, Fig. 1 is a kind of flow chart of method for detecting charged state provided in an embodiment of the present invention, and Fig. 2 is
A kind of communication system hardware block diagram provided in an embodiment of the present invention, as shown in figure 1, comprising the following steps:
Step 101, by the first communication interface in I/O port pattern, read level state.
In the step, in the charging process using charger to mobile terminal, can be by mobile terminal and charging
Communication system as shown in Figure 2 is built between device, and by the first communication interface in I/O port pattern, can quickly be read
To the level state of the first communication interface, wherein, the first communication interface is that charger sets up connecing for communication connection with mobile terminal
Mouthful.In the present embodiment, the first communication interface can be the data positive signal pin of charger, i.e., the D+ of charger shown in Fig. 2
Signal pins.
As shown in Fig. 2 the communication system includes charger, mobile terminal, wherein, charger side is provided with data minus letter
Number pin (D- signal pins) and data positive signal pin (D+ signal pins), are provided with data negative signal and draw in mobile terminal side
Pin (D- signal pins) and data positive signal pin (D+ signal pins).Wherein, the data minus signal pins of mobile terminal with fill
The data minus signal pins connection of electrical equipment, the data positive signal pin of mobile terminal connects with the data positive signal pin of charger
Connect.In the present embodiment, can be TX+ signals by the D+ signal definitions of charger, D- signal definitions are RX- signals;Will be mobile
The D+ signal definitions of terminal are RX+ signals, and D- signal definitions are TX- signals, and wherein TX+ signals and TX- signals are sending signal,
RX- signals and RX+ signals are reception signal.
It should be noted that can be by setting pull-up resistor in the charging circuit of mobile terminal, by mobile terminal side
The voltage of data positive signal pin be pulled to predeterminated voltage.For example, when charging voltage is 5V, can be by mobile terminal
Charging circuit in 100 kilo-ohms of pull-up resistor is set, the data positive signal pin voltage of mobile terminal side is pulled up by 2.5V
To 3.3V.And the initial voltage of the data positive signal pin of charger side is 2.5V, then can be by reading charger side
Data positive signal pin voltage status, that is, read the voltage status of the first communication interface, you can determine charger and movement
Charged state between terminal.
Step 102, according to level state, determine charged state.
In the step, filling between charger and mobile terminal can be determined according to the level state of the first communication interface
Electricity condition.Wherein, when the level state of the first communication interface is high level, then can determine between charger and mobile terminal
Charged state be access state;When the level state of the first communication interface is low level, then charger and shifting can be determined
Charged state between dynamic terminal is off-state.
If for example, the initial voltage of the first communication interface is 2.5V, when reading the communication interface under I/O port pattern
Voltage when be 3.3V, then can determine that charged state between charger and mobile terminal is access state;If first
The voltage of communication interface is 3.3V, when the voltage for reading the communication interface under I/O port pattern is 2.5V, then may be used
It is off-state with the charged state determined between charger and mobile terminal.
In the embodiment of the present invention, the above method can apply to charger, and the charger includes to carry out mobile terminal
The charger of quick charge, the wherein mobile terminal can be mobile phone, the panel computer (Tablet for being capable of quick charge
Personal Computer), kneetop computer (Laptop Computer), personal digital assistant (personal digital
Assistant, abbreviation PDA), mobile Internet access device (Mobile Internet Device, MID) or Wearable device
(Wearable Device) etc..
The method of the detection charged state of the embodiment of the present invention, the present invention provides a kind of method for detecting charged state and fills
Electrical equipment, the method includes:By the first communication interface in I/O port pattern, level state is read;According to level state, it is determined that
Charged state.So, when the first communication interface is configured to I/O port pattern, charged state is determined by reading level state, from
And the charged state between quick detection charger and mobile terminal, in order to be timely responded to the exception that charges, improve
Communication success rate and response speed, enhance the security of system.
Referring to Fig. 3, Fig. 3 is the flow chart of the method for another detection charged state provided in an embodiment of the present invention, this reality
It is by detecting that interrupt signal realizes quick reading level state, as shown in figure 3, bag that example is applied with the main distinction of a upper embodiment
Include following steps:
Step 301, when interrupt signal is detected, by the first communication interface in I/O port pattern, reads level shape
State.
In the step, when the first communication interface is in I/O mode, if detecting interrupt signal, reads the first communication and connect
The level state of mouth.And in the present embodiment, the classification of the interrupt signal can be determined according to level state.If for example,
The level state of the first communication interface is high level, then the interrupt signal is rising edge interruption;If the level of the first communication interface
State is low level, then the interrupt signal is trailing edge interruption, it is possible to interrupted according to rising edge or trailing edge is interrupted come really
Determine the charged state between charger and mobile terminal.
Step 302, when level state be high level when, determine charged state be access state.
In the step, when the level state of the first communication interface is high level, it may be determined that charger and mobile terminal
Between charged state be access state.But also can be determined between charger and mobile terminal according to the type of interrupt signal
Charged state, for example, when interrupt signal is interrupted for rising edge, it is determined that the charged state between charger and mobile terminal
It is access state.
Step 303, when level state be low level when, determine charged state be off-state.
In the step, when the level state of the first communication interface is low level, it may be determined that charger and mobile terminal
Between charged state be off-state.But also can be determined between charger and mobile terminal according to the type of interrupt signal
Charged state, for example, when interrupt signal is interrupted for trailing edge, it is determined that the charged state between charger and mobile terminal
It is off-state.
Optionally, by the first communication interface in I/O port pattern, level state is read, including:
First communication interface is configured to I/O port pattern, and by the first communication interface, reading level state.
In the implementation method, in the charging process using charger to mobile terminal, match somebody with somebody by by the first communication interface
I/O port pattern is set to, so the first communication interface can quickly be read by the first communication interface in I/O port pattern
Level state, and then determine the charged state between charger and mobile terminal, so as to realize quick detection charger and movement
Charged state between terminal.
Optionally, before the first communication interface being configured into I/O port pattern, also include:
By the first communication interface in serial communication port pattern, according to default polling cycle, enter with mobile terminal
Row communication handshake;
First communication interface is configured to I/O port pattern, including:
In polling interval, the first communication interface is configured to I/O port pattern;
By the first communication interface in I/O port pattern, read after level state, method also includes:
By the first communication interface from I/O port pattern switching to serial communication port pattern, and continue according to polling cycle, with shifting
Dynamic terminal carries out communication handshake.
In the implementation method, in the charging process using charger to mobile terminal, can be by presetting poll
Cycle, and being adjusted to the voltage and current parameter in charging process by the way of poll, when during in poll, can be with
By the first communication interface in serial communication port pattern, communication handshake is carried out with mobile terminal.Wherein, when charger and shifting
When data communication between dynamic terminal is in the polling interval phase, then the first communication interface is configured to I/O port pattern, uses I/O port
Interrupt function under pattern, it is possible to achieve the charged state of quick detection charger.When polling interval, the phase terminates, then lead to first
Letter interface continues according to polling cycle set in advance from I/O port pattern switching to serial communication port pattern, with mobile terminal
Communication handshake is carried out, continuation is polled treatment to charging process.So, connect by the first communication under I/O port pattern
Mouthful, the level state of the first communication interface can be quickly read, and then determine the charging shape between charger and mobile terminal
State, realizes the charged state between quick detection charger and mobile terminal.
Optionally, by the first communication interface in serial communication port pattern, according to default polling cycle, with movement
Terminal carries out communication handshake, including:
When the first communication interface is configured to serial communication port pattern, handshake data is sent to mobile terminal;
First communication interface is configured to I/O port pattern, including:
After handshake data is sent, by the first communication interface from serial communication port pattern switching to I/O port pattern.
In the implementation method, can be by being polled treatment, real-time adjustment charging voltage and the electricity that charges to charging process
Stream parameter.Wherein, when the first communication interface is configured to serial communication port pattern, handshake data is sent to mobile terminal, when holding
After the completion of hand data is activation, by the first communication interface from serial communication port pattern switching to I/O port pattern, so by using IO
Interrupt function under mouth mold formula, can in polling interval quick detection charger charged state, realize safe charging.
Optionally, by the first communication interface in serial communication port pattern, according to default polling cycle, with movement
Terminal carries out communication handshake, including:
When the first communication interface is configured to serial communication port pattern, handshake data is sent to mobile terminal;
By setting up the second communication interface of communication connection in charger with mobile terminal, the sound that mobile terminal is returned is received
Answer data;
First communication interface is configured to I/O port pattern, including:
After response data is received by the second communication interface, by the first communication interface from serial communication port pattern switching
To I/O port pattern.
In the implementation method, can be by being polled treatment, real-time adjustment charging voltage and the electricity that charges to charging process
Stream parameter.Wherein, when the first communication interface is configured to serial communication port pattern, handshake data is sent to mobile terminal, and lead to
Overcharge the second communication interface in electrical equipment and receive the response data that mobile terminal is returned, when the second communication interface receives movement eventually
After holding the response data for returning, then by the first communication interface from serial communication port pattern switching to I/O port pattern, so by making
With the interrupt function under I/O port pattern, can in polling interval quick detection charger charged state, realize safe charging.
It should be noted that in the present embodiment, the first communication interface is the data positive signal pin of charger, second
Communication interface is the data minus signal pins of charger.
So, the method for detection charged state provided in an embodiment of the present invention, when interrupt signal is detected, by being in
First communication interface of I/O port pattern, reads level state;When level state is high level, charged state is determined to access shape
State;When level state is low level, determine that charged state is off-state.So, when the first communication interface is configured to I/O port
During pattern, charged state is determined by reading level state, so that the charging shape between quick detection charger and mobile terminal
State, in order to be timely responded to the exception that charges, improves communication success rate and response speed, enhances the safety of system
Property.
Referring to Fig. 4, Fig. 4 is the flow chart of the method for another detection charged state provided in an embodiment of the present invention, this reality
Example is applied with the main distinction of above-described embodiment for charged state is the situation of access state, as shown in figure 4, comprising the following steps:
Step 401, by the first communication interface in I/O port pattern, read level state.
It is logical by I/O port pattern first in the charging process using charger to mobile terminal in the step
Letter interface, can quickly read the level state of the first communication interface, wherein, the first communication interface is charger and movement
Terminal sets up the interface of communication connection.
Step 402, when level state be high level when, determine charged state be access state.
In the step, when the level state of the first communication interface of charger is high level, then charger can be determined
Charged state and mobile terminal between is access state, and charger starts to mobile terminal output voltage, and is started to moving
Dynamic terminal charge.
It should be noted that the embodiment of the present invention can also determine charged state by way of detecting and interrupting.For example, working as
When charger accesses mobile terminal, and the initial voltage of the data positive signal pin of mobile terminal is 3.3V, then the of charger
The voltage of one communication interface also can rise to 3.3V by initial 2.5V, and when the first communication interface of charger is configured to I/O port mould
When under formula, it is that the corresponding upper drop edge of situation of change that low level is converted to high level is interrupted that can produce level situation of change.It is based on
The rising edge is interrupted, then can determine that, in access state between charger and mobile terminal, charger starts to mobile terminal
Output voltage, and start to charge mobile terminal.
Step 403, by the first communication interface from I/O port pattern switching to serial communication port pattern.
In the step, when it is determined that charged state be access state when, then by the first communication interface from I/O port pattern switching to
Serial communication port pattern, it is possible to send handshake data to mobile terminal side using the characteristic of serial communication mouthful.
Step 404, by the first communication interface in serial communication port pattern, according to default polling cycle, with shifting
Dynamic terminal carries out communication handshake.
In the step, after first object data communication interface is from I/O port pattern switching to serial communication mode, can be by
According to the polling cycle for pre-setting, communication handshake is carried out with mobile terminal, i.e., send handshake data to mobile terminal, started to moving
Dynamic terminal charge.
So, the method for detection charged state provided in an embodiment of the present invention, by input and output I/O port pattern
First communication interface, reads level state;When level state is high level, determine that charged state is access state;By first
Communication interface is from I/O port pattern switching to serial communication port pattern;By the first communication interface in serial communication port pattern,
According to default polling cycle, communication handshake is carried out with mobile terminal.So, when the first communication interface is configured to I/O port pattern
When, determine charged state by reading level state, so that the charged state between quick detection charger and mobile terminal, with
It is easy to timely respond to the exception that charges, improves communication success rate and response speed, enhances the security of system.
Referring to Fig. 5, Fig. 5 is the structure chart of the charger that the present invention implements offer, as shown in figure 5, charger 500 includes reading
Modulus block 501 and determining module 502, wherein, read module 501 and determining module 502 are connected.
Read module 501, for by the first communication interface in I/O port pattern, reading level state, wherein, it is described
First communication interface is the interface that the charger sets up communication connection with mobile terminal;
Determining module 502, for according to the level state, determining charged state.
Optionally, as shown in fig. 6, the determining module 502 includes:
First determination sub-module 5021, for when the level state is high level, determining charged state to access shape
State;
Second determination sub-module 5022, for when the level state is low level, determining charged state to disconnect shape
State.
Optionally, as shown in fig. 7, the read module 501 includes:
First reading submodule 5011, for when interrupt signal is detected, by the first communication in I/O port pattern
Interface, reads level state;
Or,
Second reading submodule 5012, for first communication interface to be configured into I/O port pattern, and by described
One communication interface, reads level state.
Optionally, as shown in figure 8, the read module 501 include second reading submodule 5012 when, the charging
Device 500 also includes:
First communication module 503, for by first communication interface in serial communication port pattern, according to default
Polling cycle, carry out communication handshake with the mobile terminal;
Second reading submodule 5012, specifically in polling interval, first communication interface being configured to
I/O port pattern, and by first communication interface, read level state;
The first communication module 503, is additionally operable to be connect by the described first communication in second reading submodule 5012
Mouth is read after level state, by first communication interface from I/O port pattern switching to serial communication port pattern, and continues to press
According to the polling cycle, communication handshake is carried out with the mobile terminal.
Optionally, the first communication module 503, specifically for being configured to serial communication port in first communication interface
During pattern, handshake data is sent to the mobile terminal;
Second reading submodule 5012, specifically for after the handshake data is sent, the described first communication being connect
Mouth reads level state from the serial communication port pattern switching to I/O port pattern, and by first communication interface.
Optionally, as shown in figure 9, the first communication module 503 includes:
Sending submodule 5031, for when first communication interface is configured to serial communication port pattern, to the shifting
Dynamic terminal sends handshake data;
Receiving submodule 5032, for being led to by setting up the second of communication connection in the charger with the mobile terminal
Letter interface, receives the response data that the mobile terminal is returned;
Second reading submodule 5012, specifically for receiving the number of responses by second communication interface
According to rear, by first communication interface from the serial communication port pattern switching to I/O port pattern, and communicated by described first
Interface, reads level state.
Optionally, first communication interface is the data positive signal pin of the charger, second communication interface
It is the data minus signal pins of the charger.
Optionally, as shown in Figure 10, the charger 500 also includes:
Configuration module 504, for after first determination sub-module 5021 determines that charged state is access state, by institute
The first communication interface is stated from I/O port pattern switching to serial communication port pattern;
Second communication module 505, for by first communication interface in serial communication port pattern, according to default
Polling cycle, carry out communication handshake with the mobile terminal.
Charger 500 can realize each process that mobile terminal is realized in the embodiment of the method for Fig. 1 to Fig. 4, to avoid
Repeat, repeat no more here.
Charger provided in an embodiment of the present invention, the present invention provides a kind of method and charger for detecting charged state, should
Method includes:By the first communication interface in I/O port pattern, level state is read;According to level state, it is determined that charging shape
State.So, when the first communication interface is configured to I/O port pattern, charged state is determined by reading level state, so that quickly
Charged state between detection charger and mobile terminal, in order to be timely responded to the exception that charges, improves and communicates into
Power and response speed, enhance the security of system.
The above, specific embodiment only of the invention, but protection scope of the present invention is not limited thereto, and it is any
Those familiar with the art the invention discloses technical scope in, change or replacement can be readily occurred in, should all contain
Cover within protection scope of the present invention.Therefore, protection scope of the present invention should be defined by scope of the claims.