Hi everyone, I am using the BMX160 and I wrote the firmware based on the BMI160 API and BMM150 API and the integration procedure I am facing issues while switching modes and especially when I try to switch from BMM150_SUSPEND_MODE to BMM150_FORCED_MODE When the firmware starts, I first configure the power mode to BMM150_FORCED_MODE. The magnetometer works fine bmm150.settings.preset_mode = BMM150_PRESETMODE_REGULAR;
rslt = bmm150_set_presetmode(&bmm150);
APP_ERROR_CHECK(rslt);
bmm150.settings.pwr_mode = BMM150_FORCED_MODE;
rslt = bmm150_set_op_mode(&bmm150);
sensor.aux_cfg.aux_odr = BMI160_AUX_ODR_100HZ;
bmi160_config_aux_mode(&sensor);
bmi160_set_aux_auto_mode(&aux_addr, &sensor); Then I want to switch to BMM150_SUSPEND_MODE as follow: void low_active_state(struct bmi160_dev *dev_bmi160, struct bmm150_dev *dev_bmm150, int state) {
int8_t rslt;
// na - MAG: change the power mode to suspended
dev_bmm150->settings.pwr_mode = BMM150_SUSPEND_MODE;
rslt = bmm150_set_op_mode(dev_bmm150);
APP_ERROR_CHECK(rslt);
nrf_delay_ms(2);
NRF_LOG_INFO("info: Enter LOW ACTIVE STATE %d", state);
} Until here everything works fine Then I want to switch to BMM150_FORCED_MODE as follow: void active_state(struct bmi160_dev *dev_bmi160, struct bmm150_dev *dev_bmm150, int state) {
int8_t rslt;
// na - MAG: change the power mode to suspended
dev_bmm150->settings.pwr_mode = BMM150_FORCED_MODE;
rslt = bmm150_set_op_mode(dev_bmm150);
APP_ERROR_CHECK(rslt);
nrf_delay_ms(2);
NRF_LOG_INFO("info: Enter ACTIVE STATE %d", state);
} but the magnetometer does not change state.. It remains on suspended mode.. Looking the bmm150 API I found the function bmm150_set_op_mode(struct bmm150_dev *dev) I found that when I set either BMM150_NORMAL_MODE or BMM150_FORCED_MODE the system enters to sleep mode calling the function suspend_to_sleep_mode(dev) int8_t bmm150_set_op_mode(struct bmm150_dev *dev)
{
int8_t rslt;
uint8_t pwr_mode = dev->settings.pwr_mode;
/* Check for null pointer in the device structure*/
rslt = null_ptr_check(dev);
/* Proceed if null check is fine */
if (rslt == BMM150_OK)
{
/* Select the power mode to set */
switch (pwr_mode)
{
case BMM150_NORMAL_MODE:
/* If the sensor is in suspend mode
* put the device to sleep mode */
rslt = suspend_to_sleep_mode(dev);
if (rslt == BMM150_OK)
{
/* write the op mode */
rslt = write_op_mode(pwr_mode, dev);
}
break;
case BMM150_FORCED_MODE:
/* If the sensor is in suspend mode
* put the device to sleep mode */
rslt = suspend_to_sleep_mode(dev);
if (rslt == BMM150_OK)
{
/* write the op mode */
rslt = write_op_mode(pwr_mode, dev);
}
break;
case BMM150_SLEEP_MODE:
/* If the sensor is in suspend mode
* put the device to sleep mode */
rslt = suspend_to_sleep_mode(dev);
if (rslt == BMM150_OK)
{
/* write the op mode */
rslt = write_op_mode(pwr_mode, dev);
}
break;
case BMM150_SUSPEND_MODE:
/* Set the power control bit to zero */
rslt = set_power_control_bit(BMM150_POWER_CNTRL_DISABLE, dev);
break;
default:
rslt = BMM150_E_INVALID_CONFIG;
break;
}
}
return rslt;
} Also on the datasheet sais that: So what I understand so far is that: 1. From suspended mode I have to jump into sleep mode first. That's why the API calls the suspend_to_sleep_mode(dev) for BMM150_FORCED_MODE and BMM150_NORMAL_MODE 2. Then I have to configure the presetmode (is it necessary?) 3. Indirectly configure to force mode via magnetometer interface Are these steps correct? In case that is correct, can you help me with step 3. How do I indirectly configure to force mode using the magnetometer interface? Thanks in advance Nick
... View more