Skip to content

blocking DAC trait #240

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

Closed
wants to merge 2 commits into from
Closed

blocking DAC trait #240

wants to merge 2 commits into from

Conversation

mendelt
Copy link

@mendelt mendelt commented Jul 23, 2020

After some discussion on the rust embedded matrix chat during the Oxidize impl days I made a very simple implementation for a blocking DAC trait. This is a blocking implementation to make it usable for implementing in peripherals that use busses that do not have an nb interface like I2C.

I created a sample implementation for the Microchip mcp4725 I2C DAC here; https://github.com/mendelt/mcp4725/blob/dac-hal/src/lib.rs

The trait only supports setting the output of a single DAC channel. I'm planning on trying this out for the AD5668 8 channel DAC using a .split method that returns a channel instance for each of the 8 channels next.

Some discussion. We might want to have prescribed behavior for DACs that use less than the full word-length. The mcp4725 for example uses 12 of the 16 bits. Right now it uses the least significant bits but I'm thinking about fixing this and using the 12 most significant bits. I think this might make more sense in terms of the abstraction the trait provides. Programs using this trait would get more logical behavior when replacing a 16 bit DAC with a 14 or 12 bit one.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ryankurte (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@mendelt mendelt closed this Jul 30, 2020
@mendelt
Copy link
Author

mendelt commented Jul 30, 2020

I experimented a bit more but I'm a stuck on how to implement something like a .split() method for multi channel DACs so they return one struct implementing this trait per channel. I'll need to spend time on other things the coming weeks. So I closed this PR to keep other people from wasting time on it.

@eldruin
Copy link
Member

eldruin commented Sep 2, 2020

@mendelt have you seen #247 ? Further input would be valuable there.

@mendelt mendelt mentioned this pull request Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Review is incomplete T-hal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants