CN107562666A - Method, system and the relevant apparatus of communication between devices based on spi bus - Google Patents

Method, system and the relevant apparatus of communication between devices based on spi bus Download PDF

Info

Publication number
CN107562666A
CN107562666A CN201710882738.9A CN201710882738A CN107562666A CN 107562666 A CN107562666 A CN 107562666A CN 201710882738 A CN201710882738 A CN 201710882738A CN 107562666 A CN107562666 A CN 107562666A
Authority
CN
China
Prior art keywords
spi
communication
frame
frame structure
slave units
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.)
Granted
Application number
CN201710882738.9A
Other languages
Chinese (zh)
Other versions
CN107562666B (en
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.)
Vtron Technologies Ltd
Vtron Group Co Ltd
Original Assignee
Vtron Group 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 Vtron Group Co Ltd filed Critical Vtron Group Co Ltd
Priority to CN201710882738.9A priority Critical patent/CN107562666B/en
Publication of CN107562666A publication Critical patent/CN107562666A/en
Application granted granted Critical
Publication of CN107562666B publication Critical patent/CN107562666B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Small-Scale Networks (AREA)

Abstract

This application discloses a kind of method of the communication between devices based on spi bus, including:SPI main equipments are connected with each SPI slave units using MISO lines, MOSI lines, SCLK lines and the NCS lines that quantity is 1;The default communication protocol of target SPI device identifying informations is carried according to the communication requirement generation between master-slave equipment, and communication protocol realization and the communication between each communication protocol SPI slave units are preset using communication protocol, to realize the communication between SPI master-slave equipments in the case of using only 1 communication protocol NCS line.This method only needs to select signal wire to can be realized as the determination of target electronic device, the read-write of data using 1 heel piece, is greatly saved the O&M cost that communication connection is established, and adds the utilization rate of wiring space.The application further simultaneously discloses a kind of system and relevant apparatus of the communication between devices based on spi bus, has above-mentioned beneficial effect.

Description

