Futures for Stm32f4


#1

Hello, Rust community and embedded developers!

I would like to introduce the async-hal-stm32. async-hal-stm32 is a library targeted to use the futures-rs crate on stm32 boards.

Here is a pwm example (there are a couple of other examples available):

#[async]
fn task_pwm<'f, E>(period: u16, pin: &'f E, pwm: &'f Cell<u8>) -> Result<(), ()>
    where E: BasicPin + 'f
{   
    let mut interval = timer::interval_ms(100);

    loop {
        let duty = ((period as u32) * (pwm.get() as u32) >> 8) as u16;

        interval.set_interval_us(duty);
        await_item!(interval)?;
        pin.set_high();
        
        interval.set_interval_us(period - duty);
        await_item!(interval)?;
        pin.set_low();
    }
}

And also pelase check my opencm repo. opencm is my port of original libopencm3 to rust.