S5PV210的I2C通信

来源:互联网 发布:路由器虚拟服务器 知乎 编辑:程序博客网 时间:2024/06/05 20:51

(原创,转载请说明出处)

S5PV210 I2C总线接口

S5PV210RISC(精简指令集)式微处理器支持四个多控制I2C总线串行接口。为了在总线主设备和连接了I2C总线的外部设备(从设备)之间传输数据信息,需要用到一条专用的串行数据线SDA和一条串行时钟线SCLSDASCL都是双向通信的。

 

在多控制I2C总线主设备模式中,多种S5PV210RISC微处理器接收从设备串行数据或者发送串行数据到从设备。S5PV210主控制器在I2C总线上启动数据或终止数据传送。在S5PV210I2C总线使用一个标准总线分配程序。

 

为了控制I2C总线主设备操作,需要对它的下列寄存器进行设置:

I2C总线主设备控制寄存器——I2CCON;

I2C总线主设备控制状态寄存器——I2CSTAT;

I2C总线主设备发送\接收数据移位寄存器——I2CDS

I2C总线主设备地址寄存器——I2CADD;

 

如果I2C总线被释放(空闲状态),串行数据线(SDA)和串行时钟线(SCL)都应该是高电平。当SDA电平出现由高向低的转变,则意为开始一个启动过程;

SCL电平稳定保持在高电平而SDA的电平出现由低向高的转变,则意为开始一个停止过程;

 

主设备总是产生启动和停止的过程;在开始启动过程后,数据字节地址中的7个位(bit[1]-bit[7])会被传送到串行数据线SDA上,通过它能够确定总线主设备所选的通信从设备;而第8位(bit[0])则决定是读或是写。

 

每个数据字节放到串行数据线上都必须是完整的八位。在总线传输操作中,不限制发送或接收的字节数量;数据总是先发送高位(MSB),每发送一位都需要立即跟上一个响应(ACK)位来反馈。



翻译原文来源于S5PV210数据手册:
S5PV210 IIC-BUS INTERFACE 
The S5PV210 RISC microprocessor supports four multi-master I2Cbus serial interfaces. To carry information between bus masters andperipheral devices connected to the I2C bus, a dedicated SerialData Line (SDA) and an Serial Clock Line (SCL) is used. Both SDAand SCL lines are bi-directional. 

In multi-master I2C-bus mode, multiple S5PV210 RISCmicroprocessors receive or transmit serial data to or from slavedevices. The master S5PV210 initiates and terminates a datatransfer over the I2C bus. The I2C bus in the S5PV210 uses astandard bus arbitration procedure. 

To control multi-master I2C-bus operations, values must bewritten to the following registers: 
•Multi-master I2C-bus control register-I2CCON 
•Multi-master I2C-bus control/status register-I2CSTAT 
•Multi-master I2C-bus Tx/Rx data shift register-I2CDS 
•Multi-master I2C-bus address register-I2CADD 

If the I2C-bus is free, both SDA and SCL lines should be bothat High level. A High-to-Low transition of SDA initiates a Startcondition. A Low-to-High transition of SDA initiates a Stopcondition while SCL remains steady at HighLevel. 

The master device always generates Start and Stop conditions.First 7-bit address value in the data byte that is transferred viaSDA line after the Start condition has been initiated, candetermine the slave device which the bus master device hasselected. The 8th bit determines the direction of the transfer(read or write).

 Every data byte put onto the SDA line shouldbe eight bits in total. There is no limit to send or receive bytesduring the bus transfer operation. Data is always sent frommost-significant bit (MSB) first, and every byte should beimmediately followed by acknowledge (ACK)bit. 
S5PV210的I2C通信

0 0