-
Notifications
You must be signed in to change notification settings - Fork 7.4k
drivers: sensor: bmm350: add default odr/osr from dts and attr_get api #90078
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
base: main
Are you sure you want to change the base?
drivers: sensor: bmm350: add default odr/osr from dts and attr_get api #90078
Conversation
dfcb7ad
to
229d446
Compare
drivers/sensor/bosch/bmm350/bmm350.c
Outdated
uint8_t odr_bits; | ||
|
||
/* read current state */ | ||
ret = bmm350_reg_read(dev, BMM350_REG_PMU_CMD_AGGR_SET, &rx_buf[0], 3); |
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.
ret = bmm350_reg_read(dev, BMM350_REG_PMU_CMD_AGGR_SET, &rx_buf[0], 3); | |
ret = bmm350_reg_read(dev, BMM350_REG_PMU_CMD_AGGR_SET, &rx_buf[0], sizeof(rx_buf)); |
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.
fixed... also made a nit picky cleanup commit which included fixing this in other places
drivers/sensor/bosch/bmm350/bmm350.c
Outdated
} | ||
} | ||
|
||
void mag_reg_to_osr(uint8_t bits, struct sensor_value *val) |
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.
void mag_reg_to_osr(uint8_t bits, struct sensor_value *val) | |
static void mag_reg_to_osr(uint8_t bits, struct sensor_value *val) |
case 0: | ||
case 1: |
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.
Stray change? This doesn't look related to adding default odr/osr
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.
This was intentional to be consistent with other drivers, which just have a 1
as the no average for osr... I can separate it in to another commit
6.25 - 25/4 - 160ms | ||
3.125 - 25/8 - 320ms | ||
1.5625 - 25/16 - 640ms | ||
default: "100" |
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.
Need to explain in the description why the default value was selected
https://docs.zephyrproject.org/latest/build/dts/bindings-upstream.html#dt-bindings-default-rules
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.
4 - 4x | ||
2 - 2x | ||
1 - 1x | ||
default: 2 |
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.
Need to explain in the description why the default value was selected
https://docs.zephyrproject.org/latest/build/dts/bindings-upstream.html#dt-bindings-default-rules
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.
same comment #90078 (comment)
b29c3a5
to
4e178b2
Compare
52dfb2b
to
7ec33bc
Compare
pinging @maxd-nordic to also take a look |
7ec33bc
to
0126df7
Compare
@MaureenHelm sorry, for the churn after your approval, but I found a function where I forgot to change the return code from a int8_t to a int ( |
35c710a
to
5df74bf
Compare
Add the attr_get api. Also rename functions where they implied accelerometer to imply magnetometer. Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
Add a way to define the default odr and osr with devicetree for the bmm350. Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
Fix the oversampling value to be 1 from 0 for no oversampling to be consistant with other sensor drivers. Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
There is a race condition where an interrupt can fire before the drdy_handler is registered. The drdy_handler will tradionaly callback the sample get clearing the interrupt... but if it's not configured and NULL, the interrupt will stay forever latched. Read the interrupt status to clear the interrupt flag allowing it to trigger again. Also, move the serial api function helpers in to the header allowing them to be used from other c files. Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
Add configurations for setting the pad drive strength and the interrupt active high/low and od/pp. Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
There were a lot of places where the return value was sum'ed up which can be slightly easier to read, but can give an odd return value in the end. This changes it to just return immediately if an error is seen. There was also runtime NULL checking of input arguments that are rather programmer clown prevention. Change these to asserts. The return value didn't have a consistant type through the file, make it consistently an int. This changes the name of the return value of fix_sign to be signed_value differenating it from the ret name used elsewhere. Use the sizeof(buffer) as the argument for reg reads and writes rather than a hard number. Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
Run clang-format on files Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
This exposes a driver specific function to perform a magentic reset by the application. Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
5df74bf
to
41d663e
Compare
|
Rebased to get around the CI flake |
Add a default odr/osr from the dts and implement the attr_get api
This also adds the ability to set the pad drive strength as well as the interrupt line being od/pp or active high/low.