Method, system and the relevant apparatus of communication between devices based on spi bus
Technical field
The application is related to electronic equipment communication technical field, more particularly to a kind of communication between devices based on spi bus Method, system, device and computer-readable recording medium.
Background technology
Interconnection and interflow between multiple electronic equipments or electronic component, commonly uses bus connection, and conventional bus has SPI (Serial Peripheral Interface, Serial Peripheral Interface (SPI)) bus, IIC (Inter-Integrated Circuit, IC bus, be otherwise known as I2C) bus, CAN (Controller Area Network, controller local area network) bus Deng, and which kind of specifically chosen bus communication usually requires requirement and the bus of the size, transmission speed according to transmitted data amount Quantity several respects factor of signal and characteristic and the advantage and disadvantage selection for concentrating bus.
Wherein, CAN and be only to need 2 with signal wire the advantages of iic bus, multiple slave units can be hung in bus, Shortcoming is that transmission rate is relatively low relative to SPI device-speeds;Spi bus uses four signal wires, and transmission speed is fast, and shortcoming is to work as , it is necessary to each single chip selection signal of slave unit when slave unit has multiple, thus the signal wire needed when slave unit is more compared with It is more.When needing to be carried out at high speed communication between one master and multiple slaves equipment, the quantity of meeting chip selection signal line caused by using spi bus Excessively, cause very chaotic, take extremely limited wiring space.
So on the basis of how realizing high-speed communication using spi bus between the electronic equipment of one master and multiple slaves, there is provided It is a kind of need not often increase a slave unit also accordingly increase a heel piece select signal wire, communication connection to establish accurate, to save wiring empty Between, to reduce the communication between devices mechanism of O&M cost that communication connection is established be those skilled in the art's urgent problem to be solved.
The content of the invention
The purpose of the application is to provide a kind of method, system, device and the calculating of the communication between devices based on spi bus Machine readable storage medium storing program for executing, can on the basis of it realizes high-speed communication between the electronic equipment of one master and multiple slaves using spi bus Select signal wire to realize the determination of target electronic device, the read-write of data using 1 heel piece, be greatly saved what communication connection was established O&M cost, add the utilization rate of wiring space.
In order to solve the above technical problems, the application provides a kind of method of the communication between devices based on spi bus, this method Including:
Using quantity be 1 MISO lines, MOSI lines, SCLK lines and NCS lines by SPI main equipments and each SPI slave units It is connected;
The default communication protocols of target SPI device identifying informations are carried according to the communication requirement generation between master-slave equipment View, and the communication between each SPI slave units is realized using the default communication protocol, with using only 1 NCS line In the case of realize communication between SPI master-slave equipments.
Optionally, the default of target SPI device identifying informations is carried according to the communication requirement generation between master-slave equipment Communication protocol, including:
Started successively according to frame according to the communication requirement, frame type, device address, frame length, data and frame end Be sequentially generated SPI communication frame structure;
According to the difference of each several part parameter in the SPI communication frame structure, generation comprises at least inquiry frame, point-to-point writes number According to the default communication protocol including frame, point-to-point read data frame and broadcast frame.
Optionally, the communication between each SPI slave units is realized using the default communication protocol, including:
The concrete kind of SPI communication frame structure in the default communication protocol is determined according to the demand of outside input selection information Type;
According to the particular type, each several part carries out the setting of relevant parameter in the SPI communication frame structure, obtains mesh Mark frame structure;
The communication between the SPI main equipments and each SPI slave units is realized using the target frame structure.
Optionally, according to the particular type, each several part carries out the setting of corresponding parameter in the SPI communication frame structure, Target frame structure is obtained, including:
When the SPI main equipments need to inquire about the essential information of each SPI slave units, by the SPI communication frame knot The parameter of frame-type portion is arranged to inquire about frame in structure, obtains SPI inquiry frames;Wherein, the essential information include presence, It is at least one in status information, version information and fault message.
Optionally, the communication between the SPI main equipments and each SPI slave units is realized using the target frame structure, Including;
Each SPI slave units receive the SPI inquiries frame from the MOSI lines being connected with the SPI main equipments;
Using time-multiplexed mode by the essential information of each SPI slave units pass sequentially through the MISO lines transmit to The SPI main equipments.
Present invention also provides a kind of system of the communication between devices based on spi bus, the system includes:
Spi bus connection unit, for be using quantity 1 MISO lines, MOSI lines, SCLK lines and NCS lines by SPI Main equipment is connected with each SPI slave units;
Equipment communication unit, for carrying the identification of target SPI equipment according to the communication requirement generation between master-slave equipment The default communication protocol of information, and the communication between each SPI slave units is realized using the default communication protocol, with only The communication between SPI master-slave equipments is realized in the case of using 1 NCS line.
Optionally, the equipment communication unit includes:
SPI communication frame structure arranges subelement, for being started successively according to frame according to the communication requirement, frame type, sets SPI communication frame structure is sequentially generated for address, frame length, data and frame end;
Default communication protocol generation subelement, it is raw for the difference according to each several part parameter in the SPI communication frame structure Default communication protocol into including including at least inquiry frame, point-to-point write data frame, point-to-point read data frame and broadcast frame;
Particular type determination subelement, for selecting information to determine the default communication protocol according to the demand of outside input The particular type of middle SPI communication frame structure;
Target frame structure obtain subelement, for according to the particular type in the SPI communication frame structure each several part The setting of relevant parameter is carried out, obtains target frame structure;
Subelement is realized in communication, for realizing the SPI main equipments and each SPI from setting using the target frame structure Communication between standby.
Optionally, the target frame structure obtains subelement and included:
SPI inquires about frame setup module, for the parameter of frame-type portion in the SPI communication frame structure to be arranged to inquire about Frame, obtain SPI inquiry frames.
Present invention also provides a kind of communication between devices device based on spi bus, is somebody's turn to do the equipment room based on spi bus and leads to T unit includes:
Memory, for storing computer program;
Processor, the equipment based on spi bus as described in above-mentioned content is realized during for performing the computer program Between communicate method the step of.
Present invention also provides a kind of computer-readable recording medium, meter is stored with the computer-readable recording medium Calculation machine program, the equipment room based on spi bus as described in above-mentioned content is realized when the computer program is executed by processor The step of method of communication.
A kind of method of communication between devices based on spi bus provided herein, is 1 by using quantity SPI main equipments are connected by MISO lines, MOSI lines, SCLK lines and NCS lines with each SPI slave units;According between master-slave equipment Communication requirement generation carry the default communication protocol of target SPI device identifying informations, and utilize the default communication protocol The communication between each SPI slave units is realized, to realize in the case of using only 1 NCS line between SPI master-slave equipments Communication.
Obviously, technical scheme provided herein, merely with 1 NCS line by SPI main equipments and each SPI slave units After being connected, collocation carries the default communication protocol of target SPI device identifying informations, and changes this according to communication requirement and preset The content of communication protocol makes it have different functions.This method is real using spi bus between the electronic equipment of one master and multiple slaves On the basis of existing high-speed communication, using 1 heel piece signal wire can be selected to realize the determination of target electronic device, the read-write of data, pole The big O&M cost for saving communication connection and establishing, add the utilization rate of wiring space.The application additionally provides one simultaneously System, device and the computer-readable recording medium of communication between devices of the kind based on spi bus, have above-mentioned beneficial effect, It will not be repeated here.
Brief description of the drawings
, below will be to embodiment or existing in order to illustrate more clearly of the embodiment of the present application or technical scheme of the prior art There is the required accompanying drawing used in technology description to be briefly described, it should be apparent that, drawings in the following description are only this The embodiment of application, for those of ordinary skill in the art, on the premise of not paying creative work, can also basis The accompanying drawing of offer obtains other accompanying drawings.
Fig. 1 realizes the structural representation of communication connection between one master and multiple slaves SPI equipment in the prior art using spi bus Figure;
A kind of flow chart of the method for communication between devices based on spi bus that Fig. 2 is provided by the embodiment of the present application;
The flow chart of the method for another communication between devices based on spi bus that Fig. 3 is provided by the embodiment of the present application;
Fig. 4 by communication between devices of another that the embodiment of the present application provides based on spi bus method flow chart;
A kind of structured flowchart of the system for communication between devices based on spi bus that Fig. 5 is provided by the embodiment of the present application;
Fig. 6 is shown by the structure of the system for another communication between devices based on spi bus that the embodiment of the present application provides It is intended to.
Embodiment
The core of the application is to provide a kind of method, system, device and the calculating of the communication between devices based on spi bus Machine readable storage medium storing program for executing, can on the basis of it realizes high-speed communication between the electronic equipment of one master and multiple slaves using spi bus Select signal wire to realize the determination of target electronic device, the read-write of data using 1 heel piece, be greatly saved what communication connection was established O&M cost, add the utilization rate of wiring space.
To make the purpose, technical scheme and advantage of the embodiment of the present application clearer, below in conjunction with the embodiment of the present application In accompanying drawing, the technical scheme in the embodiment of the present application is clearly and completely described, it is clear that described embodiment is Some embodiments of the present application, rather than whole embodiments.Based on the embodiment in the application, those of ordinary skill in the art The all other embodiment obtained under the premise of creative work is not made, belong to the scope of the application protection.
Spi bus is a kind of high speed, full duplex, synchronous communication bus, four lines, section is taken on the pin of chip The about pin of chip, while to save space in PCB layout, there is provided it is convenient, just it is being in order at this characteristic easy to use, Nowadays increasing integrated chip this communication protocol, its four signal wire possessed are respectively:
(1) MISO-main equipment data input, slave unit data output;
(2) MOSI-main equipment data output, slave unit data input;
(3) SCLK-clock signal, is produced by main equipment;
(4) NCSn-slave unit piece selects enable signal, is controlled by main equipment.
The spi bus of standard, it is each slave unit in the case where a SPI main equipment is connected with multiple SPI slave units One piece of distribution selects enable signal, also just corresponding to need and SPI slave unit quantity identicals if multiple SPI slave units NCSn lines are enable signals to provide a piece for it and select.
Fig. 1 is referred to, Fig. 1 realizes communication connection between one master and multiple slaves SPI equipment in the prior art using spi bus Structural representation, enable signal is selected to the piece on the NCSn that needs with target SPI slave units will to be first connected before SPI equipment operations Low level is set to, other are selected enable signal to be set to high level, when target SPI slave units detect that the piece of itself selects enable signal For low level when, just as requested by the MISO lines that are connected with SPI main equipments to SPI main equipment output datas.So, In the case of SPI slave units are a fairly large number of, the NCSn line consistent with SPI quantity not only need certain space set interface, Wiring space is taken, is also faced with the higher grade other problems of O&M cost.
Below in conjunction with Fig. 2, a kind of side for communication between devices based on spi bus that Fig. 2 is provided by the embodiment of the present application The flow chart of method.
It specifically includes following steps:
S101:Using quantity be 1 MISO lines, MOSI lines, SCLK lines and NCS lines by SPI main equipments and each SPI from Equipment is connected;
The application is established on the basis of one master and multiple slaves equipment room needs to carry out high-speed data communication, from meeting high speed number According to the spi bus of communication, and be different from the prior art for each SPI slave units distribute one individually with SPI main equipment phases NCSn lines even, i.e., be using quantity 1 MISO lines, MOSI lines, SCLK lines and NCS lines by SPI main equipments and each SPI from Equipment is connected, and with a set of communication protocol that can realize same purpose of collocation creative on this basis, can subtract significantly The quantity of few NCSn lines, saves wiring space.
In other words, it is only necessary to which a NCSn signal wire, each SPI slave units share this root NCSn lines, without to original Equally, each SPI slave units are connected by single NCSn lines with SPI main equipments.
Specifically each SPI slave units how are enabled to share this root NCSn lines, it is varied first in connected mode, For example, it is contemplated that to each SPI slave units relative to the orientation of SPI main equipments, by the wire laying mode of the NCSn lines according to appropriate orientation It is arranged, the branch of parallel connection can also be being outputed from the NCSn lines apart from the position of each SPI slave units relative close, realized Share effect;Can also be achieved by other means, herein and be not specifically limited, should regard actual conditions combine each influence because Usually consider and select to be best suitable for the mode of itself.
S102:The default logical of target SPI device identifying informations is carried according to the communication requirement generation between master-slave equipment Believe agreement;
S103:The communication between each SPI slave units is realized using default communication protocol, with the feelings using only 1 NCS line The communication between SPI master-slave equipments is realized under condition.
On the basis of S101, S102 and S103 are intended to carry target according to the communication requirement generation between master-slave equipment The default communication protocol of SPI device identifying informations, and the communication between each SPI slave units is realized using default communication protocol, with The communication between SPI master-slave equipments is realized in the case of using only 1 NCS line.
The default communication protocol most important point seeks to carry the identification information of target SPI equipment, for target SPI Equipment accurately receive with SPI main equipments can precise positioning target, be in the prior art by the NCSn lines of physics simultaneously Low level is placed in position target SPI equipment, the application will be taken using the creative utilization of traditional identification method physically Default communication protocol with target SPI device identifying informations is realized.
Wherein, the default communication protocol be it is a kind of can position the information that target SPI is set at least, its form of expression is more Kind is various, for example, the frame structure for being divided into various pieces can be designed to, the frame structure can design by believing more as needed Breath collectively constitutes, and is put into SPI main equipments and each SPI slave units in the frame structure and determines with regard to the identification information that can be identified to realize Position target SPI equipment;Can also be a kind of corresponding relation inquiry table either other similar data that can realize identical function, Herein and it is not specifically limited, visual actual conditions combination concrete application scene, device category, unit type, support identification letter Type etc. each influence factor is ceased to consider and select most suitable mode.
Further, according to the difference of the frame structure each several part content, can play a part of also being not quite similar, Ke Yishi Now including traversal queries, write many purposes of data, reading according to this and including broadcast message.Further, can also be at this Set up writing function on SPI main equipments, the user record SPI equipment have received the data from which SPI slave unit, to which Individual SPI slave units have sent the information including what data etc. content, and can generate corresponding log query file, be easy to Subsequently inquired about and positioned.Specific manifestation form of each several part composition, log query file for frame structure etc. is not It is specifically limited, can voluntarily selects more suitable scheme.
Based on above-mentioned technical proposal, a kind of method for communication between devices based on spi bus that the embodiment of the present application provides, After merely with 1 NCS line, SPI main equipments are connected with each SPI slave units, collocation carries target SPI equipment identification letter The default communication protocol of breath, and the content for presetting communication protocol is changed according to communication requirement and makes it have different functions.Should On the basis of method realizes high-speed communication between the electronic equipment of one master and multiple slaves using spi bus, 1 heel piece choosing letter can be used Number line realizes the determination of target electronic device, the read-write of data, is greatly saved the O&M cost that communication connection is established, increase The utilization rate of wiring space.
Below in conjunction with Fig. 3, another communication between devices based on spi bus that Fig. 3 is provided by the embodiment of the present application The flow chart of method.
The present embodiment be directed in a upper embodiment how to generate in S102 and S103 default communication protocol and how profit Communication protocol is preset with this and realizes the specific restriction of made one that communicates, and other steps are substantially the same with a upper embodiment, phase Upper embodiment relevant portion is can be found in part, will not be repeated here.
It specifically includes following steps:
S201:Started successively according to frame according to communication requirement, frame type, device address, frame length, data and frame end Be sequentially generated SPI communication frame structure;
This step presets the form of expression of communication protocol using different frame structures as this, and according to principal and subordinate's SPI equipment Between communication requirement start successively according to frame, frame type, frame length, data and frame end are sequentially generated SPI communication frame Structure.
Wherein, the frame beginning in the SPI communication frame structure is the beginning part as the frame structure, containing special Identification coding, effect are to allow each identification terminal reading this partial content to be to judge that ensuing content belongs to One new frame structure, rather than it is previous or any one.
Frame type a, it can be understood as classification to frame structure, is that the purpose risen to the type frame structure is drawn Branch away, can including inquiry frame, it is point-to-point write, the polytype including point-to-point reading and broadcast frame, since it is considered that Different frame types may need different code encoding/decoding modes, supporting content analysis method etc., act as herein really Data division is laid the groundwork, so as to unscrambling data.
Device address, can be that physical address can also be logical address etc. even if address corresponding to target SPI equipment; Frame length, as the term suggests it is exactly the length of this frame structure, the guidance for continuing to understand backward as guiding;Data division is deposited The purpose really to be realized of the type frame structure;Frame end is initially an end signal relative to frame.
Sequence according to each part mentioned above forms the SPI communication frame structure, wherein, the SPI communication frame structure each several part The form of expression is varied, and the conversion of row information is entered for example with different systems, using different intervals and combination etc., this Place is simultaneously not specifically limited, and can be considered according to the restriction condition of actual conditions combination each side.
S202:According to the difference of each several part parameter in SPI communication frame structure, generation comprises at least inquiry frame, point-to-point write Default communication protocol including data frame, point-to-point read data frame and broadcast frame;
On the basis of S201, this step by actual parameter by inserting each several part in the SPI communication frame structure, and generation is extremely Few default communication protocol comprising including inquiry frame, point-to-point write data frame, point-to-point read data frame and broadcast frame.
Wherein, inquiry frame is the frame structure that SPI main equipments obtain each SPI slave units parameter information;It is point-to-point to write number It is that the SPI main equipments are wanted to write target data into a frame structure of target SPI slave units according to frame;Point-to-point read data frame It is that the SPI main equipments are wanted to read a frame structure of target data from target SPI slave units;Broadcast frame is that SPI equipment needs Some information are sent to a frame structure of all SPI slave units simultaneously.All types of frame structures are wanted to realize that its is respective Purpose, most important is exactly to position target SPI equipment, i.e., is known by the device address of precise positioning target SPI equipment Not, only need to be by each SPI slave units according to the equipment of itself although all SPI slave units can all receive all types of frame structures Location makes a decision with the device address in the frame structure received, judges whether it is that itself can carry out follow-up process.
S203:Information is selected to determine the specific of SPI communication frame structure in default communication protocol according to the demand of outside input Type;
S204:According to particular type, each several part carries out the setting of relevant parameter in SPI communication frame structure, obtains target frame Structure;
On the basis of S202, the demand selection information that S203 is intended to outside input determines SPI in the default communication protocol The specific manifestation form of communication frame structure, that is, determine it is which type of frame structure.And then by S204 according to S203 it is determined that The SPI communication frame structure of good particular type, and the setting of each several part parameter, the target frame structure completed are carried out successively.
Wherein, the form of expression of the demand selection information of the outside input is varied, can be inputted and set by external information The standby demand directly inputted selects information or information can be selected to be converted into accordingly position as touch display screen Demand selection information etc., herein and be not specifically limited.
S205:The communication between SPI main equipments and each SPI slave units is realized using target frame structure.
On the basis of S204, this step is intended to realize the SPI main equipments and each SPI slave units using the target frame structure Between communication, for example, realizing that the SPI main equipments obtain the parameter information of each SPI slave units by inquiring about frame, certainly, also may be used To realize other purposes using other types of frame structure.
Below in conjunction with Fig. 4, Fig. 4 is by communication between devices of another that the embodiment of the present application provides based on spi bus The flow chart of method.
The present embodiment is to be directed to how to obtain target frame structure in S204 and S205 in a upper embodiment and how to utilize The target frame structure realize that the communication between SPI main equipments and each SPI slave units made one is specific to be limited, other steps with A upper embodiment is substantially the same, and same section can be found in an embodiment relevant portion, will not be repeated here.
It specifically includes following steps:
S301:When SPI main equipments need to inquire about the essential information of each SPI slave units, by frame class in SPI communication frame structure The parameter of type part is arranged to inquire about frame, obtains SPI inquiry frames;
S302:Each SPI slave units receive SPI inquiry frames from the MOSI lines being connected with SPI main equipments;
S303:The essential information of each SPI slave units is passed sequentially through into MISO lines using time-multiplexed mode to transmit to SPI Main equipment;
This implementation carries out the description of a specific implementation by inquiring about the example of frame, wherein a because only that MISO The reason of line, if all SPI slave units send the parameter of itself to SPI main equipments within same time or same time interval Information, inherently cause mixing and can not understanding for parameter information, therefore solve this hidden danger using time-multiplexed mode herein. It is of course also possible to use other manner realizes the order transfer of parameter information, such as packet transmission, zero padding method etc., herein simultaneously It is not specifically limited, should be considered depending on actual conditions with reference to each restraining factors.
Based on above-mentioned technical proposal, a kind of method for communication between devices based on spi bus that the embodiment of the present application provides, After merely with 1 NCS line, SPI main equipments are connected with each SPI slave units, collocation carries target SPI equipment identification letter The default communication protocol of breath, and the content for presetting communication protocol is changed according to communication requirement and makes it have different functions.Should On the basis of method realizes high-speed communication between the electronic equipment of one master and multiple slaves using spi bus, 1 heel piece choosing letter can be used Number line realizes the determination of target electronic device, the read-write of data, is greatly saved the O&M cost that communication connection is established, increase The utilization rate of wiring space.
Because situation is complicated, it can not enumerate and be illustrated, those skilled in the art should be able to recognize more the application The basic skills principle combination actual conditions of offer may have many examples, in the case where not paying enough creative works, Should be in the protection domain of the application.
Fig. 5 is referred to below, a kind of communication between devices based on spi bus that Fig. 5 is provided by the embodiment of the present application The structured flowchart of system.
The system can include:
Spi bus connection unit 100, MISO lines, MOSI lines, SCLK lines and NCS lines for using quantity being 1 will SPI main equipments are connected with each SPI slave units;
Equipment communication unit 200, know for carrying target SPI equipment according to the communication requirement generation between master-slave equipment The default communication protocol of other information, and the communication between each SPI slave units is realized using default communication protocol, with using only 1 The communication between SPI master-slave equipments is realized in the case of root NCS lines.
Wherein, equipment communication unit 200 includes:
SPI communication frame structure arrange subelement, for being started successively according to frame according to communication requirement, frame type, frame length, Data and frame end are sequentially generated SPI communication frame structure;
Default communication protocol generation subelement, for the difference according to each several part parameter in SPI communication frame structure, generation is extremely Few default communication protocol comprising including inquiry frame, point-to-point write data frame, point-to-point read data frame and broadcast frame;
Particular type determination subelement, for selecting information to determine in default communication protocol according to the demand of outside input The particular type of SPI communication frame structure;
Target frame structure obtains subelement, for according to particular type, each several part to be carried out accordingly in SPI communication frame structure The setting of parameter, obtain target frame structure;
Subelement is realized in communication, for realizing the communication between SPI main equipments and each SPI slave units using target frame structure.
Wherein, target frame structure obtains subelement and included:
SPI inquires about frame setup module, for the parameter of frame-type portion in SPI communication frame structure to be arranged to inquire about frame, Obtain SPI inquiry frames.
Wherein, communication realizes that subelement includes:
Frame receiving module is inquired about, SPI inquiry frames are received from the MOSI lines being connected with SPI main equipments for each SPI slave units;
Time multiplexed transmission module, for being led to the essential information of each SPI slave units successively using time-multiplexed mode MISO lines are crossed to transmit to SPI main equipments.
Above each unit can apply in the specific concrete instance of following one:
Refer to Fig. 6, Fig. 6 is by another communication between devices based on spi bus that the embodiment of the present application provides The structural representation of system.
Whole communication system is made up of one piece of master control borad and 7 block signal collection plates.Pass through between master control borad and signal acquiring board Bottom plate connects.Master control borad is shown in that needs are configured and signal acquisition to each signal acquiring board, is not required between each signal acquiring board Communication.Because transmitted data amount is larger, iic bus and CAN can not meet performance requirement, plate signal wire limited amount, So using spi bus, and a set of communication protocol is defined, a chip selection signal is shared, meets equipment transmission demand.
Communication protocol is divided into four kinds of frame types:(1) frame is inquired about;(2) point-to-point write data frame;(3) point-to-point read data frame; (4) broadcast frame.
Four kinds of frame formats are described in detail below:
1) frame is inquired about:
Piece is selected enable signal line (NCSn) to be arranged to low level by SPI main equipments, exports clock and data.
Its specific frame structure composition is as follows:
Frame start frame type frame length data frame end
Inquire about frame
Now SPI slave units can receive data, and judgment frame type is inquiry frame, then ready data exists simultaneously Output data on MISO lines.To avoid conflicting, each SPI slave units use time-multiplexed mode according to the clock of SPI main equipments. SPI slave units 1 are sent in the DATA1 times, and the output of other times pin is high level, and SPI slave units 2 are sent in the DATA2 times, The output of other times pin is high level, by that analogy.The DATA periods that each SPI slave units are sent send some numbers According to:
DATA1 DATA2 DATA3 DATA4 DATA5 DATA6 DATA7
Another flexible method is:If the valid data of each SPI slave units are N, SPI slave units quantity is M, Then send N and be multiplied by M data, be i.e. valid data are N, other positions filling data 0xFF, equivalent in other times section pin Export high level.
Inquire about frame and be used for the essential information that SPI main equipments inquire about each SPI slave units, such as presence, status information, version Information, fault message etc., all data to be collected being formed a packet, disposably inquiry is returned, and can also be divided into Multiple frame inquiries.
2) point-to-point write data frame
If necessary to only send the data to some SPI slave unit, point-to-point transmission frame format, i.e. data can be used Partial length, can be several bytes or a few K bytes, herein can according to demand and slave unit disposal ability it is true It is fixed.
Whether the device address that each SPI slave units judge to receive after receiving according to frame category and device address is this SPI The address of equipment, the address for not being this SPI equipment, then by MISO high resistants.If it does, then prepare to receive and handle hair The data come.
Frame start frame type equipment address frame length data frame end
It is point-to-point to write a few bytes in datum target SPI device addresses or a few K bytes
3) point-to-point read data frame
SPI main equipments, which first write data notification, to be needed to read the device address of which SPI slave unit, and target SPI slave units are received Output data and high resistant are judged whether according to device address after, SPI main equipments are responsible for reading data.
Frame start frame type equipment address frame length data frame end
The point-to-point several bytes in reading datum target SPI device addresses or a few K bytes
4) broadcast frame
Broadcast frame is used for the information broadcast transmission of main equipment to all units.
Frame start frame type equipment address frame length data frame end
The address of all SPI slave units of broadcast frame
To the coding of device address, if bit positions are 1, can illustrate by the way of each slave unit takes 1bit Device address is selected, if complete 1 explanation in bit positions all receives to broadcast all slave units, if the more than one that bit positions are 1 is said Bright is multicast.
Such as 8 slave units, 1 byte can be used as device address, bit7~bit0 represent respectively 1 from Equipment, bit0 is that 1 (device address numerical value 0x01) illustrates that No. 1 slave unit is selected, if bit0, bit3 are 1 (device address number Value 0x03) No. 1 and No. 2 equipment are selected, if bit7~bit0 illustrates that all devices are chosen for 1 (device address 0xff) In.
Present invention also provides a kind of communication between devices device based on spi bus, can include memory and processor, Wherein, there is computer program in the memory, when the processor calls the computer program in the memory, it is possible to achieve on State the step of embodiment provides.Certain setting device can also include various necessary network interfaces, power supply and other Parts etc..
Present invention also provides a kind of computer-readable recording medium, there is computer program thereon, the computer program The step of above-described embodiment provides can be realized when being performed terminal or computing device.The storage medium can include:U Disk, mobile hard disk, read-only storage (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disc or CD etc. are various can be with the medium of store program codes.
It is apparent to those skilled in the art that for convenience and simplicity of description, the system of foregoing description, The specific work process of device and unit, the corresponding process in preceding method embodiment is may be referred to, will not be repeated here.
Each embodiment is described by the way of progressive in specification, and what each embodiment stressed is and other realities Apply the difference of example, between each embodiment identical similar portion mutually referring to.For device disclosed in embodiment Speech, because it is corresponded to the method disclosed in Example, so description is fairly simple, related part is referring to method part illustration .
Professional further appreciates that, with reference to the unit of each example of the embodiments described herein description And algorithm steps, can be realized with electronic hardware, computer software or the combination of the two, in order to clearly demonstrate hardware and The interchangeability of software, the composition and step of each example are generally described according to function in the above description.These Function is performed with hardware or software mode actually, application-specific and design constraint depending on technical scheme.Specialty Technical staff can realize described function using distinct methods to each specific application, but this realization should not Think to exceed scope of the present application.
Specific case used herein is set forth to the principle and embodiment of the application, and above example is said It is bright to be only intended to help and understand the present processes and its core concept.It should be pointed out that the ordinary skill for the art For personnel, on the premise of the application principle is not departed from, some improvement and modification, these improvement can also be carried out to the application Also fallen into modification in the application scope of the claims.
It should also be noted that, in this manual, such as first and second or the like relational terms be used merely to by One entity or operation make a distinction with another entity or operation, and not necessarily require or imply these entities or operation Between any this actual relation or order be present.Moreover, term " comprising ", "comprising" or its any other variant meaning Covering including for nonexcludability, so that process, method, article or equipment including a series of elements not only include that A little key elements, but also other key elements including being not expressly set out, or also include for this process, method, article or The intrinsic key element of equipment.In the absence of more restrictions, the key element limited by sentence "including a ...", is not arranged Except other identical element in the process including key element, method, article or equipment being also present.

Claims (10)

  1. A kind of 1. method of the communication between devices based on spi bus, it is characterised in that including:
    SPI main equipments are connected with each SPI slave units using MISO lines, MOSI lines, SCLK lines and the NCS lines that quantity is 1 Connect;
    The default communication protocol of target SPI device identifying informations is carried according to the communication requirement generation between master-slave equipment, and The communication between each SPI slave units is realized using the default communication protocol, with the feelings using only 1 NCS line The communication between SPI master-slave equipments is realized under condition.
  2. 2. according to the method for claim 1, it is characterised in that carried according to the communication requirement generation between master-slave equipment The default communication protocol of target SPI device identifying informations, including:
    Started successively according to frame according to the communication requirement, frame type, device address, frame length, data and frame end it is suitable Sequence generates SPI communication frame structure;
    According to the difference of each several part parameter in the SPI communication frame structure, generation comprises at least inquiry frame, point-to-point writes data Default communication protocol including frame, point-to-point read data frame and broadcast frame.
  3. 3. method according to claim 1 or 2, it is characterised in that using the default communication protocol realize with it is each described Communication between SPI slave units, including:
    The particular type of SPI communication frame structure in the default communication protocol is determined according to the demand of outside input selection information;
    According to the particular type, each several part carries out the setting of relevant parameter in the SPI communication frame structure, obtains target frame Structure;
    The communication between the SPI main equipments and each SPI slave units is realized using the target frame structure.
  4. 4. according to the method for claim 3, it is characterised in that according to the particular type in the SPI communication frame structure Middle each several part carries out the setting of corresponding parameter, obtains target frame structure, including:
    When the SPI main equipments need to inquire about the essential information of each SPI slave units, by the SPI communication frame structure The parameter of frame-type portion is arranged to inquire about frame, obtains SPI inquiry frames;Wherein, the essential information includes presence, state It is at least one in information, version information and fault message.
  5. 5. according to the method for claim 4, it is characterised in that realize the SPI main equipments using the target frame structure With the communication between each SPI slave units, including;
    Each SPI slave units receive the SPI inquiries frame from the MOSI lines being connected with the SPI main equipments;
    The essential information of each SPI slave units is passed sequentially through into the MISO lines using time-multiplexed mode to transmit to described SPI main equipments.
  6. A kind of 6. system of the communication between devices based on spi bus, it is characterised in that including:
    Spi bus connection unit, MISO lines, MOSI lines, SCLK lines and NCS lines for using quantity being 1 set SPI master It is standby to be connected with each SPI slave units;
    Equipment communication unit, for carrying target SPI device identifying informations according to the communication requirement generation between master-slave equipment Default communication protocol, and realize the communication between each SPI slave units using the default communication protocol, with using only The communication between SPI master-slave equipments is realized in the case of 1 NCS line.
  7. 7. system according to claim 6, it is characterised in that the equipment communication unit includes:
    SPI communication frame structure arranges subelement, for being started successively according to frame according to the communication requirement, frame type, equipment Location, frame length, data and frame end are sequentially generated SPI communication frame structure;
    Default communication protocol generation subelement, for the difference according to each several part parameter in the SPI communication frame structure, generation is extremely Few default communication protocol comprising including inquiry frame, point-to-point write data frame, point-to-point read data frame and broadcast frame;
    Particular type determination subelement, for selecting information to determine in the default communication protocol according to the demand of outside input The particular type of SPI communication frame structure;
    Target frame structure obtains subelement, for according to the particular type, each several part to be carried out in the SPI communication frame structure The setting of relevant parameter, obtain target frame structure;
    Subelement is realized in communication, for being realized using the target frame structure between the SPI main equipments and each SPI slave units Communication.
  8. 8. system according to claim 7, it is characterised in that the target frame structure, which obtains subelement, to be included:
    SPI inquires about frame setup module, for the parameter of frame-type portion in the SPI communication frame structure to be arranged to inquire about frame, Obtain SPI inquiry frames.
  9. A kind of 9. communication between devices device based on spi bus, it is characterised in that including:
    Memory, for storing computer program;
    Processor, realize during for performing the computer program as described in any one of claim 1 to 5 based on spi bus The step of method of communication between devices.
  10. 10. a kind of computer-readable recording medium, it is characterised in that be stored with computer on the computer-readable recording medium Program, the setting based on spi bus as described in any one of claim 1 to 5 is realized when the computer program is executed by processor The step of method to be communicated between standby.
CN201710882738.9A 2017-09-26 2017-09-26 Method, system and related device for communication between devices based on SPI bus Active CN107562666B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710882738.9A CN107562666B (en) 2017-09-26 2017-09-26 Method, system and related device for communication between devices based on SPI bus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710882738.9A CN107562666B (en) 2017-09-26 2017-09-26 Method, system and related device for communication between devices based on SPI bus

Publications (2)

Publication Number Publication Date
CN107562666A true CN107562666A (en) 2018-01-09
CN107562666B CN107562666B (en) 2020-10-23

Family

ID=60982483

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710882738.9A Active CN107562666B (en) 2017-09-26 2017-09-26 Method, system and related device for communication between devices based on SPI bus

Country Status (1)

Country Link
CN (1) CN107562666B (en)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108055186A (en) * 2018-01-30 2018-05-18 浙江鸿泉车联网有限公司 A kind of principal and subordinate processor communication means and device
CN108768450A (en) * 2018-06-01 2018-11-06 威创集团股份有限公司 Communication means and system, computer storage media
CN109240971A (en) * 2018-09-26 2019-01-18 威创集团股份有限公司 Communication means, apparatus and system
CN109359073A (en) * 2018-09-18 2019-02-19 深圳吉迪思电子科技有限公司 A kind of communication between devices method and apparatus topological structure based on spi bus
CN109639379A (en) * 2018-12-20 2019-04-16 武汉耐普登科技有限公司 Sensor module and sensing system
CN111625487A (en) * 2020-04-17 2020-09-04 惠州市德赛西威汽车电子股份有限公司 SPI communication system and communication method thereof
CN112822002A (en) * 2021-01-04 2021-05-18 北京地平线信息技术有限公司 SPI (Serial peripheral interface) -based communication method and device, electronic equipment and storage medium
CN114138703A (en) * 2022-02-07 2022-03-04 成都时识科技有限公司 Method, device and chip for communication based on serial peripheral interface
CN115061961A (en) * 2022-06-29 2022-09-16 西安易朴通讯技术有限公司 SPI-based communication method and device
CN115080477A (en) * 2022-05-30 2022-09-20 杭州初灵信息技术股份有限公司 Serial communication method and system

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN2682480Y (en) * 2003-12-31 2005-03-02 上海贝岭股份有限公司 SPI synchronous serial communication interface circuit integrated in a chip
CN2710264Y (en) * 2004-03-09 2005-07-13 国电南京自动化股份有限公司 Time-division multiple real-time communication bus
CN1637256A (en) * 2004-01-07 2005-07-13 株式会社日立制作所 Data communication apparatus and controller using the same
CN101174253A (en) * 2006-06-02 2008-05-07 旺宏电子股份有限公司 Method and apparatus for communicating data over multiple pins of a multi-mode bus
CN102508812A (en) * 2011-11-30 2012-06-20 上海大学 Dual-processor communication method based on SPI (serial peripheral interface) bus
WO2012155674A1 (en) * 2011-07-25 2012-11-22 中兴通讯股份有限公司 Concurrent access method and system and interface device
US20130111085A1 (en) * 2011-10-28 2013-05-02 Sumitomo Electric Industries, Ltd. Apparatus installing devices controlled by mdio or spi protocol and method to control the same
CN103377170A (en) * 2012-04-26 2013-10-30 上海宝信软件股份有限公司 Inter-heterogeneous-processor SPI (serial peripheral interface) high speed two-way peer-to-peer data communication system
CN104133792A (en) * 2013-05-03 2014-11-05 珠海全志科技股份有限公司 RSB communication method and RSB communication system
US20150100716A1 (en) * 2013-10-09 2015-04-09 Goodrich Corporation Systems and methods of using an spi controller
US20150103845A1 (en) * 2012-10-11 2015-04-16 Jiangsu Xidiannanzi Smart Electric Power Equipment Co., Ltd Synchronization time-division multiplexing bus communication method adopting serial communication interface

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN2682480Y (en) * 2003-12-31 2005-03-02 上海贝岭股份有限公司 SPI synchronous serial communication interface circuit integrated in a chip
CN1637256A (en) * 2004-01-07 2005-07-13 株式会社日立制作所 Data communication apparatus and controller using the same
CN2710264Y (en) * 2004-03-09 2005-07-13 国电南京自动化股份有限公司 Time-division multiple real-time communication bus
CN101174253A (en) * 2006-06-02 2008-05-07 旺宏电子股份有限公司 Method and apparatus for communicating data over multiple pins of a multi-mode bus
WO2012155674A1 (en) * 2011-07-25 2012-11-22 中兴通讯股份有限公司 Concurrent access method and system and interface device
US20130111085A1 (en) * 2011-10-28 2013-05-02 Sumitomo Electric Industries, Ltd. Apparatus installing devices controlled by mdio or spi protocol and method to control the same
CN102508812A (en) * 2011-11-30 2012-06-20 上海大学 Dual-processor communication method based on SPI (serial peripheral interface) bus
CN103377170A (en) * 2012-04-26 2013-10-30 上海宝信软件股份有限公司 Inter-heterogeneous-processor SPI (serial peripheral interface) high speed two-way peer-to-peer data communication system
US20150103845A1 (en) * 2012-10-11 2015-04-16 Jiangsu Xidiannanzi Smart Electric Power Equipment Co., Ltd Synchronization time-division multiplexing bus communication method adopting serial communication interface
CN104133792A (en) * 2013-05-03 2014-11-05 珠海全志科技股份有限公司 RSB communication method and RSB communication system
US20150100716A1 (en) * 2013-10-09 2015-04-09 Goodrich Corporation Systems and methods of using an spi controller

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108055186A (en) * 2018-01-30 2018-05-18 浙江鸿泉车联网有限公司 A kind of principal and subordinate processor communication means and device
CN108055186B (en) * 2018-01-30 2020-08-25 浙江鸿泉车联网有限公司 Master-slave processor communication method and device
CN108768450A (en) * 2018-06-01 2018-11-06 威创集团股份有限公司 Communication means and system, computer storage media
CN109359073A (en) * 2018-09-18 2019-02-19 深圳吉迪思电子科技有限公司 A kind of communication between devices method and apparatus topological structure based on spi bus
CN109240971A (en) * 2018-09-26 2019-01-18 威创集团股份有限公司 Communication means, apparatus and system
CN109639379A (en) * 2018-12-20 2019-04-16 武汉耐普登科技有限公司 Sensor module and sensing system
CN111625487A (en) * 2020-04-17 2020-09-04 惠州市德赛西威汽车电子股份有限公司 SPI communication system and communication method thereof
CN111625487B (en) * 2020-04-17 2024-05-31 惠州市德赛西威汽车电子股份有限公司 SPI communication system and communication method thereof
CN112822002A (en) * 2021-01-04 2021-05-18 北京地平线信息技术有限公司 SPI (Serial peripheral interface) -based communication method and device, electronic equipment and storage medium
CN114138703A (en) * 2022-02-07 2022-03-04 成都时识科技有限公司 Method, device and chip for communication based on serial peripheral interface
CN114138703B (en) * 2022-02-07 2022-05-03 成都时识科技有限公司 Method, device and chip for communication based on serial peripheral interface
CN115080477A (en) * 2022-05-30 2022-09-20 杭州初灵信息技术股份有限公司 Serial communication method and system
CN115080477B (en) * 2022-05-30 2024-01-30 杭州初灵信息技术股份有限公司 Method and system for serial communication
CN115061961A (en) * 2022-06-29 2022-09-16 西安易朴通讯技术有限公司 SPI-based communication method and device

Also Published As

Publication number Publication date
CN107562666B (en) 2020-10-23

Similar Documents

Publication Publication Date Title
CN107562666A (en) Method, system and the relevant apparatus of communication between devices based on spi bus
CN102523129B (en) Universal avionics bus test analysis method and device
CN103064805B (en) SPI controller and communication means
CN111294413B (en) Method, device and readable medium for determining Internet Protocol (IP) address
CN103439677A (en) Method and system for detecting numeration table meter
CN101089838A (en) Method for implementing 12C read-write sequence
CN103200078A (en) Gateway, communication network and data processing method
CN201035568Y (en) USB equipment logical numbering and physical numbering mapping device
CN204331878U (en) Control circuit in a kind of managing system of car parking
CN103069793A (en) System and method for mapping audio and video streams from audio/video source to multiple audio/video sinks
CN104461603B (en) A kind of information processing method and electronic equipment
CN202385128U (en) Gateway and communication network
CN104680769A (en) Bluetooth-to-infrared meter reading system of intelligent mobile phone
CN103856466A (en) Acquisition terminal device capable of configuring protocols automatically
CN202693680U (en) M-BUS three-phase electronic type electric energy meter
CN204992516U (en) Computer protection device and power equipment
CN105093937B (en) Building control system designs device and method
CN208172840U (en) Equipment management system and warehouse management system
CN102722975A (en) Method and system for reading data of electricity meter based on PROFIBUS
CN206004851U (en) A kind of Set Top Box of tape swap machine function
CN202145308U (en) Multi-master module management interface module of severe-environment-resistant computer
CN204761798U (en) Restructural multichannel lighting control device
CN205943043U (en) Power utilization information acquisition system
CN103580928A (en) System and method for visually controlling and operating devices
CN204925753U (en) Instrument monitored control system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant