Skip to content

Add an easy way to use timers #53

@oli-obk

Description

@oli-obk

I really just want something like

let _ = tim6.repeat(1000, Priority::P1 || {
                // toggle the led
                let current_state = led.get();
                led.set(!current_state);
});

instead of

    tim6.sr.update(|sr| sr.set_uif(false));

    // setup timing
    tim6.psc.update(|psc| psc.set_psc(42000));
    tim6.arr.update(|arr| arr.set_arr(3000));

    // enable interrupt
    tim6.dier.update(|dier| dier.set_uie(true));
    // start the timer counter
    tim6.cr1.update(|cr1| cr1.set_cen(true));

            let _ = interrupt_table.register(InterruptRequest::Tim6Dac, Priority::P1, || {
                // toggle the led
                let current_state = led.get();
                led.set(!current_state);
                // make sure the interrupt doesn't just restart again by clearing the flag
                tim6.sr.update(|sr| sr.set_uif(false));
            });

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions