After discussing the initialization and deletion of drivers for I2C devices and I2C adapters, we will focus on several function operations in file_operations, paste the file_operations struct code first. Let's see which functions are included.
Static const struct file_operations i2cdev_fops ={
The structure must be quite clear. Therefore, the I2C Driver provide
Since the use of computers and networks, it has greatly changed our world. So far, the intelligent brain of chips and hardware devices has been applied and developed in more and more fields. As for protocol, there are also many changes. Next we will introduce the I2C bus protocol for audio and video devices.
I2C bus Definition
The I2C (Inter-Integrated Circuit) b
I2C bus principle and application example
The I2C (Inter-Integrated Circuit) bus is a two-line serial bus developed by Philips to connect the microcontroller and its peripheral devices. The I2C bus was originally developed for audio and video devices in 1980s and is now mainly used in server management, including communication in the status of a
After completing the Platform_device addition, the I2C subsystem will perform the Platform_driver registration process.
Platform_driver registration by calling the initialization function I2c_adapter_s3c_init letter
Number to complete.
The I2c_adap_s3c_init () function body is as follows:
static int __init i2c_adap_s3c_init (void)
{return
platform_driver_register (s3c24xx_i2c_driver);
}Platform_driver_register (s3c24xx_i2c_driver), will complete the
I'm confused about the I2C bus protocol? I was not quite clear when I first saw it. Let's take a look at the role of the I2C bus. Maybe this will give you a little bit of understanding.
I2C bus application
At present, many semiconductor integrated circuits have integrated I2C interfaces. Single-Chip Microcomputer with
Linux I2C driver architecture1. Linux I2C driver architecture in Linux, I2C BUS drivers are divided into two parts: BUS and DEVICE drivers ). The role of the bus driver is to add corresponding read/write methods for each I2C bus in the system. However, the bus driver does not communicate with each other. It only exists
The I2C architecture consists of three components:
(1) I2C Core
(2) I2C bus driver
(3) I2C Device Driver
I2C core: Provides the registration and cancellation methods for I2C bus drivers and device drivers, the upper layer of the
A cssp specification-visual enhancement engine chip produced by quick logic is used to enhance the image data output to the Panel. Schematic:
Generally, you only need to add an I2C device and write it to the register group during initialization. Linux I2C architecture:I2C core i2c-core.c: Provides I2C bus drivers and
I2C bus signal timing Summary
Idle bus statusThe SDA and SCL signal lines of the I2C bus are in the idle state at the same time.At this time, the output-level FET of each device is in the cutoff state, that is, the bus is released.By the two signal lines of the respective pull-up resistance to raise the level.
Start SignalThe SDA level of the data line is lowered (that is, the negative hop) during the hig
The premise is that the driver of the I2C controller must have been running normally, the standard I2C tool can only read and write to 8-bit address, but the EEPROM of this 16-bit address will be powerless
So this kind of 16-bit address for read and write support, in the embedded domain is still very common
The main use of standard Linux I2C interface, struct i2c
1. Communication Interface
The data sent or received by I2C is encapsulated by the packet struct i2c_msg.
Struct i2c_msg {_ 2010addr; // slave address _ 2010flags; // flag # define i2c_m_ten 0x0010 // ten address flag # define i2c_m_rd 0x0001 // receives the data flag _ Len; // Data Length _ u8 * Buf; // Data Pointer };
ADDR indicates the slave address, flags indicates the communication, 0 indicates the sent data, and i2c_m_rd indicates the received d
ack and nack of I2C signal
We usually in debugging I2C may rarely pay attention to the nack signal, only know if the master send data, MSB first, LSB after sending a byte (8 bit), then Slave will reply to an ACK signal, but sometimes I2C Slave may send a nack signal, let's take a look at the nack signal.
1, from the spec under a paragraph:
2. Translation:
E
Address: http://blog.csdn.net/coder_jack/article/details/6419903
Send a start and stop command consecutively for the following test:
1. Send the start command to address an existing device, receive the ACK, and then send the Stop command. Everything is normal and the Stop waveform is displayed.
2. Send the start command to address a non-existing slave device. If no response is received, send the Stop command to release the bus and the waveform of the bus release cannot be seen. Only the check re
Principles, differences and Applications of SPI, I2C, and UART Serial Bus
1. UART is a two-line interface. One transmission and one receiving interface can communicate with each other in full duplex mode, and the number of lines is relatively small. Data is transmitted asynchronously, with strict timing requirements on both parties, and the communication speed is not fast. It is used most frequently for multi-host communication.2. Compared
1. Get the source code of I2C tools
Reference: http://lm-sensors.org/wiki/I2CTools
$ Wget http://dl.lm-sensors.org/i2c-tools/releases/i2c-tools-3.1.0.tar.bz2
2. Compile the source code
$ Tar-jxvf i2c-tools-3.1.0.tar.bz2
$ I2c-tools-3.1.0 CD
$ Cc = arm-None-Linux-gnueabi-GCC
EmbeddedLinux Bare Metal Development (13)--i²c communication a,IIC Protocol 1. Introduction ofIIC bus i2c (Inter - integrated circuit) bus is a philips The company developed a two-wire serial bus for connecting microcontrollers and peripherals. i2c Bus is a serial data bus, only two signal lines, one is two-way cable sda and the other one is the clock line scl
Debug I2C modules in the near future. I think I am the most familiar with I2C. One is that the Protocol price is simple, and the other is that this module is also available in the set-top box. However, this familiar thing has made me tune it for three days! Some of the failure lessons are summarized as follows to learn from yourself and later.
1. When there is no problem with all the time sequences, I modi
Differences:
SPI: high-speed synchronous serial port. 3 ~ 4-line interface, independent and synchronous sending and receiving
UART: Universal asynchronous serial port. Bidirectional communication based on the standard baud rate is slow
I2C: A three-line serial transmission mode. The communication protocol and usage can be found on the Internet.
Bidirectional data transmission with three linesSerial peripheral interfaceUART: Universal asynchronous tra
1. Communication interface
I2C send or receive data in packets struct I2C_MSG encapsulation
[CPP]
struct I2C_MSG {
__u16 addr; From machine address
__U16 flags; Sign
#define I2c_m_ten 0x0010//10-bit address flag
#define I2C_M_RD 0x0001//Receive data markers
__u16 Len; Data length
__u8 *buf; Data pointers
};
Where addr is the address of the machine; flags are the sign of this communication, sending the data as 0, and receiving the data as the number of
The following is a detailed analysis of how to write the first part: the I2C driver of the master chip is divided into two steps: Write the bus driver: select a master chip, for example: (self-compiled chip) the I2C support for this chip (bus driver support) is not found in Driver/I2C/busses/i2c-s3c2410.c )... (Unlucky
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.