drivers/sensor: lsm6dso: Remove LE to CPU conversions

In ST HAL v2.00, the functions to get the raw sensors values, e.g.
lsm6dso_acceleration_raw_get(), convert from little-endian to CPU.

Previous versions of ST HAL didn't do this.

The conversion here in the driver is converting a second time.  It's not
an issue on a LE system, the conversion is a no-op, but on a BE system
it would be broken.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
This commit is contained in:
Trent Piepho 2022-05-03 19:33:17 -07:00 committed by Marti Bolivar
commit c269692b1d
2 changed files with 4 additions and 17 deletions

View file

@ -297,17 +297,12 @@ static int lsm6dso_sample_fetch_accel(const struct device *dev)
const struct lsm6dso_config *cfg = dev->config;
stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx;
struct lsm6dso_data *data = dev->data;
int16_t buf[3];
if (lsm6dso_acceleration_raw_get(ctx, buf) < 0) {
if (lsm6dso_acceleration_raw_get(ctx, data->acc) < 0) {
LOG_DBG("Failed to read sample");
return -EIO;
}
data->acc[0] = sys_le16_to_cpu(buf[0]);
data->acc[1] = sys_le16_to_cpu(buf[1]);
data->acc[2] = sys_le16_to_cpu(buf[2]);
return 0;
}
@ -316,17 +311,12 @@ static int lsm6dso_sample_fetch_gyro(const struct device *dev)
const struct lsm6dso_config *cfg = dev->config;
stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx;
struct lsm6dso_data *data = dev->data;
int16_t buf[3];
if (lsm6dso_angular_rate_raw_get(ctx, buf) < 0) {
if (lsm6dso_angular_rate_raw_get(ctx, data->gyro) < 0) {
LOG_DBG("Failed to read sample");
return -EIO;
}
data->gyro[0] = sys_le16_to_cpu(buf[0]);
data->gyro[1] = sys_le16_to_cpu(buf[1]);
data->gyro[2] = sys_le16_to_cpu(buf[2]);
return 0;
}
@ -336,15 +326,12 @@ static int lsm6dso_sample_fetch_temp(const struct device *dev)
const struct lsm6dso_config *cfg = dev->config;
stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx;
struct lsm6dso_data *data = dev->data;
int16_t buf;
if (lsm6dso_temperature_raw_get(ctx, &buf) < 0) {
if (lsm6dso_temperature_raw_get(ctx, &data->temp_sample) < 0) {
LOG_DBG("Failed to read sample");
return -EIO;
}
data->temp_sample = sys_le16_to_cpu(buf);
return 0;
}
#endif

View file

@ -79,7 +79,7 @@ struct lsm6dso_data {
int16_t gyro[3];
uint32_t gyro_gain;
#if defined(CONFIG_LSM6DSO_ENABLE_TEMP)
int temp_sample;
int16_t temp_sample;
#endif
#if defined(CONFIG_LSM6DSO_SENSORHUB)
uint8_t ext_data[2][6];