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

Basic ADC DMA capture - help needed #547

Open
mryndzionek opened this issue Feb 8, 2023 · 1 comment
Open

Basic ADC DMA capture - help needed #547

mryndzionek opened this issue Feb 8, 2023 · 1 comment

Comments

@mryndzionek
Copy link

mryndzionek commented Feb 8, 2023

I'm trying to add basic ADC DMA capture. I've added ReadTarget for ADC like so:

impl ReadTarget for Adc {
    type ReceivedWord = u8;

    fn rx_treq() -> Option<u8> {
        Some(TREQ_SEL_A::ADC.into())
    }

    fn rx_address_count(&self) -> (u32, u32) {
        (&self.device.fifo as *const _ as u32, u32::MAX)
    }

    fn rx_increment(&self) -> bool {
        false
    }
}

The following code compiles now:

    let mut adc = Adc::new(pac.ADC, &mut pac.RESETS);

    let rx_buf = singleton!(: [u8; 5] = [0; 5]).unwrap();
    let rx_transfer = hal::dma::single_buffer::Config::new(ch0, adc, rx_buf).start();
    let (ch0, mut adc, rx_buf) = rx_transfer.wait();

It won't work however, as ADC conversion needs to be enabled just after the DMA channel has been setup, so it seems it needs to be done inside the start() (in single_buffer::Config) function. What would be the best way to achieve this, i.e. add device-specific 'actions' inside the single_buffer::Config? Does it require significant changes to the single_buffer traits? I guess it relates to this comment.

@Rhvarrier
Copy link

Hello, I'm having the same issue. Has there been any update concerning this issue?

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

No branches or pull requests

2 participants