First knowledge of I2C bus protocol for Linux bus drivers with cainiao

Source: Internet
Author: User

It was so confusing that I spent two days in the company. In order not to work in my task, is it true or wrong. I didn't even implement my own plan, nor did I read any books I wanted to watch. However, I have finally experienced it. Working overtime is not enough for the IT industry. The current department is okay, basically no need to work overtime, the small tasks can still be completed in advance, and a little time is used to record the learning process and grow slowly. Yesterday, the engineer from our subsidiary rushed back to the project until half past nine. Today, he said that he went back at a.m. It's not easy. Should I do the same after four years of work? Their company is working on software by himself, and andriod is applied to the underlying driver by him.

Hearing from him, their Deputy Director of Technology, who has been working for 10 years, he can draw a PCB, write a driver, and then apply it to the UI. The whole project can be operated by a person. In the past 10 years, many people may only repeat the code in 10 years. In addition, he is still in the same school with me, starting with a test without any knowledge, and then engaged in technology, and then became him 10 years later. I think I should be lucky to him. I just started technology after graduation, and now I am getting started, and I have been recognized by my colleagues and leaders. So I firmly believe that I don't need 10 years to achieve anything better than him. People are forced out. Only a firm belief will prompt us to grow and we will not be on the road to success. If you want or don't want to, the target will always be waiting for you. All you need is time and your yearning heart. Tired, always an excuse.

Many Linux devices are controlled by the I2C bus. Therefore, it is good to learn the I2C bus driver. First, let's look at the I2C protocol.

The I2C bus consists of two lines, namely, serial data (SDA) and serial clock (SCL ). Each device has a unique address recognition and can be used as a transmitter or receiver. The following are some main terms.

Transmitter:
Devices that send data to the bus

Receiver:
Devices that receive data from the bus

Host:
Initialize devices that generate clock signals and terminate sending.

SLAVE:
Host-addressable device

Multi-Host:
At the same time, more than one host tries to control the bus but does not destroy packets.

Arbitration: a process in which multiple hosts attempt to control the bus at the same time, but only one of them is allowed to control the bus and the packets are not damaged.

Synchronization:
The process of synchronizing clock signals between two or more devices

 

As shown in, many devices are mounted online for SDA and SCL. There are also two hosts, A and B.

Both SDA and SCL are two-way lines, that is, they can be either input or output, and they are connected to the positive power supply voltage through the over-drawing resistor. When the bus is idle, both lines are high. The output level of the device connected to the bus must be an open-drain or open-collector circuit.

The data transmission rate on the I2C bus can reach 100 kbit/s in standard mode, 400 kbit/s in fast mode, and 3.4 Mbit/s in high-speed mode. The number of interfaces connected to the bus is only determined by the limit that the bus capacitor is 400pf.

 

I2C is transmitted by bit, with one clock and one bit of data. Data on the SDA line must be stable during the high-level cycle of the clock. The high or low level status of the data line can be changed only when the clock signal of the SCL line is low.

 

In the I2C bus, there are start (s) and stop (P ).

Start position: When the SCL is high, the SDA line is switched from high to low.

Stop bit: When the SCL is high, the SDA line is switched from low to high.

:

In I2C data transmission, each byte sent to the SDA line is 8 bits. Each byte must be followed by a response bit, namely ack. Its simple data transmission sequence is as follows:

 

The I2C address has a total of 7 digits, followed by 8th digits in the Data direction. 0 indicates sending (writing), and 1 indicates requesting data (reading ). Complete data transmission Diagram

 

It is the entire process of I2C protocol. The first step is to start the bit, then find the device, send the device address, and then send data or request data. The last stop bit.

As for many other models, I will not talk about them. It is often used.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.