[RFC] WIP: shared adc #6
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi @Rahix
Here is an attempt to implement ADC proxy. The first commit is the same as in #5 , so it will be removed as soon as
shared-bus
is updated for Rust 2018.Suggested implementation is not complete and has issues. However so far I could not find a proper way to fix them. So the purpose of this PR is to get feedback and find a better approach for shared ADC.
Example 1: using shared ADC for single channel
The following example appears to be working (full example is here) for single channel
Measurement
wrapper:And then create multiple instances each using different channel:
Example 2: using shared ADC for multiple channels
Similar approach does not work for
Measurement
with multiple channels (full example here):Due to strict type inference the following snippet results in compilation error:
Compiler expects ch0 and ch1 to be of the same type which is not the case.
Straightforward attempt to fix includes the following two steps:
PIN
to trait objects&'a mut dyn Channel<ADC, ID = u8
method `channel` has no receiver
issueHowever this brings errors for ADC reading in test mehods:
Regards,
Sergey