saul_adc: Add conversion functionality#8581
saul_adc: Add conversion functionality#8581jnohlgard wants to merge 7 commits intoRIOT-OS:masterfrom
Conversation
29c9df3 to
3e275ac
Compare
|
One caveat is that the sensor type is still determined by the driver (saul_adc), so the source is still listed as SENSE_ANALOG when enumerated, regardless whether it puts out values in raw ADC numbers or e.g. a temperature reading |
aabadie
left a comment
There was a problem hiding this comment.
Found some minors things. The feature is interesting.
| * Real Vrefh = vrefh * 10^(scale) | ||
| * For example, scale = -3 means that vrefh, vrefl are given in millivolts. | ||
| */ | ||
| void adc_conv_set_scale(int new_scale); |
There was a problem hiding this comment.
new_scale is not documented (use @param[in] new_scale ...)
sys/phydat/phydat.c
Outdated
| */ | ||
|
|
||
| /** | ||
| * @ingroup driver_sensif |
There was a problem hiding this comment.
weird, this group is not defined (git grep only return an @ingroup driver_sensif in phydat_str.c. Looks like there a typo somewhere or something missing.
boards/mulle/include/board.h
Outdated
| * @name ADC sample conversion configuration | ||
| * @{ | ||
| */ | ||
| #define BOARD_ADC_VREFH_DEFAULT 33000 |
There was a problem hiding this comment.
maybe put parenthesis around values
|
|
||
| static void test_phydat_fit(void) | ||
| { | ||
| int val0 = 100000; |
There was a problem hiding this comment.
Might be interesting to put a comment explaining what this test is supposed to do.
6b5e4ef to
39469e3
Compare
cddbf1c to
e406001
Compare
|
This feature is interesting and I'm wondering whether it could be extended to work with any type of sensor within saul. My use case would be to convert a raw adc value form an i2c ADC to a voltage. |
|
@vincent-d I agree that it might be useful, but might be better then to create a saul filter device which wraps another saul device. |
Optionally specify a conversion function to convert the ADC sample into a physical measurement.
e406001 to
cee7722
Compare
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
Contribution description
Adds an option to specify an additional conversion function to the adc_params.h saul_adc configuration struct. The conversion function should take a raw ADC sample and convert it to some other measurement.
Included in the PR is an example generic filter function to convert ADC reading to real voltage. Only the Mulle platform is configured yet, but it is quite straightforward to implement the configuration.
Issues/PRs references
Depends on #8566, #8577, #8592, #8593