This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

about the drive of sensor

when config 'CONFIG_BMA280=y' in 'prj.conf' file,but Solution 'build' not compiled,the code 'bma280.c' also not included in the project,why???

Parents Reply
  • static int i2c_nrfx_twim_transfer(struct device *dev, struct i2c_msg *msgs,
    u8_t num_msgs, u16_t addr)
    {
    int ret = 0;

    k_sem_take(&(get_dev_data(dev)->transfer_sync), K_FOREVER);
    nrfx_twim_enable(&get_dev_config(dev)->twim);

    for (size_t i = 0; i < num_msgs; i++) {
    if (I2C_MSG_ADDR_10_BITS & msgs[i].flags) {
    ret = -ENOTSUP;
    break;
    }

    nrfx_twim_xfer_desc_t cur_xfer = {
    .p_primary_buf = msgs[i].buf,
    .primary_length = msgs[i].len,
    .address = addr,
    .type = (msgs[i].flags & I2C_MSG_READ) ?
    NRFX_TWIM_XFER_RX : NRFX_TWIM_XFER_TX
    };
    LOG_INF("i2c device transfer: %x,%x", *msgs[i].buf, addr);
    nrfx_err_t res = nrfx_twim_xfer(&get_dev_config(dev)->twim,
    &cur_xfer,
    (msgs[i].flags & I2C_MSG_STOP) ?
    0 : NRFX_TWIM_FLAG_TX_NO_STOP);
    LOG_INF("i2c device ret: %d", res);
    if (res != NRFX_SUCCESS) {
    if (res == NRFX_ERROR_BUSY) {
    ret = -EBUSY;
    break;
    } else {
    ret = -EIO;
    break;
    }
    }

    k_sem_take(&(get_dev_data(dev)->completion_sync), K_FOREVER);
    res = get_dev_data(dev)->res;
    if (res != NRFX_SUCCESS) {
    LOG_ERR("Error %d occurred for message %d", res, i);
    ret = -EIO;
    break;
    }
    }

    nrfx_twim_disable(&get_dev_config(dev)->twim);
    k_sem_give(&(get_dev_data(dev)->transfer_sync));

    return ret;
    }

    =======================================

    look at here pls:

    LOG_INF("i2c device transfer: %x,%x", *msgs[i].buf, addr);

    It show that reg & addr is ok,but the result is that:

    LOG_ERR("Error %d occurred for message %d", res, i);

Children
No Data
Related