你好,初始化以及读取代码如下,读取到的x,y,z数据一直变化,变化范围还很大,是有哪块还需要配置吗?
初始化:
uint8_t reg_val = 0x00;
i2c2_register_write(ADXL375_SLAVE_ADDR, 0x2D, reg_val, 1); //
reg_val = 0x0B;
i2c2_register_write(ADXL375_SLAVE_ADDR, 0x31, reg_val, 1); //
reg_val = 0x0D;
i2c2_register_write(ADXL375_SLAVE_ADDR, 0x2C, reg_val, 1); //
reg_val = 0x08;
i2c2_register_write(ADXL375_SLAVE_ADDR, 0x2D, reg_val, 1); //
读取:
i2c2_register_read(ADXL375_SLAVE_ADDR, 0x32, adxl_data, 6);
HAILIAN_LOGI("ADXL375 x : %d", (int16_t)((uint16_t)adxl_data[0] | (uint16_t)adxl_data[1] << 8));
HAILIAN_LOGI("ADXL375 y : %d", (int16_t)((uint16_t)adxl_data[2] | (uint16_t)adxl_data[3] << 8));
HAILIAN_LOGI("ADXL375 z : %d", (int16_t)((uint16_t)adxl_data[4] | (uint16_t)adxl_data[5] << 8));