Method and apparatus for serial data transmission, intelligent electronic device and storage medium

By detecting the status of the VBUS and data lines of the USB interface, the operating mode of the USB controller is determined, which solves the problem that the USB port of smart electronic devices does not support OTG function, and realizes wider device compatibility and flexible data transmission.

CN115203098BActive Publication Date: 2025-12-23ACTIONS ZHUHAI TECH CO
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202110376130.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-04-08
Publication Date
2025-12-23
Estimated Expiration
2041-04-08

AI Technical Summary

Technical Problem

The USB ports of existing smart electronic devices may not support USB OTG functionality, which prevents the device from connecting to any USB peripheral and limits its usability.

Method used

By detecting the status of the VBUS line and data line of the USB interface, the operating mode of the USB controller is determined, including master mode and slave mode, to achieve data transmission.

Benefits of technology

This expands the applicability of USB controllers, reduces the number of wires required, and improves the flexibility of device use.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115203098B_ABST
    Figure CN115203098B_ABST
Patent Text Reader

Abstract

The application discloses a serial data transmission method and device, intelligent electronic equipment and a storage medium, to solve the technical problem that the application range of the intelligent electronic equipment with master and slave dual functions is small in the prior art. A data line of a USB controller is connected with a first USB interface, and the first USB interface supports at least an external device as a master device to access the USB controller. The method comprises the following steps: detecting the state of a first VBUS line of the first USB interface; setting the working mode of the USB controller according to the state of the first VBUS line and the state of the data line; wherein the working mode comprises a master device mode and a slave device mode; and performing data transmission with the external device in the working mode.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of serial communication, in particular to a serial data transmission method and device, an intelligent electronic device and a storage medium. BACKGROUND

[0002] OTG (On The Go) technology allows data transmission between devices without a host. For example, a digital camera is directly connected to a printer, and through OTG technology, the USB ports between the two devices are connected, so that the taken photos can be immediately printed out; or the data in the digital camera can be sent to a mobile hard disk through the USB interface.

[0003] In the prior art, to realize the USB device (slave device) / host (master device) mode switching, the intelligent electronic device needs to have a standard micro / mini port supporting the USB OTG function. When a slave device such as a U disk or a master device such as a computer is connected to the intelligent electronic device, the intelligent electronic device needs to determine its role by detecting the id line in the standard micro / mini port, i.e., whether the intelligent electronic device should be switched to the device mode (as a master device) or the host mode (as a slave device). The implementation of the above function is based on the micro / mini port of both parties, which has an ID line in addition to the 4 lines commonly used by USB (VBUS and GND lines as power lines, a pair of data lines D+ and D- for transmitting data), that is, the USB port of both parties has an ID line (i.e., has a micro / mini port supporting the USB OTG function).

[0004] However, most of the devices currently use USB ports that may be micro / mini ports or type-A ports. Even if some peripherals use micro / mini ports, they may not support the USB OTG function. Therefore, the intelligent electronic device with master and slave dual functions cannot be connected to any peripheral with a USB port and realize the USB device / host mode switching, which further limits the use range of the intelligent electronic device. SUMMARY

[0005] The present application provides a serial data transmission method, device, intelligent electronic device and storage medium to solve the above technical problems in the prior art.

[0006] In a first aspect, to solve the above technical problems, the present application provides a serial data transmission method applied to a universal serial bus (USB) controller, wherein a data line of the USB controller is connected to a first USB interface, and the first USB interface supports at least a master device access. The technical scheme of the method is as follows:

[0007] detecting a state of a first VBUS line of the first USB interface;

[0008] setting a working mode of the USB controller according to the state of the first VBUS line and the state of the data line, wherein the working mode comprises a master mode and a slave mode;

[0009] performing data transmission with an external device in the working mode.

[0010] In a possible implementation, the data line is further connected with a second USB interface, and the first VBUS line and a second VBUS line of the second USB interface correspond to different power sources, and the second USB interface is configured to support access of a slave device.

[0011] In a possible implementation, the first USB interface comprises a min / micro USB interface, and the second USB interface comprises a TYPEC A interface.

[0012] In a possible implementation, the working mode of the USB controller is set according to whether a device accesses or not according to the state of the first VBUS line and the state of the data line, and the setting comprises:

[0013] determining whether a device accesses the USB controller according to the state of the first VBUS line and the state of the data line;

[0014] when it is determined that an external device accesses the USB controller, setting the working mode of the USB controller according to the state of the first VBUS line.

[0015] In a possible implementation, the working mode of the USB controller is set according to the state of the first VBUS line, and the setting comprises:

