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

Add an easy way to use timers #53

Open
oli-obk opened this issue Nov 28, 2017 · 0 comments
Open

Add an easy way to use timers #53

oli-obk opened this issue Nov 28, 2017 · 0 comments

Comments

@oli-obk
Copy link
Member

oli-obk commented Nov 28, 2017

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));
            });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant