Skip to content

Conversation

@avisconti
Copy link
Contributor

Return to sensor_api i/f the temperature in Celsius instead of the register raw value in LSB.

Fixes #75686

Moreover, it fixes few other issues discovered while debugging.

@avisconti avisconti added bug The issue is a bug, or the PR is fixing a bug area: Drivers area: Sensors Sensors area: Samples Samples labels Jul 24, 2024
@avisconti avisconti self-assigned this Jul 24, 2024
@zephyrbot zephyrbot added the area: Shields Shields (add-on boards) label Jul 24, 2024
Extended the x-nucleo-iks4a1 shield standard sample adding lsm6dsv16x
sensor die temperature display.

Signed-off-by: Armando Visconti <[email protected]>
When setting the full scale through SENSOR_ATTR_FULL_SCALE the
driver must convert the g value (i.e. one of 2g/4g/8g/16g) to
the corrispondent sensor fs raw value.

Signed-off-by: Armando Visconti <[email protected]>
The current implementation assumes that sensor odr and range are
always configured in the Device Tree at compile time which might
not be the case.

Instead, application can set odr and range either at compile time
through the DT or using SENSOR_ATTR_SAMPLING_FREQUENCY and
SENSOR_ATTR_FULL_SCALE attributes at runtime, so each driver instance
must keep trace of the latest values set and use them in the sensor
APIs which require them (e.g. lis2dux12_mode_set).

Signed-off-by: Armando Visconti <[email protected]>
Return to sensor_api i/f the temperature in Celsius instead
of the register raw value in LSB.

Fixes zephyrproject-rtos#75686

Signed-off-by: Armando Visconti <[email protected]>
@MaureenHelm MaureenHelm added the backport v3.7-branch Request backport to the v3.7-branch label Jul 24, 2024
@MaureenHelm MaureenHelm added this to the v3.7.1 milestone Jul 24, 2024
@MaureenHelm
Copy link
Member

@avisconti does this fix need to be backported to v3.6?

stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx;
lis2dux12_md_t mode = {.odr = odr};

data->odr = odr;
Copy link
Member

@ubieda ubieda Jul 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling lis2dux12_set_range() includes odr when calling lis2dux12_mode_set(), but lis2dux12_set_odr() does not consider fs (thus setting it to zero).

Suggestion:

lis2dux12_md_t mode = {.odr = odr .fs = data->range};

EDIT: Not blocking this PR as it's not the issue being fixed. Can be followed on a separate one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ubieda Good advise! I'm doing it as a separate PR. Thanks for catching it.

@avisconti
Copy link
Contributor Author

@avisconti does this fix need to be backported to v3.6?

No need Maureen. The lis2dux12 driver has been introduced in a846b81, after v3.6.0 has been released. So, it's not present there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Drivers area: Samples Samples area: Sensors Sensors area: Shields Shields (add-on boards) backport v3.7-branch Request backport to the v3.7-branch bug The issue is a bug, or the PR is fixing a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ST LIS2DUX12 driver: temperature is not converted to Celsius and raw values are returned

7 participants