Control method for I2C device of I2C system and I2C device using the same
20170371819 ยท 2017-12-28
Inventors
- Chih-Huang Lin (Hsinchu City, TW)
- Hong-Chu Chen (Hsinchu City, TW)
- Min-Hui Chu (Hsinchu County, TW)
- Chin-Hui Huang (Hsinchu City, TW)
- Wei-Lung Liu (Hsinchu County, TW)
- Tai-Yu Chiu (Hsinchu County, TW)
- Chao-Chun Huang (Taipei City, TW)
- Su-Wei Lien (Hsinchu City, TW)
Cpc classification
G06F13/364
PHYSICS
International classification
G06F13/364
PHYSICS
Abstract
A control method for a first device of an inter-integrated circuit (I.sup.2C) system including a microcontroller unit (MCU), includes receiving a first indication from the MCU of the I.sup.2C system, wherein the first indication configures the first device from a slave mode to a master mode; polling the first device itself for status information of the first device when the first device is in the master mode; determining whether the status information of the first device matches a target status after polling; and determining to perform a parameter adjustment on a second device of the I.sup.2C system when determining that the status information of the first device matches the target status.
Claims
1. A control method for a first device of an inter-integrated circuit (I.sup.2C) system comprising a microcontroller unit (MCU), the control method comprising: receiving a first indication from the MCU of the I.sup.2C system, wherein the first indication configures the first device from a slave mode to a master mode; polling the first device itself for status information of the first device when the first device is in the master mode; determining whether the status information of the first device matches a target status after polling; and determining to perform a parameter adjustment on a second device of the I.sup.2C system when determining that the status information of the first device matches the target status.
2. The control method of claim 1, further comprising: performing the parameter adjustment on the second device in response to determining that the status information of the first device matches the target status.
3. The control method of claim 2, wherein performing the parameter adjustment on the second device comprises transmitting, via an I.sup.2C bus, an address of the second device, a write signal, an address of a parameter register to be adjusted of the second device, and a parameter value to be set in the parameter register.
4. The control method of claim 1, further comprising: transmitting a second indication to the MCU in response to determining that the status information of the first device matches the target status, to instruct the MCU to perform the parameter adjustment on the second device.
5. The control method of claim 4, further comprising: transmitting a third indication to the MCU, wherein the third indication configures the MCU from the slave mode to the master mode and thereby allows the MCU to perform the parameter adjustment on the second device.
6. The control method of claim 4, wherein the second indication comprises an address of the MCU, a write signal, an address of a register of the MCU or a flag of the MCU, and a value to be set in the register or in the flag, wherein the register or the flag indicates that a parameter register of the second device is to be adjusted.
7. The control method of claim 1, wherein the step of polling the first device itself for the status information of the first device comprises periodically polling the first device itself for the status information of the first device.
8. A device of an inter-integrated circuit (I.sup.2C) system, the device supporting a master mode and a slave mode, and comprising: a register module, for storing status information and mode information of the device; a register control module, coupled to the register module, for performing the following steps: polling the register module for the status information of the device when the device is in the master mode; determining whether the status information of the device matches a target status after polling; and determining to perform a parameter adjustment on an I.sup.2C device of the I.sup.2C system when determining that the status information of the device matches the target status; and an I.sup.2C controller, coupled to the register module and the register control module, for receiving a first indication from a microcontroller unit (MCU) of the I.sup.2C system, wherein the first indication configures the device from the slave mode to the master mode.
9. The device of claim 8, further comprising: a multiplexer, coupled to the register module and the I.sup.2C controller, for selecting an operation mode of the device to be the master mode or the slave mode by receiving a control signal from the register module.
10. The device of claim 8, wherein the I.sup.2C controller further performs the following step: performing the parameter adjustment on the I.sup.2C device according to instructions from the register control module.
11. The device of claim 10, wherein when performing the parameter adjustment, the I.sup.2C controller transmits, via an I.sup.2C bus, an address of the I.sup.2C device, a write signal, an address of a parameter register to be adjusted of the I.sup.2C device, and a parameter value to be set in the parameter register, which are instructed by the register control module.
12. The device of claim 8, wherein the I.sup.2C controller further performs the following step: transmitting a second indication to the MCU in response to the register control module determining that the status information of the device matches the target status, to instruct the MCU to perform the parameter adjustment on the I.sup.2C device.
13. The device of claim 12, wherein the I.sup.2C controller further performs the following step: transmitting a third indication to the MCU, wherein the third indication configures the MCU from the slave mode to the master mode and thereby allows the MCU to perform the parameter adjustment on the I.sup.2C device.
14. The device of claim 12, wherein the second indication comprises an address of the MCU, a write signal, an address of a register of the MCU or a flag of the MCU, and a value to be set in the register or in the flag, wherein the register or the flag indicates that a parameter register of the I.sup.2C device is to be adjusted.
15. The device of claim 8, further comprising: a counter, coupled to the register control module, for configuring a period of polling the device itself for the status information of the device.
16. The device of claim 8, wherein the step of polling the register module for the status information of the device comprises: transmitting, by the register control module, a polling request to the register module; and receiving, from the register module, the status information of the device in response to the polling request.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
[0009]
[0010]
[0011]
[0012]
[0013]
[0014]
[0015]
DETAILED DESCRIPTION
[0016] Please refer to
[0017] Please refer to
[0018] A general I.sup.2C system includes a serial clock line (SCL) for transmitting clock signals and a serial data line (SDA) for transmitting data. Conventionally, the polling operations of the master device in the I.sup.2C system mean that the master device transmits a message on the SDA to a slave device, where the message indicates that the master device needs to read data in a register of a specific slave device. This message may be forwarded to every slave device on the I.sup.2C bus, but only the specific slave device reacts in response to this message. This slave device replies a response message to the master device, and the response message indicates the register data or the status queried by the master device. After receiving the register data or the status of the slave device, the master device may determine whether the status of the slave device matches the target status. The determination result may lead to a specific operation or configuration performed by the master device, e.g., a parameter adjustment of a slave device.
[0019] As can be seen in
[0020] Please refer to
Step 300: Start.
[0021] Step 302: Receive a first indication from the MCU 100 of the I.sup.2C system 10, wherein the first indication configures the I.sup.2C device 104 from a slave mode to a master mode.
Step 304: Poll the I.sup.2C device 104 itself for status information of the I.sup.2C device 104 when the I.sup.2C device 104 is in the master mode.
Step 306: Determine whether the status information of the I.sup.2C device 104 matches a target status after polling.
Step 308: Determine to perform a parameter adjustment on another I.sup.2C device 102 of the I.sup.2C system 10 when determining that the status information of the I.sup.2C device 104 matches the target status.
Step 310: End.
[0022] According to the process 30, the I.sup.2C device 104 supports a master mode and a slave mode. The I.sup.2C device 104 receives a first indication from the MCU 100, where the first indication configures the I.sup.2C device 104 from the slave mode to the master mode. In other words, by transmitting the first indication, the MCU 100 configures the I.sup.2C device 104 to the master mode. The MCU 100 also configures itself to the slave mode accordingly. Therefore, the I.sup.2C device 104 may act as a master device and start the polling operations for itself. The I.sup.2C device 104 may poll itself for status information of the I.sup.2C device 104, and determine whether the status information of the I.sup.2C device 104 matches a target status after polling. After determining that the status information matches the target status, the I.sup.2C device 104 determines to perform a parameter adjustment on the I.sup.2C device 102.
[0023] Please refer to
[0024] In detail, the I.sup.2C device 104 may include a mode switch register indicating to operate in the master mode or the slave mode. The first indication I1 may include but is not limited to an address of the I.sup.2C device 104, a write signal, an address of the mode switch register of the I.sup.2C device 104, and a value indicating the master mode to be set in the mode switch register of the I.sup.2C device 104. After the I.sup.2C device 104 receives the first indication I1 and determines that the first indication I1 is configured to the I.sup.2C device 104 according to the address, the I.sup.2C device 104 may write the value indicating the master mode into the mode switch register according to the information carried by the first indication I1, allowing the I.sup.2C device 104 to enter the master mode.
[0025] Subsequently, the I.sup.2C device 104 keeps polling itself to obtain the status information when it is in the master mode; that is, the I.sup.2C device 104 keeps polling itself to check if a status of the I.sup.2C device 104 changes and matches a target status. If the detected status information does not match the target status, the I.sup.2C device 104 then polls itself again. After the I.sup.2C device 104 determines that the status information matches the target status, the I.sup.2C device 104 may determine to perform the parameter adjustment on the I.sup.2C device 102.
[0026] In response to determining that the status information of the I.sup.2C device 104 matches the target status, the I.sup.2C device 104 may transmit a second indication I2 to the MCU 100, to instruct the MCU 100 to perform the parameter adjustment on the I.sup.2C device 102. The second indication I2 may include but is not limited to an address of the MCU 100, a write signal, an address of a designated register of the MCU 100 or a flag of the MCU 100, and a value to be set in the designated register or the flag, wherein the designated register or the flag indicates that a parameter register of the I.sup.2C device 102 is to be adjusted. Therefore, after receiving the second indication I2, the MCU 100 may know that the second indication I2 is configured to the MCU 100 according to the address. The MCU 100 may also know which parameter register of the I.sup.2C device 102 needs to be adjusted according to the address and the setting value of the register or the flag. Note that the value to be set in the designated register of the MCU 100 may be a parameter value to be set in the parameter register of the I.sup.2C device 102. Alternatively, if the value to be set in the designated register or the flag of the MCU 100 is a simple value such as 0 or 1 instructing to perform the parameter adjustment, the second indication may further include a parameter value to be set in the parameter register of the I.sup.2C device 102. For example, the parameter register of the I.sup.2C device 102 may be associated with brightness control, contrast control, or saturation control on images displayed in the I.sup.2C device 102, and the parameter value may indicate the brightness, contrast, or saturation to be applied.
[0027] In addition, the I.sup.2C device 104 may further transmit a third indication I3 to the MCU 100, where the third indication I3 configures the MCU 100 from the slave mode to the master mode. After switched to the master mode, the MCU 100 is allowed to perform the parameter adjustment on the I.sup.2C device 102. Accordingly, the I.sup.2C device 104 also configures itself to the slave mode. In detail, the MCU 100 may also include a mode switch register indicating to operate in the master mode or the slave mode. The third indication I3 may include but is not limited to an address of the MCU 100, a write signal, an address of the mode switch register of the MCU 100, and a value indicating the master mode to be set in the mode switch register of the MCU 100. After the MCU 100 receives the third indication I3 and determines that the third indication I3 is configured to the MCU 100 according to the address, the MCU 100 may write the value indicating the master mode into the mode switch register according to the information carried by the third indication I3, allowing the MCU 100 to enter the master mode. Note that the second indication I2 and the third indication I3 transmitted by the I.sup.2C device 104 may be transmitted separately as shown in
[0028] As shown in
[0029] Please note that the embodiment of message flows shown in FIG. 4 is one of various embodiments of the present invention. For example, the parameter adjustment of the I.sup.2C device 102 may be performed by the I.sup.2C device 104 instead of the MCU 100. Please refer to
[0030] After the parameter adjustment of the I.sup.2C device 102 is completed, if it is necessary, the I.sup.2C device 104 may transmit another indication I5 to the MCU 100, to configure the MCU 100 to the master mode. The content of the indication I5 is similar to the content of the indication I3, and will not be narrated herein. The I.sup.2C device 104 may transmit the indication I5 to configure the MCU 100 to the master mode at any time according to a predefined configuration, and the I.sup.2C device 104 configures itself to the slave mode accordingly. The I.sup.2C device 104 may be configured to return to the slave mode at any time. Alternatively, the MCU 100 is capable of automatically configuring itself to the master mode. Since the I.sup.2C system cannot have two master devices simultaneously according to its specification, the I.sup.2C device 104 should return to the slave mode when the MCU 100 automatically changes to the master mode.
[0031] Please note that the above self-polling operations of the I.sup.2C device 104 are performed periodically; that is, the I.sup.2C device 104 may poll itself for the status information of the I.sup.2C device 104 periodically. The period of polling may be configured arbitrarily.
[0032] As can be seen in the message flows shown in
[0033] Please refer to
[0034] Initially, the register control module 604 may provide a default value for the mode switch register and status register(s) in the register module 602, to control the I.sup.2C device to be in the master mode or the slave mode. Alternatively, the I.sup.2C controller 606 may receive a control signal from an external I.sup.2C device or an MCU via the I.sup.2C bus, and the control signal controls the I.sup.2C device to enter the master mode or the slave mode. When the I.sup.2C device is in the slave mode, the I.sup.2C controller 606 may receive the first indication from the MCU, which may include a write signal, an address of the mode switch register of the I.sup.2C device 104, and a value indicating the master mode. After receiving the first indication, the I.sup.2C controller 606 writes the value indicating the master mode into the mode switch register in the register module 602. The register module 602 thereby transmits a control signal to the multiplexer 608, to switch the operation mode of the I.sup.2C device from the slave mode to the master mode. When the I.sup.2C device is in the master mode, the register control module 604 then polls the register module 602 for the status information of the I.sup.2C device. In detail, the register control module 604 may transmit a polling request to the register module 602, and in response to the polling request, the register module 602 may transmit the status information stored in the status register to the register control module 604. Note that the polling operation is performed periodically, and the counter 610 may configure the period of polling the register module 602 for the status information such that the register control module 604 performs self-polling operation periodically.
[0035] Subsequently, the register control module 604 determines whether the status information of the I.sup.2C device matches the target status after receiving the status information. When determining that the status information of the I.sup.2C device matches the target status, the register control module 604 may determine to perform parameter adjustment on another I.sup.2C device of the I.sup.2C system which is to be adjusted. Therefore, the I.sup.2C controller 606 may perform the parameter adjustment on the adjusted I.sup.2C device according to instructions from the register control module 604. More specifically, the I.sup.2C controller 606 may transmit an indication, such as I4 in
[0036] In an embodiment, the I.sup.2C system is used for data transmission in a monitoring system. Please refer to
[0037] In an embodiment, the MCU 702 may transmit an indication, such as the first indication I1 in
[0038] It should be noted that whether the modulator 706 receives the control signal CTRL or not yet, the modulator 706 keeps polling itself periodically. After receiving the control signal CTRL which triggers the status register to change its value, the modulator 706 may determine, based on the polled status information, that the status information corresponding to the brightness matches the target status. Therefore, the modulator 706 may configure the MCU 702 to enter the master mode via the I.sup.2C bus, allowing the MCU 702 to adjust the brightness which is set in the corresponding parameter register in the image sensor 704 according to the target brightness value obtained from the control center device 710. Alternatively, the modulator 706 may directly adjust the brightness which is set in the corresponding parameter register in the image sensor 704 via the I.sup.2C bus according to the target brightness value obtained from the control center device 710.
[0039] The above monitoring system may be applied to monitor the real-time image in any places required by the user. In an embodiment, the camera of the monitoring system may be a rear-view camera installed on a vehicle. In another embodiment, the camera of the monitoring system may be implemented with a doorbell to capture an image outside the door. In addition, the camera of the monitoring system may be integrated with a temperature sensor; hence, the self-polling operation of the present invention allows the MCU to reserve more resources for dealing with temperature sensing operations. In a further embodiment, the camera of the monitoring system is utilized for a video conference and integrated with an audio device; hence, the self-polling operation of the present invention allows the MCU to reserve more resources for managing the audio functions.
[0040] Please note that the present invention aims at providing a self-polling operation for an I.sup.2C system, allowing an I.sup.2C device to poll itself for status information of the I.sup.2C device. Those skilled in the art can make modifications and alternations accordingly. For example, in the above embodiments, the MCU is in the master mode and the I.sup.2C devices are in the slave mode in an initial condition. In another embodiment, an I.sup.2C device other than the MCU may be configured to the master mode when the I.sup.2C system is powered on. This configuration may be predefined in the I.sup.2C system and stored in registers of the I.sup.2C devices. In addition, the MCU refers to a processing unit of an electronic system, and may be replaced by a central processing unit (CPU) or another type of processor. Note that a general polling operation of an I.sup.2C system should follow the specification of the I.sup.2C system, where the polling request and response have predefined formats, allowing the master device and the slave devices to communicate with each other. On the other hand, in the embodiments of the present invention, the self-polling operation refers to an I.sup.2C device polling itself, so the formats of the polling request and response do not need to follow the I.sup.2C specification, as long as the formats of the polling request and response are recognizable by the register control module, the register module and/or other related devices in the I.sup.2C device. Furthermore, in the above embodiments, the status information refers to a value in a status register. In another embodiment, the status information may be a combination of values in multiple status registers indicating any possible statuses of the I.sup.2C device; this is not limited herein.
[0041] To sum up, the present invention provides a control method for an I.sup.2C device of an I.sup.2C system, where the I.sup.2C device is allowed to poll itself for status information of the I.sup.2C device. This reduces data transmissions for polling operation in the I.sup.2C system, and thereby improves the efficiency of the I.sup.2C system. With the self-polling operation of the present invention, the loading of the MCU is significantly reduced, so that the MCU may reserve more resources for other operations. In addition, signal transmissions on the I.sup.2C bus are reduced; this reduces electromagnetic interference problems generated from the I.sup.2C bus.
[0042] Those skilled in the art will readily observe that numerous modifications and alterations of the device and method may be made while retaining the teachings of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims.