我想了解下面的代碼片段從i2c-mpc.c I2C控制器。這段代碼片段是如何工作在I2C控制器
https://github.com/torvalds/linux/blob/master/drivers/i2c/busses/i2c-mpc.c#L440
static int mpc_write(struct mpc_i2c *i2c, int target,
const u8 *data, int length, int restart)
{
int i, result;
unsigned timeout = i2c->adap.timeout;
u32 flags = restart ? CCR_RSTA : 0;
/* Start as master */
writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA | CCR_MTX | flags);
/* Write target byte */
writeb((target << 1), i2c->base + MPC_I2C_DR);
result = i2c_wait(i2c, timeout, 1);
if (result < 0)
return result;
for (i = 0; i < length; i++) {
/* Write data byte */
writeb(data[i], i2c->base + MPC_I2C_DR);
result = i2c_wait(i2c, timeout, 1);
if (result < 0)
return result;
}
return 0;
}
任何人都可以請點我確切是我們正在做的第440行writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA | CCR_MTX | flags);
是它的全部四個寄存器越來越設置到值1,究竟是什麼標誌varibales包含?
請不要用 '***',以確定有問題的路線 - 它給貢獻者噩夢。 – 2014-10-04 13:44:29
它或運算四位爲標誌並將結果寫入到控制寄存器。應該有一個包含文件標識「CCR_MIEN」等位掩碼,並且控制器用戶手冊應解釋在硬件了每個位控制。 – 2014-10-04 13:48:16
對於寄存器描述:看到MPC107 PCI橋/內存 控制器用戶手冊,頁408個http://cache.freescale.com/files/32bit/doc/ref_manual/MPC107UM.pdf – 2014-10-04 19:40:05