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

Erase PWM channel #687

Open
kossnikita opened this issue Oct 14, 2023 · 1 comment
Open

Erase PWM channel #687

kossnikita opened this issue Oct 14, 2023 · 1 comment

Comments

@kossnikita
Copy link

kossnikita commented Oct 14, 2023

I have the similar problem as #499. But in addition to this, I would like to use channels without binding to timers and their channels.
Is there any way to erase the timer and channel? To use a channel in an array for example.

    let pins = (Channel1::new(gpioa.pa0), Channel2::new(gpioa.pa1));
    let mut pwm = dp.TIM5.pwm_hz(pins, 1.kHz(), &clocks).split();

    let mut channels = [pwm.0, pwm.1];
|                              ^^^^^ expected `0`, found `1`
|
= note: expected struct `PwmChannel<_, 0, _>`
          found struct `PwmChannel<_, 1, _>`

Or like this

use hal::{
    prelude::*,
    timer::{Channel1, Channel2, PwmChannel, Instance, WithPwm},
|                                                      ^^^^^^^ private trait
};

struct CommonChannel<TIM, const C: u8> {
    pwm: PwmChannel<TIM, C>,
}

impl<TIM: Instance + WithPwm, const C: u8> CommonChannel<TIM, C> {
    pub fn enable(&self) {
        self.pwm.enable();
    }
}
@burrbull
Copy link
Contributor

burrbull commented Jun 1, 2024

Is there any way to erase the timer and channel? To use a channel in an array for example.

This is reasonable. Could you make PR with ErasedPwmChannel?

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