WO2018058862A1 - 一种基于spi的数据传输方法及装置 - Google Patents

一种基于spi的数据传输方法及装置 Download PDF

Info

Publication number
WO2018058862A1
WO2018058862A1 PCT/CN2017/071295 CN2017071295W WO2018058862A1 WO 2018058862 A1 WO2018058862 A1 WO 2018058862A1 CN 2017071295 W CN2017071295 W CN 2017071295W WO 2018058862 A1 WO2018058862 A1 WO 2018058862A1
Authority
WO
WIPO (PCT)
Prior art keywords
spi
query
transceiver
data
processor
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2017/071295
Other languages
English (en)
French (fr)
Inventor
钟少华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to EP17854324.5A priority Critical patent/EP3502908B1/en
Priority to CN201780001952.7A priority patent/CN108475241B/zh
Priority to US16/336,839 priority patent/US10789180B2/en
Publication of WO2018058862A1 publication Critical patent/WO2018058862A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • G06F13/4291Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus using a clocked protocol
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/10Program control for peripheral devices
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0002Serial port, e.g. RS232C
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Definitions

  • the embodiments of the present invention relate to the field of communications technologies, and in particular, to an SPI-based data transmission method and apparatus.
  • IoT devices include a host and a WWAN (Wireless Wide Area Network) module.
  • the host is used to implement services and data processing in the M2M (Machine To Machine) service;
  • the WWAN module is used to implement communication between the Internet of Things device and the Internet device through the wireless network.
  • USB Universal Serial Bus
  • UART Universal Asynchronous Receiver-Transmitter
  • USB interface High transmission rate (about 480Mbps) High power consumption UART interface Low power consumption Low transmission rate (about 3Mbps)
  • the power consumption is higher. If the device does not have high requirements on the transmission rate, such as smart water meters (requires that the battery is not replaced for several years, but the data is transmitted. Smaller, lower transmission rate requirements), using the UART interface.
  • the device needs to upgrade the MCU (Microcontroller Unit) in the host through OTA (Over The Air), due to MCU firmware upgrade.
  • MCU Microcontroller Unit
  • OTA Over The Air
  • the data to be transmitted is large. If the UART interface with a lower transmission rate is used for data transmission, it takes a long time to complete the upgrade process, resulting in an increase in power consumption.
  • SPI Serial Peripheral Interface
  • UART interface the transmission rate of SPI is greater than the transmission rate of the UART interface, which is about 24 Mbps. It is suitable for the above requirements for power consumption and transmission rate. IoT device.
  • the WWAN module in the prior art generally only supports the SPI master mode, and does not support the SPI slave mode. That is, the WWAN module can actively initiate a communication process to the host through the SPI, but the host cannot initiate a communication process to the WWAN through the SPI, which is generated for the actual application. Larger limit.
  • the embodiment of the invention provides an SPI-based data transmission method, so that whether the WWAN module in the IoT device supports the SPI main mode or the SPI slave mode, the host can communicate with the host in the IoT device through the SPI.
  • an SPI-based data transmission method includes:
  • the first device sends a first query request to the second device by using the UART interface, where the first query request is used to query the SPI mode supported by the second device; the first device receives the first query response returned by the second device; A device determines, according to the first query response, that the second device supports the SPI master mode, the first device sends a setup SPI connection request to the second device, so that the second device initiates an SPI connection process with the first device; After the second device establishes the SPI connection, the first device receives the data sent by the second device through the SPI or sends the data to the second device through the SPI.
  • the above method circumvents that the SPI slave device cannot initiate the SPI communication process actively, so that the first device can request the second device to initiate the SPI connection process as the SPI master device through the UART interface even if it is an SPI slave device, and further, the data is transmitted by using the SPI. So that the transmission rate is guaranteed, and the power consumption is not significantly increased.
  • the first device determines, according to the first query response, that the second device supports the SPI slave mode, the first device initiates an SPI connection process with the second device. . If the first device determines that the second device supports the SPI slave mode, the first device can communicate as the SPI master device with the second device through the SPI, and therefore, the first device that is the SPI master device initiates the SPI connection process to the second device. .
  • the first device may further send the second device to the second device by using the UART interface.
  • a second query request the request is used to query whether data required by the first device is stored in the second device, and if the data required by the first device is stored in the second device, the first device sends the data to the second device The first query request; if the second device does not have the data required by the first device, the process ends, and the first device does not need to send the first query request to the second device to improve system efficiency.
  • the first device may further send the dialing instruction to the second device before sending the first query request to the second device by using the UART interface. Receiving a response message of successfully establishing a session channel returned by the second device, so that the first device establishes a session channel with the second device.
  • the first device may further send a dial-up command to the second device by using the SPI, so that the second device The device is dial-up.
  • the first device is a host in the Internet of Things device
  • the second device is a WWAN module in the Internet of Things device.
  • the method provided by the embodiment of the present invention circumvents that the SPI slave device cannot actively initiate the SPI communication process, and uses the SPI to transmit data, so that the power consumption is not significantly increased while ensuring the transmission rate, and is applicable to the power consumption and the transmission rate. Communication between the host and the WWAN module in the IoT device with higher requirements.
  • the host in the IoT device can receive the MCU firmware data sent by the WWAN module through the SPI. Due to the large firmware data of the MCU, it is suitable to transmit using the SPI which takes into consideration both transmission efficiency and power consumption.
  • the SPI-based data transmission method includes:
  • the second device receives the first query request sent by the first device by using the UART interface, where the first query request is used to query the SPI mode supported by the second device; the second device sends the first query to the first device Responding to: when the first query response is used to notify the second device to support the SPI main mode, the second device receives an establishment SPI connection request sent by the first device; The first device establishes an SPI connection process; after the second device establishes an SPI connection with the first device, the second device sends the first device to the first device through the SPI Sending data or receiving data transmitted by the first device through the SPI.
  • the second device when the first query response is used to notify the second device to support the SPI slave mode, the second device responds to the first Device initiated SPI connection.
  • the second device before the second device receives the first query request sent by the first device by using the UART interface, the second device receives the a second query request sent by the device, the second query request is used to query whether data required by the first device is stored in the second device, and the second device sends a message to the first query device The second query response is used to notify the second device that the data required by the first device is stored.
  • the second device before the second device receives the first query request sent by the first device by using the UART interface, the second device sends the first device to send Dialing instruction; the second device sends a response message to the first device to successfully establish a session channel.
  • the second device may further receive the dial-up Internet command sent by the first device through the SPI, and receive the Dial-up Internet access after the order.
  • the first device is a host in the Internet of Things device
  • the second device is a wireless WAN WWAN module in the Internet of Things device.
  • the second device sends data to the first device by using the SPI, specifically, the: The host sends the micro control unit MCU firmware data.
  • an embodiment of the present invention provides a data transmission device based on a serial peripheral interface SPI.
  • the device as a first device, includes: a processor, and a memory and a transceiver respectively connected to the processor.
  • the processor is configured to read a program in the memory and perform the following process:
  • the query response determines that the second device supports the SPI master mode, and sends a setup SPI connection request to the second device by using the transceiver, so that the second device initiates an SPI connection process with the first device;
  • the transceiver transmits data sent by the second device through the SPI or sends data to the second device through the SPI.
  • the processor is further configured to: if the second device supports the SPI slave mode according to the first query response, initiate the scenario The second device establishes an SPI connection process.
  • the processor is further configured to: pass the transceiver through the UART before sending the first query request to the second device by using the transceiver through the UART interface
  • the interface sends a second query request to the second device, where the second query request is used to query whether the data required by the first device is stored in the second device, and the second device returns according to the second device.
  • the query response determines that the data required by the first device is stored in the second device.
  • the processor is further configured to: pass the transceiver to the device before sending the first query request to the second device by using the UART interface through the transceiver
  • the second device sends a dialing command, so that the first device establishes a session with the second device, and receives, by the transceiver, a response message that is successfully sent by the second device to establish a session channel.
  • the processor is further configured to send the dialing to the second device by using the transceiver and the SPI. Internet access instructions to enable the second device to dial up.
  • the first device is a host in the Internet of Things device
  • the second device is a wireless WAN WWAN module in the Internet of Things device.
  • the processor when the processor receives the data sent by the second device by using the SPI, the processor is specifically configured to: The micro control unit MCU firmware data sent by the WWAN module.
  • an embodiment of the present invention provides a data transmission device based on a serial peripheral interface SPI, including: a processor, and a memory and a transceiver respectively connected to the processor.
  • the processor is configured to read a program in the memory and perform the following process:
  • the first query request is used to query the SPI mode supported by the second device; and the first device is sent by the transceiver a query response; when the first query response is used to notify the second device to support the SPI master mode, receiving, by the transceiver, an establishment SPI connection request sent by the first device; initiating establishing an SPI with the first device a connection process; after establishing an SPI connection with the first device, transmitting data to the first device via the SPI or receiving data transmitted by the first device through the SPI.
  • the processor is further configured to: when the first query response is used to notify the second device to support the SPI slave mode, The SPI connection initiated by the first device.
  • the processor is further configured to: before the receiving, by the transceiver, the first query request sent by the first device by using the UART interface Receiving, by the transceiver, the second query request sent by the first device by using the UART interface, where the second query request is used to query whether data required by the first device is stored in the second device; Sending, by the transceiver, a second query response to the first query device, where the second query response is used to notify the second device that the data required by the first device is stored.
  • the processor is further configured to: receive, by the transceiver, before receiving, by the transceiver, the first query request sent by the first device by using the UART interface a dialing instruction sent by the first device; sending, by the transceiver, a response message for successfully establishing a session channel to the first device.
  • the processor is further configured to receive, by the transceiver, the first device to send through the SPI. Dial-up Internet access and dial-up Internet access.
  • the first device is a host in the Internet of Things device
  • the second device is a wireless WAN WWAN module in the Internet of Things device.
  • the processor when the processor sends data to the first device by using a SPI, the processor is specifically configured to:
  • the micro control unit MCU firmware data is sent to the host of the IoT device through the SPI via the transceiver.
  • an embodiment of the present invention provides a data transmission system based on a serial peripheral interface SPI, including a first device and a fourth aspect of the third aspect and possible implementation manners thereof, and a possible implementation thereof a second design Ready.
  • FIG. 1 is a schematic diagram of a SPI connection in the prior art
  • FIG. 2 is a schematic diagram of a device connection according to an embodiment of the present invention.
  • FIG. 3 is a schematic flowchart of a data transmission method based on SPI according to an embodiment of the present invention
  • FIG. 4 is a schematic diagram of a specific application scenario according to an embodiment of the present disclosure.
  • FIG. 5 is a schematic diagram of another specific application scenario according to an embodiment of the present disclosure
  • FIG. 6 is a schematic structural diagram of a first device according to an embodiment of the present disclosure.
  • FIG. 7 is a schematic structural diagram of a second device according to an embodiment of the present invention.
  • the SPI bus system is a synchronous serial peripheral interface that allows the microcontroller to communicate serially with various peripherals to exchange information.
  • the clock signal is sent by the master device to the slave device, and the slave device itself cannot generate or control the clock signal. If the slave device does not receive the clock signal, it cannot work normally; the pin SS is used to control whether the chip is selected, that is, the chip select When the signal is a pre-defined enable signal, the master can communicate via the SPI, which allows the master to connect multiple slaves over the same bus.
  • SPI is a high-speed, full-duplex, synchronous communication bus, and only takes four wires on the pins of the chip, it saves the pins of the chip and is also a PCB (Printed Circuit Board).
  • PCB Print Circuit Board
  • the layout saves space, and the power consumption is small, and the transmission rate is high. It is because of these characteristics that more and more chips are communicating with SPI, for example, between the host of the IoT device and the WWAN module. Communication, especially for IoT devices with high power consumption and transmission rate requirements.
  • the host in the IoT device can be used as the master device or the slave device, and can be set according to specific application scenarios.
  • the WWAN module in the IoT device usually only supports the SPI master mode, that is, through the SPI. It can only be used as a master device when communicating. Therefore, when the host of the IoT device and the WWAN module communicate through the SPI, the WWAN can only be used as the master device, and the host acts as the slave device, and cannot be adjusted according to the actual application requirements, so that the host acting as the slave device cannot actively pass the SPI to the WWAN.
  • the module initiates the communication process, which has a large limitation.
  • the embodiment of the present invention provides an SPI-based data transmission method to implement a slave device as an SPI, and may also initiate a communication process.
  • the method is applicable to the communication process of the first device and the second device as shown in FIG. 2.
  • the flow of data transmission by the first device and the second device by using the method provided by the embodiment of the present invention can be seen in FIG. 3.
  • the method includes the following steps:
  • Step 301 The first device sends a first query request to the second device by using a UART interface.
  • the first query request is used to query the supported SPI mode of the second device.
  • Step 302 The second device sends a first query response to the first device.
  • the first query response sent by the second device through the UART interface includes the SPI mode supported by the second device. If the second device supports the SPI master mode, the process proceeds to step 303. Otherwise, the process proceeds to step 305.
  • Step 303 If the first device determines, according to the first query response, that the second device supports the SPI master mode, the first device sends a setup SPI connection request to the second device.
  • the first device can only function as a slave device when performing SPI communication with the second device.
  • the slave device needs to receive the SPI clock signal Clock sent by the master device to work normally. Therefore, the first device can send a setup SPI connection request to the second device through the UART interface, so that the second device receives the After the request, the SPI clock signal Clock is sent to the first device.
  • the data required by the first device may also be used. Notifying the second device, so that after the first device and the second device establish an SPI connection, the second device can immediately transmit the data required by the first device to the first device.
  • the first device may also send a data transmission request to the second device after establishing the SPI connection, so that the second device knows the data required by the first device and passes the data through the MOSI tube after establishing the SPI establishment with the first device. The foot is sent to the first device.
  • Step 304 After receiving the setup SPI connection request sent by the first device, the second device establishes an SPI connection with the first device.
  • the second device sends a clock signal Clock to the first device through the SCLK pin.
  • the first device After receiving the clock signal Clock, the first device returns a response message to the second device through the MISO pin, that is, the SPI connection between the first device and the second device has been successfully established, and subsequent data transmission can be performed.
  • the first device may also The required data is notified to the second device after step 304.
  • Step 305 If the first device determines, according to the first query response, that the second device supports the SPI slave mode, the first device establishes an SPI connection with the second device.
  • the second device If the second device supports the SPI slave mode, the second device performs SPI communication as the slave device, and therefore, the first device can control the second device as the master device for SPI communication.
  • the first device sends a clock signal Clock to the second device through the SCLK pin.
  • the second device After receiving the clock signal Clock, the second device returns a response message to the first device through the MISO pin, that is, the SPI connection between the first device and the second device has been successfully established, and subsequent data transmission can be performed.
  • Step 306 Perform data transmission between the first device and the second device.
  • the two-way transmission of the signal can be simultaneously performed. Therefore, the first device and the second device can simultaneously transmit data to the other device, and the first device can transmit data to the second device, and the second device can also The first device sends data.
  • the second device may directly transmit the data required by the first device to the first device through the MOSI pin.
  • the first device needs to obtain a new version of the MCU firmware from the second device, and may notify the WWAN in step 303 or after step 304, the second device will store the new version.
  • the MCU firmware program is sent to the first device through the MOSI pin to enable the MCU in the first device to complete the firmware upgrade.
  • the first device may also send the first query request to the second device through the UART interface.
  • the second device sends a second query request for querying whether the data required by the first device is stored in the second device. If the data required by the first device is stored in the second device, the first device sends the data to the second device.
  • the first query request performs the above process; if the second device does not have the data required by the first device, the process ends.
  • the UART interface is used to communicate with the second device to query whether the second device includes the data required by the first device. If not, the step 301 to the step 306 are not performed.
  • the first device has been prevented from performing the foregoing steps, and the data required by the first device is not found in the second device, which improves system efficiency.
  • the first device may further send a dialing instruction to the second device through the UART interface, so as to establish a session channel between the first device and the second device;
  • the session channel establishment state may also be maintained between the second devices, and the first device is not required to send the dialing command.
  • the dialing instruction may be an AT command.
  • AT Attention, AT command is generally applied to the connection and communication between the terminal device and the host.
  • the AT command is preceded by the character "AT”, and the response packet is placed in the middle, ending with a preset string, and each instruction succeeds in returning or not, so the second device receives the AT.
  • the dialing success message is returned to the first device through the UART interface, indicating that the session channel between the first device and the second device has been established.
  • the first device may further send a dial-up Internet command to the second device, and the second device dials the Internet after receiving the command.
  • the first device may not be connected to the network, and the second device can be connected to the network.
  • the first device can instruct the second device to dial the Internet through the SPI, and obtain the network device from the network side. The data required by the first device.
  • the first device in the Internet of Things device communicates with the second device through the UART interface with less power consumption, and queries the SPI mode supported by the second device according to the SPI mode supported by the second device and the second device.
  • the device establishes an SPI connection to realize data transmission with a large amount of data through the SPI. While ensuring the transmission rate, the power consumption is not significantly increased, and the problem that the SPI slave device cannot initiate the SPI communication process is solved. Good for IoT devices that have high power and transfer rates.
  • the following uses the first device as the host in the Internet of Things device, the second device, and the WWAN module in the Internet of Things device as an example for description.
  • FIG. 4 a schematic diagram of a process for obtaining an upgraded MCU firmware from a WWAN module after a host in an IoT device is powered on periodically. as the picture shows:
  • Step 1 After the host is powered on, send an AT dialing command to the WWAN module through the UART interface.
  • Step 2 The WWAN module returns a response message for successfully establishing a session channel to the host through the UART interface.
  • Step 3 The host queries whether the WWAN module stores a new version of the MCU firmware data through the UART interface.
  • Step 4 The WWAN module replies to the host through the UART interface.
  • the WWAN module stores a new version of the MCU firmware data.
  • Step 5 The host queries the SPI mode supported by the WWAN module through the UART interface.
  • the query instruction may be an AT command.
  • Step 6 The WWAN module responds to the host through the UART interface.
  • the WWAN module supports the SPI slave mode.
  • Step 7 The host sends a request for establishing an SPI connection request and transmitting a new version of the MCU firmware data to the WWAN module through the UART interface.
  • Step 8 The WWAN module sends a clock signal Clock to the host through the SCLK pin.
  • Step 9 The host returns a response message for successfully establishing an SPI connection to the WWAN module through the MISO pin.
  • Step 10 The WWAN module sends a new version of the MCU firmware data to the host through the MOSI pin.
  • FIG. 5 it is a schematic diagram of a process in which a host in an IoT device instructs a WWAN module to dial-up after a scheduled boot. as the picture shows:
  • Steps 1 and 2 are consistent with steps 1 and 2 in the first embodiment.
  • Step 3 The host queries the SPI mode supported by the WWAN module through the UART interface.
  • the query instruction may be an AT command.
  • Step 4 The WWAN module responds to the host through the UART interface.
  • the WWAN module supports the SPI slave mode.
  • Step 5 The host sends an SPI connection request to the WWAN module through the UART interface.
  • Step 6 The WWAN module sends a clock signal Clock to the host through the SCLK pin.
  • Step 7 The host returns a response message for successfully establishing an SPI connection to the WWAN module through the MISO pin.
  • Step 8 The host sends a dial-up Internet command to the WWAN module through the MISO pin.
  • Step 9 The WWAN module performs dial-up Internet access.
  • the embodiment of the present invention further provides a data transmission device based on the serial peripheral interface SPI, which is used as the first device to implement the foregoing method embodiment.
  • the processor 601 includes a memory 602 and a transceiver 603 respectively connected to the processor 601.
  • the processor 601 is configured to read a program in the memory 602 and perform the following process:
  • An inquiry response determines that the second device supports the SPI master mode, and sends a setup SPI connection request to the second device by the transceiver 603, so that the second device initiates an SPI connection process with the first device;
  • the transceiver 603 receives data transmitted by the second device via the SPI or transmits data to the second device through the SPI.
  • the processor 601 is further configured to: if the second device supports the SPI slave mode according to the first query response, initiate an SPI connection process with the second device.
  • the processor 601 is further configured to: send, by the transceiver 603, the second query request to the second device by using the UART interface.
  • the second query request is used to query whether the data required by the first device is stored in the second device; and determining, according to the second query response returned by the second device, that the second device stores The data required by the first device.
  • the processor 601 is further configured to: send, by the transceiver 603, a dialing instruction to the second device, to enable the The first device establishes a session with the second device, and receives, by the transceiver 603, a response message that is successfully sent by the second device to establish a session channel.
  • the processor 601 is further configured to: send, by the transceiver 603, an instruction for dialing the Internet to the second device through the SPI, so that the second device performs dial-up access. .
  • the first device is a host in an Internet of Things device
  • the second device is a wireless wide area network WWAN module in the Internet of Things device.
  • the processor 601 when the processor 601 receives the data sent by the second device by using the SPI, the processor 601 is configured to: receive, by using the SPI, the micro control unit MCU firmware data sent by the WWAN module by using the SPI.
  • the embodiment of the present invention further provides a data transmission device based on the serial peripheral interface SPI, and the device is used as a second device to implement the foregoing method embodiment.
  • the processor 701 includes a memory 702 and a transceiver 703 respectively connected to the processor 701.
  • the processor 701 is configured to read a program in the memory 702 and perform the following process:
  • the first query request is used to query the SPI mode supported by the second device; and the first device is sent by the transceiver 703 Sending a first query response; when the first query response is used to notify the second device to support the SPI main mode, receiving, by the transceiver 703, the setup SPI connection request sent by the first device; initiating the first The device establishes an SPI connection process; after establishing an SPI connection with the first device, the transceiver 703 transmits data to the first device via the SPI or receives data transmitted by the first device through the SPI.
  • the processor 701 is further configured to respond to the first device initiated SPI connection when the first query response is used to notify the second device to support the SPI slave mode.
  • the processor 701 is further configured to: before the receiving, by the transceiver 703, the first query request sent by the first device by using the UART interface, the processor 701: receiving, by the transceiver 703, the first a second query request sent by the device, the second query request is used to query whether data required by the first device is stored in the second device, and the processor 701 sends the first query to the first query by using the transceiver 703.
  • the device sends a second query response, where the second query response is used to notify the second device that the data required by the first device is stored.
  • the processor 701 is further configured to: before receiving the first query request sent by the first device by using the UART interface, the transceiver 701 is configured to: receive, by the transceiver 703, the dialing command sent by the first device; The machine 703 sends a response message to the first device to successfully establish a session channel.
  • the processor 701 is further configured to: receive, by the transceiver 703, a dial-up Internet command sent by the first device through the SPI, and perform dial-up Internet access.
  • the first device is a host in an Internet of Things device
  • the second device is a wireless wide area network WWAN module in the Internet of Things device.
  • the processor 701 when the processor 701 sends data to the first device by using the SPI, the processor 701 is configured to send, by using the SPI, the SPI to the host of the Internet of Things device via the SPI to send the micro control unit MCU firmware data. .
  • the embodiment of the present invention further provides an SPI-based data transmission system, where the system includes the first device in any of the foregoing embodiments and the second device in any of the foregoing embodiments.
  • the Internet of Things device can be configured by the system provided by the embodiment of the present invention, wherein the host in the Internet of Things device is the first device in the system, and the WWAN module in the Internet of Things device is the second device in the system,
  • the implementation of the host and WWAN modules can be based on SPI for data transfer without being limited by the SPI master/slave mode.
  • embodiments of the present application can be provided as a method, system, or computer program product. Therefore, the present application may employ an entirely hardware embodiment, an entirely software embodiment, or a combination of software and hardware aspects.
  • the application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

一种基于SPI的数据传输方法及装置。该方法中,第一设备与通过UART接口向第二设备发送第一查询请求,用于查询第二设备支持的SPI模式,若第一设备根据第二设备返回的第一查询响应确定第二设备支持SPI主模式,则第一设备通过UART接口向第二设备发送建立SPI连接请求,以使第二设备发起与第一设备建立SPI连接过程,在第一设备与第二设备建立SPI连接之后,第一设备通过SPI接收第二设备发送的数据或通过SPI向第二设备发送数据。通过上述方法,避免了SPI从设备不能主动发起SPI通信,且在保证传输速率的同时,功耗没有显著增加。

Description

一种基于SPI的数据传输方法及装置
本申请要求在2016年9月29日提交中国专利局、申请号为201610868296.8、发明名称为“一种SPI接口模块的Host和Device连接方法和设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明实施例涉及通信技术领域,尤其涉及一种基于SPI的数据传输方法及装置。
背景技术
物联网设备包括主机和WWAN(Wireless Wide Area Network,无线广域网)模块。其中,主机用于实现M2M(Machine To Machine,机器对机器)业务中的业务、数据处理;WWAN模块用于通过无线网络实现物联网设备与互联网设备的通信。
目前,主机与WWAN模块之间通常采用USB(Universal Serial Bus,通用串行总线)接口或UART(Universal Asynchronous Receiver-Transmitter,通用异步收发器)接口进行数据传输。USB接口和UART接口各自的优缺点如表1所示。
表1
  优点 缺点
