Exemplo n.º 1
0
/* transmit txcnt bytes to device */
static int I2C_backend_Write(struct i2c_state *i2c, int addr, unsigned char *i2c_tx_buf, int txcnt)
{
    int i;
    //int err;

    if (!i2c_tx_buf && txcnt)     /* check tx buffer */
        return 1;
    if(0)
    {
            printk((char *)"-W- ");	
            printk("0x%02x] ", addr);
            printk("[%d]", txcnt);
    		
            for(i=0;i<txcnt;i++)
            {
                printk(" 0x%02x ", i2c_tx_buf[i]);
            }

            if(txcnt==3)
            {
                printk(" [%d: %d]", i2c_tx_buf[0], (i2c_tx_buf[1]<<8)|i2c_tx_buf[2]);

            }
            else
            {
                printk(" [%d: %d]", (i2c_tx_buf[0]<<8)|i2c_tx_buf[1], (i2c_tx_buf[2]<<8)|i2c_tx_buf[3]);
            }
            printk("\r\n");		
        }
    addr = addr & 0xfe;

    //transmit ...
    if(DiBcom_i2c_write(addr, i2c_tx_buf, txcnt) !=DIB_RETURN_SUCCESS)
    {
        printk((char *)"-W- ");
        printk("0x%02x] ", addr);
        printk("DiBcom_i2c_write error");
        printk("\r\n");		
        return 1;
    }
    return 0;
}
Exemplo n.º 2
0
/* transmit txcnt bytes to device */
static int I2C_backend_Write(struct i2c_state *i2c, int addr, unsigned char *i2c_tx_buf, int txcnt)
{
    int i;
    int err;

    if (!i2c_tx_buf && txcnt)     /* check tx buffer */
    return 1;

    if(g_DebutI2cData)
    {
        printk("-W- ");
        printk("0x%02x] ", addr);
        printk("[%ld]", txcnt);
        for(i=0;i<txcnt;i++)
        {
            printk(" 0x%02x ", i2c_tx_buf[i]);
        }

        if(txcnt==3)
        {
            printk(" [%d: %d]", i2c_tx_buf[0], (i2c_tx_buf[1]<<8)|i2c_tx_buf[2]);
        }
        else
        {
            printk(" [%d: %d]", (i2c_tx_buf[0]<<8)|i2c_tx_buf[1], (i2c_tx_buf[2]<<8)|i2c_tx_buf[3]);
        }
        printk("\n");
        //printk("\n");
    }
    addr = addr & 0xfe;
    //transmit ...
    if(DiBcom_i2c_write((unsigned char)addr, i2c_tx_buf, txcnt))
    {
        printk("-W- ");
        printk("0x%02x] ", addr);
        printk("DiBcom_i2c_write error\n");
        return 1;
    }
    return 0;
}