Skip to content
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

Draft: DAC support with cs43l22 (for embedded-hal v0.2.x) #16

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

maxekman
Copy link
Contributor

Work in progress for the I2S embedded-hal trait (rust-embedded/embedded-hal#204). Just a sound playing demo using the I2S together with a driver for the DAC chip.

@maxekman maxekman force-pushed the dac-support-with-cs43l22_v0.2.x branch from 632e2e5 to 5791e21 Compare September 15, 2020 18:16
Copy link

@RaoulHC RaoulHC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unable to get sound out of my board for your example, though I've got it to compile and run, and can hear sounds when I stop and start the code in gdb, is this change missing, or am I doing something wrong?


// Demonstrating decoupling of audio device and application code using the
// embedded-hal trait for I2S.
fn play_sawtooth(i2s: &mut impl Write<u16>) -> ! {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a signed integer would make more sense here. I2s expects a signed integer, so a saw tooth happens to be the same, but it will be swapping to negative as it goes over 2^15 rather than when you're setting it back to 0, and other waves wont have the same shape.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can look into it, but I think the DAC expects unsigned data, and that audio data in general is unsigned. But I need to learn more about that to be sure.

}

impl AudioOut {
pub fn new<DELAY: DelayMs<u8>>(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would make more sense to pass the specific pins rather than the full gpio blocks. As it is all blocks get moved into the new method and then you can't any pins for anything else.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s done like this as that’s how it was done for the LED and accelerometer setup in this crate. I believe passing parts only moves the used pins after the function returns?

@chaosprint
Copy link

Hi,

This is an interesting topic. I wonder how this is going? Are you still working on it?

@eldruin
Copy link
Member

eldruin commented Oct 9, 2022

In the mean time I have published the traits as a separate crate: embedded-i2s

@maxekman
Copy link
Contributor Author

maxekman commented Oct 9, 2022

Very nice @eldruin!

@maxekman
Copy link
Contributor Author

maxekman commented Oct 9, 2022

@chaosprint Not much progress I’m afraid, been busy with other things.

@burrbull
Copy link
Contributor

burrbull commented Oct 9, 2022

About VSCode:

  1. rust-rls extention is deprecated and will be removed soon. Use rust-analyzer instead
  2. Instead of openocd + CortexM Debug you could use probe-rs-debugger + https://github.com/probe-rs/vscode/releases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants