Disclosure of Invention
Based on this, it is necessary to provide a method for controlling USB data transmission and related device, so that when data transmission is performed by connecting a mobile terminal with other devices through USB, interference from other modules in the mobile terminal during level change can be effectively reduced, thereby improving efficiency of data transmission and overall performance of the mobile terminal.
A USB data transfer control method, comprising:
A. when the electrical signal transmitted in the USB transmission line is subjected to level switching, the level state of the switching output of the USB data transmission pin is controlled to be unchanged;
B. and the processor reads the level of the switching output of the USB data transmission pin and performs data transmission in real time.
Wherein, before the step A, the method further comprises the following steps: a trigger for controlling the level state of the switching output of the USB data transmission pin to be unchanged when the level of the USB transmission line is switched is arranged between the USB transmission line and the processor in advance.
The step A specifically comprises the following steps:
a1, when an electric signal transmitted in a USB transmission line is switched from a low level to a high level, the level of an output end of the trigger is kept to be kept at the high level;
when the electric signal transmitted in the USB transmission line is switched from a high level to a low level, the level of the output end of the flip-flop is kept at the low level.
The step B specifically comprises the following steps:
b1, the processor reads the level of the USB data transmission pin;
b2, judging whether the pin is at a high level at the moment, if so, setting the current USB transmission line to be a second logic value, otherwise, setting the current USB transmission line to be a first logic value;
and B3, the processor acquires the data transmitted by the USB transmission line.
A USB data transfer control system, comprising: a trigger and a processor;
the trigger is respectively connected with the USB transmission line and the processor;
the trigger is used for controlling the level state of the switching output of the USB data transmission pin to be kept unchanged when the level of the electric signal transmitted in the USB transmission line is switched;
the processor is used for reading the level output by the switching of the USB data transmission pins and transmitting data in real time.
The processor reads the level of the switching output of the USB data transmission pin, judges whether the pin is at a high level at the moment, if so, the current USB transmission line is at a second logic value, and if not, the current USB transmission line is at a first logic value, and acquires the data transmitted by the USB transmission line.
The trigger comprises an S end and an R end which are connected with contacts of the USB transmission line, and also comprises an output end Q which is connected with the processor, wherein the R end of the trigger is connected with a pull-down resistor R1, and the S end of the trigger is connected with a pull-down resistor R2.
The three end points of the USB transmission line are fixedly connected with VDD, the other two ends are respectively connected with the R end and the S end of the trigger, when the USB transmission line is at a first logic value, the contact point of the USB transmission line is contacted with the R end, and when the data on the USB transmission line is at a second logic value, the contact point of the USB data transmission line is contacted with the S end.
When the contact of the USB transmission line is positioned at the R end and level switching is performed, the contact is turned from the R end to the S end, and the output end Q of the trigger always keeps high level; when the contact of the USB transmission line is positioned at the S end and level switching is performed, the contact is turned from the S end to the R end, and the output end Q of the trigger always keeps high level.
A computer device comprising a trigger, a memory and a processor, the memory storing a computer program, the trigger being for cancelling interference generated by other modules on a mobile terminal on a USB transmission line to a level; the processor, when executing the computer program, implements the steps of the method of any one of claims 1 to 4.
A computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method of any of claims 1 to 4.
In summary, the method for controlling USB data transmission and related devices provided by the present invention include: when the electrical signal transmitted in the USB transmission line is subjected to level switching, the level state of the switching output of the USB data transmission pin is controlled to be unchanged; and the processor reads the level of the switching output of the USB data transmission pin and performs data transmission in real time. When the computer equipment is connected with other equipment through USB to carry out data transmission, the level of the USB data transmission pin is kept to be stable high level or stable low level through the trigger, the interference of other modules in the mobile terminal when the level changes can be effectively reduced, the stable waveform can be output by the output end when the level is switched each time, and the processor can easily judge that the level on the USB transmission line is high level or low level according to the stable waveform output by the output end, so that the data transmission efficiency is improved, and the integral performance of the computer equipment is improved.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more clear and clear, the present invention will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
The USB data transmission control method can be applied to a terminal. The terminal may be, but is not limited to, various personal computers, notebook computers, cell phones, tablet computers, car computers, and portable wearable devices. The terminal of the invention adopts a multi-core processor. The processor of the terminal may be at least one of a central processing unit (Central Processing Unit, CPU), a graphics processor (Graphics Processing Unit, GPU), a video processing unit (Video Processing Unit, VPU), and the like.
In one embodiment, as shown in fig. 1, a USB data transmission control method is provided, and the method is applied to the terminal for illustration, and includes the following steps:
s100, when the electrical signal transmitted in the USB transmission line is subjected to level switching, the level state of the switching output of the USB data transmission pin is controlled to be unchanged.
A trigger for keeping the level of the USB data transmission pin to be high level or low level is arranged between the USB transmission line and the processor in advance, wherein the trigger is an RS trigger.
Specifically, when the electric signal transmitted in the USB transmission line is switched from a low level to a high level, the level of the output end of the flip-flop is kept at the high level; when the electric signal transmitted in the USB transmission line is switched from a high level to a low level, the level of the output end of the flip-flop is kept at the low level.
And S200, the processor reads the level output by switching the USB data transmission pins, and performs data transmission in real time.
The step S200 specifically includes:
s201, a processor reads the level of a pin of the USB transmission line;
s202, judging whether the pin is at a high level at the moment, if yes, the current USB transmission line is at a second logic value, otherwise, the current USB transmission line is at a first logic value, wherein the second logic value is 1 when the first logic value is 0, and the second logic value is 0 when the first logic value is 1, for example, the high level is to transmit one data 1, and the low level is to transmit one data 0;
s203, the processor acquires the data transmitted by the USB transmission line.
In the USB data transmission control method of this embodiment, when data is transmitted by connecting a USB with another device in a computer device, the level of a USB data transmission pin is kept to be a stable high level or a stable low level by a trigger, which can effectively reduce interference from other modules in a mobile terminal when the level changes, ensure that an output end can output a stable waveform when each level is switched, and enable a processor to easily determine that the level on the USB transmission line is a high level or a low level according to the stable waveform output by the output end, thereby improving the efficiency of data transmission and the overall performance of the computer device.
It should be understood that, although the steps in the flowchart of fig. 1 are shown in sequence as indicated by the arrows, the steps are not necessarily performed in sequence as indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in fig. 1 may include multiple sub-steps or stages that are not necessarily performed at the same time, but may be performed at different times, nor do the order in which the sub-steps or stages are performed necessarily performed in sequence, but may be performed alternately or alternately with at least a portion of other steps or sub-steps of other steps.
In one embodiment, as shown in fig. 2, there is provided a USB data transmission control system, the system comprising: a trigger and a processor;
the trigger is respectively connected with the USB transmission line and the processor;
the trigger is used for controlling the level state of the switching output of the USB data transmission pin to be unchanged when the level of the electric signal transmitted in the USB transmission line is switched, wherein the trigger is an RS trigger;
the processor is used for reading the level output by the switching of the USB data transmission pins and transmitting data in real time.
The processor reads the level of the switching output of the USB data transmission pin, judges whether the pin is at a high level at the moment, if so, the current USB transmission line is at a second logic value, and if not, the current USB transmission line is at a first logic value, and acquires the data transmitted by the USB transmission line.
The trigger comprises an S end and an R end which are connected with contacts of the USB transmission line, and also comprises an output end Q which is connected with the processor, wherein the R end of the trigger is connected with a pull-down resistor R1, and the S end of the trigger is connected with pull-down resistors R2, and R1 and R2 are used for limiting current.
The three end points of the USB transmission line are fixedly connected with VDD, the other two ends are respectively connected with the R end and the S end of the trigger, when the USB transmission line is at a first logic value, the contact point of the USB transmission line is contacted with the R end, and when the data on the USB transmission line is at a second logic value, the contact point of the USB data transmission line is contacted with the S end.
When the contact of the USB transmission line is positioned at the R end and performs level switching, the contact is turned from the R end to the S end, and the output end Q of the trigger always keeps high level as long as the contact does not return to the R end even though the contact is disturbed and dithered back and forth at the S end; when the contact of the USB transmission line is positioned at the S end and carries out level switching, the contact is turned from the S end to the R end, and the output end Q of the trigger always keeps high level as long as the contact does not return to the S end although the contact is disturbed and dithered back and forth at the R end.
In one embodiment, a computer device is provided, which may be a terminal, and the internal structure of which may be as shown in fig. 3. The computer device includes a processor, a memory, a trigger, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program, when executed by a processor, implements a USB data transfer control method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, can also be keys, a track ball or a touch pad arranged on the shell of the computer equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by those skilled in the art that the structure shown in fig. 3 is merely a block diagram of some of the structures associated with the present application and is not limiting of the computer device to which the present application may be applied, and that a particular computer device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, including a trigger, a memory, and a processor, where the trigger is configured to eliminate interference generated by other modules on a mobile terminal on a USB transmission line to a level; the memory stores a computer program which when executed by the processor performs the steps of:
s100, when the electrical signal transmitted in the USB transmission line is subjected to level switching, the level state of the switching output of the USB data transmission pin is controlled to be unchanged.
A trigger for keeping the level of the USB data transmission pin to be high level or low level is arranged between the USB transmission line and the processor in advance, wherein the trigger is an RS trigger.
Specifically, when the electric signal transmitted in the USB transmission line is switched from a low level to a high level, the level of the output end of the flip-flop is kept at the high level; when the electric signal transmitted in the USB transmission line is switched from a high level to a low level, the level of the output end of the flip-flop is kept at the low level.
And S200, the processor reads the level output by switching the USB data transmission pins, and performs data transmission in real time.
The step S200 specifically includes:
s201, a processor reads the level of a pin of the USB transmission line;
s202, judging whether the pin is at a high level at the moment, if so, setting the current USB transmission line to be at a second logic value, otherwise, setting the current USB transmission line to be at a first logic value;
s203, the processor acquires the data transmitted by the USB transmission line.
In one embodiment, a computer readable storage medium is provided having a computer program stored thereon, which when executed by a processor, performs the steps of:
s100, when the electrical signal transmitted in the USB transmission line is subjected to level switching, the level state of the switching output of the USB data transmission pin is controlled to be unchanged.
A trigger for keeping the level of the USB data transmission pin to be high level or low level is arranged between the USB transmission line and the processor in advance, wherein the trigger is an RS trigger.
Specifically, when the electric signal transmitted in the USB transmission line is switched from a low level to a high level, the level of the output end of the flip-flop is kept at the high level; when the electric signal transmitted in the USB transmission line is switched from a high level to a low level, the level of the output end of the flip-flop is kept at the low level.
And S200, the processor reads the level output by switching the USB data transmission pins, and performs data transmission in real time.
The step S200 specifically includes:
s201, a processor reads the level of a pin of the USB transmission line;
s202, judging whether the pin is at a high level at the moment, if so, setting the current USB transmission line to be at a second logic value, otherwise, setting the current USB transmission line to be at a first logic value;
s203, the processor acquires the data transmitted by the USB transmission line.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the various embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples merely represent a few embodiments of the present application, which are described in more detail and are not to be construed as limiting the scope of the invention. It should be noted that it would be apparent to those skilled in the art that various modifications and improvements could be made without departing from the spirit of the present application, which would be within the scope of the present application. Accordingly, the scope of protection of the present application is to be determined by the claims appended hereto.