[0016] when the state of the first VBUS line is a low-level state, setting the first VBUS line to be effective in outputting a power source to the outside, and detecting whether the state of the data line changes within a set time length;

[0017] if the state changes, determining that the external device accesses the USB controller from the first USB interface;

[0018] setting the working mode to the master mode.

[0019] In a possible implementation, the working mode of the USB controller is set according to the state of the first VBUS line, and the setting comprises:

[0020] determining that the external device accesses the USB controller from the first USB interface when the state of the first VBUS line is a high level state;

[0021] detecting whether the state of the data line changes within a set time period, and determining and setting the working mode as the slave mode if the state of the data line changes.

[0022] In a possible implementation, after detecting whether the state of the data line changes within a set time period, the method further includes:

[0023] determining that the external device is a power device when it is determined that the state of the data line does not change.

[0024] In a possible implementation, when the data line is further connected to a second USB interface, after determining that the external device accesses the USB controller from the first USB interface, the method further includes:

[0025] controlling a second VBUS line of the second USB interface to be invalid for outputting power externally.

[0026] In a possible implementation, when the data line is further connected to a second USB interface, after detecting whether the state of the data line changes within a set time period, the method further includes:

[0027] if it is detected that the state of the data line does not change within the set time period, determining that no device accesses the USB controller from the first USB interface, setting the first VBUS line to be invalid for outputting power externally, and setting the second VBUS line to be valid for outputting power externally.

[0028] detecting again whether the state of the data line changes within the set time period.

[0029] if the state of the data line changes, determining that the external device accesses the USB controller from the second USB interface, and determining and setting the working mode as the master mode.

[0030] In a possible implementation, after detecting again whether the state of the data line changes within the set time period, the method further includes:

[0031] if it is determined that the state of the data line does not change again within the set time period, determining that no device accesses the USB controller from the first USB interface and the second USB interface, and setting the second VBUS line to be invalid for outputting power externally.

[0032] In a second aspect, an embodiment of the present application provides a device for serial data transmission, applied to a universal serial bus (USB) controller, a data line of the USB controller being connected with a first USB interface, the first USB interface supporting at least host device access, and the device comprising:

[0033] a detection unit configured to detect a state of a first VBUS line of the first USB interface;

[0034] a setting unit configured to set a working mode of the USB controller according to the state of the first VBUS line and a state of the data line, wherein the working mode comprises a host device mode and a slave device mode;

[0035] a transmission unit configured to perform data transmission with an external device in the working mode.

[0036] In a possible implementation, the data line is further connected with a second USB interface, and the first VBUS line and a second VBUS line of the second USB interface correspond to different power supplies, and the second USB interface is configured to support slave device access.

[0037] In a possible implementation, the first USB interface comprises a min / micro USB interface, and the second USB interface comprises a TYPEC A interface.

[0038] In a possible implementation, the setting unit is configured to:

[0039] determine whether a device accesses the USB controller according to the state of the first VBUS line and the state of the data line;

[0040] when it is determined that an external device accesses the USB controller, determine and set the working mode of the USB controller according to the state of the first VBUS line.

[0041] In a possible implementation, the setting unit is further configured to:

[0042] when the state of the first VBUS line is a low-level state, set the first VBUS line to be effective in external power output, and detect whether the state of the data line changes within a set time length;

[0043] if the state changes, determine that the external device accesses the USB controller from the first USB interface;

[0044] determine and set the working mode as the host device mode.

[0045] In a possible implementation, the setting unit is further configured to:

[0046] determining that the external device accesses the USB controller from the first USB interface when the state of the first VBUS line is a high level state;

[0047] detecting whether the state of the data line changes within a set time length, and determining and setting the working mode as the slave device mode if the state changes.

[0048] In a possible implementation, the setting unit is further configured to:

[0049] determining that the external device is a power device when it is determined that the state of the data line does not change.

[0050] In a possible implementation, the setting unit is further configured to:

[0051] controlling a second VBUS line of a second USB interface to remain invalid for outputting power to the outside after it is determined that the external device accesses the USB controller from the first USB interface when the data line is also connected to the second USB interface.

[0052] In a possible implementation, the setting unit is further configured to:

[0053] determining that no device accesses the USB controller from the first USB interface, setting the first VBUS line to be invalid for outputting power to the outside, and setting the second VBUS line to be valid for outputting power to the outside, if it is determined that the state of the data line does not change within the set time length after it is detected that the state of the data line changes within the set time length when the data line is also connected to the second USB interface.

[0054] detecting again whether the state of the data line changes within the set time length.

