Hello I am trying to set the registers for BMA253 and was looking at the source code - in BMA2-Sensor-API bma2.c - and I have a few questions. I am looking at v0.3.0 On line 726, in bma2_set_accel_conf() function, it is reading the register 0x11(PMU_LPW) and that doesn't make sense. below is the code snippet: -------------------------------------------------------------------------------------------------------------------------------------------- Line726: rslt = bma2_get_regs(BMA2_REG_PMU_LPW, reg_data, 2, dev); Line727: Line728: if (rslt == BMA2_OK) Line729: { Line730: reg_data[0] = BMA2_SET_BITS_POS_0(reg_data[0], BMA2_RANGE, accel_conf->range); Line731: reg_data[1] = BMA2_SET_BITS_POS_0(reg_data[1], BMA2_BW, accel_conf->bw); Line732: Line733: /* Set the values in the accel configuration registers */ Line734: rslt = bma2_set_regs(BMA2_REG_PMU_RANGE, reg_data, 2, dev); -------------------------------------------------------------------------------------------------------------------------------------------- it is reading from 0x11(PMU_LPW) , setting the range and bandwith and writing it to 0x0F(PMU_RANGE). shouldn' t it be getting from register 0x0F(PMU_RANGE)? (it doesn't really matter because PMU_LPW is 0x00 and you are setting the reg_data with your range and bw) The code just after this is, I think, setting 0x3 in the reserved bit. (Line742) code snippets below: ------------------------------------------------------------------------------------------------------------------------- Line736: if (rslt == BMA2_OK) Line737: { Line738: reg_data[0] = BMA2_SET_BITS(reg_data[0], BMA2_SHADOW_DIS, accel_conf->shadow_dis); Line739: reg_data[0] = BMA2_SET_BITS(reg_data[0], BMA2_DATA_HIGH_BW, accel_conf->data_high_bw); Line740: Line741: /* Set the values in the accel config register */ Line742: rslt = bma2_set_regs(BMA2_REG_ACCD_HBW, ®_data[0], 1, dev); ------------------------------------------------------------------------------------------------------------------------- when i printf the reg_data , reg_data[0] has 0x03 when setting data to register 0x13(ACCD_HBW). In the case of BMA253, according to the data sheet, bit7 and bit6 is for data_high_bw and shadow_dis. bit5 to bit0 are for reserved and setting 0x03 means strange because you set data on the reserved bit. I think you have previous data (pmu range) in reg_data[0]. it seems that you should be calling bma2_get_regs() function with parameter 0x13(ACCD_HBW) before setting reg_data[0] on line738. that's all. I appreciate if you could give me a feedback.
... View more