stm32f4xx-hal icon indicating copy to clipboard operation
stm32f4xx-hal copied to clipboard

Erase PWM channel

Open kossnikita opened this issue 2 years ago • 1 comments

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();
    }
}

kossnikita avatar Oct 14 '23 07:10 kossnikita