The I2C bus uses only two signal lines, SCL and SDA, to implement data interaction between devices, greatly simplifying the occupation of hardware resources and PCB board layout space. Therefore, the I2C bus is widely used in interfaces between devices such as EEPROMs, real clocks, and small LCDs and CPUs.
Linux defines the system's I2C driver architecture. In Linux systems, the I2C driver consists of three parts, namely the I2C core, the I2C bus driver, and the I2C device driver. These three parts work together to form a very versatile and adaptable I2C framework.
The first section of this chapter will analyze the Linux I2C architecture and explain the functions and interconnections of the three components.
Section 2 will analyze the Linux I2C core and explain the functions of the i2c-core.c file and the implementation of the main functions.
Sections 3 and 4 will detail the I2C bus driver and I2C device driver writing methods, respectively, and give a design template for reference.
Sections 5 and 6 will be based on the design templates given in Sections 3 and 4, explaining the S3C2410 ARM processor I2C bus driver and the SAA7113H video analog/digital converter chip device mounted on it. Write a method.
15.1 Linux I2C Architecture
The Linux I2C architecture is divided into three components:
? I2C Core
I2C Core provides I2C bus Driver and device driver registration, logout method, I2C communication method (ie, "algorithm", I believe that literal translation is "calculation method" is not appropriate, in order to avoid misunderstanding, the following will directly use the "algorithm" The code that is not related to the specific adapter, the detection device, the upper layer code of the detection device address, and the like.
? I2C Bus Driver
The I2C bus driver is an implementation of the adapter side of the I2C hardware architecture. The adapter can be controlled by the CPU or even directly integrated into the CPU.
The I2C bus driver mainly includes the I2C adapter data structure i2c_adapter, the I2C adapter's algorithm data structure i2c_algorithm, and a function that controls the I2C adapter to generate communication signals.
The code driven by the I2C bus allows us to control the I2C adapter to generate the start bit, stop bit, read and write cycle, and read and write, generate ACK, etc. in slave mode.
? I2C device driver
I2C device driver is the implementation of the device side in the I2C hardware architecture. The device is generally attached to the CPU-controlled I2C adapter and exchanges data with the CPU through the I2C adapter. .
The I2C device driver mainly includes the data structures i2c_driver and i2c_client. We need to implement the member functions according to the specific device.
Figure 15.1 Linux I2C Architecture
In the Linux 2.6 kernel, all I2C devices are displayed in the sysfs file system and exist in /sys/bus/I2c/directory, listed in the form of adapter address and chip address, such as:
$ tree /sys/bus/i2c/
/sys/bus/i2c/
Slightly larger sites are inevitably load balanced, but hardware load balancing is expensive. There
I. Manually compile and install 1, download the installation package, wget https://ohse.de/uwe/rele
1. Lock the redundant self-built account in the systemCheck method:Execute the command#cat /etc/pas
When dealing with Oracle problems in the actual production environment, sometimes you need a remote
How to copy LINUX user information
NFS service common troubleshooting
Familiar with Linux virus to do system protection engineering
The difference between the init function and the init process is
The method of making rpm packages under linux
Linux View Disk IO Status Operation Guide
Linux mysql boot automatically start 3 methods
Linux environment variable settings summary
WindowsXP shutdown failure full contact, Window XP operating system tutorial
The whole process of automatically generating Makefile is detailed.
How does Win10 system verify system files? Win10 file signature verification method
Win10 new function exposure improved 4K screen display effect
Win10 new function continuum on mobile phone experience video online watch
Windows7 computer right copy and paste can not be used how to do
U disk installation Win7 system tutorial (a)
Four ways to install 64-bit Vista system
The Win10 interface will be revised! Microsoft is adjusting Win10 UI
How to view the power usage of win7 system
Startup prompts on the network have a solution for the name
Win7 login QQ right lower corner does not display qq icon how to do?