2 Replies Latest reply on Jul 28, 2016 3:59 PM by Lockdog

    D2000: BMC150 Library

    Lockdog

      Hello!

      I'm trying to use BMC150 on D2000 dev board. And looked at the library in functionof reading magentometer data:

       

      qm_rc_t bmc150_read_mag(bmc150_mag_t *const mag)
      {
      ...
        rc = read_register(magneto_addr, BMC150_REG_MAG_X_LSB, raw_mag,
          sizeof(raw_mag));
        if (QM_RC_OK != rc) {
        return rc;
        }
      
        x = EXTRACT_MAG_XY(raw_mag[1], raw_mag[0]);
        y = EXTRACT_MAG_XY(raw_mag[3], raw_mag[2]);
        z = EXTRACT_MAG_Z(raw_mag[5], raw_mag[4]);
        rhall = EXTRACT_RHALL(raw_mag[7], raw_mag[6]);
      
        mag->x = compensate_xy(&digital_comp, rhall, x, AXIS_X);
        mag->y = compensate_xy(&digital_comp, rhall, y, AXIS_Y);
        mag->z = compensate_z(&digital_comp, rhall, z);
      
        return QM_RC_OK;
      }
      

       

      This function read only BMC150_REG_MAG_X_LSB which content only 5bits LSB data for the X-axis. How it works?

      I want to use High-Threshold Interrupt for Z-axis, and then I need to read Z register, but I don't know how...

       

      Thanks.

       

      UPD. Sorry, missed one thing: function read_register can read more than one byte at time. and BMC150_REG_MAG_X_LSB just a start point.