Patent Description:
With the development of wireless terminal products, the products are becoming more and more integrated and have more and more functions. Especially for the data terminal products, in order to improve the performance and competitiveness of the products, single-core processors in terminals have gradually been updated to multi-core processors, for example, from a modem to a Microcontroller Unit (MCU)+modem, an Access Point (AP)+modem, etc. Each processor in a multiprocessor has its own function, and each processor has its own interface for debugging and data communication, such as a Universal Serial Bus (USB) interface, a Universal Asynchronous Receiver/Transmitter (UART) interface and a Serial Peripheral Interface (SPI).

However, there may be a plurality of processors in the terminal and each processor has its own processor interface for debugging and data communication, or, there may be one processor in the terminal and the processor includes at least two processor interfaces. Therefore, the terminal needs to be provided with a plurality of interfaces for peripheral access that respectively transmit data for debugging and communication to corresponding processor ports, thereby realizing debugging and data communication for the processor. Taking a dual-processor product as an example, each processor has one port for debugging and communication, for example, a UART interface+USB interface. In this case, the terminal product needs to be designed with at least <NUM> interfaces for peripheral access to transmit data for debugging and communication to the processor ports. Forms of the interfaces for peripheral access include standard USB interfaces, debugging connectors, test points, etc., which is complex. In particular, for some products, it is required to design the debugger separately, and destructive operations such as disassembling the device are needed in subsequent debugging or fault handling. Therefore, for these products, it is required to design dual USB interfaces for peripheral access, or some functions have to be abandoned if only one USB interface is designed for peripheral access.

"<NPL> discloses in electronics, a multiplexer ( or mux; spelled sometimes as multiplexor), also known as a data selector, is a device that selects between several analog or digital input signals and forwards the selected input to a single output line. The selection is directed a separate set of digital inputs known as select lines. A multiplexer of 2n inputs has n select lines, which are used to select which input line to send to the output. A demultiplexer (or demux) is a device taking a single input and selecting signals of the output of the compatible mux, which is connected to the single input, and a shared selection line. A multiplexer is often used with a complementary demultiplexer on the receiving end. An electronic multiplexer can be considered as a multiple-input, single-output switch, and a demultiplexer as a single-input, multiple-output switch.

European patent application <CIT> discloses a communication connector that provides an increase in the number and type of communication circuits available on an electronic device without increasing the number and type of physical connectors. The communication connector electrically includes a set of inputs to couple to both a USB <NUM> connector and a HDMI connector. A set of outputs from the communication connector provides a third connector with a pin out specification compatible with a USB <NUM> connector or a PCle connector.

The invention provides a method for multiplexing a USB interface, an electronic device to which the USB interface belongs includes a plurality of ports of one processor, or includes a plurality of processors, and each processor includes at least one port. The method includes: acquiring at least a level signal other than a service data signal and a ground signal in the USB interface; determining, according to a logic result of the at least a level signal and a predefined correlation, a target port of a target processor corresponding to the logic result as a transmission object of the USB interface, wherein the correlation comprises a logic result of the at least a level signal uniquely corresponding to each port of each processor; and transmitting received data to the transmission object by means of the USB interface, and sending data to be sent of the transmission object by means of the USB interface.

The invention further provides a circuit for multiplexing a USB interface, including: a USB interface, configured to transmit signals; a decoder, configured to acquire at least a level signal other than a service data signal and a ground signal in the USB interface, and determine, according to a logic result of the at least a level signal and a predefined correlation, a target port of a target processor corresponding to the logic result as a transmission object of the USB interface; wherein, the correlation includes a logic result of the at least a level signal uniquely corresponding to each port of each processor; and a multiway switch, configured to select a transmission channel between the USB interface and the transmission object, such that received data is transmitted to the transmission object by means of the USB interface and data to be sent of the transmission object is sent by means of the USB interface.

An embodiment of this application further provides an electronic device, the device including the circuit for multiplexing a USB interface as described above.

The invention further provides a computer-readable storage medium storing a computer program, and the computer program, when executed by a processor, implements the method for multiplexing a USB interface as described above.

One or more embodiments are described exemplarily by pictures in the corresponding drawings, and these exemplary descriptions do not constitute the limitations to the embodiments.

A main objective of embodiments of this application is to provide a method and circuit for multiplexing a USB interface, an electronic device and a storage medium, in order to multiplex the USB interface in a multiprocessor terminal, so that data can be transmitted to different types of ports of a plurality of processors by using only one standard USB interface without a plurality of interfaces for peripheral access such as test points and debugging connectors, thereby realizing data communication and debugging, which is very conducive to simplified design and function extension of product interfaces, and subsequent debugging and fault handling of the whole device.

A first embodiment of this application relates to a method for multiplexing a USB interface, applied to an electronic device, so that by multiplexing one USB interface, data can be transmitted to a plurality of ports of one processor or ports of a plurality of processors included in the electronic device to which the USB interface belongs. The electronic device here may be a wireless terminal device such as Tracker and CPE. As shown in <FIG>, the method specifically includes:
At step <NUM>, at least one path of level signal other than a service data signal and a ground signal in the USB interface is acquired.

Specifically, in a universal serial bus (USB) interface, a USB_DP pin and a USB_DM pin are configured to transmit service data, and signals provided by the USB_DP pin and the USB_DM pin are called service data signals. A GND pin is configured to be grounded, and signals provided by the GND pin are ground signals. Since the service data signal and the ground signal in the USB interface cannot be adjusted at will in the communication process, only signals other than the service data signal and the ground signal in the USB interface can be selected for subsequent selection of processor ports. That is, a level signal provided by at least one different pin other than the USB_DP pin, the USB_DM pin and the GND pin in the USB interface is acquired.

More specifically, when the USB interface is a Micro USB interface, signals provided by the USB interface include the service data signal, the ground signal, a USB_VBUS signal and a USB_ID signal. In this case, the acquired level signal is the USB_VBUS signal and/or the USB_ID signal. When the USB interface is a Type-C USB interface, signals provided by the USB interface include a signal for service data transmission, the ground signal, a USB_VBUS signal, an SBU1 signal, an SBU2 signal, a CC1 signal, and a CC2 signal, the acquired signal is any one or a combination of the USB_VBUS signal, the SBU1 signal, the SBU2 signal, the CC1 signal and the CC2 signal, for example, to acquire the CC1 signal, or to acquire the CC1 signal and the SBU2 signal, or to acquire the CC1 signal, the USB_VBIS signal and the CC2 signal. Of course, the above is only specific exemplary illustration, and in the actual use process, at least one path of signal other than the signal for service data transmission and the ground signal in other types of USB interfaces, may be also included, which will not be elaborated one by one herein.

In an example, in order to meet actual demands of users, before executing the step <NUM>, the method further includes: setting high and low level states of the at least one path of level signal according to demands. Moreover, in order to set the level signal, a control switch may be designed to control the high/low level state of the level signal in the USB port, for example, selection and setting with the switch on a USB cable or a USB debugger. Of course, the above is only specific exemplary illustration, in the actual use process, setting of the level signal may also be realized by other manners, which will not be elaborated one by one herein.

It should also be illustrated that, the above description of the signals are named by pins, such as the CC2 signal is the signal provided by a CC2 pin of the USB interface.

At step <NUM>, according to a logic result of the at least one path of level signal and a predefined correlation, a target port of a target processor corresponding to the logic result is determined as a transmission object of the USB interface, wherein the correlation includes a logic result of the at least one path of level signal uniquely corresponding to each port of each processor.

Specifically, the processor ports include the USB interface, a UART interface, an I2C interface, an SPI interface, etc. Of course, the above is only specific exemplary illustration, In the actual use process, the processor interfaces may also include other interfaces, by which service data can be transmitted by the USB interface after being converted, which will not be described one by one in detail herein.