USB接口 传输速率高(约480Mbps) 功耗高
UART接口 功耗低 传输速率低(约3Mbps)
对于一些使用电池的物联网设备,对功耗的要求较高,若该设备对传输速率没有较高的要求,例如智能水表之类的设备(要求长达数年不更换电池,但传输的数据较小,对传输速率要求较低),采用UART接口即可。
但是对于一些使用电池且对传输速率有较高要求的物联网设备,例如该设备需要通过OTA(Over The Air,空中激活)升级主机中的MCU(Microcontroller Unit,微控制单元),由于MCU固件升级时需要传输的数据较大,若采用较低传输速率的UART接口进行数据传输,则需要较长时间完成升级过程,从而导致耗电量增加。
SPI(Serial Peripheral Interface,串行外设接口)的功耗相对较低,且SPI的传输速率大于UART接口的传输速率,约为24Mbps,适合应用于上述对功耗和传输速率均有较高要求的物联网设备。
然而,现有技术中的WWAN模块通常仅支持SPI主模式,不支持SPI从模式,即WWAN模块可以通过SPI主动向主机发起通信过程,但主机不能通过SPI向WWAN发起通信过程,对实际应用产生较大限制。
发明内容
本发明实施例提供一种基于SPI的数据传输方法,使得不论物联网设备中的WWAN模块支持SPI主模式还是SPI从模式,均能够实现与物联网设备中的主机通过SPI进行数据传输。
第一方面,本发明实施例提供的基于SPI的数据传输方法,包括:
第一设备通过UART接口向第二设备发送第一查询请求,其中,第一查询请求用于查询第二设备所支持的SPI模式;第一设备接收第二设备返回的第一查询响应;若第一设备根据第一查询响应确定第二设备支持SPI主模式,则第一设备向第二设备发送建立SPI连接请求,以使第二设备发起与第一设备建立SPI连接过程;在第一设备与第二设备建立SPI连接之后,第一设备通过SPI接收第二设备发送的数据或通过SPI向第二设备发送数据。
通过上述方法规避了SPI从设备不能主动发起SPI通信过程,使得第一设备即使作为SPI从设备,也可以通过UART接口请求第二设备作为SPI主设备发起SPI连接过程,此外,由于采用SPI传输数据,使得在保证传输速率的同时,不会使功耗显著增加。
结合第一方面,在第一方面的第一种可能的实现方式中,若第一设备根据第一查询响应确定第二设备支持SPI从模式,则第一设备发起与第二设备建立SPI连接过程。若第一设备确定第二设备支持SPI从模式,则第一设备可作为SPI主设备与第二设备通过SPI进行通信,因此,由作为SPI主设备的第一设备向第二设备发起SPI连接过程。
结合第一方面,在第一方面的第二种可能的实现方式中,第一设备在通过UART接口向第二设备发送第一查询请求之前,第一设备还可以通过UART接口向第二设备发送第二查询请求,该请求用于查询第二设备中是否存储有第一设备所需的数据,若第二设备中存储有第一设备所需的数据,则第一设备再向第二设备发送第一查询请求;若第二设备中没有第一设备所需的数据,流程结束,第一设备无需再向第二设备发送第一查询请求,以提高系统效率。
结合第一方面,在第一方面的第三种可能的实现方式中,第一设备在通过UART接口向第二设备发送第一查询请求之前,第一设备还可以向第二设备发送拨号指令,接收第二设备返回的成功建立会话通道的响应消息,以实现第一设备与第二设备建立会话通道。
结合第一方面,在第一方面的第四种可能的实现方式中,第一设备在与第二设备建立SPI连接之后,还可以通过SPI向第二设备发送拨号上网的指令,以使第二设备进行拨号上网。
结合第一方面,在第一方面的第五种可能的实现方式中,第一设备为物联网设备中的主机,第二设备为物联网设备中的WWAN模块。由于本发明实施例提供的方法规避了SPI从设备不能主动发起SPI通信过程,且采用SPI传输数据,使得在保证传输速率的同时,不会使功耗显著增加,适用于对功耗和传输速率均有较高要求的物联网设备中的主机和WWAN模块之间的通信。
结合第一方面,在第一方面的第六种可能的实现方式中,物联网设备中的主机可以通过SPI接收WWAN模块发送的MCU固件数据。由于MCU固件数据较大,适宜采用兼顾传输效率和功耗的SPI进行传输。
第二方面,本发明实施例提供的基于SPI的数据传输方法,包括:
第二设备通过UART接口接收第一设备发送的第一查询请求,所第一查询请求用于查询所述第二设备支持的SPI模式;所述第二设备向所述第一设备发送第一查询响应;当所述第一查询响应用于通知所述第二设备支持SPI主模式时,所述第二设备接收所述第一设备发送的建立SPI连接请求;所述第二设备发起与所述第一设备建立SPI连接过程;在所述第二设备与所述第一设备建立SPI连接之后,所述第二设备通过SPI向所述第一设备发 送数据或通过SPI接收所述第一设备发送的数据。
结合第二方面,在第二方面的第一种可能的实现方式中,当所述第一查询响应用于通知所述第二设备支持SPI从模式时,所述第二设备响应所述第一设备发起的SPI连接。
结合第二方面,在第二方面的第二种可能的实现方式中,在第二设备通过UART接口接收第一设备发送的第一查询请求之前,所述第二设备通过UART接口接收所述第一设备发送的第二查询请求,所述第二查询请求用于查询所述第二设备中是否存储有所述第一设备所需数据;所述第二设备向所述第一查询设备发送第二查询响应,所述第二查询响应用于通知第二设备中存储有所述第一设备所需数据。
结合第二方面,在第二方面的第三种可能的实现方式中,在第二设备通过UART接口接收第一设备发送的第一查询请求之前,所述第二设备接收所述第一设备发送的拨号指令;所述第二设备向所述第一设备发送成功建立会话通道的响应消息。
结合第二方面,在第二方面的第四种可能的实现方式中,第二设备在与第一设备建立SPI连接之后,还可以接收第一设备通过SPI发送的拨号上网指令,并在接收到指令之后进行拨号上网。
结合第二方面,在第二方面的第五种可能的实现方式中,所述第一设备为物联网设备中的主机,所述第二设备为物联网设备中的无线广域网WWAN模块。
结合第二方面,在第二方面的第六种可能的实现方式中,所述第二设备通过SPI向所述第一设备发送数据,具体包括:所述WWAN模块通过SPI向所述物联网设备的主机发送微控制单元MCU固件数据。
第三方面,本发明实施例提供了一种基于串行外设接口SPI的数据传输设备,所述设备作为第一设备,包括:处理器,以及分别与处理器连接的存储器和收发机。
其中,处理器,用于读取所述存储器中的程序,执行下列过程:
通过收发机经过通用异步收发器UART接口向第二设备发送第一查询请求,所述第一查询请求用于查询所述第二设备支持的SPI模式;若根据所述第二设备返回的第一查询响应确定所述第二设备支持SPI主模式,则通过收发机向所述第二设备发送建立SPI连接请求,以使所述第二设备发起与所述第一设备建立SPI连接过程;在与所述第二设备建立SPI连接之后,通过收发机经过SPI接收所述第二设备发送的数据或通过SPI向所述第二设备发送数据。
结合第三方面,在第三方面的第一种可能的实现方式中,所述处理器还用于:若根据所述第一查询响应确定所述第二设备支持SPI从模式,则发起与所述第二设备建立SPI连接过程。
结合第三方面,在第三方面的第二种可能的实现方式中,所述处理器在通过收发机经过UART接口向第二设备发送第一查询请求之前,还用于:通过收发机经过UART接口向所述第二设备发送第二查询请求,所述第二查询请求用于查询所述第二设备中是否存储有所述第一设备所需数据;根据所述第二设备返回的第二查询响应,确定所述第二设备中存储有所述第一设备所需的数据。
结合第三方面,在第三方面的第三种可能的实现方式中,所述处理器在通过收发机经过UART接口向第二设备发送第一查询请求之前,还用于:通过收发机向所述第二设备发送拨号指令,以使所述第一设备与所述第二设备建立建立会话通道;通过收发机接收所述第二设备发送的成功建立会话通道的响应消息。
结合第三方面,在第三方面的第四种可能的实现方式中,在第一设备与第二设备建立SPI连接之后,所述处理器还用于通过收发机以及SPI向第二设备发送拨号上网的指令,以使第二设备进行拨号上网。
结合第三方面,在第三方面的第五种可能的实现方式中,所述第一设备为物联网设备中的主机,所述第二设备为物联网设备中的无线广域网WWAN模块。
结合第三方面,在第三方面的第六种可能的实现方式中,所述处理器通过收发机经过SPI接收所述第二设备发送的数据时,具体用于:通过收发机经过SPI接收所述WWAN模块发送的微控制单元MCU固件数据。
第四方面,本发明实施例提供了一种基于串行外设接口SPI的数据传输设备,包括:处理器,以及分别与处理器连接的存储器和收发机。
其中,所述处理器,用于读取所述存储器中的程序,执行下列过程:
通过收发机经过通用异步收发器UART接口接收第一设备发送的第一查询请求,所第一查询请求用于查询所述第二设备支持的SPI模式;通过收发机向所述第一设备发送第一查询响应;当所述第一查询响应用于通知所述第二设备支持SPI主模式时,通过收发机接收所述第一设备发送的建立SPI连接请求;发起与所述第一设备建立SPI连接过程;在与所述第一设备建立SPI连接之后,通过收发机经过SPI向所述第一设备发送数据或通过SPI接收所述第一设备发送的数据。
结合第四方面,在第四方面的第一种可能的实现方式中,所述处理器还用于:当所述第一查询响应用于通知所述第二设备支持SPI从模式时,响应所述第一设备发起的SPI连接。
结合第四方面,在第四方面的第二种可能的实现方式中,所述处理器在通过收发机经过UART接口接收第一设备发送的第一查询请求之前,还用于:所述处理器通过收发机经过UART接口接收所述第一设备发送的第二查询请求,所述第二查询请求用于查询所述第二设备中是否存储有所述第一设备所需数据;所述处理器通过收发机向所述第一查询设备发送第二查询响应,所述第二查询响应用于通知第二设备中存储有所述第一设备所需数据。
结合第四方面,在第四方面的第三种可能的实现方式中,所述处理器在通过收发机经过UART接口接收第一设备发送的第一查询请求之前,还用于:通过收发机接收所述第一设备发送的拨号指令;通过收发机向所述第一设备发送成功建立会话通道的响应消息。
结合第四方面,在第四方面的第四种可能的实现方式中,在第二设备与第一设备建立SPI连接之后,所述处理器还用于通过收发机接收第一设备通过SPI发送的拨号上网指令,并进行拨号上网。
结合第四方面,在第四方面的第五种可能的实现方式中,所述第一设备为物联网设备中的主机,所述第二设备为物联网设备中的无线广域网WWAN模块。
结合第四方面,在第四方面的第六种可能的实现方式中,所述处理器通过收发机经过SPI向所述第一设备发送数据时,具体用于:
通过收发机经过SPI向所述物联网设备的主机发送微控制单元MCU固件数据。
第五方面,本发明实施例提供了一种基于串行外设接口SPI的数据传输系统,包括第三方面及其可能实现方式中任一种第一设备和第四方面及其可能实现中人一种第二设 备。
附图说明
图1为现有技术中SPI连接示意图;
图2本发明实施例提供的一种设备连接的示意图;
图3为本发明实施例提供的基于SPI进行数据传输方法的流程示意图;
图4为本发明实施例提供的一个具体应用场景示意图;
图5为本发明实施例提供的另一个具体应用场景示意图
图6为本发明实施例提供的第一设备的结构示意图;
图7为本发明实施例提供的第二设备的结构示意图。
具体实施方式
下面将结合附图对本申请实施例作进一步地详细描述。
SPI总线系统是一种同步串行外设接口,它可以使微控制器与各种外围设备以串行方式进行通信以交换信息。
如图1所示,通过SPI进行通信的两个设备,一个作为主设备(Master),另一个作为从设备(Slave),主设备和从设备之间通过四个管脚相连:
MOSI—主设备数据输出,从设备数据输入
MISO—主设备数据输入,从设备数据输出
SCLK—时钟信号Clock,由主设备产生
SS—从设备使能信号(片选信号),由主设备控制
其中,时钟信号由主设备发送给从设备,而从设备本身不能产生或控制时钟信号,若从设备没有接收到时钟信号则不能正常工作;管脚SS用于控制芯片是否被选中,即片选信号为预先规定的使能信号时,主设备才能通过SPI进行通信,这就使得主设备通过同一总线连接多个从设备。
由于SPI是一种高速的、全双工、同步的通信总线,并且在芯片的管脚上只占用四根线,节约了芯片的管脚,同时为PCB(Printed Circuit Board,印制电路板)的布局节省空间,且功耗较小、传输速率较高,正是出于这些特性,如今越来越多的芯片采用SPI进行通信,例如,可应用于物联网设备的主机和WWAN模块之间的通信,尤其适用于对功耗和传输速率均有较高要求的物联网设备。
通常情况下,物联网设备中的主机既可以作为主设备,也可以作为从设备,可以根据具体的应用场景进行设置;而物联网设备中的WWAN模块通常仅支持SPI主模式,即在通过SPI进行通信时仅能够作为主设备使用。因此,物联网设备的主机和WWAN模块通过SPI进行通信时,只能由WWAN作为主设备,主机作为从设备,而不能根据实际应用需求进行调整,使得作为从设备的主机不能主动通过SPI向WWAN模块发起通信过程,产生较大的局限性。
为了解决上述问题,本发明实施例提供了一种基于SPI的数据传输方法,以实现作为SPI的从设备,也可以主动发起通信过程。该方法可应用于如图2所示的第一设备和第二设备的通信过程中。第一设备和第二设备通过本发明实施例提供的方法进行数据传输的流程可参见图3,如图所示,该方法包括以下步骤:
步骤301、第一设备通过UART接口向第二设备发送第一查询请求。
其中,第一查询请求用于查询第二设备所述支持的SPI模式。
步骤302、第二设备向第一设备发送第一查询响应。
其中,第二设备通过UART接口发送的第一查询响应中包含有该第二设备所支持的SPI模式,若第二设备支持SPI主模式,则转入步骤303,否则,转入步骤305。
步骤303、若第一设备根据第一查询响应确定第二设备支持SPI主模式,则第一设备向第二设备发送建立SPI连接请求。
若第二设备支持SPI主模式,即第二设备作为主设备进行SPI通信,因此,第一设备与第二设备进行SPI通信时仅能作为从设备。如前所述,从设备需要接收到主设备发送的SPI时钟信号Clock才能正常工作,因此,第一设备可以通过UART接口向第二设备发送建立SPI连接请求,以使第二设备在接收到该请求后,向第一设备发送SPI时钟信号Clock。
若第一设备主动发起通信过程的目的为从第二设备中获取所需数据,可选地,该第一设备向第二设备发送建立SPI连接请求时,还可以将第一设备所需的数据通知给第二设备,以使第一设备和第二设备在建立SPI连接之后,第二设备能够马上将第一设备所需的数据传送给第一设备。当然第一设备也可以在建立SPI连接之后在向第二设备发送数据传输请求,以使第二设备知道第一设备所需的数据并在与第一设备建立SPI建立之后将该数据通过MOSI管脚发送给第一设备。
步骤304、第二设备在接收到第一设备发送的建立SPI连接请求后,与第一设备建立SPI连接。
具体地,第二设备通过SCLK管脚向第一设备发送时钟信号Clock。第一设备在接收到时钟信号Clock后,通过MISO管脚向第二设备返回响应消息,即第一设备和第二设备之间的SPI连接已经成功建立,可以进行后续的数据传输。
若第一设备主动发起通信过程的目的是从第二设备中获取所需数据,且在上述步骤303中未将该第一设备所需的数据通知给第二设备,则该第一设备还可以在步骤304之后将所需的数据通知给第二设备。
步骤305、若第一设备根据第一查询响应确定第二设备支持SPI从模式,则第一设备与第二设备建立SPI连接。
若第二设备支持SPI从模式,则第二设备作为从设备进行SPI通信,因此,第一设备可作为主设备控制第二设备进行SPI通信。
具体地,第一设备通过SCLK管脚向第二设备发送时钟信号Clock。第二设备在接收到时钟信号Clock后,通过MISO管脚向第一设备返回响应消息,即第一设备和第二设备之间的SPI连接已经成功建立,可以进行后续的数据传输。
步骤306、第一设备和第二设备之间进行数据传输。
由于SPI支持全双工,即可以同时进行信号的双向传输,因此,在第一设备和第二设备可以同时向对方传输数据,第一设备可以向第二设备发送数据,第二设备也可以向第一设备发送数据。
若第一设备已将其需要的数据通知给第二设备,则第二设备可直接将第一设备所需数据通过MOSI管脚传输给第一设备。例如,第一设备需要从第二设备处获取新版本的MCU固件,可以在步骤303中或在步骤304之后通知WWAN,第二设备将存储的新版本 的MCU固件程序通过MOSI管脚发送给第一设备,以使第一设备中的MCU完成固件升级。
在一些实施例中,若第一设备主动发起通信过程的目的是从第二设备中获取数据,那么第一设备在通过UART接口向第二设备发送第一查询请求之前,还可以通过UART接口向第二设备发送第二查询请求,用于查询第二设备中是否存储有第一设备所需的数据,若第二设备中存储有第一设备所需数据,第一设备再向第二设备发送第一查询请求,执行上述流程;若第二设备中没有第一设备所需的数据,则流程结束。
由于在第一设备与第二设备建立SPI连接之前,先通过UART接口与第二设备进行通信,查询第二设备是否包含有第一设备所需数据,若没有则无需进行步骤301至步骤306,避免第一设备已经执行前述步骤,才发现第二设备中没有第一设备所需的数据,提高了系统效率。
在一些实施例中,在上述步骤301之前,第一设备还可以通过UART接口向第二设备发送拨号指令,以使第一设备与第二设备之间建立会话通道;当然,若第一设备与第二设备之间也可能一直保持会话通道建立状态,则无需第一设备再发送拨号指令。具体地,该拨号指令可以是AT指令。AT即Attention,AT指令一般应用于终端设备与主机之间的连接与通信。AT指令是以字符“AT”为首,将响应数据包放在中间,以预先设定的字符串为结束,且每个指令执行成功与否都有相应的返回,因此第二设备在接收到AT拨号指令后,通过UART接口向第一设备返回拨号成功消息,则表示第一设备与第二设备之间的会话通道已经建立。
在另外一些实施例中,第一设备与第二设备建立SPI连接之后,第一设备还可以向第二设备发送拨号上网指令,第二设备在接收到指令后进行拨号上网。第一设备可能并没有连接网络,而第二设备能够连接网络,此时,第一设备在与第二设备建立SPI连接之后,第一设备可以通过SPI指示第二设备拨号上网,从网络侧获取第一设备所需的数据。
在上述实施例中,物联网设备中的第一设备通过功耗较小的UART接口与第二设备进行通信,查询第二设备所支持的SPI模式,根据第二设备支持的SPI模式与第二设备建立SPI连接,以实现通过SPI传输数据量较大的数据,在保证传输速率的同时,并不会使功耗显著增加,且解决了SPI从设备不能主动发起SPI通信过程的问题,能够较好的适用于对功耗和传输速率均有较高要求的物联网设备。
为了更清楚的理解本发明实施例提供的基于SPI的数据传输方法,下面以第一设备为物联网设备中的主机、第二设备为和物联网设备中的WWAN模块为例进行说明。
实施例一、
参见图4,为物联网设备中的主机在定时开机后,从WWAN模块中获取升级的MCU固件的流程示意图。如图所示:
步骤1、主机开机后通过UART接口向WWAN模块发送AT拨号指令。
步骤2、WWAN模块通过UART接口向主机返回成功建立会话通道的响应消息。
步骤3、主机通过UART接口查询WWAN模块是否存储有新版本的MCU固件数据。
步骤4、WWAN模块通过UART接口回复主机该WWAN模块中存储有新版本的MCU固件数据。
步骤5、主机通过UART接口查询WWAN模块所支持的SPI模式。其中,查询指令可以是AT指令。
步骤6、WWAN模块通过UART接口回复主机该WWAN模块支持SPI从模式。
步骤7、主机通过UART接口向WWAN模块发送建立SPI连接请求和传输新版本MCU固件数据的请求。
步骤8、WWAN模块通过SCLK管脚向主机发送时钟信号Clock。
步骤9、主机通过MISO管脚向WWAN模块返回成功建立SPI连接的响应消息。
步骤10、WWAN模块通过MOSI管脚向主机发送新版本的MCU固件数据。
实施例二、
参见图5,为物联网设备中的主机在定时开机后,指示WWAN模块进行拨号上网的流程示意图。如图所示:
其中,步骤1和步骤2与实施例一中的步骤1和步骤2一致。
步骤3、主机通过UART接口查询WWAN模块所支持的SPI模式。其中,查询指令可以是AT指令。
步骤4、WWAN模块通过UART接口回复主机该WWAN模块支持SPI从模式。
步骤5、主机通过UART接口向WWAN模块发送建立SPI连接请求。
步骤6、WWAN模块通过SCLK管脚向主机发送时钟信号Clock。
步骤7、主机通过MISO管脚向WWAN模块返回成功建立SPI连接的响应消息。
步骤8、主机通过MISO管脚向WWAN模块发送拨号上网指令。
步骤9、WWAN模块进行拨号上网。
基于相同的技术构思,本发明实施例还提供了一种基于串行外设接口SPI的数据传输设备,该设备作为第一设备,用于实现上述方法实施例,其结构示意图如图6所示,包括:处理器601,分别与处理器601连接的存储器602和收发机603。
其中,处理器601用于读取所述存储器602中的程序,执行下列过程:
通过收发机603经过通用异步收发器UART接口向第二设备发送第一查询请求,所述第一查询请求用于查询所述第二设备支持的SPI模式;若根据所述第二设备返回的第一查询响应确定所述第二设备支持SPI主模式,则通过收发机603向所述第二设备发送建立SPI连接请求,以使所述第二设备发起与所述第一设备建立SPI连接过程;在与所述第二设备建立SPI连接之后,通过收发机603经过SPI接收所述第二设备发送的数据或通过SPI向所述第二设备发送数据。
可选地,所述处理器601还用于:若根据所述第一查询响应确定所述第二设备支持SPI从模式,则发起与所述第二设备建立SPI连接过程。
可选地,所述处理器601在通过收发机603经过UART接口向第二设备发送第一查询请求之前,还用于:通过收发机603经过UART接口向所述第二设备发送第二查询请求,所述第二查询请求用于查询所述第二设备中是否存储有所述第一设备所需数据;根据所述第二设备返回的第二查询响应,确定所述第二设备中存储有所述第一设备所需的数据。
可选地,所述处理器601在通过收发机603经过UART接口向第二设备发送第一查询请求之前,还用于:通过收发机603向所述第二设备发送拨号指令,以使所述第一设备与所述第二设备建立建立会话通道;通过收发机603接收所述第二设备发送的成功建立会话通道的响应消息。
可选地,所述处理器601在第一设备与第二设备建立SPI连接之后,还用于:通过收发机603经过SPI向第二设备发送拨号上网的指令,以使第二设备进行拨号上网。
可选地,所述第一设备为物联网设备中的主机,所述第二设备为物联网设备中的无线广域网WWAN模块。
可选地,所述处理器601通过收发机603经过SPI接收所述第二设备发送的数据时,具体用于:通过收发机603经过SPI接收所述WWAN模块发送的微控制单元MCU固件数据。
基于相同的技术构思,本发明实施例还提供了一种基于串行外设接口SPI的数据传输设备,该设备作为第二设备,用于实现上述方法实施例,其结构示意图如图7所示,包括:处理器701,分别与处理器701连接的存储器702和收发机703。
其中,所述处理器701,用于读取所述存储器702中的程序,执行下列过程:
通过收发机703经过通用异步收发器UART接口接收第一设备发送的第一查询请求,所第一查询请求用于查询所述第二设备支持的SPI模式;通过收发机703向所述第一设备发送第一查询响应;当所述第一查询响应用于通知所述第二设备支持SPI主模式时,通过收发机703接收所述第一设备发送的建立SPI连接请求;发起与所述第一设备建立SPI连接过程;在与所述第一设备建立SPI连接之后,通过收发机703经过SPI向所述第一设备发送数据或通过SPI接收所述第一设备发送的数据。
可选地,所述处理器701还用于:当所述第一查询响应用于通知所述第二设备支持SPI从模式时,响应所述第一设备发起的SPI连接。
可选地,所述处理器701在通过收发机703经过UART接口接收第一设备发送的第一查询请求之前,还用于:所述处理器701通过收发机703经过UART接口接收所述第一设备发送的第二查询请求,所述第二查询请求用于查询所述第二设备中是否存储有所述第一设备所需数据;所述处理器701通过收发机703向所述第一查询设备发送第二查询响应,所述第二查询响应用于通知第二设备中存储有所述第一设备所需数据。
可选地,所述处理器701在通过收发机703经过UART接口接收第一设备发送的第一查询请求之前,还用于:通过收发机703接收所述第一设备发送的拨号指令;通过收发机703向所述第一设备发送成功建立会话通道的响应消息。
可选地,所述处理器701在第一设备与第二设备建立SPI连接之后,还用于:通过收发机703接收第一设备通过SPI发送的拨号上网指令,并进行拨号上网。
可选地,所述第一设备为物联网设备中的主机,所述第二设备为物联网设备中的无线广域网WWAN模块。
可选地,所述处理器701通过收发机703经过SPI向所述第一设备发送数据时,具体用于:通过收发机703经过SPI向所述物联网设备的主机发送微控制单元MCU固件数据。
基于相同的技术构思,本发明实施例还提供了一种基于SPI的数据传输系统,该系统包括上述任一实施例中的第一设备和上述任一实施例中的第二设备。例如,物联网设备即可由本发明实施例提供的系统构成,其中,物联网设备中的主机为上述系统中的第一设备,物联网设备中的WWAN模块为上述系统中的第二设备,以实现主机和WWAN模块可以基于SPI进行数据传输,而不受SPI主/从模式的限制。
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面 的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
显然,本领域的技术人员可以对本申请实施例进行各种改动和变型而不脱离本申请实施例的精神和范围。这样,倘若本申请实施例的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。

Claims (25)

  1. 一种基于串行外设接口SPI的数据传输方法,其特征在于,包括:
    第一设备通过通用异步收发器UART接口向第二设备发送第一查询请求,所述第一查询请求用于查询所述第二设备支持的SPI模式;
    若所述第一设备根据所述第二设备返回的第一查询响应确定所述第二设备支持SPI主模式,则所述第一设备向所述第二设备发送建立SPI连接请求,以使所述第二设备发起与所述第一设备建立SPI连接过程;
    在所述第一设备与所述第二设备建立SPI连接之后,所述第一设备通过SPI接收所述第二设备发送的数据或通过SPI向所述第二设备发送数据。
  2. 如权利要求1所述的方法,其特征在于,还包括:
    若所述第一设备根据所述第一查询响应确定所述第二设备支持SPI从模式,则所述第一设备发起与所述第二设备建立SPI连接过程。
  3. 如权利要求1所述的方法,其特征在于,在第一设备通过UART接口向第二设备发送第一查询请求之前,还包括:
    所述第一设备通过UART接口向所述第二设备发送第二查询请求,所述第二查询请求用于查询所述第二设备中是否存储有所述第一设备所需数据;
    所述第一设备根据所述第二设备返回的第二查询响应,确定所述第二设备中存储有所述第一设备所需的数据。
  4. 如权利要求1所述的方法,其特征在于,在第一设备UART接口向第二设备发送第一查询请求之前,还包括:
    所述第一设备向所述第二设备发送拨号指令,以使所述第一设备与所述第二设备建立建立会话通道;
    所述第一设备接收所述第二设备发送的成功建立会话通道的响应消息。
  5. 如权利要求1所述的方法,其特征在于,所述第一设备为物联网设备中的主机,所述第二设备为物联网设备中的无线广域网WWAN模块。
  6. 如权利要求5所述的方法,其特征在于,所述第一设备通过SPI接收所述第二设备发送的数据,包括:
    所述物联网设备的主机通过SPI接收所述WWAN模块发送的微控制单元MCU固件数据。
  7. 一种基于串行外设接口SPI的数据传输方法,其特征在于,包括:
    第二设备通过通用异步收发器UART接口接收第一设备发送的第一查询请求,所第一查询请求用于查询所述第二设备支持的SPI模式;
    所述第二设备向所述第一设备发送第一查询响应;
    当所述第一查询响应用于通知所述第二设备支持SPI主模式时,所述第二设备接收所述第一设备发送的建立SPI连接请求;
    所述第二设备发起与所述第一设备建立SPI连接过程;
    在所述第二设备与所述第一设备建立SPI连接之后,所述第二设备通过SPI向所述第一设备发送数据或通过SPI接收所述第一设备发送的数据。
  8. 如权利要求7所述的方法,其特征在于,还包括:
    当所述第一查询响应用于通知所述第二设备支持SPI从模式时,所述第二设备响应所述第一设备发起的SPI连接。
  9. 如权利要求7所述的方法,其特征在于,在第二设备通过UART接口接收第一设备发送的第一查询请求之前,还包括:
    所述第二设备通过UART接口接收所述第一设备发送的第二查询请求,所述第二查询请求用于查询所述第二设备中是否存储有所述第一设备所需数据;
    所述第二设备向所述第一查询设备发送第二查询响应,所述第二查询响应用于通知第二设备中存储有所述第一设备所需数据。
  10. 如权利要求7所述的方法,其特征在于,在第二设备通过UART接口接收第一设备发送的第一查询请求之前,还包括:
    所述第二设备接收所述第一设备发送的拨号指令;
    所述第二设备向所述第一设备发送成功建立会话通道的响应消息。
  11. 如权利要求7所述的方法,其特征在于,所述第一设备为物联网设备中的主机,所述第二设备为物联网设备中的无线广域网WWAN模块。
  12. 如权利要求11所述的方法,其特征在于,所述第二设备通过SPI向所述第一设备发送数据,包括:
    所述WWAN模块通过SPI向所述物联网设备的主机发送微控制单元MCU固件数据。
  13. 一种基于串行外设接口SPI的数据传输设备,所述设备作为第一设备,其特征在于,包括:处理器,以及分别与处理器连接的存储器和收发机;
    所述处理器,用于读取所述存储器中的程序,执行下列过程:
    通过收发机经过通用异步收发器UART接口向第二设备发送第一查询请求,所述第一查询请求用于查询所述第二设备支持的SPI模式;
    若根据所述第二设备返回的第一查询响应确定所述第二设备支持SPI主模式,则通过收发机向所述第二设备发送建立SPI连接请求,以使所述第二设备发起与所述第一设备建立SPI连接过程;
    在与所述第二设备建立SPI连接之后,通过收发机经过SPI接收所述第二设备发送的数据或通过SPI向所述第二设备发送数据。
  14. 如权利要求13所述的设备,其特征在于,所述处理器还用于:
    若根据所述第一查询响应确定所述第二设备支持SPI从模式,则发起与所述第二设备建立SPI连接过程。
  15. 如权利要求13所述的设备,其特征在于,所述处理器在通过收发机经过UART接口向第二设备发送第一查询请求之前,还用于:
    通过收发机经过UART接口向所述第二设备发送第二查询请求,所述第二查询请求用于查询所述第二设备中是否存储有所述第一设备所需数据;
    根据所述第二设备返回的第二查询响应,确定所述第二设备中存储有所述第一设备所需的数据。
  16. 如权利要求13所述的设备,其特征在于,所述处理器在通过收发机经过UART接口向第二设备发送第一查询请求之前,还用于:
    通过收发机向所述第二设备发送拨号指令,以使所述第一设备与所述第二设备建立建立会话通道;
    通过收发机接收所述第二设备发送的成功建立会话通道的响应消息。
  17. 如权利要求13所述的设备,其特征在于,所述第一设备为物联网设备中的主机,所述第二设备为物联网设备中的无线广域网WWAN模块。
  18. 如权利要求17所述的设备,其特征在于,所述处理器通过收发机经过SPI接收所述第二设备发送的数据时,具体用于:
    通过收发机经过SPI接收所述WWAN模块发送的微控制单元MCU固件数据。
  19. 一种基于串行外设接口SPI的数据传输设备,所述设备作为第二设备,其特征在于,包括:处理器,以及分别与处理器连接的存储器和收发机;
    所述处理器,用于读取所述存储器中的程序,执行下列过程:
    通过收发机经过通用异步收发器UART接口接收第一设备发送的第一查询请求,所第一查询请求用于查询所述第二设备支持的SPI模式;
    通过收发机向所述第一设备发送第一查询响应;
    当所述第一查询响应用于通知所述第二设备支持SPI主模式时,通过收发机接收所述第一设备发送的建立SPI连接请求;
    发起与所述第一设备建立SPI连接过程;
    在与所述第一设备建立SPI连接之后,通过收发机经过SPI向所述第一设备发送数据或通过SPI接收所述第一设备发送的数据。
  20. 如权利要求19所述的设备,其特征在于,所述处理器还用于:
    当所述第一查询响应用于通知所述第二设备支持SPI从模式时,响应所述第一设备发起的SPI连接。
  21. 如权利要求19所述的设备,其特征在于,所述处理器在通过收发机经过UART接口接收第一设备发送的第一查询请求之前,还用于:
    所述处理器通过收发机经过UART接口接收所述第一设备发送的第二查询请求,所述第二查询请求用于查询所述第二设备中是否存储有所述第一设备所需数据;
    所述处理器通过收发机向所述第一查询设备发送第二查询响应,所述第二查询响应用于通知第二设备中存储有所述第一设备所需数据。
  22. 如权利要求19所述的设备,其特征在于,所述处理器在通过收发机经过UART接口接收第一设备发送的第一查询请求之前,还用于:
    通过收发机接收所述第一设备发送的拨号指令;
    通过收发机向所述第一设备发送成功建立会话通道的响应消息。
  23. 如权利要求19所述的设备,其特征在于,所述第一设备为物联网设备中的主机,所述第二设备为物联网设备中的无线广域网WWAN模块。
  24. 如权利要求23所述的设备,其特征在于,所述处理器通过收发机经过SPI向所述第一设备发送数据时,具体用于:
    通过收发机经过SPI向所述物联网设备的主机发送微控制单元MCU固件数据。
  25. 一种基于串行外设接口SPI的数据传输系统,其特征在于,包括如权利要求13至18中任一项所述的第一设备和如权利要求19至24中任一项所述的第二设备。