[0055] determining that the external device accesses the USB controller from the second USB interface, and determining and setting the working mode as the master device mode if the state changes.

[0056] In a possible implementation, the setting unit is further configured to:

[0057] setting the second VBUS line to be invalid for outputting power to the outside if it is determined that the state of the data line does not change within the set time length again after it is detected again whether the state of the data line changes within the set time length.

[0058] In a third aspect, an embodiment of the present application further provides an intelligent electronic device, including:

[0059] The first USB interface supports at least host device access;

[0060] A universal serial bus (USB) controller, a data line of the USB controller being connected with the first USB interface, the USB controller being configured to perform the method of the first aspect.

[0061] In a possible implementation, the electronic device further includes:

[0062] A second USB interface connected with the data line, the second USB interface being configured to access a device of a slave device type, and the VBUS line and the interface type of the first USB interface and the second USB interface being different.

[0063] In a fourth aspect, an embodiment of the present application further provides a readable storage medium, including:

[0064] A memory,

[0065] The memory is configured to store instructions, when the instructions are executed by a processor, causing an apparatus including the readable storage medium to perform the method of the first aspect.

[0066] Through the technical solutions in one or more of the above embodiments of the present application, the embodiments of the present application have at least the following technical effects:

[0067] In the embodiments provided by the present application, whether a device is accessed is determined by the state of the VBUS line and the data line in the USB interface, and when it is determined that a device is accessed, the working mode of the USB controller is also determined and set by the state of the VBUS line in the USB interface, so it is not necessary to use the USB interface with the ID line as the interface of the USB controller as in the prior art, and determine whether the USB controller should be set to the host device mode or the slave device mode according to the state of the ID line, so the present application determines the working mode of the USB controller by the VBUS line in the USB interface, and has a wider application range than the prior art. BRIEF DESCRIPTION OF DRAWINGS

[0068] Figure 1 A connection diagram of the USB controller and the first USB interface provided by the embodiments of the present application;

[0069] Figure 2 A flowchart of a serial data transmission method provided by the embodiments of the present application;

[0070] Figure 3 A connection diagram of the intelligent electronic device and the U disk provided by the embodiments of the present application;

[0071] Figure 4A connection diagram of an intelligent electronic device and a computer provided for implementation of the present application;

[0072] Figure 5 A diagram showing connection of a USB controller to a first USB interface and a second USB interface provided for an embodiment of the present application;

[0073] Figure 6 A structural diagram of a serial data transmission device provided for an embodiment of the present application;

[0074] Figure 7 An intelligent electronic device provided for an embodiment of the present application;

[0075] Figure 8 Another intelligent electronic device provided for an embodiment of the present application. DETAILED DESCRIPTION

[0076] The present application provides a serial data transmission method and device, an intelligent electronic device and a storage medium, to solve the above technical problems in the prior art.

[0077] A device supporting OTG technology (referred to as OTG device) uses the ID pin in the min USB plug to distinguish whether it should work in the master device (A-Device) mode or the slave device (B-Device) mode. For example, the ID pin is grounded to work in the master device mode, and the A-Device always provides power for the USB bus. The ID pin is suspended to work in the slave device mode, and the USB Host / USB Device role of the OTG device can be switched through HNP (Host Negotiation Protocol). The OTG device cannot cross the USB Hub when connected, and will lose the HNP function if it crosses the USB Hub.

[0078] The technical solution in the embodiments of the present application is to solve the above technical problems, and the general idea is as follows:

[0079] The present application provides a serial data transmission method, which is applied to a universal serial bus (USB) controller. A data line of the USB controller is connected to a first USB interface. The first USB interface supports at least a master device. The method comprises the following steps: detecting a state of a first VBUS line of the first USB interface; setting a working mode of the USB controller according to the state of the first VBUS line and a state of the data line; wherein the working mode comprises a master device mode and a slave device mode; and performing data transmission with an external device in the working mode.

[0080] Since in the above scheme, the working mode of the USB controller is set by the state of the VBUS line and the data line in the USB interface, the USB interface with the ID line as in the prior art is not needed as the interface of the USB controller, and the state of the ID line is not needed to determine whether the USB controller should be set to the master device mode or the slave device mode, so the working mode of the USB controller is determined by the state of the first VBUS line and the data line in the first USB interface, and the application range is wider than that of the prior art.

[0081] In order to better understand the above technical solutions, the technical solutions of the present application are described in detail below by means of the accompanying drawings and specific embodiments. It should be understood that the embodiments of the present application and the specific features in the embodiments are detailed descriptions of the technical solutions of the present application, and are not limitations of the technical solutions of the present application. In the case of no conflict, the technical features in the embodiments of the present application and the embodiments can be combined with each other.

