From zephyr/samples/sensor/lsm6dso, I found the following code using sensor_channel_get(). API from sensor.h.
static void fetch_and_display(const struct device *dev)
{
struct sensor_value x, y, z;
static int trig_cnt;
trig_cnt++;
/* lsm6dso accel */
sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ);
sensor_channel_get(dev, SENSOR_CHAN_ACCEL_X, &x);
sensor_channel_get(dev, SENSOR_CHAN_ACCEL_Y, &y);
sensor_channel_get(dev, SENSOR_CHAN_ACCEL_Z, &z);
printf("accel x:%f ms/2 y:%f ms/2 z:%f ms/2\n",
out_ev(&x), out_ev(&y), out_ev(&z));
/* lsm6dso gyro */
sensor_sample_fetch_chan(dev, SENSOR_CHAN_GYRO_XYZ);
sensor_channel_get(dev, SENSOR_CHAN_GYRO_X, &x);
sensor_channel_get(dev, SENSOR_CHAN_GYRO_Y, &y);
sensor_channel_get(dev, SENSOR_CHAN_GYRO_Z, &z);
printf("gyro x:%f dps y:%f dps z:%f dps\n",
out_ev(&x), out_ev(&y), out_ev(&z));
printf("trig_cnt:%d\n\n", trig_cnt);
}However, there are more driver API in zephyr/drivers/sensor/lsm6dso
For example
static int lsm6dso_gyro_config(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val)
I could not find the corresponding sensor_gyro_config() API in sensor.h.
What is the proper way to use API to configure the lsm6dso chip ??
Thanks,
JC