Hello, I am testing the BMX160 shuttle board and trying to get accelerometer, gyroscope and magnetometer data off it using BMI160/BMM150 driver provided. I'm able to get accelerometer and gyroscope data, but am not able to interact with the magnetometer. I'm following the user guide in the BMI160 driver readme and on the BMI160 wiki, but both appear to be out of date. In particular, the things that are out-of-date are: The wrapper functions no longer take the device id, and now takes a bmi160_dev struct The bmm150_dev type no longer has an id or settings attribute, and takes instead an interface pointer The bmm150_dev object now uses a microsecond delay function, not a millisecond delay function The bmm150_set_op_mode and bmm150_set_presetmode functions now take a separate bmm150_settings struct I've done my best to adapt the example code to the updated drivers, but still am not able to get magnetometer data. Relevant sections of my code are below. None of the driver functions are returning error codes. I am using v3.8.1 of the BMI160 drivers and v2.0.0 of the BMM150 drivers. Any clues about where I am mis-stepping or how to debug this issue would be appreciated. //wrapper functions for bmm150 int8_t user_aux_read(uint8_t reg_addr, uint8_t *aux_data, uint16_t len, bmi160_dev *dev) { int8_t rslt; rslt = bmi160_aux_read(reg_addr, aux_data, len, dev); return rslt; } /*wrapper function to match the signature of bmm150.write */ int8_t user_aux_write(uint8_t reg_addr, uint8_t *aux_data, uint16_t len, bmi160_dev *dev) { int8_t rslt; rslt = bmi160_aux_write(reg_addr, aux_data, len, dev); return rslt; } void main() { int8_t rslt = BMI160_OK; //configure bmi160 struct bmi160_dev bmi160; bmi160.id = BMI160_I2C_ADDR; bmi160.interface = BMI160_I2C_INTF; bmi160.read = (bmi160_com_fptr_t) &i2c_read; bmi160.write = (bmi160_com_fptr_t) &i2c_write; bmi160.delay_ms = (bmi160_delay_fptr_t) &delay; rslt = bmi160_init(&bmi160); //accel and gyro configuration bmi160.accel_cfg.odr = BMI160_ACCEL_ODR_25HZ; bmi160.accel_cfg.range = BMI160_ACCEL_RANGE_4G; bmi160.accel_cfg.bw = BMI160_ACCEL_BW_NORMAL_AVG4; bmi160.accel_cfg.power = BMI160_ACCEL_NORMAL_MODE; bmi160.gyro_cfg.odr = BMI160_GYRO_ODR_25HZ; bmi160.gyro_cfg.range = BMI160_GYRO_RANGE_250_DPS; bmi160.gyro_cfg.bw = BMI160_GYRO_BW_NORMAL_MODE; bmi160.gyro_cfg.power = BMI160_GYRO_NORMAL_MODE; rslt = bmi160_set_sens_conf(&bmi160); //auxillary interface bmi160.aux_cfg.aux_sensor_enable = 1; bmi160.aux_cfg.aux_i2c_addr = BMI160_AUX_BMM150_I2C_ADDR; bmi160.aux_cfg.manual_enable = 1; bmi160.aux_cfg.aux_rd_burst_len = 2; rslt = bmi160_aux_init(&bmi160); //bmm150 configuration struct bmm150_dev bmm150; bmm150.read = (bmm150_read_fptr_t) &user_aux_read; bmm150.write = (bmm150_write_fptr_t) &user_aux_write; bmm150.delay_us = (bmm150_delay_us_fptr_t) &delayMicroseconds; bmm150.intf = BMM150_I2C_INTF; bmm150.intf_ptr = &bmi160; rslt = bmm150_init(&bmm150); //bmm150 settings struct bmm150_settings settings; settings.pwr_mode = BMM150_POWERMODE_FORCED; settings.preset_mode= BMM150_PRESETMODE_REGULAR; rslt = bmm150_set_op_mode(&settings, &bmm150); rslt = bmm150_set_presetmode(&settings, &bmm150); //auxillary data rate bmi160.aux_cfg.aux_odr = BMI160_AUX_ODR_200HZ; rslt = bmi160_config_aux_mode(&bmi160); //set auto mode uint8_t aux_addr = 0x42; rslt = bmi160_set_aux_auto_mode(&aux_addr, &bmi160); //output data structures uint8_t mag_data[8] = {0}; struct bmi160_sensor_data accel; struct bmi160_sensor_data gyro; struct bmm150_mag_data magn; //get sensor data while(1) { rslt = bmi160_get_sensor_data((BMI160_ACCEL_SEL | BMI160_GYRO_SEL | BMI160_TIME_SEL), &accel, &gyro, &bmi160); rslt = bmi160_read_aux_data_auto_mode(mag_data, &bmi160); rslt = bmm150_aux_mag_data(mag_data, &magn, &bmm150); } }
... View more