[0082] Please refer to Figure 1 and Figure 2 , Figure 1 The connection schematic diagram of the USB controller and the first USB interface provided by the embodiment of the present application, Figure 2 The flowchart of a serial data transmission method provided by the embodiment of the present application.

[0083] The serial data transmission method provided by the embodiment of the present application is applied to a universal serial bus (USB) controller. The data line of the USB controller is connected with a first USB interface. The first USB interface supports at least an external device as a master device to access the USB controller. The method comprises the following steps:

[0084] Step 201: detecting the state of the first VBUS line of the first USB interface;

[0085] Step 202: setting the working mode of the USB controller according to the state of the first VBUS line and the state of the data line; wherein the working mode comprises a master device mode and a slave device mode;

[0086] Step 203: performing data transmission with the external device in the working mode.

[0087] In the embodiment provided by the present application, the VBUS line supplies power to the outside when the USB controller works in the master device mode, and the VBUS line does not need to supply power to the outside when the USB controller works in the slave device mode.

[0088] In Figure 1The VBUS end of the USB controller is connected with the VBUS1 (regarded as the first VBUS line) of the first USB interface, the D+ and D- (regarded as a pair of data lines) of the USB controller are connected with the corresponding data lines of the first USB interface, and the GND (ground) of the USB controller is connected with the GND of the first USB interface. The working modes supported by the USB controller include the host mode and the slave mode, and the USB controller makes the first USB interface correspond to at least the slave mode, that is, the first USB interface at least allows external devices to access the USB controller as the host. That is, the first USB interface can allow external devices to access the USB controller as the host, or the first USB interface can allow external devices to access the USB controller as the slave and as the host.

[0089] By detecting the state of the first VBUS line of the first USB interface, the first VBUS line can be multiplexed as a detection line and a power line, and the working mode of the USB controller is set in combination with the state of the data line, so that the USB controller does not have special requirements for the USB interface type and the USB protocol of the accessed external device, and can determine the working mode to be used to communicate with the accessed external device, and therefore the application range of the above technical solution of the present application is wider than that of the prior art.

[0090] In addition, since the original VBUS line used only for power supply is multiplexed as a detection line for determining the working mode of the USB controller, the number of required USB interface lines is reduced, so that the number of lines is reduced while maintaining the working mode switching function of the USB controller, and the use range is improved.

[0091] It should be noted that the data line in the state of the first VBUS line and the state of the data line can be one or both of a pair of data lines connected between the USB controller and the first USB interface. Since the above pair of data lines needs to transmit data during communication, the state of any one data line can be detected to determine whether an external device is connected. Of course, the state of the data line can also not be detected, and a communication mode can be used, such as the USB controller sending data to the outside through the above pair of data lines, and then detecting whether data is received within a period of time. If data is received, it is determined that an external device is connected to the USB controller, otherwise it is determined that no external device is connected to the USB controller.

[0092] In a possible implementation, whether a device is connected is determined according to the state of the first VBUS line and the state of the data line, and the working mode of the USB controller is set, which can be realized by the following modes:

[0093] According to the state of the first VBUS line and the state of the data line, it is determined whether a device is connected to the USB controller; when it is determined that an external device is connected to the USB controller, the working mode of the USB controller is determined and set according to the state of the first VBUS line.

[0094] In a possible implementation, the working mode of the USB controller is determined and set according to the state of the first VBUS line, which can be implemented in the following manner:

[0095] When the state of the first VBUS line is a low state, the first VBUS line is set to output power externally, and it is detected whether the state of the data line changes within a set time period; if the state changes, it is determined that an external device is connected to the USB controller from the first USB interface; and the working mode is determined and set to a slave mode.

[0096] Please refer to Figure 3 The connection diagram of the intelligent electronic device and the U disk provided for the implementation of the present application.

[0097] In Figure 3 The intelligent electronic device uses the above-mentioned USB controller and the first USB interface provided by the embodiment of the present application.

[0098] Since the U disk (external device) is usually used as a slave device, when no external device is connected to the first USB interface of the intelligent electronic device, the VBUS end of the USB controller does not output power (i.e., no external power supply), and thus the first VBUS line (i.e., VBUS1 in Figure 3 ) of the first USB interface does not provide power externally, and the U disk as a slave device has no power supply by itself and needs external power supply, and thus the state of the first VBUS line detected before the USB controller provides power through the first VBUS line of the first USB interface is a low state.

