I2c能否通过mmap读写
现在要做一个I2C的键盘的控制程序,我想直接在用户态写比较简单.
#define I2C0_REG_BASE (0x01C22000)m_nFd = open("/dev/mem", O_RDWR); m_pBaseAddr = (i2c_regs_t *)mmap(0, sizeof(i2c_regs_t), PROT_READ | PROT_WRITE, MAP_SHARED, m_nFd, (0x00000000+I2C0_REG_BASE ) >>0 );在I2C 的读写函数中,总是死在红色的位置 // transmit data one byte at a time. for (i = 0; i < in_length; i++) { i2c->ICDXR = src_buffer[i]; // wait for data to be copied to shift register. cnt = 0; do { if (cnt++ > I2C_TIMEOUT) { // timed out waiting for data...reinit and return error. //I2C_init(i2c, g_clock_rate); // return (ERR_TIMEOUT); } } [color=#FF0000]while (!CHKBIT(i2c->ICSTR, ICXRDY));[/color] }