Data interaction method and device between devices, electronic device and readable storage medium
By using a single input and output interface and custom commands for data interaction under the bus connection between devices, the problem of high cost of data interaction between devices is solved, and more efficient and low-power data transmission is achieved.
Patent Information
- Application Number
- CN202410601657.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-15
- Publication Date
- 2024-09-03
AI Technical Summary
Data interaction between devices requires multiple input and output interfaces, resulting in higher costs and reliability issues.
Through the bus connection, a single input and output interface is used between the master device and the slave device for data interaction. Custom commands and verification algorithms are used. Each data bit transmitted on the bus is composed of two signal bits to realize data interaction and perform data processing when necessary. Make a correction request.
It reduces the cost required for data interaction between devices, improves low-power performance and anti-interference capabilities, reduces signal transmission paths and delays, and improves data transmission efficiency.
Smart Images

Figure CN118585474A
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of electrical technology, and in particular, to a method for data interaction between devices, an apparatus for data interaction between devices, an electronic device, and a computer-readable storage medium. Background Art
[0002] As market competition becomes increasingly fierce, product manufacturers in various fields have strict cost and reliability requirements for their products, such as equipment in the home appliance field.
[0003] In the specific implementation, data interaction is required between devices to realize various functions. Currently, there are two methods involved in data interaction between devices. One is software-defined identification code, which is implemented through multi-line interaction, but this requires more resources and complex design; the other is dip switch. Although the dip switch is simple to implement as an identification, it needs to occupy multiple IO (Input / Output) interfaces and has reliability issues.
[0004] It can be seen that currently, data interaction between devices requires the use of multiple input and output interfaces, which leads to high costs. Summary of the invention
[0005] The embodiments of the present invention provide a method, apparatus, electronic device and computer-readable storage medium for data interaction between devices to solve the problem that data interaction between devices requires occupying multiple input and output interfaces and is costly.
[0006] An embodiment of the present invention discloses a method for data interaction between devices, wherein the device comprises a master device and a slave device, wherein the master device and the slave device are connected via a bus, wherein a single input / output interface of the master device and a single input / output interface of the slave device are connected to the bus, wherein a custom command is pre-designed between the master device and the slave device, wherein each data bit transmitted on the bus is composed of two signal bits, and when the master device and the slave device perform data interaction, the method comprises:
[0007] The master device sends a start bit to the slave device via the bus;
[0008] If the master device receives a response bit sent by the slave device via the bus in response to the start bit, the master device sends a pending command and pending data corresponding to the pending command to the slave device via the bus; the slave device is used to determine the command type according to the custom command and the pending command after receiving the pending command and the pending data, so as to process the pending data according to the command type.
[0009] Optionally, a verification algorithm is pre-set between the master device and the slave device, and after the master device sends a to-be-processed command and to-be-processed data corresponding to the to-be-processed command to the slave device through the bus, the method further includes:
[0010] The master device generates a first check value according to the command to be processed and the data to be processed by using a preset check algorithm;
[0011] The master device sends the first check value to the slave device via the bus; the slave device is used to generate a second check value according to the command to be processed and the data to be processed by adopting a preset check algorithm, and processes the command to be processed and the data to be processed when the first check value and the second check value are the same, and sends an error correction request to the master device via the bus when the first check value and the second check value are different.
[0012] Optionally, the command type of the to-be-processed command includes at least a write command, and the master device sends the to-be-processed command and the to-be-processed data corresponding to the to-be-processed command to the slave device through the bus; the slave device is used to determine the command type according to the custom command and the to-be-processed command after receiving the to-be-processed command and the to-be-processed data, so as to process the to-be-processed data according to the command type, including:
[0013] The master device sends a pending command, a write bit, and pending data corresponding to the pending command to the slave device through the bus; the slave device is used to perform a write operation according to the write bit and the pending data after receiving the pending command, the write bit, and the pending data, if the pending command is determined to be a write command according to the custom command.
[0014] Optionally, the command type of the to-be-processed command includes at least a read command, and the master device sends the to-be-processed command and the to-be-processed data corresponding to the to-be-processed command to the slave device through the bus; the slave device is used to determine the command type according to the custom command and the to-be-processed command after receiving the to-be-processed command and the to-be-processed data, so as to process the to-be-processed data according to the command type, including:
[0015] The master device sends a pending command, a read bit, and pending data corresponding to the pending command to the slave device through the bus; the slave device is used to perform a read operation according to the read bit and the pending data after receiving the pending command, the read bit, and the pending data, if the pending command is determined to be a read command according to the custom command.
[0016] Optionally, the start bit consists of a preset setup time and a preset start phase, the response bit consists of a preset response high phase and a preset response low phase, the write bit consists of a preset write high phase and a preset write low phase, and the read bit consists of a preset read high phase, a preset read low phase and a preset read sampling time.
[0017] Optionally, the bus is connected to an external pull-up resistor, and the method further includes: when no data interaction is performed between the master device and the slave device, the master device and the slave device respectively release control of their input and output interfaces connected to the bus, and set the bus to an idle state through the external pull-up resistor.
[0018] Optionally, the two signal bits are a high level and a low level.
[0019] Optionally, the method also includes: when the master device receives the current signal bit sent by the slave device through the bus, if the previous signal bit received by the master device is a high level, and the current signal bit is lower than a preset input high voltage threshold and higher than a preset input low voltage threshold, and the time of the current signal bit is less than a preset establishment time, then filtering the current signal bit.
[0020] Optionally, the method also includes: when the master device receives the current signal bit sent by the slave device through the bus, if the previous signal bit received by the master device was converted from a low level to a high level, and the current signal bit is lower than a preset input low voltage threshold and the previous signal bit is lower than an input high voltage threshold, and the time between the current signal bit and the previous signal bit is less than a preset setup time, then filtering the current signal bit.
[0021] The embodiment of the present invention further discloses a device for data interaction between devices, wherein the device comprises a master device and a slave device, wherein the master device and the slave device are connected via a bus, wherein a single input / output interface of the master device and a single input / output interface of the slave device are connected to the bus, wherein a custom command is pre-designed between the master device and the slave device, wherein each data bit transmitted on the bus is composed of two signal bits, and when the master device and the slave device perform data interaction, the device comprises:
[0022] A start bit sending module, used for the master device to send a start bit to the slave device through the bus;
[0023] A command sending module is used for, if the master device receives a response bit sent by the slave device via the bus in response to the start bit, the master device sends a pending command and pending data corresponding to the pending command to the slave device via the bus; the slave device is used to determine the command type according to the custom command and the pending command after receiving the pending command and the pending data, so as to process the pending data according to the command type.
[0024] Optionally, the device also includes: a verification module, which is used to: the master device uses a preset verification algorithm to generate a first verification value according to the command to be processed and the data to be processed; the master device sends the first verification value to the slave device through the bus; the slave device uses a preset verification algorithm to generate a second verification value according to the command to be processed and the data to be processed, and processes the command to be processed and the data to be processed when the first verification value and the second verification value are the same, and sends an error correction request to the master device through the bus when the first verification value and the second verification value are different.
[0025] Optionally, the command type of the pending command includes at least a write command, and the command sending module is used for: the master device sends the pending command, the write bit and the pending data corresponding to the pending command to the slave device through the bus; the slave device is used for, after receiving the pending command, the write bit and the pending data, if it is determined according to the custom command that the pending command is a write command, then performing a write operation according to the write bit and the pending data.
[0026] Optionally, the command type of the pending command includes at least a read command, and the command sending module is used for: the master device sends the pending command, the read bit and the pending data corresponding to the pending command to the slave device through the bus; the slave device is used for, after receiving the pending command, the read bit and the pending data, if it is determined according to the custom command that the pending command is a read command, then performing a read operation according to the read bit and the pending data.
[0027] Optionally, the start bit consists of a preset setup time and a preset start phase, the response bit consists of a preset response high phase and a preset response low phase, the write bit consists of a preset write high phase and a preset write low phase, and the read bit consists of a preset read high phase, a preset read low phase and a preset read sampling time.
[0028] Optionally, the bus is connected to an external pull-up resistor, and the device also includes: a release module, which is used to: when there is no data interaction between the master device and the slave device, the master device and the slave device respectively release the control of their input and output interfaces connected to the bus, and set the bus to enter an idle state through the external pull-up resistor.
[0029] Optionally, the two signal bits are a high level and a low level.
[0030] Optionally, the device also includes: a first filtering module, used for: when the master device receives the current signal bit sent by the slave device through the bus, if the previous signal bit received by the master device is a high level, and the current signal bit is lower than a preset input high voltage threshold and higher than a preset input low voltage threshold, and the time of the current signal bit is less than a preset establishment time, then filtering the current signal bit.
[0031] Optionally, the device also includes: a second filtering module, used for: when the master device receives the current signal bit sent by the slave device through the bus, if the previous signal bit received by the master device is a low level to high level transition, and the current signal bit is lower than a preset input low voltage threshold and the previous signal bit is lower than an input high voltage threshold, and the time between the current signal bit and the previous signal bit is less than a preset setup time, then filtering the current signal bit.
[0032] The embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0033] The memory is used to store computer programs;
[0034] The processor is used to implement the method described in the embodiment of the present invention when executing the program stored in the memory.
[0035] The embodiment of the present invention further discloses a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the embodiment of the present invention.
[0036] The embodiment of the present invention further discloses a computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, enables the processors to execute the method described in the embodiment of the present invention.
[0037] The embodiments of the present invention include the following advantages:
[0038] In an embodiment of the present invention, a master device and a slave device are connected via a bus, a single input / output interface of the master device and a single input / output interface of the slave device are connected to the bus, a custom command is pre-designed between the master device and the slave device, each data bit transmitted on the bus is composed of two signal bits, when the master device and the slave device perform data exchange, the master device sends a start bit to the slave device via the bus, if the master device receives a response bit sent by the slave device via the bus for the start bit, the master device sends a pending command and pending data corresponding to the pending command to the slave device via the bus, after receiving the pending command and pending data, the slave device can determine the command type according to the custom command and the pending command, so as to process the pending data according to the command type. The master device and the slave device of the embodiment of the present invention can exchange data through the bus after being connected to the bus via a single input / output interface, have better low-power performance, and because there is no need to occupy multiple input / output interfaces, the cost required to realize the master device and the slave device is reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 is a flowchart of a method for data interaction between devices provided in an embodiment of the present invention;
[0040] Figure 2 is a schematic diagram of an application environment provided in an embodiment of the present invention;
[0041] Figure 3 is a timing diagram of a start bit provided in an embodiment of the present invention;
[0042] Figure 4 is a timing diagram of a response bit provided in an embodiment of the present invention;
[0043] Figure 5 is a timing diagram of a write operation provided in an embodiment of the present invention;
[0044] Figure 6 is a timing diagram of a read operation provided in an embodiment of the present invention;
[0045] Figure 7 is a schematic diagram of a frame structure provided in an embodiment of the present invention;
[0046] Figure 8 is a schematic diagram of a write timing provided in an embodiment of the present invention;
[0047] Fig. 9 is a schematic diagram of a signal filtering provided in an embodiment of the present invention;
[0048] Fig.10 is a schematic diagram of another signal filtering provided in an embodiment of the present invention;
[0049] Fig.11 It is a structural block diagram of an apparatus for data interaction between devices provided in an embodiment of the present invention;
[0050] Fig.12 It is a schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention. DETAILED DESCRIPTION
[0051] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0052] Reference Figure 1 , shows a flow chart of the steps of a method for data interaction between devices provided in an embodiment of the present invention, the device includes a master device and a slave device, the master device and the slave device are connected via a bus, a single input / output interface of the master device and a single input / output interface of the slave device are connected to the bus, a custom command is pre-designed between the master device and the slave device, each data bit transmitted on the bus is composed of two signal bits, when the master device and the slave device perform data interaction, the method may specifically include the following steps:
[0053] Step 101: The master device sends a start bit to the slave device via the bus.
[0054] Step 102: If the master device receives a response bit sent by the slave device via the bus in response to the start bit, the master device sends a pending command and pending data corresponding to the pending command to the slave device via the bus; the slave device is used to determine the command type according to the custom command and the pending command after receiving the pending command and the pending data, so as to process the pending data according to the command type.
[0055] In a specific implementation, a master device (host) refers to a device that actively sends data, and a slave device (slave) refers to a device that passively receives data, and data transmission and reception are determined by the master device. Of course, in actual applications, the master device can also be used as a slave device, and the slave device can also be used as a master device, and the transformation can be based on actual needs, and the embodiments of the present invention do not need to be limited to this. As a specific example, the master device and the slave device can be electrical appliances in the field of household appliances, or they can be devices in other fields.
[0056] Reference Figure 2, is a schematic diagram of an application environment provided in an embodiment of the present invention. In the embodiment of the present invention, the master device and the slave device are connected via a bus, and a single input / output interface of the master device and a single input / output interface of the slave device are connected to the bus, so that data can be exchanged between the master device and the slave device via the bus. It can be understood that since the master device and the slave device use a single input / output interface for data exchange, the chip IO (input / output port) of the master device and the slave device is reduced, thereby reducing costs.
[0057] In the embodiment of the present invention, the bus between the master device and the slave device is an ESLP (Edgeless Single Line Protocol) bus. The data on the ESLP bus adopts unipolar encoding. Specifically, unipolar encoding is a digital signal encoding method in which the amplitude of the signal changes only in one direction, usually within the positive level range. In unipolar encoding, only one level is used to represent a binary data bit, usually a high level or a low level. In addition, the embodiment of the present invention is based on a single line to achieve data interaction. In order to maintain the synchronization of the data, each data bit transmitted on the bus consists of two signal bits, which provides good synchronization. The ESLP bus exchanges data on a single input and output interface through data encoding in the read and write phases. The ESLP bus requires the input and output interfaces of the master device and the slave device to be in an open-drain state. Its data rate can reach 16Kbps (bits per second), and even 110Kbps in fast mode.
[0058] In an embodiment of the present invention, the encoding of the ESLP bus may include 7 phases, namely, a start bit (startphase), an acknowledge bit (acknowledge phase), a write bit (write phase), a read bit (read phase), a numerical value 1 (1phase), a digital value 0 (0phase), and an idle state (idle phase). The start bit may be composed of a preset setup time and a preset start phase, the acknowledge bit may be composed of a preset acknowledge high phase and a preset acknowledge low phase, the write bit may be composed of a preset write high phase and a preset write low phase, and the read bit may be composed of a preset read high phase, a preset read low phase, and a preset read sampling time. Exemplarily, V LT Indicates the input low voltage threshold, V HT Indicates the input high voltage threshold, V P Indicates the maximum voltage, V 0 Indicates 0 volts, refer to Figure 3 , the start bit can be determined by the setup time (T setup >2us) and start phase (440us< TSP <700us); reference Figure 4, the response bit can be set by the response high phase (10us <T APH <70us and response low phase (60us <T APL <240us) Figure 5 , the write bit is determined by the write high phase (T WPH >2us) and write low phase (5us <T WPL <15us) Figure 6 , the read bit is determined by the read high phase (T RPH >2us), read low phase (5us <T RLH <15us) formation and reading sampling time (1us) <T RS Due to the wide voltage range of the start bit, the response bit, etc. of the embodiment of the present invention, the anti-interference capability is stronger.
[0059] In the embodiment of the present invention, each transmission of a piece of data between the master device and the slave device is called a frame. Figure 7 , is a schematic diagram of a frame structure provided in an embodiment of the present invention, and a frame may include a start, a response, a read / write command (i.e., a read command and a write command), data (data to be processed), and a check value. It should be noted that the read / write command in an embodiment of the present invention is defined by the user, and the read / write operation area needs to be distinguished when the user defines it. In an example of the present invention, the read / write command is determined by the read / write bit (read bit and write bit), and the custom command refers to the user designing the operation instruction (command), for example, 0xA0 can be used as the read command, which is converted to binary as 10100000, and 0XB1 is designed as the write command, which is converted to binary as 10110001. Since the user defines the command in the embodiment of the present invention, the custom command can be flexible and adaptable to a variety of application scenarios, such as address chip, reading peripheral information, etc. Of course, in addition to the read command and the write command, the user can also set other commands according to actual needs, and the embodiment of the present invention does not need to be limited to this.
[0060] In the embodiment of the present invention, when data is exchanged between the master device and the slave device, the master device sends a start bit for each data exchange to detect the state of the slave device so as to perform data exchange according to the state of the slave device. Figure 8, is a schematic diagram of a write timing provided in an embodiment of the present invention. Each time the master device uses the ESLP bus to exchange data with the slave device, it needs to send a start bit to the slave device through the ESLP bus, and wait for the slave device to respond with an acknowledgement bit through the ESLP bus. After receiving the acknowledgement bit sent by the slave device, the master device actively sends a pending command. The pending command may be a read command or a write command. After receiving the pending command, the decoder of the slave device will distinguish the command type of the pending command according to the pre-defined command, that is, whether the pending command is a read command or a write command, and then perform corresponding processing according to the determined command type and the pending data. To further ensure synchronization and accuracy, the master device will send a write phase or a read phase according to the pending command, followed by a numerical value (to be processed). To ensure synchronization, each numerical value will be preceded by a write bit or a read bit, which is used to indicate that the device starts writing data from the write bit or starts reading data from the read bit.
[0061] It should be noted that the embodiment of the present invention adopts a single bus single input and output interface data transmission mode, which has better low power consumption performance, and because it does not need to occupy multiple input and output interfaces, in addition, the waveform structure of the signal for each pending command (such as a read operation or a write operation) in the embodiment of the present invention is different from the signal structure of the existing data transmission scheme. The signal of the existing transmission scheme is at the millisecond level, and the embodiment of the present invention is at the microsecond level. In addition, the existing data transmission scheme requires synchronization words, PRE, and preparation bits to send instructions (wherein the synchronization word is used for synchronization and identification of data, PRE is used for synchronization and preparation before the start of communication, and the preparation bit is used to indicate the available status of the device or module), while in the embodiment of the present invention, the synchronization word, PRE, and preparation bit are not required, so the data transmission between the master device and the slave device is more concise. These are because the embodiment of the present invention adopts a single bus single input and output interface, that is, only one transmission path (bus) and one input and output interface (IO interface) are required to complete data transmission. Compared with the multi-line multi-interface transmission mode, the path and complexity of signal transmission are reduced, and it is also the same, reducing the delay and loss of signal transmission and improving transmission efficiency.
[0062] In an embodiment of the present invention, a master device and a slave device are connected via a bus, a single input / output interface of the master device and a single input / output interface of the slave device are connected to the bus, a custom command is pre-designed between the master device and the slave device, each data bit transmitted on the bus is composed of two signal bits, when the master device and the slave device perform data exchange, the master device sends a start bit to the slave device via the bus, if the master device receives a response bit sent by the slave device via the bus for the start bit, the master device sends a pending command and pending data corresponding to the pending command to the slave device via the bus, after receiving the pending command and pending data, the slave device can determine the command type according to the custom command and the pending command, so as to process the pending data according to the command type. The master device and the slave device of the embodiment of the present invention can exchange data through the bus after being connected to the bus via a single input / output interface, have better low-power performance, and because there is no need to occupy multiple input / output interfaces, the cost required to realize the master device and the slave device is reduced.
[0063] In one embodiment of the present invention, a verification algorithm is pre-set between the master device and the slave device. After the master device sends the command to be processed and the data to be processed corresponding to the command to be processed to the slave device through the bus in step 102, the method may further include:
[0064] The master device generates a first check value according to the command to be processed and the data to be processed by using a preset check algorithm;
[0065] The master device sends the first check value to the slave device via the bus; the slave device is used to generate a second check value according to the command to be processed and the data to be processed by adopting a preset check algorithm, and processes the command to be processed and the data to be processed when the first check value and the second check value are the same, and sends an error correction request to the master device via the bus when the first check value and the second check value are different.
[0066] The preset verification algorithm may be a verification algorithm such as Checksum (checksum) and CRC (Cyclic Redundancy Check), and the verification algorithm may be used to detect whether data is erroneous during data interaction between a master device and a slave device.
[0067] In an embodiment of the present invention, the verification value between the master device and the slave device can be added or deleted by the user according to needs. The master device and the slave device can pre-agree and store the verification algorithm. The verification value can be generated by the verification algorithm using read commands, write commands and data (data to be processed).
[0068] Specifically, the master device can use a preset verification algorithm to generate a first verification value based on the pending commands and the pending data. Then, the master device sends the first verification value to the slave device through the ESLP bus. The slave device can use the pending commands and the pending data received by the preset verification algorithm to generate a second verification value. Then, the slave device can compare whether the first verification value and the second verification value are the same. If the first verification value and the second verification value are the same, it means that there is no error in the data sent by the master device, and the slave device can process it normally. If the first verification value and the second verification value are different, it means that there is an error in the data sent by the master device. At this time, the slave device can send an error correction request to the master device through the ESLP bus, so that the master device resends the data based on the error correction request or performs other error correction operations, thereby ensuring the accuracy and reliability of data transmission between the master device and the slave device.
[0069] In one embodiment of the present invention, the command type of the pending command includes at least a read command and a write command, the master device sends the pending command and the pending data corresponding to the pending command to the slave device through the bus; the slave device is used to determine the command type according to the custom command and the pending command after receiving the pending command and the pending data, so as to process the pending data according to the command type, including:
[0070] The master device sends a pending command, a write bit, and pending data corresponding to the pending command to the slave device through the bus; the slave device is used to perform a write operation according to the write bit and the pending data if it is determined that the pending command is a write command according to the custom command after receiving the pending command, the write bit, and the pending data;
[0071] The master device sends a pending command, a read bit, and pending data corresponding to the pending command to the slave device through the bus; the slave device is used to perform a read operation according to the read bit and the pending data after receiving the pending command, the read bit, and the pending data, if the pending command is determined to be a read command according to the custom command.
[0072] In an embodiment of the present invention, the command type of the pending command may include at least a read command and a write command. When the pending command is a write command, the master device sends a write command, a write bit, and pending data to the slave device through the ESLP bus. The write command is used to instruct the slave device to write data, and the write bit is used to instruct the slave device to write data starting from the write bit. The pending data is the data content required by the write command. After the slave device receives the write command, the write bit, and the pending data, if it is determined to be a write command according to the custom command, the slave device performs a write operation according to the write bit and the pending data, that is, writes the pending data to the specified location;
[0073] When the pending command is a read command, the master device sends a read command, a read bit and pending data to the slave device through the ESLP bus. The read command is used to indicate reading data from a specified position, and the read bit is used to indicate reading data starting from the read bit. The pending data is the data content required by the read command. After the slave device receives the read command, the read bit and the pending data, if it is determined to be a read command according to the custom command, the slave device performs a read operation according to the read bit and the pending data, such as reading data from a specified position.
[0074] In one embodiment of the present invention, the method may further include:
[0075] When there is no data interaction between the master device and the slave device, the master device and the slave device respectively release the control of their input and output interfaces connected to the bus, and set the bus to enter an idle state through the external pull-up resistor.
[0076] In an embodiment of the present invention, the bus ESLP can be connected to an external pull-up resistor. When there is no data interaction on the ESLP bus, the master device and the slave device will release the control of the input and output interfaces connected to the ESLP bus, and the ESLP bus will be placed in an idle state by the external pull-up resistor. In this way, the ESLP bus or related electronic components can be placed in a low power consumption state, thereby saving resources.
[0077] In one embodiment of the present invention, the method may further include:
[0078] When the master device receives the current signal bit sent by the slave device through the bus, if the previous signal bit received by the master device is a high level, and the current signal bit is lower than a preset input high voltage threshold and higher than a preset input low voltage threshold, and the time of the current signal bit is less than a preset establishment time, then the current signal bit is filtered;
[0079] When the master device receives the current signal bit sent by the slave device through the bus, if the previous signal bit received by the master device is a transition from a low level to a high level, and the current signal bit is lower than a preset input low voltage threshold and the previous signal bit is lower than an input high voltage threshold, and the time between the current signal bit and the previous signal bit is less than a preset setup time, the current signal bit is filtered.
[0080] Reference Fig. 9 , is a schematic diagram of a signal filtering provided in an embodiment of the present invention, V LT Indicates the input low voltage threshold, V HT Indicates the input high voltage threshold, V P Indicates the maximum voltage, V 0Indicates 0 volts. When the master device receives the current signal bit A sent by the slave device through the ESLP bus, if the previous signal bit received by the master device is high and the current signal bit A is lower than the preset input high voltage threshold V HT and is higher than the preset input low voltage threshold V LT , and the time between the current signal bit A and the previous signal bit is less than the preset establishment time T setup , then filter the current signal bit A.
[0081] Reference Fig.10 , is a schematic diagram of another signal filtering provided in an embodiment of the present invention, V LT Indicates the input low voltage threshold, V HT Indicates the input high voltage threshold, V P Indicates the maximum voltage, V 0 Indicates 0 volts. When the master receives the current signal bit C sent by the slave through the ESLP bus, if the previous signal bit B received by the master is low level and converts to high level, and the current signal bit C is lower than the preset input low voltage threshold V LT And the previous signal bit is lower than the input high voltage threshold V HT , and the current signal bit C is equal to the previous signal bit V HT The time between them is less than the preset establishment time T setup , then filter the current signal bit C.
[0082] The master device and the slave device of the embodiment of the present invention can judge the received signal bits (input signals) to filter out interference signals and ensure the stability and reliability of the devices.
[0083] By using the embodiment of the present invention, the master device and the slave device only use one IO (input and output interface) for data exchange, which reduces the usage of the IO of the master device and the slave device, and reduces the product cost in disguise. In addition, each data bit transmitted between the master device and the slave device is composed of 2 signal bits, which provides good data synchronization, has better anti-interference due to its wide voltage domain, and has better low power consumption performance due to data exchange based on a single line, thereby improving the data rate between the master device and the slave device.
[0084] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0085] Reference Fig.11 , shows a structural block diagram of an apparatus for data interaction between devices provided in an embodiment of the present invention, wherein the apparatus comprises a master device and a slave device, wherein the master device and the slave device are connected via a bus, wherein a single input / output interface of the master device and a single input / output interface of the slave device are connected to the bus, wherein a custom command is pre-designed between the master device and the slave device, wherein each data bit transmitted on the bus is composed of two signal bits, and when the master device and the slave device perform data interaction, the apparatus may specifically include the following modules:
[0086] A start bit sending module 1101, configured for the master device to send a start bit to the slave device via the bus;
[0087] The command sending module 1102 is used for sending a pending command and pending data corresponding to the pending command to the slave device through the bus if the master device receives a response bit sent by the slave device through the bus in response to the start bit; the slave device is used to determine the command type according to the custom command and the pending command after receiving the pending command and the pending data, so as to process the pending data according to the command type.
[0088] In one embodiment of the present invention, the device further comprises: a verification module, configured to:
[0089] The master device generates a first check value according to the command to be processed and the data to be processed by using a preset check algorithm;
[0090] The master device sends the first check value to the slave device via the bus; the slave device is used to generate a second check value according to the command to be processed and the data to be processed by adopting a preset check algorithm, and processes the command to be processed and the data to be processed when the first check value and the second check value are the same, and sends an error correction request to the master device via the bus when the first check value and the second check value are different.
[0091] In an embodiment of the present invention, the command type of the to-be-processed command includes at least a write command, and the command sending module is used to:
[0092] The master device sends a pending command, a write bit, and pending data corresponding to the pending command to the slave device through the bus; the slave device is used to perform a write operation according to the write bit and the pending data after receiving the pending command, the write bit, and the pending data, if the pending command is determined to be a write command according to the custom command.
[0093] In an embodiment of the present invention, the command type of the command to be processed includes at least a read command, and the command sending module is used to:
[0094] The master device sends a pending command, a read bit, and pending data corresponding to the pending command to the slave device through the bus; the slave device is used to perform a read operation according to the read bit and the pending data after receiving the pending command, the read bit, and the pending data, if the pending command is determined to be a read command according to the custom command.
[0095] In one embodiment of the present invention, the start bit is composed of a preset setup time and a preset start phase, the response bit is composed of a preset response high phase and a preset response low phase, the write bit is composed of a preset write high phase and a preset write low phase, and the read bit is composed of a preset read high phase, a preset read low phase and a preset read sampling time.
[0096] In one embodiment of the present invention, the bus is connected to an external pull-up resistor, and the device further comprises: a release module, configured to:
[0097] When there is no data interaction between the master device and the slave device, the master device and the slave device respectively release the control of their input and output interfaces connected to the bus, and set the bus to enter an idle state through the external pull-up resistor.
[0098] In an embodiment of the present invention, the two signal bits are a high level and a low level.
[0099] In one embodiment of the present invention, the device further comprises: a first filtering module, configured to:
[0100] When the master device receives the current signal bit sent by the slave device through the bus, if the previous signal bit received by the master device is a high level, and the current signal bit is lower than the preset input high voltage threshold and higher than the preset input low voltage threshold, and the time of the current signal bit is less than the preset establishment time, the current signal bit is filtered.
[0101] In one embodiment of the present invention, the device further comprises: a second filtering module, configured to:
[0102] When the master device receives the current signal bit sent by the slave device through the bus, if the previous signal bit received by the master device is a transition from a low level to a high level, and the current signal bit is lower than a preset input low voltage threshold and the previous signal bit is lower than an input high voltage threshold, and the time between the current signal bit and the previous signal bit is less than a preset setup time, the current signal bit is filtered.
[0103] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0104] In addition, an embodiment of the present invention further provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned embodiment of the method for data interaction between devices are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0105] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above-mentioned embodiment of the method for data interaction between devices is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0106] An embodiment of the present invention also provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned embodiment of the data interaction method between devices, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0107] Fig.12 A schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention.
[0108] The electronic device 1200 includes but is not limited to: a radio frequency unit 1201, a network module 1202, an audio output unit 1203, an input unit 1204, a sensor 1205, a display unit 1206, a user input unit 1207, an interface unit 1208, a memory 1209, a processor 1210, and a power supply 1211. Those skilled in the art will appreciate that Fig.12 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and the electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. In the embodiments of the present invention, the electronic device includes but is not limited to a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted terminal, a wearable device, and a pedometer.
[0109] It should be understood that in the embodiment of the present invention, the radio frequency unit 1201 can be used for receiving and sending signals during information transmission or communication. Specifically, after receiving downlink data from the base station, it is sent to the processor 1210 for processing; in addition, uplink data is sent to the base station. Generally, the radio frequency unit 1201 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, etc. In addition, the radio frequency unit 1201 can also communicate with the network and other devices through a wireless communication system.
[0110] The electronic device provides users with wireless broadband Internet access through the network module 1202, such as helping users to send and receive emails, browse web pages, and access streaming media.
[0111] The audio output unit 1203 can convert the audio data received by the RF unit 1201 or the network module 1202 or stored in the memory 1209 into an audio signal and output it as sound. Moreover, the audio output unit 1203 can also provide audio output related to a specific function performed by the electronic device 1200 (for example, a call signal reception sound, a message reception sound, etc.). The audio output unit 1203 includes a speaker, a buzzer, a receiver, etc.
[0112] The input unit 1204 is used to receive audio or video signals. The input unit 1204 may include a graphics processor (GPU) 12041 and a microphone 12042. The graphics processor 12041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The processed image frame can be displayed on the display unit 1206. The image frame processed by the graphics processor 12041 can be stored in the memory 1209 (or other storage medium) or sent via the radio frequency unit 1201 or the network module 1202. The microphone 12042 can receive sound and can process such sound into audio data. The processed audio data can be converted into a format output that can be sent to a mobile communication base station via the radio frequency unit 1201 in the case of a telephone call mode.
[0113] The electronic device 1200 also includes at least one sensor 1205, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor, wherein the ambient light sensor can adjust the brightness of the display panel 12061 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 12061 and / or the backlight when the electronic device 1200 is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary, which can be used to identify the posture of the electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; the sensor 1205 can also include a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.
[0114] The display unit 1206 is used to display information input by the user or information provided to the user. The display unit 1206 may include a display panel 12061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
[0115] The user input unit 1207 can be used to receive input digital or character information, and to generate key signal input related to user settings and function control of the electronic device. Specifically, the user input unit 1207 includes a touch panel 12071 and other input devices 12072. The touch panel 12071, also known as a touch screen, can collect user touch operations on or near it (such as operations performed by users using fingers, styluses, or any other suitable objects or accessories on or near the touch panel 12071). The touch panel 12071 may include a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact point coordinates, and then sends it to the processor 1210, receives the command sent by the processor 1210 and executes it. In addition, the touch panel 12071 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 12071, the user input unit 1207 may also include other input devices 12072. Specifically, other input devices 12072 may include but are not limited to physical keyboards, function keys (such as volume control keys, switch keys, etc.), trackballs, mice, and joysticks, which will not be repeated here.
[0116] Furthermore, the touch panel 12071 may be overlaid on the display panel 12061. When the touch panel 12071 detects a touch operation on or near it, it is transmitted to the processor 1210 to determine the type of touch event. Then, the processor 1210 provides corresponding visual output on the display panel 12061 according to the type of touch event. Fig.12 In the figure, the touch panel 12071 and the display panel 12061 are two independent components to realize the input and output functions of the electronic device. However, in some embodiments, the touch panel 12071 and the display panel 12061 can be integrated to realize the input and output functions of the electronic device, which is not limited here.
[0117] The interface unit 1208 is an interface for connecting an external device to the electronic device 1200. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, etc. The interface unit 1208 may be used to receive input (e.g., data information, power, etc.) from an external device and transmit the received input to one or more elements within the electronic device 1200 or may be used to transmit data between the electronic device 1200 and an external device.
[0118] The memory 1209 can be used to store software programs and various data. The memory 1209 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 1209 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0119] The processor 1210 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 1209 and calling data stored in the memory 1209, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. The processor 1210 may include one or more processing units; preferably, the processor 1210 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 1210.
[0120] The electronic device 1200 may also include a power supply 1211 (such as a battery) for supplying power to each component. Preferably, the power supply 1211 may be logically connected to the processor 1210 via a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system.
[0121] In addition, the electronic device 1200 includes some functional modules not shown, which will not be described in detail here.
[0122] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0123] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0124] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
[0125] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the embodiments of the present invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0126] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0127] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0128] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0129] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0130] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical disks.
[0131] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for data interaction between devices, characterized in that: The device comprises a master device and a slave device, the master device and the slave device are connected via a bus, a single input / output interface of the master device and a single input / output interface of the slave device are connected to the bus, a custom command is pre-designed between the master device and the slave device, each data bit transmitted on the bus is composed of two signal bits, and when the master device and the slave device perform data interaction, the method comprises: The master device sends a start bit to the slave device via the bus; If the master device receives a response bit sent by the slave device via the bus in response to the start bit, the master device sends a pending command and pending data corresponding to the pending command to the slave device via the bus; the slave device is used to determine the command type according to the custom command and the pending command after receiving the pending command and the pending data, so as to process the pending data according to the command type.
2. The method according to claim 1, characterized in that A verification algorithm is pre-set between the master device and the slave device. After the master device sends a to-be-processed command and to-be-processed data corresponding to the to-be-processed command to the slave device through the bus, the method further includes: The master device generates a first check value according to the command to be processed and the data to be processed by using a preset check algorithm; The master device sends the first check value to the slave device via the bus; the slave device is used to generate a second check value according to the command to be processed and the data to be processed by adopting a preset check algorithm, and processes the command to be processed and the data to be processed when the first check value and the second check value are the same, and sends an error correction request to the master device via the bus when the first check value and the second check value are different.
3. The method according to claim 1, characterized in that The command type of the to-be-processed command at least includes a write command, and the master device sends the to-be-processed command and the to-be-processed data corresponding to the to-be-processed command to the slave device through the bus; The slave device is used to determine the command type according to the custom command and the command to be processed after receiving the command to be processed and the data to be processed, so as to process the data to be processed according to the command type, including: The master device sends a pending command, a write bit, and pending data corresponding to the pending command to the slave device via the bus; The slave device is used for, after receiving the command to be processed, the write bit and the data to be processed, if it is determined according to the custom command that the command to be processed is a write command, then performing a write operation according to the write bit and the data to be processed.
4. The method according to claim 1, characterized in that: The command type of the to-be-processed command at least includes a read command, and the master device sends the to-be-processed command and the to-be-processed data corresponding to the to-be-processed command to the slave device through the bus; The slave device is used to determine the command type according to the custom command and the command to be processed after receiving the command to be processed and the data to be processed, so as to process the data to be processed according to the command type, including: The master device sends a command to be processed, a read bit and data to be processed corresponding to the command to be processed to the slave device via the bus; The slave device is used for, after receiving the command to be processed, the read bit and the data to be processed, if it is determined according to the custom command that the command to be processed is a read command, then performing a read operation according to the read bit and the data to be processed.
5. The method according to any one of claims 1 to 4, characterized in that: The start bit is composed of a preset setup time and a preset start phase, the response bit is composed of a preset response high phase and a preset response low phase, the write bit is composed of a preset write high phase and a preset write low phase, and the read bit is composed of a preset read high phase, a preset read low phase and a preset read sampling time.
6. The method according to claim 1, characterized in that The bus is connected to an external pull-up resistor, and the method further comprises: When there is no data interaction between the master device and the slave device, the master device and the slave device respectively release the control of their input and output interfaces connected to the bus, and set the bus to enter an idle state through the external pull-up resistor.
7. The method according to claim 1, characterized in that The two signal bits are high level and low level.
8. The method according to claim 7, characterized in that The method further comprises: When the master device receives the current signal bit sent by the slave device through the bus, if the previous signal bit received by the master device is a high level, and the current signal bit is lower than the preset input high voltage threshold and higher than the preset input low voltage threshold, and the time of the current signal bit is less than the preset establishment time, the current signal bit is filtered.
9. The method according to claim 7, characterized in that: The method further comprises: When the master device receives the current signal bit sent by the slave device through the bus, if the previous signal bit received by the master device is a transition from a low level to a high level, and the current signal bit is lower than a preset input low voltage threshold and the previous signal bit is lower than an input high voltage threshold, and the time between the current signal bit and the previous signal bit is less than a preset setup time, the current signal bit is filtered.
10. A device for data interaction between devices, characterized in that: The device comprises a master device and a slave device, wherein the master device and the slave device are connected via a bus, a single input / output interface of the master device and a single input / output interface of the slave device are connected to the bus, a custom command is pre-designed between the master device and the slave device, each data bit transmitted on the bus is composed of two signal bits, and when the master device and the slave device perform data exchange, the device comprises: A start bit sending module, used for the master device to send a start bit to the slave device through the bus; A command sending module is used for, if the master device receives a response bit sent by the slave device via the bus in response to the start bit, the master device sends a pending command and pending data corresponding to the pending command to the slave device via the bus; the slave device is used to determine the command type according to the custom command and the pending command after receiving the pending command and the pending data, so as to process the pending data according to the command type.
11. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the method according to any one of claims 1 to 9 when executing the program stored in the memory.
12. A computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 9.