In a specific example, the correlation defines a one-to-one correlation between ports of processors and various possible logics of the at least one path of level signal, for example, the logic of the CC1 signal corresponding to the USB <NUM> port of the processor <NUM> is represented as <NUM>, and the logic of the CC1 signal corresponding to the USB2 port of the processor <NUM> is represented as <NUM>. Assuming that the level signal logic of the CC1 signal obtained after step <NUM> is executed is <NUM>, then it is uniquely determined that the transmission object is the USB1 port of the processor <NUM> according to the correlation. When a plurality of level signals are acquired, the logic result refers to a logic combination result of the plurality of level signals, such as a logic combination <NUM> of two paths of level signals corresponding to the USB port of the processor <NUM>, a logic combination <NUM> of two paths of level signals corresponding to the Universal Asynchronous Receiver/Transmitter (UART) interface of the processor <NUM> and a logic combination <NUM> of two paths of level signals corresponding to the USB port of the processor <NUM>. Assuming that the two paths of level signals are obtained after step <NUM> is executed and the logic combination result is <NUM>, then according to the correlation, it is uniquely determined that the transmission object is the USB port of the processor <NUM>.

It should be illustrated that, in the correlation, the total number of ports of the processor is not greater than the total number of various possible logic results of the at least one path of level signal.

At step <NUM>, received data is transmitted to the transmission object by means of the USB interface, and data to be sent of the transmission object is sent by means of the USB interface.

Particularly, after step <NUM> is executed to determine the transmission object, a channel for data transmission is established between the USB interface and the transmission object, a peripheral sends data in the peripheral to the target processor sequentially through the USB interface, the channel for data transmission and the transmission object, then, the target processor correspondingly processes the received data, and sends a processing result as data to be sent to the peripheral sequentially through the transmission object, the channel for data transmission and the USB interface.

Compared with the prior art, in the embodiments provided by this application, after the at least one path of level signal other than the service data signal and the ground signal in the USB interface is acquired, according to the logic combination result of the at least one path of level signal, the target port of one target processor is selected from various ports of all the processors as the transmission object of the USB interface according to the logic result of the at least one path of level signal uniquely corresponding to each port of each processor and the logic result of at least one path of level signal. Thereby, the received data is transmitted to the transmission object by means of the USB interface, and the data to be sent of the transmission object is sent by means of the USB interface. Since all the processor ports in the terminal may be used as the transmission object, the one-to-one correlation between the USB interface for peripheral access on the terminal and the processor port is destroyed, so that one USB interface can communicate with various ports of all the processors in the terminal. Multiplexing of the USB interface in the multiprocessor terminal is realized, so that data can be transmitted to the plurality of processor ports by using only one standard USB interface without test points and debugging connectors to realize data communication and debugging, which is very conducive to simplified design and function extension of product interfaces and subsequent debugging and fault handling of the whole device.

A second embodiment of this application relates to a method for multiplexing a USB interface. In this embodiment, before transmitting the received data to the transmission object by means of the USB interface, and sending the data to be sent of the transmission object by means of the USB interface, whether the transmission object uses a two-wire serial bus is detected. As shown in <FIG>, the method specifically includes:
At step <NUM>, at least one path of level signal other than a service data signal and a ground signal in the USB interface is acquired.

Specifically, step <NUM> in this embodiment is substantially the same as step <NUM> in the first embodiment, and details will not be repeated herein.

At step <NUM>, whether the transmission object uses a two-wire serial bus is detected, if so, step <NUM> is executed, and if not, step <NUM> is executed.

Specifically, the type of the interface indicates the form of the bus used by the interface, for example, an SPI interface uses a four-wire serial bus, and a two-wire UART interface uses a two-wire serial bus. Therefore, detecting whether the transmission object adopts a two-wire serial bus can be realized by detecting the type of the interface of the transmission obj ect.

At step <NUM>, the received data is adjusted to a receivable form of the transmission object, and the data to be sent is adjusted to a receivable form of the USB interface.

Particularly, since the two-wire serial bus transmits data in <NUM> channels at one time and the four-wire serial bus transmits data in <NUM> channels at one time, data cannot be transmitted directly from one interface to the other interface when the data is transmitted between two interfaces using different types of serial buses. The data cannot be normally sent and received between two interfaces using different types of serial buses unless being processed. By adjusting the received data to the receivable form of the transmission object, and adjusting the data to be sent to the receivable form of the USB interface, when data is transmitted between interfaces using different types of serial buses, data of a sender can be converted into data that can be received by a receiver, so that the data can be transmitted normally.

In one example, in order to convert data stored in an interface using certain type of serial bus into receivable data of an interface using another type of serial bus, a bridge chip may be used to process the stored data, for example, a USB-to-SPI bridge chip is used to convert data sent by a USB interface into a form that can be received by an SPI interface.

At step <NUM>, the received data is transmitted to the transmission object by means of the USB interface, and the data to be sent of the transmission object is sent by means of the USB interface.

Specifically, if the transmission object and the USB interface use different types of serial buses, the received and adjusted data is transmitted to the transmission object by means of the USB interface, and the adjusted data to be sent of the transmission object is sent by means of the USB interface. If the transmission object and the USB interface uses the same type of serial bus, the received data is directly transmitted to the transmission object by means of the USB interface, and the data to be sent of the transmission object is directly sent by means of the USB interface.

Compared with the prior art, in this embodiment of the disclosure, on the basis of realizing the beneficial effects of the first embodiment, whether the USB interface and the transmission object can communicate directly can be detected, and in the case of being incapable of direct communication, the received data is adjusted to the receivable form of the transmission object, and the data to be sent is adjusted to the receivable form of the USB interface. When data is transmitted between interfaces using different types of serial buses, the data of the sender is converted into the data that can be received by the receiver, so that the data can be transmitted normally, which avoids data transmission error caused by mismatch between the USB interface and the transmission object, and improves the accuracy of data transmission.

A third embodiment of this application relates to a method for multiplexing a USB interface. In this embodiment, after transmitting the received data to the transmission object by means of the USB interface, and sending the data to be sent of the transmission object by means of the USB interface, the transmission object can be switched. As shown in <FIG>, the method specifically includes:
At step <NUM>, at least one path of level signal other than a service data signal and a ground signal in the USB interface is acquired.

At step <NUM>, if change of high and low level states of the at least one path of level signal is detected, the method for multiplexing a USB interface is re-executed according to a changed level signal.

Specifically, since the high and low level states of the level signal uniquely determines the logic result of the at least one path of level signal, and the transmission object is uniquely determined according to the correlation, once the high and low level states of the level signal changes, it is indicated that the uniquely determined transmission object has changed. The high and low level states of the at least one path of level signal acquired in step <NUM> may be detected in real time or periodically. If any one of the at least one path of level signal changes, the method for multiplexing the USB interface is re-executed to re-determine the transmission object, thereby realizing switching of the transmission object.

It should be illustrated that when a user needs to switch the transmission object while keeping the conditions such as the electronic device and peripheral unchanged, by only resetting the high and low level states of the level signal acquired in step <NUM> according to the needs and the correlation, switching among the debugging and communication ports of the processor in the terminal, or switching among different processors can be controlled by means of the method for multiplexing a USB interface provided by this embodiment without replacement of the USB interface, thereby realizing the smooth switching of USB ports among processors and processor ports, reducing the waste of labor and time, and improving the efficiency of data transmission and debugging.

Compared with the prior art, in this embodiment of the disclosure, on the basis of realizing the beneficial effects of the first embodiment, when any one of the at least one path of level signal changes, the method for multiplexing a USB interface can be re-executed to re-determine the transmission object, thereby realizing switching of the transmission object. Further, the user can control switching among the debugging and communication ports of the processor in the terminal, or switching among different processors, by resetting the high and low level states of the level signal without replacement of the USB interface, thereby realizing smooth switching of USB ports among processors and processor ports, reducing the waste of labor and time, and improving the efficiency of data transmission and debugging.

A fourth embodiment of the disclosure relates to a circuit for multiplexing a USB interface, as shown in <FIG>, including the following:
A USB interface <NUM> is configured to transmit signals.

A decoder <NUM> is configured to acquire at least one path of level signal other than a service data signal and a ground signal in the USB interface, and determine, according to a logic result of the at least one path of level signal and a predefined correlation, a target port of a target processor corresponding to the logic result as a transmission object of the USB interface; wherein, the correlation includes a logic result of the at least one path of level signal uniquely corresponding to each port of each processor.

