Computing devices frequently include a variety of components, such as peripheral integrated circuits, microcontrollers, etc. Such components are configured to exchange data by transmitting and interpreting signals according to a communication protocol. There are a variety of communication protocols that are currently in use. For example, some computing device components are configured to communicate using inter-integrated circuit (I2C) protocol while other computing device components are configured to communicate using serial peripheral interface (SPI) protocol. Signals transmitted to a computing device based on a particular protocol may be interpreted incorrectly if the computing device is not configured to operate on data according to the particular protocol. Accordingly, an I2C device may be unable to properly process data received from a SPI device and a SPI device may be unable to properly process data received from an I2C device.
Components that can switch from operating according to one protocol to operating according to another protocol have been developed to provide a more versatile product for end users and to simplify inventory requirements for sellers. Such components include one or more dedicated pins configured to toggle the device between operating various protocols. However, incorporating such dedicated pins in an interface of a component increases a size of the interface or sacrifices a data pin.
Disclosed is an apparatus that is configured to operate according to more than one communication protocol. Further, methods of operating such an apparatus are disclosed. In some implementations, the apparatus is configured to operate according to I2C and SPI protocols. The apparatus is configured to concurrently monitor signals received at input pins according to more than one protocol (e.g., I2C and SPI) and to automatically detect which of the protocols was used to transmit the signals. The apparatus then stops monitoring the input pins for the other protocol(s) and continues functioning according to the detected protocol.
Thus, the disclosed apparatus may be used in systems that operate according to any one of several different protocols. Advantageously, the disclosed apparatus is able to detect which protocol to use automatically without monitoring a dedicated protocol selection pin or receiving a message explicitly identifying a protocol to use for communication (e.g., a communication configuration/setup message).
A disclosed method includes receiving signals at pins of an interface. The method further includes concurrently processing the signals according to a first protocol at first components of the interface and according to a second protocol at second components of the interface. The method further includes transmitting a reset signal from the first components to the second components to disable the second components in response to determining, at the first components, that the signals received at the pins correspond to the first protocol.
A disclosed device includes an interface. The interface includes a plurality of pins. The interface further includes first components configured to interpret signals received at the plurality of pins according to a first protocol. The device further includes second components configured to the interpret signals received at the plurality of pins according to a second protocol. The first components are configured to transmit a reset signal to the second components to disable the second components in response to a determination that the signals received at the pins correspond to the first protocol. Further, the second components are configured to transmit a second reset signal to the first components to disable the first components in response to a determination that the signals received at the pins correspond to the second protocol.
For a detailed description of various examples, reference will now be made to the accompanying drawings in which:
Referring to
In the illustrated example, the device 101 includes look-up tables 120 coupled to the interface via a bus 118. In addition, the device 101 includes an electrically erasable programable read-only memory (EEPROM) 122 coupled to the bus 118. Data received via the interface 102 is stored in the EEPROM 122 and the look-up tables 120 and is used by the device 101 to control operations of various other components of the device 101.
The interface 102 is configured to automatically detect a communication protocol used to transmit signals to the interface 102 from an external device, as explained further below, and then to use that communication protocol to interpret received signals and to transmit signals. Accordingly, the device 101 can be coupled to and communicate with another device that operates according to any one of several supported protocols. In the illustrated example, the interface 102 is configured to operate according to both inter-integrated circuit (I2C) protocol and serial peripheral interface (SPI) protocol but different combinations of protocols may be supported in other implementations. The interface 102 includes a first pin 104, a second pin 106, a third pin 108, a fourth pin 110, and a fifth pin 112.
The interface 102 monitors signals received by the pins 102-112 and sends the signals to both interface components associated with I2C communication and interface components associated with SPI communication. Each of the pins 104-112 is thus mapped to both an I2C signal and an SPI signal. At least some of the mappings do not map analogous signals in the different protocols to the same pin. To illustrate, in the illustrated example, a clock signal for SPI (e.g., a serial clock signal (SCLK)) is mapped to the fifth pin 112 while a clock signal for I2C (e.g., a serial clock (SCL)) is mapped to the first pin 104. Because at least some analogous signals from the two different protocols are mapped to different pins, signals transmitted to the interface 102 according to one of the protocols will be recognized by the corresponding protocol components of the interface 102 while being unrecognized by the other protocol components of the interface 102. In the illustrated example, the first pin 104 is mapped to a chip select signal (
As explained further below, the I2C components of the interface 102 monitor the pins assigned to SCL (e.g., the first pin 104) and SDA (e.g., the second pin 106) to determine whether received signals are I2C signals and the SPI components of the interface simultaneously monitor the pins assigned to
Thus, the device 101 may be used in conjunction with a greater variety of devices as compared to a device that includes an interface that only operates according to a single protocol. Further, the interface 102 may be smaller or include more data pins as compared to an interface that relies on a dedicated pin to switch between protocols. In addition, because the interface 102 automatically detects a communication protocol used to transmit signals to the interface 102, a device communicating with the interface 102 need not send a special configuration message to the device 101 in order for the interface 102 to select an appropriate protocol. Thus, devices that communicate with the device 101 need not be modified to support the ability of the device 101 to operate according to more than one protocol.
Referring to
The SPI finite state machine 228 receives a SPI reset line 220, an SPI finite state machine reset line 222, and an SCLK line 226. The SCLK line 226 is coupled to a pin of the interface that includes the SPI components 210. For example, the SCLK line 226 may be coupled to the fifth pin 112 of the interface 102. The SPI finite state machine 228 monitors the SCLK line to determine whether a SPI frame has been received and drives an SPI done line 232 based on the determination. The SPI reset line 220 is driven by the I2C components 258. Further, while not illustrated, the SPI reset line 220 may correspond to the CSN line 212. The SPI finite state machine 228 is configured to drive a SPI clear (CLR) line 218 based on the SCLK line 226. The first flip flop device 214 drives an SPI start line 216 based on the SPI CLR line 218 and an inverted CS not (CSN) line 212. As used herein CSN and
The first AND gate 230 receives the SPI start line 216 and the SCLK line 226 and drives an SPI shift register clock line 244 accordingly. The SPI shift register 241 includes flip flops clocked by the SPI shift register clock line 244. When the SPI start line 216 is high, the SPI shift register clock line 244 matches the SCLK line 226. When the SPI start line 216 is low, the SPI shift register clock line 244 is low and the SPI shift register 241 is disabled. Thus, the SPI finite state machine 228 is configured to disable the SPI shift register 241 based on the SPI reset line 220. As illustrated, the SPI shift register 241 is configured to receive and store data from an SPI data in line 242 when enabled. The SPI data in line 242 may be coupled to the fourth pin 110 of the interface 102.
The SPI finite state machine 228 drives an SPI done line 232 based on whether the SPI finite state machine 228 has detected a complete SPI frame. The SPI finite state machine 228 determines whether a complete SPI frame has been detected based on a count of pulses on the SCLK line 226 while the SPI reset line 220 (i.e., the CSN line 212) is low. The SPI finite state machine 228 is configured to prevent the SCLK count from incrementing in response to detecting that the SPI finite state machine reset line 222 is high. The first multiplexor 234 receives a high signal and an I2C reset line 240 as inputs and selects an output based on a value of the SPI done line 232. The second flip flop device 236 receives output of the first multiplexor 234 as input, is clocked by the CSN line 212, and drives the I2C reset line 240 accordingly.
The first multiplexor 234 is configured to select the I2C reset line 240 as output in response to the SPI done line 232 having a low value. Further, the second flip flop device 236 initially stores a low signal. Accordingly, while the SPI done line 232 is low, the second flip flop device 236 continues to store and output a low signal responsive to the CSN line 212. In contrast, the first multiplexor 234 is configured to select the high signal in response to detecting the SPI done line 232 is high. Upon detecting a rising edge of the CSN line 212 and a high value from the first multiplexor 234, the second flip flop device 236 begins driving the I2C reset line 240 at a high value. Once the I2C signal is driven high, both values received by the multiplexor are high and so the second flip flop device 236 outputs a high value on the I2C reset line 240 regardless of a condition of the SPI done line 232. As explained further below, a high value on the I2C reset line 240 disables the I2C components 258. Accordingly, once the SPI finite state machine 228 detects a complete SPI frame and drives the SPI done line 232 high during a rising edge on the CSN line 212, the I2C components 258 are disabled. While not illustrated, the second flip flop device 236 may be reset back to store a low value by an external reset, a power-on reset, or a software reset command. Resetting the second flip flop device 236 reenables the I2C components 258 and causes the interface to enter protocol auto-detect mode.
The I2C finite state machine 280 receives the I2C reset line 240, an I2C finite state machine reset line 260, and an SCL line 262. A high value on the I2C finite state machine reset line 260 disable the I2C finite state machine 280. The SCL line 262 is coupled to a pin of the interface that includes the I2C components 258. For example, the SCL line 262 may be coupled to the first pin 104 of the interface 102. While not illustrated, the I2C state machine 280 further receives contents of the I2C shift register 294 as input. The I2C finite state machine 280 monitors the SCL line 262 and the content of the I2C shift register 294 to determine whether an I2C message has been received and drives an I2C acknowledge (ACK) line based on the determination. As explained above, the I2C reset line 240 corresponds to an output of the SPI components 210. The I2C finite state machine 280 is configured to drive an I2C CLR line 264 based on the SCL line 262. The third flip flop device 263 drives an I2C start line 270 based on the I2C CLR line 264 and an inverted SDA line 266. The SDA line 266 may be coupled to the second pin 106 of the interface 102. A falling edge on the SDA line 266 causes the third flip flop device 263 to store a high value drive the I2C start line 270 high.
The second AND gate 282 receives the I2C start line 270 and the SCL line 262 and drives an I2C shift register clock line 293 accordingly. The I2C shift register 294 includes flip flops clocked by the I2C shift register clock line 293. When the I2C start line 270 is high, the I2C shift register clock line 293 matches the SCL line 262. When the I2C start line 270 is low, the I2C shift register clock line 293 is low and the I2C shift register 294 is disabled. Thus, the I2C finite state machine 280 is configured to disable the I2C shift register 294 based on the I2C reset line 240. As illustrated, the I2C shift register 294 is configured to receive and store data from an I2C data in line 268 when enabled. The I2C data in line 268 may be the SDA line 266.
The I2C finite state machine 280 drives the I2C ACK line 284 based on whether the I2C finite state machine 228 has detected a valid I2C device ID in the I2C shift register 294. It should be noted that the I2C ACK line 284 may correspond to the SDA line 266. In some implementations, the I2C state machine 280 drives the I2C ACK line 284 low to acknowledge receipt of an I2C byte. The second multiplexor 286 receives a low signal and the SPI reset line 220 as inputs and selects an output based on a value of the I2C ACK line 284. The fourth flip flop device 292 receives output of the second multiplexor 286 as input, is clocked by the SCL line 288, and drives the SPI reset line 220 accordingly.
The second multiplexor 286 is configured to select the SPI reset line 220 as output in response to the I2C ACK line 284 having a low value. Further, the fourth flip flop device 292 initially stores a low signal. Accordingly, while the I2C ACK line 284 is low, the fourth flip flop device 292 continues to store and output a low signal responsive to the SCL line 288. In contrast, the second multiplexor 286 is configured to select the high signal in response to detecting the I2C ACK line 284 is high. Upon detecting a rising edge of the SCL line 288 and a high value from the second multiplexor 286, the fourth flip flop device 292 begins driving the SPI reset line 220 at a high value. Once the SPI reset line 220 is driven high, both values received by the multiplexor are high and so the fourth flip flop device 292 outputs a high value on the SPI reset line 220 regardless of a condition of the I2C ACK line 284. A high value on the SPI reset line 220 (i.e., the CSN line 212) disables the SPI components 210 because the high value prevents the finite state machine 228 from counting SCLK pulses and prevents the first and second flip flop devices 214, 236 from storing new values. Accordingly, once the I2C finite state machine 280 detects an I2C message and drives the I2C ACK line 284 high during a rising edge on the SCL line 288, the SPI components 210 are disabled. While not illustrated, the fourth flip flop device 292 may be reset by an external reset, a power-on reset, or a software reset command. Resetting the fourth flip flop device 292 reenables the SPI components 210 and causes an interface to enter protocol auto-detect mode.
The SPI components 210 and the I2C components 258 simultaneously monitor pins of an interface to detect that the corresponding protocol is in use. Once one of the protocols is detected, the components associated with the other protocol are disabled. Thus,
Referring to
The SPI frame detection method 310 includes idling, at 312. For example, the SPI finite state machine 228 may wait in an idle state until an SPI start condition is detected. The SPI frame detection method 310 further includes resetting an SCLK counter upon detecting a falling edge on a CSN line, at 314. For example, the SPI finite state machine 228 may maintain a count of rising edges detected on the SCLK line 226 (a SCLK count), and upon detecting, a falling edge on the CSN line 212 while the SPI finite state machine 228 is in the idle state, the SPI finite state machine 228 may reset the SCLK count. As used herein, a CSN falling edge while the SPI finite state machine 228 is in the idle state is a SPI start condition.
The SPI frame detection method 310 further includes returning to the idle state if an SPI reset is detected. For example, the SPI finite state machine 228 may return to the idle state in response to detecting a high value on the SPI reset line 220.
If no SPI reset is detected, the SPI frame detection method 310 further includes continuing to count SCLK rising edges while CSN is low, at 316. For example, the SPI finite state machine 228 may continue to count rising edges on the SCLK line 226 while the CSN line 212 (i.e., the SPI reset line 220) is low. The SPI frame detection method 310 further includes returning to the idle state if an SPI reset is detected or if an invalid frame SPI frame is detected. The SPI finite state machine 228 may detect an invalid SPI frame in response to a rising edge on the CSN line 212 before the SCLK counter reaches threshold count (e.g., 24) indicative of an SPI frame. In various implementations, a valid SPI frame will cause the SCLK counter to reach a value that is a multiple of 8, such as 8, 16, 24, 32, etc.
If a valid SPI frame is detected and no SPI reset is detected, the SPI frame detection method 310 includes executing the SPI frame, at 318. For example, the SPI finite state machine 228 may initiate processing of data received in the SPI shift register 241. The SPI frame detection method 310 further includes returning to the idle state if an SPI reset is detected.
If no SPI reset is detected, the SPI frame detection method 310 includes activating an interface SPI mode and disabling I2C components, at 320. For example, the SPI finite state machine 228 may drive the SPI done line 232 to a high state in order to trigger the I2C reset line 240. As explained above, the I2C finite state machine 280 may disable the I2C components 258 based on the I2C reset line 240 being driven high. In some implementations, some pins of the interface are disabled as outputs in I2C mode and these pins may be enabled as outputs by the SPI finite state machine 228 in response to entering SPI mode. For example, output from the third pin 108 (e.g., SDO in SPI) may be disabled upon startup of the interface 102 because the interface 102 defaults to the I2C mode, but in response to entering the SPI mode (e.g., in response to detecting an SPI frame), the SPI finite state machine 228 may enable output from the third pin 108.
The SPI frame detection method 310 continues to cause the interface to operate in SPI mode while no SPI reset is detected. If an SPI reset is detected, the SPI frame detection method 310 returns to the idle state.
Thus, the SPI frame detection method 310 may be used to monitor pins of an interface for SPI communications, to disable I2C components upon detection of SPI communications, and to cause an interface to interpret signals according to the SPI protocol.
The I2C byte detection method 330 includes idling, at 332. For example, the I2C finite state machine 280 may wait in an idle state until an I2C start condition is detected. The I2C byte detection method 330 further includes attempting to decode a device identifier (ID) in response to detecting an I2C start condition, at 334. For example, the I2C finite state machine 280 may attempt to decode a device ID in the I2C shift register 294 in response to detecting a falling edge on the SDA line 266 while the SCL line 262 is high (e.g., an I2C start condition).
If a decoded device ID is not recognized or an I2C reset is detected, the I2C byte detection method 330 returns to the idle state. If the decoded device ID is recognized, the I2C byte detection method 330 generates an I2C ACK. For example, the I2C finite state machine 280 may drive the I2C ACK line 284. In some embodiments, the I2C ACK line 284 is connected to a same pin as the SDA line 266 (e.g., the second pin 106 of
The I2C byte detection method 330 continues to cause the interface to operate in I2C mode while no I2C reset is detected. If an I2C reset is detected, the I2C byte detection method 310 returns to the idle state.
Thus, the I2C byte detection method 330 may be used to monitor pins of an interface for I2C communications, to disable SPI components upon detection of I2C communications, and to cause an interface to interpret signals according to the I2C protocol.
As explained above, the methods 310, 330 concurrently monitor pins of an interface for communications that match their respective protocols. Because some analogous signals (e.g., clock signals) of the two protocols are assigned to different pins of an interface that implements the methods 310, 330, signals according to one protocol may not cause the interface to detect the other protocol, as explained further below. Thus, the methods 310, 330 may be used to automatically detect and operate according to one of several protocols without specialized setup messaging or a dedicated protocol selection pin.
Referring to
The I2C components 406 are configured to monitor the pins 414-422 for I2C bytes while the SPI components 410 are configured to monitor the pins 414-422 for SPI frames. Once one of the sets of components 406, 410 detects the corresponding protocol, the other components are disabled. In implementations in which the I2C components 406 and the SPI components 410 correspond to the I2C components 258 and the SPI components 210 of
Referring to
The I2C components 508 are configured to monitor the pins 514-520 for I2C bytes while the SPI components 510 are configured to monitor the pins 514-520 for SPI frames. Once one of the sets of components 508, 510 detects the corresponding protocol, the other components are disabled. In implementations in which the I2C components 508 and the SPI components 510 correspond to the I2C components 258 and the SPI components 210 of
Referring to
The I2C components 606 are configured to monitor the pins 614-618 for I2C bytes while the SPI components 610 are configured to monitor the pins 614-618 for SPI frames. Once one of the sets of components 606, 610 detects the corresponding protocol, the other components are disabled. In implementations in which the I2C components 608 and the SPI components 610 correspond to the I2C components 258 and the SPI components 210 of
Thus,
The I2C byte detection method 330 and the SPI frame detection method 310 are simultaneously used (e.g., by the I2C components 258 and the SPI components 210) to monitor the signals 704, 706 to determine whether the signals correspond to an I2C byte of an SPI frame. In the illustrated example, the I2C byte detection method 330 detects a falling edge 708 on the first signal 704 (i.e., SDA) while the second signal 706 (SCL) is high and so transitions from the idle state 332 and attempts to decode a device ID, at 334. Once a device ID 710 is decoded, the I2C byte detection method 330 proceeds to generate an ACK, at 336, and to disable SPI detection while causing the interface to operate in I2C mode, at 338.
The SPI frame detection method 310 transitions from the idle state 312 upon detecting a falling edge 720 in the second signal 706 (i.e., CSN) and resets the SCLK counter, at 314. However, the next rising edge of the second signal 706 occurs before the SCLK counter reaches a number indicative of SPI (e.g., 24) so the SPI frame detection method 310 determines there is no valid SPI frame and returns to the idle state 312. The SPI frame detection method 310 continues transitioning from idle and detecting invalid frames in this manner until the I2C byte detection method 330 disables SPI detection.
Thus,
The SPI frame detection method 310 transitions from the idle state 312 in response to detecting a falling edge 810 in the second signal 806 (i.e., CSN) and continues incrementing the SCLK counter based on the first signal 804, at 316. In response to determining that the SCLK counter indicates a SPI frame (e.g., equals 24) when a next rising edge 812 occurs in the second signal 806. Accordingly, the SPI frame detection method 310 causes the interface to operate in SPI mode and disables I2C detection.
Before being disabled, the I2C byte detection method 330 stays in the idle state 332 because no I2C start condition is detected in the signals 804, 806. Thus,
As described with respect to
Thus,
Thus,
In this description, the term “couple” or “couples” means either an indirect or direct wired or wireless connection. Thus, if a first device couples to a second device, that connection may be through a direct connection or through an indirect connection via other devices and connections. The recitation “based on” means “based at least in part on.” Therefore, if X is based on Y, X may be a function of Y and any number of other factors.
Modifications are possible in the described embodiments, and other embodiments are possible, within the scope of the claims.
The above discussion is meant to be illustrative of the principles and various embodiments of the present invention. Numerous variations and modifications will become apparent to those skilled in the art once the above disclosure is fully appreciated. It is intended that the following claims be interpreted to embrace all such variations and modifications.
Number | Name | Date | Kind |
---|---|---|---|
6038400 | Bell | Mar 2000 | A |
10684974 | Wright | Jun 2020 | B1 |
20080270667 | Bracamontes Del Toro | Oct 2008 | A1 |
20100150338 | Nguyen | Jun 2010 | A1 |
20120079138 | Obkircher | Mar 2012 | A1 |
20130019037 | Flippin | Jan 2013 | A1 |
20130100825 | Bancel | Apr 2013 | A1 |
20130205054 | Wright | Aug 2013 | A1 |
20130218507 | Waayers | Aug 2013 | A1 |
20170075852 | Mishra | Mar 2017 | A1 |
20200076443 | McDonough | Mar 2020 | A1 |
Number | Date | Country | |
---|---|---|---|
20200195759 A1 | Jun 2020 | US |