[0099] When the USB controller provides power externally through the first VBUS line, the U disk obtains power, and at this time, the USB controller in the intelligent electronic device transmits a handshake signal with the U disk according to the USB communication protocol, which causes a signal to be generated on the data line, and since the signal is generated, the state of the data line (i.e., the state of the signal) changes, and thus whether an external device as a slave device is connected to the intelligent electronic device can be determined by detecting whether the state of the signal of the data line changes, and when it is determined that the state of the data line changes, the USB controller of the intelligent electronic device is set to a master device mode, so that the intelligent electronic device is used as a master device.

[0100] In a possible implementation, the working mode of the USB controller is determined and set according to the state of the first VBUS line, which can be implemented in the following manner:

[0101] When the state of the first VBUS line is high, it is determined that an external device is connected to the USB controller from the first USB interface; and whether the state of the data line changes within a set time period is detected, and if the state changes, the working mode is determined and set as the slave mode.

[0102] Please refer to Figure 4 The connection diagram of the intelligent electronic device and the computer provided by the embodiment of the present application.

[0103] In Figure 4 The intelligent electronic device uses the above-mentioned USB controller and the first USB interface provided by the embodiment of the present application.

[0104] Since the computer is usually used as a master device, the VBUS line in the USB interface of the computer usually supplies power externally. At this time, the USB controller in the intelligent electronic device can determine that the state of the first VBUS line (VBUS1) is high, and further determine that an external device (such as a computer) is connected, and detect whether the state of the data line changes within a set time period, and if the state changes, it can be determined that the external device is connected as a master device, at this time, the USB controller of the intelligent electronic device can be set as a slave device mode, so that the intelligent electronic device is used as a slave device.

[0105] A possible implementation, after detecting that the first VBUS line is high, and detecting whether the state of the data line changes within a set time period, when it is determined that the state of the data line does not change, it is determined that the external device is a power device.

[0106] For example, still taking Figure 4 As an example, if the USB controller in the intelligent electronic device detects that the state of the first VBUS line is high, but does not detect that the state of the data line changes within the subsequent set time period, it can be determined that the connected external device is a power device (because the power supply has no data line), that is, the power device is charging the intelligent electronic device, at this time, there is no need to set the working mode of the USB controller in the intelligent electronic device.

[0107] A possible implementation, the data line is also connected with a second USB interface, and the first VBUS line and the second VBUS line of the second USB interface correspond to different power supplies, and the second USB interface is used to support the external device to access the USB controller as a slave device. That is, the first USB interface and the second USB interface share a pair of data lines and a USB controller, so that the USB controller can support external devices of different USB interface types to access, so that the use range of the USB controller is wider, and the intelligent electronic device using the USB controller can also allow external devices of different USB interface types to access.

[0108] In a possible implementation, when the data line of the USB controller is also connected with the second USB interface, after determining that the external device accesses the USB controller from the first USB interface, the second VBUS line of the second USB interface is controlled to keep outputting power to the outside invalid.

[0109] Please refer to Figure 5 The schematic diagram of the USB controller provided by the embodiment of the present application is connected with the first USB interface and the second USB interface. The first VBUS line (VBUS1) and the second VBUS line (VBUS2) correspond to different power sources respectively, and in Figure 5 The power source corresponding to the second VBUS line is not shown in the figure.

[0110] Suppose Figure 5 In the embodiment, the first USB interface supports the external device to access the USB controller as a host device, and the second USB interface supports the external device to access the USB controller as a slave device. When it is determined according to the state of the first VBUS line that there is an external device (not a power device) accessing the USB controller from the first USB interface (determined in a corresponding manner), the USB controller is set to the slave device mode, and the second VBUS line is controlled to keep outputting power to the outside invalid, that is, the second VBUS line is not allowed to supply power to the outside. In this way, when the external device accessing from the first USB interface communicates with the USB controller, even if there is another external device accessing from the second USB interface, since there is no power supply to the slave device (the other external device), the other external device actually cannot communicate with the USB controller, and thus communication confusion is prevented. Figure 4

[0111] In a possible implementation, when the data line is also connected with the second USB interface, after detecting whether the state of the data line changes within a set time period, if it is detected that the state of the data line does not change within the set time period, it is determined that no device accesses the USB controller from the first USB interface, the first VBUS line is set to output power to the outside invalid, and the second VBUS line is set to output power to the outside valid. The state of the data line is detected again within the set time period. If the state changes, it is determined that the external device accesses the USB controller from the second USB interface, and the working mode of the USB controller is set to the host device mode.