Specifically, when the USB interface <NUM> is a Micro USB interface, pins of the USB interface include a USB_DP pin, a USB_DM pin, a USB_ID pin, and a USB_VBUS pin. It is assumed that the electronic device to which the USB interface <NUM> belongs includes two processors, each processor including two ports; and as shown in <FIG>, the processors are respectively AP1 and AP2, ports of AP1 including an AP1 USB port and an AP1 UART port, and ports of AP2 including an AP2 USB port and an AP2 UART port. Then, <NUM>-<NUM> decoder may be selected as the decoder <NUM>. In this case, the USB_DP pin, the USB_DM pin and the USB_ID pin in the USB interface are used normally, and level signals provided by the USB_VBUS pin and the USB_ID pin are used as the input (equivalent to a logic result of the at least one path of level signal) of the decoder <NUM>. Then the decoder <NUM> outputs a control signal to control a gate state of the multiway switch <NUM> after decoding, wherein, as shown in <FIG>, the circuit where each switch of the multiway switch <NUM> is located is connected to different processor ports. Then, according to the connection relation shown in <FIG>, the correlation represented by the logic combination result of the at least one path of level signal uniquely corresponding to each port of each processor is shown in the table below:.

After every time the decoder <NUM> acquires the USB VBUS signal and the USB ID signal provided by the USB VBUS pin and the USB ID pin as input, it can uniquely determine one port from the AP1 USB port, the AP1 UART port, the AP2 USB port and the AP2 UART port as the transmission object according to the table above. For example, if the level signal input by the USB_VBUS pin and the USB_ID pin to the decoder <NUM> is <NUM>, then it is determined according to the table above that the processor port is the AP2 USB port, and the control signal <NUM> is generated to control the multiway switch to gate SWITCH2 for data transmission.

Similarly, when the USB interface <NUM> is a Type-C USB interface, pins of the USB interface include an SBU1 pin, an SBU2 pin, a CC1 pin, a CC2 pin, a USB_DP pin, a USB_DM pin, and a USB_VBUS pin. It is assumed that the electronic device to which the USB interface <NUM> belongs includes two processors, and the total number of processor ports is <NUM>; and as shown in <FIG>, the processors are respectively AP1 and AP2, ports of AP1 including an AP1 USB1 port, an AP1 communication UART port, an AP1 Debug UART port, an AP1 USB2 port and an AP1 SPI port, and ports of AP2 including an AP2 USB port, an AP2 UART port, etc. Then, a <NUM>-<NUM> decoder may be selected as the decoder <NUM>. In this case, the USB_DP pin and the USB_DM pin in the USB interface are used normally, <NUM> pins are selected from the SBU1 pin, the SBU2 pin, the CC1 pin, the CC2 pin and the USB_VBUS pin to provide input signals for the decoder <NUM>, and the unselected pins are used normally. Here, description is made in an example where the SBU1 pin, the SBU2 pin and the USB_VBUS pin are selected to provide the input signals for the decoder <NUM>. Level signals provided by the SBU1 pin, the SBU2 pin and the USB_VBUS pin are used as the input (equivalent to a logic result of the at least one path of level signal) of the decoder <NUM>. Then the decoder <NUM> outputs a control signal to control a gate state of the multiway switch <NUM> after decoding, wherein, as shown in <FIG>, the circuit where each switch of the multiway switch <NUM> is located is connected to different processor ports. Then, according to the connection relation shown in <FIG>, the correlation represented by the logic combination result of the at least one path of level signal uniquely corresponding to each port of each processor is shown in the table below:.

