The invention relates to a serial peripheral interface, in particular, to a logic control device of a serial peripheral interface, a master-slave system, and a master-slave switchover method therefor.
The Serial Peripheral Interface (SPI) Bus according to Wikipedia is a synchronous serial communication interface specification for chip communication. The prior art described in Taiwan Patent No. 1701555 (hereinafter referred to as the first case) mentions that the serial peripheral interface is commonly included in mobile devices to provide synchronous serial communication between a system-on-chip (SoC) processor and various peripheral devices. The SoC serves as a master device for SPI (hereinafter referred to as a master), and each peripheral device serves as a slave device for SPI (hereinafter referred to as a slave).
The SPI bus couples the master to all of the slaves. The master supplies a clock to clock lines in the SPI bus. All serial data exchanges between the masters and the slaves are synchronized with the clock signals. The master drives data to the slave via the master output slave input (MOSI) line. Each of the slaves can share the master input slave output (MISO) online to drive data to the masters. Since the MISO line is shared by the slaves, the SPI bus also includes a chip-select line for each of the slaves to provide access protocols to the shared MISO line.
Each of the slaves has its own chip-select line, so the SPI bus at each of the slaves is a bus with four wires to accommodate clock, MOSI, MISO, and chip select signaling. However, the SPI bus at the master is a bus with (3+N) wires, where N is the number of slaves that the master is connected to and is also equal to the number of chip-select lines. Each of the wires in the SPI bus is dedicated to its own pin, so that the number of pins at the master increases with the number of the slaves to which the master is connected.
For example, as shown in
In addition, the first case is further described. In order to solve the problem that the number of pins at the master increases with the number of slaves connected to the master, a multiplexer and I2C interface are added to the master and the slave, respectively. However, such a method has resulted in many problems, one of which is that the original masters and slaves are discarded, which leads to increased costs and waste. Another problem is that the circuit area inside the masters and the slaves is increased since the multiplexer and the embedded inter-integrated circuit interface are added to the internal circuits of the masters and the slaves in order to reduce the chip-select lines between the masters and the slaves. Still another problem is that the masters or the slaves should additionally confirm the various electrical characteristics of the derived lines since more lines are required between the multiplexer and the embedded inter-integrated circuit Interface. Further, one more problem is that all slaves can only be connected to one master.
Since all slaves 12 can only be connected to one master 10 whether traditionally or in the first case, as shown in
In summary, how to enable each of the masters to connect to different one of the slaves at the same time to fully use all the masters and the slaves in the traditional state where multiple masters are connected with multiple slaves under the premise of not needing too many multiplexers is an urgent problem to be solved.
In view of the problems in the prior art, an objective of the invention is to connect a logic control device between multiple masters and multiple slaves, and to enable the logic control device to control a connection state between each of the masters and each of the slaves at the same time.
According to the objective of the invention, a logic control device of a serial peripheral interface is provided, which includes a first logic unit, a second logic unit, a third logic unit, a fourth logic unit and a select unit, wherein the first logic unit is connected between chip-select lines of the N masters and chip-select lines of the M slaves, N and M being integers greater than or equal to two; the second logic unit is connected between clock lines of the masters and clock lines of the slaves; the third logic unit is connected between master output slave input lines of the masters and master output slave input lines of the slaves; the fourth logic unit is connected between master input slave output lines of the masters and master input slave output lines of the slaves; and logical relationships of the first logic unit, the second logic unit, the third logic unit and the fourth logic unit together define each of the master-slave connection relationships between the masters and the slaves; the select unit is connected with the first logic unit, the second logic unit, the third logic unit and the fourth logic unit, and each of the master-slave connection relationships is determined and selected to be used by the select unit; each of the master-slave connection relationships is that each of the masters simultaneously transmits information with only different one of the slaves respectively.
According to the objective of the invention, a master-slave system having the logic control device is further provided, which includes the masters, the slaves, and the logic control device, wherein each of the masters and each of the slaves are configured with a chip-select line, a clock line, a master output slave input line and a master input slave output line respectively, and each of the masters has only one chip-select line; the number of the chip-select lines of each of the masters does not increase with the number of the slaves; the logical control device is connected between each of the masters and each of the slaves, and defines the master-slave connection relationships between each of the masters and each of the slaves; each of the master-slave connection relationships is that each of the masters simultaneously transmits information with different one of the slaves respectively.
According to the objective of the invention, a switchover method for the master-slave system having the logic control device is further provided, which is applied to the master-slave system having the logic control device. The method includes steps of: providing the logic control device between the masters and the slaves, wherein the logical relationships of the first logic unit, the second logic unit, the third logic unit, and the fourth logic unit together define each of the master-slave connection relationships between the N masters and the M slaves, and each of the master-slave connection relationships is that each of the masters simultaneously transmits information with different one of the slaves respectively; confirming, by the select unit, which one of the master-slave connection relationships to use; connecting, by the logic control device, each of the masters to different one of the slaves according to the selected master-slave connection relationship.
The logic control device is a programmable logic device, and further is a simple programmable logic device (SPLD); the first logic unit, the second logic unit, the third logic unit, and the fourth logic unit are a first look-up-table (LUT) group, a second look-up-table group, a third look-up-table group, and a fourth look-up-table group of the programmable logic device or the simple programmable logic device; each of the look-up table groups has S look-up tables, wherein S is greater than or equal to M.
N and M are equal to two, i.e., there are two masters and two slaves, which are defined as a first master, a second master, a first slave, and a second slave respectively; the first look-up-table group, the second look-up-table group, the third look-up-table group, and the fourth look-up-table group have two look-up tables respectively, which define a first master-slave connection relationship and a second master-slave connection relationship, wherein the first master-slave connection relationship is that the first master transmits data with the first slave and the second master transmits data with the second slave, while the second master-slave connection relationship is that the first master transmits data with the second slave and the second master transmits data with the first slave.
The logic control device of the serial peripheral interface further includes a switch unit, wherein the switch unit is connected between the salves and the first logic unit, the second logic unit, and the third logic unit, and between the masters and the fourth logic unit; when the switch unit is turned on, the logic control device may output signals to the first logic unit, the second logic unit, the third logic unit, and the fourth logic unit; when the switch unit is turned off, the logic control device may not output signals to the first logic unit, the second logic unit, the third logic unit, and the fourth logic unit.
In summary, in the invention, the logic control device is used to control the serial peripheral Interface bus to transmit data in a one-to-one manner between each of the masters and each of the slaves at the same time, so that the problems mentioned in the prior art are completely solved.
As shown in
In order to allow the logic control device 3 to be switched so that each of the masters 4 and each of the slaves 5 are connected in a one-to-one manner at the same time, each of the masters 4 may further be selected to be switched and connected to a different slave 5. Therefore, in the invention, logical relationships of the first logic unit 30, the second logic unit 32, the third logic unit 34 and the fourth logic unit 36 together define a plurality of master-slave connection relationships between the N masters 4 and the M slaves 5. The select unit 37 provides the first logic unit 30, the second logic unit 32, the third logic unit 34 and the fourth logic unit 36 with input select signals to determine final logical relationships of the first logic unit 30, the second logic unit 32, the third logic unit 34 and the fourth logic unit 36 for further selecting to use one of the master-slave connection relationships, so that the logic control device 3 may simultaneously connect each of the masters 4 and each of the slaves 5 in a one-to-one manner, and each of the masters 4 may be selected to be connected to a different slave 5.
As shown in
In the invention, the logic control device 3 is a programmable logic device, and further is a simple programmable logic device; the first logic unit 30, the second logic unit 32, the third logic unit 34 and the fourth logic unit 36 are a first look-up-table (LUT) group, a second look-up-table group, a third look-up-table group, and a fourth look-up-table group of the programmable logic device or the simple programmable logic device; each of the look-up-table groups has S look-up tables, wherein S is greater than or equal to M. In the actual implementation of the invention, the logic control device 3 is not limited thereto, and any electronic device with a logic function may be the logic control device 3 in the invention.
In the invention, the logic control device 3 further includes a switch unit 38. In
In an embodiment of the invention, in order to facilitate the understanding of the invention, the invention is described under a situation where the logic control device 3 is the simple programmable logic device with Simple Programmable Logic Device of Model SLG46537V from German Merchant Dialog Semiconductor and two masters 4 as well as two slaves 5 as an example, wherein the two masters 4 and the two slaves 5 are respectively defined as a first master 60, a second master 62, a first slave 70 and a second slave 72, i.e., N and M are equal to two, and the logic control device 3 has 18 pins; the chip-select lines (MCS1˜MCSN, SCS1˜SCSM), the clock lines (MCLK1˜MCLKN, SCLK1˜SCLKM), the master output slave input lines (MMOSI1˜MMOSIN, SMOSI1˜SMOSIM) and the master input slave output lines (MMISO1˜MMISON, SMISO1˜SMISOM) of each of the masters 4 and each of the slaves 5 are connected with each of the pins respectively to form a total of 16 pins, and the other one and the last one of the pins are used for the select unit 37 and the switch unit 38 respectively.
The first look-up-table group, the second look-up-table group, the third look-up-table group and the fourth look-up-table group have two look-up tables respectively, which are a first to an eighth look-up tables (300, 302, 320, 322, 340, 342, 360, 362) respectively. The logical relationships established by the first to the eighth look-up tables are all the same, and include a first variable 311, a second variable 312, and a third variable 313, wherein the first variable 311 corresponds to potential changes of the select unit 37, the second variable 312 corresponds to potential changes of the first master 60, and the third variable 313 corresponds to potential changes of the second master 62 (as shown in
In the embodiment, when the switch unit 38 is in an enabled (high potential) state, no matter what kind of master-slave connection relationships is currently in, each of the masters 4 and each of the slaves 5 stop transmitting information with each other, no matter what kind of master-slave connection relationships is at this time. An equivalent circuit of the logic control device 3 of the embodiment is shown in
As shown in
In the invention, the logic control device 3 further includes the switch unit 38; the switch unit 38 is connected between each of the slaves and the first logic unit 30, the second logic unit 32 and the third logic unit 34, and between each of the masters 4 and the fourth logic unit 36. The logic control device 3 performs processing according to the following steps:
In summary, in the invention, the logic control device 3 is used to control each of the masters 4 and each of the slaves 5 of the serial peripheral interface bus to transmit data with each other in a one-to-one manner at the same time, which not only solves the problem that the traditional master 4 needs to be added with additional chip-select lines according to the number of slaves, but also solve the problem that any master 4 may not be selectively connected to one of the slaves 5 since the internal structure of the master 4 or the slave needs not to be changed in the invention. Further, the logic control device 3 does not need to use multiple multiplexers, so that any master 4 may be selectively connected to one of the slaves 5, and all the masters 4 may be connected to one of the slaves 5 at the same time, thereby completely solving the problems mentioned in the prior art.