Interface circuit and communication device
By switching between USB and SWD interfaces using a switching component in the interface circuit, the problem of poor versatility of the SWD interface is solved, the host computer design is simplified, flexibility and security are improved, and debugging and fault analysis are facilitated.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Utility models(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-03
- Publication Date
- 2026-03-31
AI Technical Summary
The existing SWD interface has poor universality, requires reserved interfaces between the lower and upper computers, is not simple enough, is inconvenient to debug after hardware disconnection, has poor flexibility, and is not secure enough.
An interface circuit is provided, including a USB lower-level machine interface, an SWD lower-level machine interface, and a USB upper-level machine interface. By switching between different states through a switch component, the USB and SWD interfaces can be flexibly switched, simplifying the upper-level machine design, and the SWD interface can be disconnected when not in use.
It simplifies the design of the host computer, improves the flexibility and security of the interface, facilitates debugging and troubleshooting, and avoids the inconvenience of hardware disconnection.
Smart Images

Figure CN224067216U_ABST
Abstract
Description
Technical Field
[0001] This utility model relates to the field of MCU technology, and in particular to an interface circuit and a communication device. Background Technology
[0002] In embedded development, various I / O interfaces of lower-level machines such as microprocessor units (MPUs) or microcontrollers (MCUs) are used to connect to mounted devices and upper-level computers to achieve corresponding functions. Among them, the SWD (Serial Wire Debug) interface is widely used in MCU debugging, system-level production debugging, and production programming scenarios due to its advantages such as high speed and fewer debugging wires, bringing great convenience to embedded development.
[0003] However, due to the poor universality of the current SWD interface, both the lower-level and upper-level computers need to reserve SWD interfaces, resulting in an unsimplistic design. Furthermore, for security reasons, the SWD interface needs to be disconnected by hardware when it is not needed, which makes debugging and troubleshooting after hardware disconnection very inconvenient. It also lacks flexibility. Utility Model Content
[0004] In order to flexibly utilize the SWD and USB interfaces of the lower-level machine to achieve the corresponding functions and ensure security, while simplifying the interface design of the upper-level machine, this utility model provides an interface circuit and a communication device.
[0005] On the one hand, this utility model provides an interface circuit, the interface circuit comprising:
[0006] USB lower-level machine interface, SWD lower-level machine interface, and USB upper-level machine interface; and
[0007] A switch assembly, wherein the switch assembly connects the USB lower-level interface and the USB upper-level interface in a first switch state, and connects the SWD lower-level interface and the USB upper-level interface in a second switch state opposite to the first switch state.
[0008] Optionally, it also includes a USB peripheral port connected to the USB host computer interface.
[0009] Optionally, the switching assembly includes a first switching assembly and a second switching assembly. The first switching assembly responds to a first control signal to turn the USB lower-level interface and the USB upper-level interface on or off, and the second switching assembly responds to a second control signal to turn the SWD lower-level interface and the USB upper-level interface on or off.
[0010] Optionally, the control terminals of the first switch assembly and the second switch assembly are connected to the same control signal, with one being on and the other off.
[0011] Optionally, the switching assembly employs a multiplexer selection circuit.
[0012] Optionally, the lower-level machine includes at least one of a microcontroller, a microprocessor unit, a programmable logic controller, and an embedded control board.
[0013] On the other hand, this utility model provides a communication device, which includes a lower-level machine, a higher-level machine, and the aforementioned interface circuit connecting the lower-level machine and the higher-level machine.
[0014] Optionally, the control terminal of the switch assembly is connected to the enable port of the lower-level machine.
[0015] The communication device also includes a mounting device connected to the lower-level machine.
[0016] Optionally, the mounted device includes at least one of a fingerprint sensor, a display screen, a voice sensor, an input device, and a storage device.
[0017] The interface circuit provided by this utility model includes a USB lower-level machine interface and an SWD lower-level machine interface for connecting a USB interface and an SWD interface on a lower-level machine, respectively. It also includes a USB upper-level machine interface for connecting to a USB interface on a higher-level machine. A switch assembly conducts the USB lower-level machine interface and the USB upper-level machine interface in a first switch state, and conducts the SWD interface and the USB upper-level machine interface in a second switch state. Through this interface circuit, the higher-level machine does not need to set up a dedicated SWD interface, but can connect to the lower-level machine's SWD interface or USB interface through a USB interface to perform corresponding functions. This helps to simplify the design of the higher-level machine, provides high flexibility, and the SWD lower-level machine interface in the interface circuit can be disconnected from the USB upper-level machine interface when not in use, ensuring good security.
[0018] The communication device provided by this utility model includes a lower-level machine, a higher-level machine, and the aforementioned interface circuit connecting the lower-level machine and the higher-level machine, and has similar advantages to the aforementioned interface circuit. Attached Figure Description
[0019] Figure 1 This is a schematic diagram of a communication device.
[0020] Figure 2 This is a schematic diagram showing the connection relationship between the MCU, interface circuit, and host computer in one embodiment of this utility model.
[0021] Figure 3This is a schematic diagram of a switch assembly in one embodiment of the present invention.
[0022] Figure 4 This is a schematic diagram showing the connection relationship between the MCU and the interface circuit in another embodiment of this utility model.
[0023] Figure 5 It is to utilize Figure 2 The diagram shows the MCU, interface circuit, and host computer transmitting signals. Detailed Implementation
[0024] The interface circuit of this utility model will be further described in detail below with reference to the accompanying drawings and specific embodiments. The advantages and features of this utility model will become clearer from the following description. It should be understood that the drawings in this specification are all in a very simplified form and use non-precise proportions, and are only used to facilitate and clarify the illustration of the embodiments of this utility model.
[0025] To make this utility model clearer, first refer to Figure 1 This section describes a communication device where both the lower-level and upper-level computers have independent hardware configuration SWD interfaces. This communication device can be used in embedded development. Figure 1 As shown, the lower-level machine is, for example, an MCU. The USB interface and SWD interface on the MCU are independently configured hardware and operate independently. The USB interface (including two signal lines: DP (represented as USB DP) and DM (represented as USB DM)) connects to the USB interface on the upper-level machine HOST1. The upper-level machine HOST1 runs the corresponding software, which can perform tasks such as data transfer, inter-device communication, or power supply as needed. The SWD interface (including two signal lines: CLK (represented as SWD CLK) and IO (represented as SWD IO)) connects to the SWD interface on the upper-level machine HOST2. The upper-level machine HOST2 runs the corresponding software, which can perform tasks such as MCU debugging, production debugging, and production programming as needed. The MCU is also connected to a mount device, such as a fingerprint sensor, which connects to the MCU via SPI and INT signal lines.
[0026] However, as described in the background section, setting up the SWD interface on the host computer is not straightforward, and the SWD interface has poor versatility. For security reasons, it needs to be hardware disconnected when it is not needed, resulting in poor flexibility in use. For example, because the SWD circuit hardware is disconnected, there is a lack of effective means to obtain data information when the MCU or the connected device malfunctions.
[0027] This utility model relates to an interface circuit and a communication device, compared to such... Figure 1The communication device shown does not require hardware disconnection of the SWD interface on the MCU, which is highly flexible. For example, it is convenient to use the SWD interface on the MCU for safe debugging and fault analysis, making the product more convenient in debugging and troubleshooting. In addition, no dedicated SWD interface needs to be set on the host computer, which can simplify the host computer design and avoid the drawbacks caused by the poor universality and low security of the SWD interface.
[0028] Reference Figure 2 In this embodiment of the invention, the interface circuit 100 is used to connect the lower-level machine and the upper-level machine HOST3. The lower-level machine may include at least one of a microcontroller (MCU), a microprocessor unit (MPU), a programmable logic controller (PLC), and an embedded control board. In the following embodiments, the lower-level machine is, for example, an MCU.
[0029] The MCU may include at least one USB interface 11, at least one SWD interface 12, and at least one GPIO enable port 13. The USB interface 11 includes a DP signal line and a DM signal line. The SWD interface 12 includes an IO signal line and a CLK signal line. The GPIO enable port 13 includes, for example, a CTRL_IO signal line. At least one USB interface 11 and at least one SWD interface 12 are used to connect to the interface circuit 100. Optionally, at least one GPIO enable port 13 is also connected to the interface circuit 100. The USB interface 11 and SWD interface 12 can be used flexibly according to their circuit and operating characteristics. For example, the USB interface 11 can be used for data transmission, inter-device communication, and power supply, while the SWD interface 12 can be used for MCU debugging, production debugging, production programming, and fault diagnosis (e.g., locating faults and performing online fault repair by writing data). The GPIO enable port 13 can output a high-level or low-level enable signal as needed. The MCU can connect to mounted devices. The mounted devices include, for example, at least one of a fingerprint sensor, a display screen, a voice sensor, an input device, and a storage device. (See reference...) Figure 2 As an example, the MCU includes an SPI interface for connecting to the mounted device. The mounted device is, for example, a fingerprint sensor. The MCU connects to the fingerprint sensor via SPI and INT signal lines.
[0030] like Figure 2As shown, the interface circuit 100 includes a USB lower-level interface 21, an SWD lower-level interface 22, and a USB upper-level interface 23. The USB lower-level interface 21 can be used to connect to the USB interface 11 on the MCU, the SWD lower-level interface 22 can be used to connect to the SWD interface 12 on the MCU, and the USB upper-level interface 23 can be used to connect to the upper-level computer HOST3. Optionally, the interface circuit 100 also includes a USB peripheral port 20 connected to the USB upper-level interface 23, so that the USB upper-level interface 23 can be connected to the upper-level computer HOST3 through the USB peripheral port 20. The USB peripheral port 20 includes, for example, a power positive connection terminal (VCC), a ground terminal (GND), and a data signal positive terminal (D+) and a data signal negative terminal (D-) connected to the USB upper-level interface 23 via a DP signal line (represented as USB DP) and a DM signal line (represented as USB DM), respectively.
[0031] The interface circuit 100 also includes a switch assembly 10, which connects the USB lower-level interface 21 and the SWD lower-level interface 22 to the USB upper-level interface 23. In this embodiment, the switch assembly 10 conducts the USB lower-level interface 21 and the USB upper-level interface 23 in a first switching state, and conducts the SWD lower-level interface 22 and the USB upper-level interface 23 in a second switching state opposite to the first switching state. Thus, using the switch assembly 10, the interface circuit 100 can form a communication channel from the MCU's USB interface 11 to the USB peripheral port 20 and the upper-level host computer HOST3, and a communication channel from the MCU's SWD interface 12 to the USB peripheral port 20 and the upper-level host computer HOST3. The switch assembly 10 allows switching between the two communication channels.
[0032] The switching assembly 10 may be an analog switch. For example, the switching assembly 10 may use a Connect_D connector, which offers advantages such as support for full USB 2.0 speeds, low conduction, and fast switching. In this embodiment, the switching assembly 10 employs a multiplexer selection circuit, such as... Figure 3 As shown.
[0033] To control the switching component 10 between the first and second switching states, it can be connected to a GPIO enable pin 13 of the MCU. The signal from the GPIO enable pin 13 can then be used as a corresponding control signal to control the switching component 10 between the first and second switching states. However, this invention is not limited to this. In other embodiments, other circuit structures can be used to connect to the switching component 10, and the switching component 10 can switch between the first and second switching states according to the electrical signals of these other circuit structures. This allows the USB lower-level interface 21 or the SWD lower-level interface 22 to connect to the USB upper-level interface 23, thus enabling the switching of the two communication channels.
[0034] Reference Figure 4 As an example, the switch assembly 10 may include a first switch assembly CON1 and a second switch assembly CON2. The first switch assembly CON1, for example, responds to a first control signal to turn the USB lower-level interface 21 and the USB upper-level interface 23 on or off, and the second switch assembly CON2, for example, responds to a second control signal to turn the SWD lower-level interface 22 and the USB upper-level interface 23 on or off. Optionally, the control terminals of the first switch assembly 10a and the second switch assembly 10b may be connected to the same control signal (such as the GPIO enable port 13 signal), with one being on and the other off.
[0035] The following description uses the signal control switch assembly 10 with GPIO enable pin 13 to connect the USB lower-level interface 21 or SWD lower-level interface 22 to the USB upper-level interface 23 as an example.
[0036] As an example, before the MCU and interface circuit 100 are powered on, the switching component 10 connects the USB lower-level interface 21 to the USB upper-level interface 23, while disconnecting the SWD lower-level interface 22 from the USB upper-level interface 23. The switching component 10 is also connected to the GPIO enable terminal 13 and the USB peripheral port 20. Afterward, the MCU dynamically controls whether the SWD lower-level interface 22 is connected to the USB upper-level interface 23 by driving the state of the CTRL_IO signal line of the GPIO enable port 13.
[0037] The switching component 10, for example, responds to a first-level signal of the connected GPIO enable port 13 to switch from enabling the USB lower-level interface 21 and the USB upper-level interface 23 to enabling the SWD lower-level interface 22 and the USB upper-level interface 23. When the circuit is first powered on, the CTRL_IO signal line of the GPIO enable terminal 13 is not enabled. At this time, for example, it is a second level signal. The switch component 10 does not perform a switching action, thereby keeping the USB lower-level interface 21 and the USB upper-level interface 23 connected, so that the USB interface 11 and the USB peripheral port 20 are connected, forming a USB channel. The upper-level computer HOST3 can communicate with the MCU through this channel. Afterwards, if the upper-level computer HOST3 needs to communicate with the MCU through the SWD interface 12, it can generate a first level signal by enabling the GPIO enable terminal 13, enabling the CTRL_IO signal line. The switch component 10 works under the first level signal, thus disconnecting the connection between the USB lower-level interface 21 and the USB upper-level interface 11, switching the connection between the SWD lower-level interface 22 and the USB upper-level interface 23, so that the SWD interface 12 and the USB peripheral port 20 are connected. That is, the SWD circuit is connected to the USB channel, and the upper-level computer HOST3 can communicate with the MCU through the USB peripheral port 20 and the SWD interface 12. For example, when the MCU malfunctions, the host computer HOST3 can read the MCU's operating data stored in the MCU's registers and the status data of the mounted devices (such as fingerprint sensors) temporarily stored in the MCU's storage unit (such as memory) through the USB channel of the SWD interface 12, effectively analyzing and locating the problem and facilitating analysis and resolution.
[0038] The switching component 10 can also switch from a state where the SWD lower-level interface 22 and the USB upper-level interface 23 are connected to a state where the USB lower-level interface 21 and the USB upper-level interface 23 are connected in response to a second-level signal from the connected GPIO enable port 13. For example, in the above process, after completing the relevant operation through the USB channel connected to the SWD interface 12, in order to communicate with the MCU using the USB interface 11, the GPIO enable port 13 can generate a second-level signal. Under the second-level signal, the switching component 10 disconnects the connection between the SWD lower-level interface 22 and the USB upper-level interface 23, and connects the USB lower-level interface 21 and the USB upper-level interface 23.
[0039] The first and second level signals described above are opposite; for example, the first level signal is high and the second level signal is low. However, this is not a limitation; in another embodiment, the first level signal is low and the second level signal is high.
[0040] Using the interface circuit 100 described in the above embodiments, the host computer does not need to set up a dedicated SWD interface. Instead, it can connect to the SWD interface or USB interface of the slave computer through the interface circuit 100 via the USB interface to perform corresponding functions. This helps to simplify the host computer design, provides high flexibility, and ensures good security because the SWD slave interface 22 in the interface circuit 100 can be disconnected from the USB host computer interface 23 when not in use.
[0041] This utility model also relates to a communication device. (See attached image) Figures 2 to 4 The communication device includes a lower-level machine (such as an MCU), a higher-level machine (HOST3), and an interface circuit 100 as described in the above embodiments connecting the lower-level machine and the higher-level machine.
[0042] In the communication device, the USB lower-level interface 21 of the interface circuit 100 is connected to the USB interface 11 on the MCU, the SWD lower-level interface 22 is connected to the SWD interface 12 on the MCU, and the USB upper-level interface 23 is connected to the USB peripheral port 20, which is connected to the upper-level computer HOST3. In another embodiment, the USB upper-level interface 23 can be directly connected to the upper-level computer HOST3.
[0043] like Figures 2 to 4 In some embodiments, the control terminal of the switch component 10 in the interface circuit 100 is connected to the enable port (such as GPIO enable port 13) of the lower-level machine. The communication device may also include a mount device connected to the lower-level machine. The mount device may include at least one of a fingerprint sensor, a display screen, a voice sensor, an input device, and a storage device.
[0044] In the communication device, the MCU can receive I / O commands sent by the host computer HOST3 and send data streams to the host computer HOST3. The MCU can also interact with mounted devices (e.g., fingerprint sensors). As an example, the MCU may internally include an instruction transmission unit, registers and storage units, and a fingerprint sensor software library. The registers and storage units can interact with the fingerprint sensor software library to obtain data from the fingerprint sensor. For details regarding the interface circuit 100 in the communication device, its connection to the lower-level and upper-level computers, and its functional implementation, please refer to the description in the above embodiments.
[0045] Figure 5 It shows the use of Figure 2 The diagram illustrates the signal transmission process between the MCU, interface circuit 100, and host computer HOST3. The following refers to... Figures 2 to 5 This paper describes the operation of a communication device in one embodiment.
[0046] First, in the initial state, the switch assembly 10 connects the USB lower-level interface 21 and the USB upper-level interface 23, thereby connecting the MCU's USB interface 11 and USB peripheral port 20. The host (i.e., the host computer HOST3) sends IO commands to the MCU through the USB peripheral port 20 and the USB interface 11. The MCU's instruction processing unit receives the IO commands and performs corresponding operations. If the IO command is "OPEN", the MCU enables the GPIO enable port 13 connected to the switch assembly 10 to a high level (corresponding to the first level signal mentioned above). At this time, the switch assembly 10 is in operation. In operation, the connection between the USB lower-level interface 21 and the USB upper-level interface 23 is disconnected, and the connection between the SWD lower-level interface 22 and the USB upper-level interface 23 is switched. This connects the SWD interface 12 in series into the USB channel between the MCU and the host. If the IO instruction is "CLOSE", the MCU receives the IO instruction and sets the GPIO enable port 13 signal to a low level (corresponding to the second level signal mentioned above). Then, the switch assembly 10 disconnects the connection between the SWD lower-level interface 22 and the USB upper-level interface 23 and switches the connection between the USB lower-level interface 21 and the USB upper-level interface 23.
[0047] Taking the example of the host sending the IO command "OPEN" to connect the SWD lower-level machine interface 22 and SWD interface 12 in series into the USB channel, the host then sends an IO command "READ" which is received by the command processing unit. The MCU reads the data from the registers and storage units and then transmits the data to the host via the USB channel connected to SWD interface 12. The host then analyzes and processes the data to facilitate fault location. Later, when it is necessary to modify the relevant settings and data within the MCU, the host can again send an IO command (e.g., "WRITE") and send data (such as a data set) to the MCU. After receiving the IO command and the data set, the MCU modifies the registers and the fingerprint sensor software library, thereby achieving online problem repair and facilitating online dynamic debugging of the MCU and fingerprint sensor.
[0048] To further enhance the security performance of the aforementioned communication device, ensure the security of transmitted data, and guarantee that SWD interface 11 and SWD lower-level interface 22 will not be compromised by unauthorized applications even when they are in operation, in one embodiment, the communication between the host and the MCU is encrypted. A suitable encryption protocol can be selected as needed. When communicating in encrypted mode, an encrypted channel is first established between the MCU and the host. Then, before the host sends data to the MCU, the data is encrypted. After the encrypted data is transmitted to the MCU via the USB channel, it is decrypted, processed, and related control operations are performed. Similarly, before the MCU sends data to the host, the data is encrypted on the MCU side. After the encrypted data is transmitted to the host via the USB channel, it is decrypted, processed, and related control operations are performed. After communication between the host and the MCU ends, the encryption context is destroyed, and the USB interface resources are released.
[0049] The communication device of this utility model embodiment uses interface circuit 100. The host computer does not need to set up a dedicated SWD interface. Instead, it can connect to the SWD interface 12 or USB interface 11 of the slave computer through USB interface and interface circuit 100 to perform corresponding functions. This helps to simplify the host computer design, has high flexibility, and the SWD slave computer interface 22 in interface circuit 100 can be disconnected from the USB host computer interface 23 when not in use, which has good security.
[0050] The above description is only a description of the preferred embodiment of the present utility model and is not intended to limit the scope of the present utility model. Any person skilled in the art can make possible changes and modifications to the technical solution of the present utility model by using the methods and techniques disclosed above without departing from the spirit and scope of the present utility model. Therefore, any simple modifications, equivalent changes and modifications made to the above embodiments based on the technical essence of the present utility model without departing from the content of the technical solution of the present utility model shall fall within the protection scope of the technical solution of the present utility model.
Claims
1. An interface circuit, characterized by Comprising: a USB slave interface, a SWD slave interface and a USB host interface; and a switch assembly, which conducts the USB slave interface and the USB host interface in a first switch state, and conducts the SWD slave interface and the USB host interface in a second switch state opposite to the first switch state.
2. The interface circuit of claim 1, wherein, Further comprising a USB peripheral port connected with the USB host interface.
3. The interface circuit of claim 1, wherein, The switch assembly comprises: a first switch assembly, which conducts or disconnects the USB slave interface and the USB host interface in response to a first control signal; and a second switch assembly, which conducts or disconnects the SWD slave interface and the USB host interface in response to a second control signal.
4. The interface circuit of claim 3, wherein, The control terminals of the first switch assembly and the second switch assembly are connected with the same control signal, and one is conducted while the other is disconnected.
5. The interface circuit of claim 1, wherein, The switch assembly adopts a multipath switch selection circuit.
6. The interface circuit of claim 1, wherein, The slave comprises at least one of a microcontroller, a micro processing unit, a programmable logic controller and an embedded control board.
7. A communication device, characterized by Comprising a slave, a host and an interface circuit as claimed in any one of claims 1 to 6 connecting the slave and the host.
8. The communication apparatus of claim 7, wherein, The control terminal of the switch assembly is connected to an enable port of the slave.
9. The communication apparatus of claim 7, wherein, Further comprising a mounting device connected with the slave.
10. The communication apparatus of claim 9, wherein, The mounting device comprises at least one of a fingerprint sensor, a display screen, a voice sensor, an input device and a storage device.