-
Notifications
You must be signed in to change notification settings - Fork 8.1k
lis2dux12: fix temp conversion (and other issues) #76279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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]>
|
@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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
No need Maureen. The lis2dux12 driver has been introduced in a846b81, after v3.6.0 has been released. So, it's not present there. |
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.