PCT/CN2017/071295 2016-09-29 2017-01-16 一种基于spi的数据传输方法及装置 Ceased WO2018058862A1 (zh)

Priority Applications (3)

Application Number Priority Date Filing Date Title
EP17854324.5A EP3502908B1 (en) 2016-09-29 2017-01-16 Spi-based data transmission method and device
CN201780001952.7A CN108475241B (zh) 2016-09-29 2017-01-16 一种基于spi的数据传输方法及装置
US16/336,839 US10789180B2 (en) 2016-09-29 2017-01-16 SPI-based data transmission method and device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610868296.8 2016-09-29
CN201610868296 2016-09-29

Publications (1)

Publication Number Publication Date
WO2018058862A1 true WO2018058862A1 (zh) 2018-04-05

Family

ID=61763076

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/071295 Ceased WO2018058862A1 (zh) 2016-09-29 2017-01-16 一种基于spi的数据传输方法及装置

Country Status (4)

Country Link
US (1) US10789180B2 (zh)
EP (1) EP3502908B1 (zh)
CN (1) CN108475241B (zh)
WO (1) WO2018058862A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112860617A (zh) * 2021-02-02 2021-05-28 浙江大华技术股份有限公司 数据传输方法和装置、存储介质及电子设备
CN113806265A (zh) * 2021-09-18 2021-12-17 国家石油天然气管网集团有限公司 一种spi主从式通讯方法

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111490920A (zh) * 2019-01-29 2020-08-04 杭州海康汽车技术有限公司 一种基于spi的数据传输方法、系统及装置
CN112631975B (zh) * 2020-12-09 2024-06-04 珠海全志科技股份有限公司 基于Linux的SPI传输方法
CN113407478B (zh) * 2021-08-23 2021-11-30 上海泰矽微电子有限公司 一种实现spi从设备主动申请传输的方法
CN114153773B (zh) * 2021-10-29 2024-05-07 山东云海国创云计算装备产业创新中心有限公司 一种基于axi总线传输数据的方法、设备、系统及可读介质
CN114443549B (zh) * 2021-11-23 2024-03-12 南京林洋电力科技有限公司 一种基于特征码流识别的spi通信方法
EP4213031B1 (en) * 2022-01-13 2025-02-26 Bayerische Motoren Werke Aktiengesellschaft Method and device for monitoring a synchronous serial master / slave connection by using an asynchronous interface
TWI818659B (zh) * 2022-08-04 2023-10-11 新唐科技股份有限公司 微控制器、操作系統及控制方法

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080307126A1 (en) * 2007-06-07 2008-12-11 Via Technologies, Inc. System and method for serial-peripheral-interface data transmission
CN101552733A (zh) * 2009-05-15 2009-10-07 深圳华为通信技术有限公司 一种基于spi实现数据传输的方法和系统
CN102231143A (zh) * 2011-07-04 2011-11-02 浙江大学 一种安全可复用spi外围接口电路

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5023778A (en) * 1990-03-23 1991-06-11 General Motors Corporation Interprocessor communication method
JP3970786B2 (ja) * 2003-03-05 2007-09-05 株式会社日立製作所 マルチプロセッサシステム
US8135881B1 (en) * 2010-09-27 2012-03-13 Skyworks Solutions, Inc. Dynamically configurable serial data communication interface
GB201102594D0 (en) * 2011-02-15 2011-03-30 Nordic Semiconductor Asa Serial interface
CN102508812B (zh) * 2011-11-30 2013-09-04 上海大学 一种基于spi总线的双处理器通信方法
CN103744825A (zh) 2013-12-31 2014-04-23 北京中宇新泰科技发展有限公司 一种扩展兼容spi接口双向实时通讯方法
US9411772B2 (en) * 2014-06-30 2016-08-09 Echelon Corporation Multi-protocol serial nonvolatile memory interface
US10372664B2 (en) * 2015-06-25 2019-08-06 Thine Electronics, Inc. Host-side transceiver device and transceiver system
KR102460750B1 (ko) * 2018-02-13 2022-10-31 삼성전기주식회사 Ois 기능을 갖는 카메라 장치 및 그 통신 방법

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080307126A1 (en) * 2007-06-07 2008-12-11 Via Technologies, Inc. System and method for serial-peripheral-interface data transmission
CN101552733A (zh) * 2009-05-15 2009-10-07 深圳华为通信技术有限公司 一种基于spi实现数据传输的方法和系统
CN102231143A (zh) * 2011-07-04 2011-11-02 浙江大学 一种安全可复用spi外围接口电路

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3502908A4

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112860617A (zh) * 2021-02-02 2021-05-28 浙江大华技术股份有限公司 数据传输方法和装置、存储介质及电子设备
CN113806265A (zh) * 2021-09-18 2021-12-17 国家石油天然气管网集团有限公司 一种spi主从式通讯方法