[0112] Please continue to refer to Figure 5 ​, continue to assume that the first USB interface supports external devices to access the USB controller as a master device, and the second USB interface supports external devices to access the USB controller as a slave device, when it is determined that there is no external device accessing the USB controller from the first USB interface according to the state (low level) of the first VBUS line (VBUS1), the second VBUS line (VBUS2) is set to be effective for externally outputting power (i.e. allowing the second VBUS line to supply power externally), and then it is detected whether the state of the data line changes within a set time period. If it changes, it is determined that there is an external device accessing the USB controller from the second USB interface, and the working mode of the USB controller is set to the master device mode.

[0113] For another example, still taking the Figure 5 as an example, assume that the first USB interface can support external devices to access the USB controller as a master device and as a slave device, and the second USB interface supports external devices to access the USB controller as a slave device. When it is determined that the state of the first VBUS line is low level, the first VBUS line is set to be effective for externally outputting power (i.e. allowing the first VBUS line to supply power externally), and then it is detected whether the state of the data line changes within a set time period. If it does not change, it can be determined that there is no external device accessing the USB controller from the first USB interface as a slave device. Then, the first VBUS line is set to be ineffective for externally outputting power (i.e. not allowing the first VBUS line to supply power externally), and the second VBUS line is set to be effective for externally outputting power (i.e. allowing the second VBUS line to supply power externally), and then it is detected again whether the state of the data line changes. If it changes, it can be determined that there is an external device accessing the USB controller from the second USB interface as a slave device, and the USB controller is set to the master device mode, so that the USB controller performs data transmission with the accessed external device in the master device mode.

[0114] In a possible implementation, after it is detected again whether the state of the data line changes within a set time period, if it is determined that the state of the data line does not change again within the set time period, it is determined that there is no device accessing the USB controller from the first USB interface and the second USB interface, and the second VBUS line is set to be ineffective for externally outputting power.

[0115] For another example, still taking the Figure 5For example, if it is determined through the foregoing detection that no external device accesses the USB controller from the first USB interface, and no change in the state of the data line is detected within a set time period after the second VBUS line supplies power externally, it can be determined that no external device accesses the USB controller from the second USB interface, and the second VBUS line is set to be invalid for externally outputting power. Since the first VBUS line is set to be invalid for externally outputting power when it is determined whether an external device accesses the USB controller from the second USB interface, the first VBUS line is still invalid for externally outputting power after it is determined that no device accesses the USB controller from the second USB interface. That is, after it is determined that no external device accesses the USB controller from the first USB interface and the second USB interface, the first VBUS line and the second VBUS line are both invalid for externally outputting power (that is, both do not provide power externally).

[0116] It should be noted that in the embodiments provided by the present application, the state of the data line can also be detected whether a signal of communication is received.

[0117] In the embodiments provided by the present application, the first USB interface can include a min / micro USB interface, and the second USB interface can include a TYPEC A interface.

[0118] The USB controller provided by the embodiments of the present application can be a separate device, or a component unit in a central processing unit (CPU) or a microcontroller unit (MCU).

[0119] Based on the same inventive concept, an embodiment of the present application provides a device for serial data transmission. The specific implementation of the serial data transmission method of the device can be referred to the description of the method embodiments, and the repeated parts will not be described here. The device is applied to a universal serial bus (USB) controller. A pair of data lines of the USB controller is connected with a first USB interface. The first USB interface supports at least an external device as a host device to access the USB controller. Please refer to Figure 6 The device comprises:

[0120] A detection unit 601 is configured to detect a state of a first VBUS line of the first USB interface.

[0121] A setting unit 602 is configured to set a working mode of the USB controller according to the state of the first VBUS line and the state of the data line. The working mode includes a host device mode and a slave device mode.

[0122] A transmission unit 603 is configured to perform data transmission with the external device in the working mode.

[0123] In a possible implementation, the data line is further connected with a second USB interface, and the first VBUS line and a second VBUS line of the second USB interface correspond to different power sources, and the second USB interface is configured to support the external device to access the USB controller as a slave device.

[0124] In a possible implementation, the first USB interface includes a min / micro USB interface, and the second USB interface includes a TYPEC A interface.

[0125] In a possible implementation, the setting unit 602 is configured to:

[0126] determine whether a device accesses the USB controller according to the state of the first VBUS line and the state of the data line;

[0127] when it is determined that the external device accesses the USB controller, determine and set the working mode of the USB controller according to the state of the first VBUS line.

[0128] In a possible implementation, the setting unit 602 is further configured to:

[0129] when the state of the first VBUS line is a low-level state, set the first VBUS line to be effective in outputting a power source to the outside, and detect whether the state of the data line changes within a set time length;

