pub fn new(
        fl: PwmPinFL,
        fr: PwmPinFR,
        rl: PwmPinRL,
        rr: PwmPinRR,
        timer: Timer,
        clocks: hal::rcc::Clocks,
    ) -> Self {
        // Arm/Stop HIGH < 1060us
        // Full Power 1860us

        let (ch_fl, ch_fr, ch_rl, ch_rr) = hal::pwm::tim3(timer, 20_000, PWM_FREQ.hz(), &clocks);

        // Config PWM Pins
        let mut ch_fl = ch_fl.output_to_pc6(fl);
        let mut ch_fr = ch_fr.output_to_pc7(fr);
        let mut ch_rl = ch_rl.output_to_pc8(rl);
        let mut ch_rr = ch_rr.output_to_pc9(rr);

        // Calculate duty
        let duty_max = ch_fl.get_max_duty() as f32;
        let pwm_period = 1.0 / PWM_FREQ as f32 * 1_000_000.0;
        let duty_stop = duty_max / pwm_period * 1060.0;
        let duty_full = duty_max / pwm_period * 1860.0;

        // Enable PWM
        ch_fl.enable();
        ch_fr.enable();
        ch_rl.enable();
        ch_rr.enable();

        let mut motors = Self {
            armed: false,
            pwm_fl: ch_fl,
            pwm_fr: ch_fr,
            pwm_rl: ch_rl,
            pwm_rr: ch_rr,
            duty_stop: duty_stop as u16,
            duty_full: duty_full as u16,
            rate_limit: 50.0,
            act_speed: (0.0, 0.0, 0.0, 0.0),
        };

        // Disable the Motors
        motors.disable();

        // Return the Motor Struct:
        motors
    }
/// Create New Struct controling the motors
Create New Struct controling the motors
Create New Struct controling the motors
pub fn new(
        fl: PwmPinFL,
        fr: PwmPinFR,
        rl: PwmPinRL,
        rr: PwmPinRR,
        timer: Timer,
        clocks: hal::rcc::Clocks,
    ) -> Self {
        // Arm/Stop HIGH < 1060us
        // Full Power 1860us
        let (ch_fl, ch_fr, ch_rl, ch_rr) = hal::pwm::tim3(timer, 20_000, PWM_FREQ.hz(), &clocks);
        // Config PWM Pins
        let mut ch_fl = ch_fl.output_to_pc6(fl);
        let mut ch_fr = ch_fr.output_to_pc7(fr);
        let mut ch_rl = ch_rl.output_to_pc8(rl);
        let mut ch_rr = ch_rr.output_to_pc9(rr);
        // Calculate duty
        let duty_max = ch_fl.get_max_duty() as f32;
        let pwm_period = 1.0 / PWM_FREQ as f32 * 1_000_000.0;
        let duty_stop = duty_max / pwm_period * 1060.0;
        let duty_full = duty_max / pwm_period * 1860.0;
        // Enable PWM
        ch_fl.enable();
        ch_fr.enable();
        ch_rl.enable();
        ch_rr.enable();
        let mut motors = Self {
            armed: false,
            pwm_fl: ch_fl,
            pwm_fr: ch_fr,
            pwm_rl: ch_rl,
            pwm_rr: ch_rr,
            duty_stop: duty_stop as u16,
            duty_full: duty_full as u16,
            rate_limit: 50.0,
            act_speed: (0.0, 0.0, 0.0, 0.0),
        };
        // Disable the Motors
        motors.disable();
        // Return the Motor Struct:
        motors
    }
pub fn new ( fl : PwmPinFL , fr : PwmPinFR , rl : PwmPinRL , rr : PwmPinRR , timer : Timer , clocks : hal :: rcc :: Clocks , ) -> Self { // Arm/Stop HIGH < 1060us // Full Power 1860us let ( ch_fl , ch_fr , ch_rl , ch_rr ) = hal :: pwm :: tim3 ( timer , 20_000 , PWM_FREQ . hz ( ) , & clocks ) ; // Config PWM Pins let mut ch_fl = ch_fl . output_to_pc6 ( fl ) ; let mut ch_fr = ch_fr . output_to_pc7 ( fr ) ; let mut ch_rl = ch_rl . output_to_pc8 ( rl ) ; let mut ch_rr = ch_rr . output_to_pc9 ( rr ) ; // Calculate duty let duty_max = ch_fl . get_max_duty ( ) as f32 ; let pwm_period = 1.0 / PWM_FREQ as f32 * 1_000_000.0 ; let duty_stop = duty_max / pwm_period * 1060.0 ; let duty_full = duty_max / pwm_period * 1860.0 ; // Enable PWM ch_fl . enable ( ) ; ch_fr . enable ( ) ; ch_rl . enable ( ) ; ch_rr . enable ( ) ; let mut motors = Self { armed : false , pwm_fl : ch_fl , pwm_fr : ch_fr , pwm_rl : ch_rl , pwm_rr : ch_rr , duty_stop : duty_stop as u16 , duty_full : duty_full as u16 , rate_limit : 50.0 , act_speed : ( 0.0 , 0.0 , 0.0 , 0.0 ) , } ; // Disable the Motors motors . disable ( ) ; // Return the Motor Struct: motors }
Create New Struct controling the motors
Create New Struct controling the motors
fl
PwmPinFL
fr
PwmPinFR
rl
PwmPinRL
rr
PwmPinRR
timer
Timer
clocks
hal::rcc::Clocks
fl
PwmPinFL
fr
PwmPinFR
rl
PwmPinRL
rr
PwmPinRR
timer
Timer
clocks
hal::rcc::Clocks