Also Published As

Publication number Publication date
EP3502908B1 (en) 2022-11-30
EP3502908A4 (en) 2019-08-28
US20190391935A1 (en) 2019-12-26
CN108475241B (zh) 2021-01-05
CN108475241A (zh) 2018-08-31
EP3502908A1 (en) 2019-06-26
US10789180B2 (en) 2020-09-29

Similar Documents

Publication Publication Date Title
WO2018058862A1 (zh) 一种基于spi的数据传输方法及装置
CN110089040B (zh) 数据传输的方法和发送端设备
US10165613B2 (en) Control method for bluetooth communication and bluetooth low energy communication
US20150065053A1 (en) Method of controlling short-range wireless communication and apparatus supporting the same
KR20110049121A (ko) 디바이스 활성화 방법 및 장치
CN102201846B (zh) 基于soft AP技术的无线数据传输系统及其方法
EP2206312A2 (en) Pairing exchange
CN104661230A (zh) 一种基于近场通信建立无线局域网的方法及装置
WO2017049553A1 (zh) 移动终端、电源适配器及其升级方法
CN112269749B (zh) I2c通信系统
CN111277988B (zh) 一种提高微信小程序蓝牙传输速度的方法
WO2021016755A1 (zh) 数据传输方法及装置
CN104955166A (zh) 蓝牙通信方法和系统
CN110199534A (zh) 利用低功耗蓝牙的数据通信方法以及装置
WO2017049549A1 (zh) 移动终端、电源适配器及其升级方法
CN102202132A (zh) 一种对上网设备进行初始化的方法、系统及设备
CN105519203A (zh) 控制近距无线通信的方法和支持该方法的装置
WO2015176320A1 (zh) 一种传输信息的方法,基站和用户设备
CN110169149B (zh) 一种上行时序调整方法及终端
CN103107831B (zh) 一种基于2.4g单向无线通信协议的数据双向传输方法
WO2016054898A1 (zh) 数据传输方法及终端、计算机存储介质
CN113900985A (zh) Io和spi复用芯片、复用辅助芯片和数据交互方法
CN117715171B (zh) 时间同步方法、电子设备及存储介质
CN103702396B (zh) 一种网络终端自动配对的方法及装置
CN115065966B (zh) 终端和通信方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17854324

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 2017854324

Country of ref document: EP

Effective date: 20190322