[0130] if the state changes, determine that the external device accesses the USB controller from the first USB interface;

[0131] determine and set the working mode as the master device mode.

[0132] In a possible implementation, the setting unit 602 is further configured to:

[0133] when the state of the first VBUS line is a high-level state, determine that the external device accesses the USB controller from the first USB interface;

[0134] detect whether the state of the data line changes within a set time length, and if the state changes, determine and set the working mode as the slave device mode.

[0135] In a possible implementation, the setting unit 602 is further configured to:

[0136] when it is determined that the state of the data line does not change, determine that the external device is a power source device.

[0137] In a possible implementation, the setting unit 602 is further configured to:

[0138] When the pair of data lines are also connected with the second USB interface, after determining that the external device accesses the USB controller from the first USB interface, the second VBUS line of the second USB interface is controlled to keep outputting power to the outside invalid.

[0139] In a possible implementation, the setting unit 602 is further configured to:

[0140] When the data line is also connected with the second USB interface, after detecting whether the state of the data line changes within a set time period, if it is detected that the state of the data line does not change within the set time period, it is determined that no device accesses the USB controller from the first USB interface, the first VBUS line is set to be invalid for outputting power to the outside, and the second VBUS line is set to be valid for outputting power to the outside.

[0141] The state of the data line is detected again within the set time period.

[0142] If the state changes, it is determined that the external device accesses the USB controller from the second USB interface, and the working mode is determined and set to the master device mode.

[0143] In a possible implementation, the setting unit 602 is further configured to:

[0144] After detecting again whether the state of the data line changes within the set time period, if it is determined that the state of the data line does not change again within the set time period, it is determined that no device accesses the USB controller from the first USB interface and the second USB interface, and the second VBUS line is set to be invalid for outputting power to the outside.

[0145] Based on the same inventive concept, an intelligent electronic device is provided in the embodiments of the present application, please refer to Figure 7 The intelligent electronic device provided in the embodiments of the present application comprises:

[0146] The first USB interface 701 supports at least the access of a master device;

[0147] The USB controller 702 is connected with the first USB interface through a pair of data lines, and the USB controller 702 is configured to perform the serial data transmission method as described above.

[0148] Please refer to Figure 8 The other intelligent electronic device provided in the embodiments of the present application further comprises:

[0149] The second USB interface 703 is connected with the pair of data lines, the second USB interface 703 is used for accessing the device of the slave device type, and the VBUS lines and the interface types of the first USB interface 701 and the second USB interface 703 are different.

[0150] Based on the same inventive concept, the embodiment of the present application also provides a readable storage medium, comprising:

[0151] a memory,

[0152] The memory is used for storing instructions, when the instructions are executed by the processor, the device comprising the readable storage medium completes the serial data transmission method as described above.

[0153] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the embodiments of the present application can adopt a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present application can adopt the form of a computer program product implemented on one or more computer usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer usable program codes.

[0154] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams according to the method, device (system), and computer program product of the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to produce a machine, so that the instructions executed by the computer or other programmable data processing devices produce a device implemented in the flowcharts and / or block diagrams. Figure 1 one or more flows and / or blocks Figure 1 an apparatus that performs the functions specified in the flow(s) or block(s).

[0155] These computer program instructions can also be stored in a computer readable memory capable of guiding the computer or other programmable data processing devices to work in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product comprising instruction apparatus, which implements the flowcharts and / or block diagrams. Figure 1 one or more flows and / or blocks Figure 1 an apparatus that performs the functions specified in the flow(s) or block(s).

[0156] These computer program instructions can also be loaded into a computer or other programmable data processing devices, so that a series of operational steps are performed on the computer or other programmable devices to generate computer-implemented processes, thus the instructions executed on the computer or other programmable devices provide processes for implementing the functions specified in the flowchart Figure 1 flowchart or multiple flows and / or blocks Figure 1 flowchart or multiple flows and / or blocks

[0157] Obviously, those skilled in the art can make various modifications and variations to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application belong to the scope of the claims of the present application and their equivalent technologies, the present application also intends to include these modifications and variations.

Claims