In this case, as shown in <FIG>, a Type-C USB cable or a patch panel is further provided for connection with a switch or a button, so that the high/low level states of the SBU1 pin, the SBU2 pin and the USB_VBUS pin in the USB interface <NUM> can be set manually. Every time the high/low level states of the SBU1 pin, the SBU2 pin and the USB_VBUS pin are set through the Type-C USB cable or the patch panel, the decoder <NUM> acquires a corresponding input, and then uniquely determines one port from the <NUM> processor ports shown in <FIG> as the transmission object according to the table above. For example, a coder is controlled through the Type-C USB cable or the patch panel to switch all logic levels of the VBUS pin, the SUB1 pin and the SBU2 pin to <NUM>, and the decoder <NUM> outputs the control signal <NUM> to control the multiway switch to gate an SWITCH0 corresponding to the AP1 USB1 port. At this time, an external USB_VBUS power supply is needed to power the AP1 VBUS port, i.e., to provide enum, thereby realizing data communication between the USB interface <NUM> and the AP1 USB1 port ;Or, the coder is controlled through the Type-C USB cable or the patch panel to switch logic levels of the VBUS pin, the SUB1 pin and the SBU2 pin to "<NUM>", and the decoder <NUM> outputs the control signal <NUM>, to control the multiway switch to gate an SWITCH6 corresponding to the AP2 UART port, thereby realizing data communication between the USB interface <NUM> and the AP2 UART port. At this time, power supply of the AP2 USB_VBUS needs to be cut off, etc..

Of course, the above is only specific exemplary illustration. In the actual use process, the decoder <NUM> may also be other types of decoders and use signals provided by other pins connected to the USB interface <NUM> as input, which will not be described in detail herein.

The multiway switch <NUM> is configured to gate a transmission channel between the USB interface and the transmission object, such that received data is transmitted to the transmission object by means of the USB interface and data to be sent of the transmission object is sent by means of the USB interface.

Specifically, the multiway switch <NUM> further includes a data transmission channel established between the USB interface and the transmission object. When communication is performed based on the multiplexing function of the USB interface <NUM>, data enters the USB interface <NUM> from the peripheral, and after the decoder <NUM> determines the gate state of the multiway switch, data in the USB interface <NUM> reaches the corresponding processor port through the multiway switch <NUM>, and finally enters the processor and is processed. After data processing is completed, a processing result is sent to the peripheral sequentially through the processor port, the multiway switch <NUM> and the USB interface <NUM>.

It is not difficult to find that this embodiment is an embodiment of the circuit for multiplexing an USB interface corresponding to the first embodiment, and this embodiment can be implemented in cooperation with the first embodiment. The related technical details mentioned in the first embodiment are still valid in this embodiment, and in order to reduce repetition, these details are not repeated here. Accordingly, the related technical details mentioned in this embodiment may also be applied to the first embodiment.

In addition, in order to highlight the innovative part of the disclosure, units that are not closely related to solving the technical problem provided by the disclosure are not introduced in this embodiment, but this does not mean that there are no other units in this embodiment.

A fifth embodiment of this application relates to an electronic device, as shown in <FIG>, the electronic device <NUM> includes a circuit for multiplexing a USB interface <NUM>. In this embodiment, the circuit for multiplexing a USB interface <NUM> is substantially the same as in the fourth embodiment, and details will not be repeated here.

A sixth embodiment of the disclosure relates to a computer-readable storage medium, storing a computer program. The computer program, when executed by a processor, implements the above method embodiment.

That is, it can be understood by those skilled in the art that all or part of the steps in the method of the above embodiments can be completed by instructing related hardware through a program, the program is stored in a storage medium, and includes a plurality of instructions to make a device (which may be a single-chip microcomputer, chip, etc.) or a processor execute all or part of the steps of the method described in the embodiments of this application. The above storage medium includes: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, an optical disk, or any medium that can store program codes.

Claim 1:
A method for multiplexing a USB interface, performed by an electronic device to which the USB interface belongs comprising a plurality of processor ports, the method comprising:
acquiring (<NUM>) at least a level signal other than a service data signal and a ground signal in the USB interface;
determining (<NUM>), according to a logic result of the at least a level signal and a predefined correlation, a target port of a target processor corresponding to the logic result as a transmission object of the USB interface, wherein, the predefined correlation comprises a logic result of the at least a level signal uniquely corresponding to each port of each processor; and
transmitting (<NUM>) received data to the transmission object by means of the USB interface, and sending data to be sent of the transmission object by means of the USB interface.