How to re-initialize a sensor driver (LSM6DSO)

Hello, 

I have a project with an LSM6DSO IMU which should be powered down between single measurements. This works fine if I supply voltage to the IMU all the time. If I turn down the power between measurements, I got wrong measurement values. 

My code:

/* initialize imu*/
void init_imu(){
	imu_dev = DEVICE_DT_GET(DT_NODELABEL(imu));;
	if (!device_is_ready(imu_dev)) {
		#ifdef CONFIG_DEBUG_INFO
		printk("%s: device not ready.\n", imu_dev->name);
		#endif
		return;
	}
}

...

sensor_sample_fetch_chan(imu_dev, SENSOR_CHAN_GYRO_XYZ);
sensor_channel_get(imu_dev, SENSOR_CHAN_GYRO_XYZ, &value);



I tried to reset the sampling interface after every reboot with the sensor API, but it doesnt help.

/* set sampling frequency for gyroscope */
	if (set_sampling_freq(imu_dev) != 0) {
		#ifdef CONFIG_DEBUG_INFO
		printk("er geht hier in sampling error");
		#endif
	}	

So i have to completely initialize se LSM6DSO. How could I do this? 

NCS 2.3.0
nRF52840

Thanks in advance!
Best regards, Jonas 

Related