1. A method for serial data transmission, applied to a Universal Serial Bus (USB) controller, wherein the data line of the USB controller is connected to a first USB interface, and the first USB interface at least supports external devices as master devices connected to the USB controller, characterized in that, The method includes: Detect the status of the first VBUS line of the first USB interface; Based on the status of the first VBUS line and the status of the data line, determine whether an external device is connected to the USB controller; After confirming that an external device is connected to the USB controller, if the USB controller is not powered through the first VBUS line and the first VBUS line is in a low-level state, the first VBUS line is set to be active for external power output, and the state of the data line is checked for changes within a set time period; if a change occurs, the device type of the external device is determined to be a slave device. If the USB controller is not powered through the first VBUS line and the first VBUS line is in a high-level state, the external device is confirmed to be connected to the USB controller from the first USB interface; the state of the data line is checked for changes within a set time period, and if a change occurs, the device type of the external device is determined to be a master device; the operating mode of the USB controller is set to a mode matching the device type; wherein, the operating mode includes master device mode and slave device mode; the device type includes master device, slave device, and power device, the operating mode matching the master device is the slave device mode, and the operating mode matching the slave device is the master device mode; In the operating mode, data is transmitted with the external device.

2. The method as described in claim 1, characterized in that, The data line is also connected to a second USB interface, and the first VBUS line and the second VBUS line of the second USB interface correspond to different power supplies. The second USB interface is used to support the external device to be connected to the USB controller as a slave device.

3. The method as described in claim 2, characterized in that, The first USB interface includes a mini / micro USB interface, and the second USB interface includes a Type-C A interface.

4. The method according to any one of claims 1-3, characterized in that, After detecting whether the state of the data line has changed within a set time period, the process also includes: If it is determined that the state of the data line has not changed, the device type of the external device is determined to be a power supply device.

5. The method as described in claim 2 or 3, characterized in that, When the data cable is still connected to the second USB interface, after determining that the external device is connected to the USB controller from the first USB interface, the method further includes: The second VBUS line of the second USB interface is kept inactive from outputting power.

6. The method as described in claim 2 or 3, characterized in that, While the data cable is still connected to the second USB interface, after detecting whether the state of the data cable has changed within a set time period, the process further includes: If the state of the data line does not change within the set time period, and it is determined that no device is connected to the USB controller from the first USB interface, the first VBUS line is set to disable external power output, and the second VBUS line is set to enable external power output. Within the set time period, check again whether the state of the data line has changed; If a change occurs, it is determined that the external device is connected to the USB controller from the second USB interface, and the operating mode is determined and set to the master device mode.

7. The method as described in claim 6, characterized in that, After detecting whether the state of the data line has changed again within the set time period, the process further includes: If it is determined that the state of the data line has not changed again within the set time period, then it is determined that no device is connected to the USB controller from the first USB interface and the second USB interface, and the second VBUS line is set to invalid for external power output.

8. A device for serial data transmission, characterized in that, A Universal Serial Bus (USB) controller is used, wherein the data line of the USB controller is connected to a first USB interface, the first USB interface supporting at least host device access, and the USB controller includes: The detection unit is used to detect the status of the first VBUS line of the first USB interface; The setting unit is configured to determine whether an external device is connected to the USB controller based on the state of the first VBUS line and the state of the data line. When the USB controller is not powered through the first VBUS line and the state of the first VBUS line is low, the first VBUS line is set to be active for external power output, and the state of the data line is checked for changes within a set time period. If a change occurs, the device type of the external device is determined to be a slave device. When the USB controller is not powered through the first VBUS line and the state of the first VBUS line is high, the external device is determined to be connected to the USB controller from the first USB interface. The state of the data line is checked for changes within a set time period, and if a change occurs, the device type of the external device is determined to be a master device. The operating mode of the USB controller is set to a mode matching the device type. The operating mode includes master mode and slave mode. The device type includes master device, slave device, and power device. The operating mode matching the master device is the slave device mode, and the operating mode matching the slave device is the master device mode. A transmission unit is used to transmit data with the device in the operating mode.

9. An intelligent electronic device, characterized in that, include: The first USB interface, which supports at least the connection of the host device; A Universal Serial Bus (USB) controller, wherein the data line of the USB controller is connected to the first USB interface, and the USB controller is configured to perform the method as described in any one of claims 1-7.

10. The intelligent electronic device as described in claim 9, characterized in that, Also includes: The second USB interface is connected to the data cable. The second USB interface is used to connect to a slave device. The VBUS lines and interface types of the first USB interface and the second USB interface are different.

11. A readable storage medium, characterized in that, Including memory, The memory is used to store instructions that, when executed by a processor, cause a device including the readable storage medium to perform the method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Device for automatically detecting universal serial bus main unit or peripherals

    CN101221546A

  • Switch control method and apparatus and electronic equipment for USB interface master-salve equipment mode

    CN101369259A

  • Method for connecting USB controller and USB controller

    CN102023955A

  • Detection device and method for USB (Universal Serial Bus) master and slave equipment

    CN108563537A