Пример #1
0
static int host_i2c_xfer(struct dibDataBusClient *client, struct dibDataBusAccess *msg)
{
    struct i2c_state *st = NULL;
    
    //DBG("TSTV:DIBCOM8076: client is %p\n", client);
    st = client->host->priv;
    msg->address = data_bus_access_device_id(client, msg);
#ifdef DEBUG_DATA
    dbgp("i2c_%s: (addr: %02x): ",msg->rx == NULL ? "wr" : "rd",data_bus_access_device_id(client, msg) >> 1);
    dbg_bufdump(msg->tx,msg->txlen);
    if (msg->rx != NULL && msg->rxlen != 0) {
        dbgp(" - ");
        dbg_bufdump(msg->rx,msg->rxlen);
    }
    dbgp("\n");
#endif

    if (msg->rx == NULL || msg->rxlen == 0) {
        // implement here the write function and return DIB_RETURN_SUCCESS in case of success
        // return DIB_RETURN_SUCCESS
        return I2C_backend_Write(st, msg->address, msg->tx, msg->txlen);
        //return DIB_RETURN_ERROR;
    }
    else {
        // implement here the read function and return DIB_RETURN_SUCCESS in case of success
        // return DIB_RETURN_SUCCESS

        //return DIB_RETURN_ERROR;
        return I2C_backend_WriteRead(st, msg->address, msg->tx, msg->txlen, msg->rx, msg->rxlen);
    }
}
Пример #2
0
static int host_i2c_xfer(struct dibDataBusClient *client, struct dibDataBusAccess *msg)
{
    struct i2c_state *st = client->host->priv;
    int ret = 0;
    msg->address = data_bus_access_device_id(client, msg);
    //printk("dibcom_i2c_master_xfer is called msg->address = 0x%x\n", msg->address);
    if (msg->rx == NULL || msg->rxlen == 0) {
        // implement here the write function and return DIB_RETURN_SUCCESS in case of success
        // return DIB_RETURN_SUCCESS
        ret = I2C_backend_Write(st, msg->address, (unsigned char *)msg->tx, msg->txlen);
    }
    else {
        // implement here the read function and return DIB_RETURN_SUCCESS in case of success
        // return DIB_RETURN_SUCCESS
        ret = I2C_backend_WriteRead(st, msg->address, (unsigned char *)msg->tx, msg->txlen, msg->rx, msg->rxlen);
    }
    return ret;
}