示例#1
0
U32 usb_i2c_write8 (U8 addr, U8 value)
{
    U32 ret_code = I2C_OK;
    U8 write_data[2];

    write_data[0]= addr;
    write_data[1] = value;

    ret_code = mt_i2c_write(USB_I2C_ID, 0xc0, write_data, 2, PATH_NORMAL);

    return ret_code;
}
 U32 sn65dsi8x_reg_i2c_write(U8 addr, U8 value)
 {
	 U32 ret_code = I2C_OK;
	 U8 write_data[2];
 
	 write_data[0]= addr;
	 write_data[1] = value;
 	
	 ret_code = mt_i2c_write(I2C_CH, sn65dsi8x_I2C_ADDR, write_data, 2,0); // 0:I2C_PATH_NORMAL
	 printf("sn65dsi8x_reg_i2c_write cmd=0x%x  data=0x%x ret_code=0x%x\n",addr,value,ret_code);
	 
	 return ret_code;
 }
 U32 sn65dsi8x_reg_i2c_read (U8 addr, U8 *dataBuffer)
 {
	 U32 ret_code = I2C_OK;
	 U8 write_data = addr;
 
	 /* set register command */
	 ret_code = mt_i2c_write(I2C_CH, sn65dsi8x_I2C_ADDR, &write_data, 1, 0); // 0:I2C_PATH_NORMAL
 
	 if (ret_code != I2C_OK)
		 return ret_code;
 
	 ret_code = mt_i2c_read(I2C_CH, (sn65dsi8x_I2C_ADDR|0x1), dataBuffer, 1,0); // 0:I2C_PATH_NORMAL
 
	 return ret_code;
 }
示例#4
0
U32 usb_i2c_read8 (U8 addr, U8 *dataBuffer)
{
    U32 ret_code = I2C_OK;
    U8 write_data = addr;

    /* set register command */
    ret_code = mt_i2c_write(USB_I2C_ID, 0xc0, &write_data, 1, PATH_NORMAL);

    if (ret_code != I2C_OK)
        return ret_code;

    ret_code = mt_i2c_read(USB_I2C_ID, 0xc0, dataBuffer, 1, PATH_NORMAL);

    return ret_code;
}
U32 it6151_reg_i2c_write_byte (U8 dev_addr,U8  cmd, U8 data)
{
    U8 cmdBufferLen = 1;
    U8 dataBufferLen = 1;	
    U32 ret_code = I2C_OK;
    U8 write_data[I2C_FIFO_SIZE];
    int transfer_len = 0;
    int i=0, cmdIndex=0, dataIndex=0;
	
    dev_addr = dev_addr<<1;  // for write
    
    transfer_len = cmdBufferLen + dataBufferLen;
    if(I2C_FIFO_SIZE < (cmdBufferLen + dataBufferLen))
    {
        dprintf(CRITICAL, "[it6151_i2c_write] exceed I2C FIFO length!! \n");
        return 0;
    }

    //write_data[0] = cmd;
    //write_data[1] = writeData;

    while(cmdIndex < cmdBufferLen)
    {
        write_data[i] = cmd;
        cmdIndex++;
        i++;
    }

    while(dataIndex < dataBufferLen)
    {
        write_data[i] = data;
        dataIndex++;
        i++;
    }


    /* dump write_data for check */
    for( i=0 ; i < transfer_len ; i++ )
    {
        dprintf(CRITICAL, "[it6151_i2c_write] write_data[%d]=%x\n", i, write_data[i]);
    }

    ret_code = mt_i2c_write(IT6151_BUSNUM, dev_addr, write_data, transfer_len,0);


    return ret_code;
}
static U32 it6151_reg_i2c_read_byte (U8 dev_addr,U8  *cmdBuffer, U8 *dataBuffer)
{
    U32 ret_code = I2C_OK;

    dev_addr = (dev_addr<<1) | 1;  // for read
    ret_code = mt_i2c_write(IT6151_BUSNUM, dev_addr, cmdBuffer, 1, 0);    // set register command
    if (ret_code != I2C_OK)
        return ret_code;

    ret_code = mt_i2c_read(IT6151_BUSNUM, dev_addr, dataBuffer, 1, 0);

    if (ret_code != I2C_OK)
        return ret_code;	


    return ret_code;
}