embedded-hal
embedded-hal copied to clipboard
Waveform generation trait
trafficstars
I'd like to propose a waveform generation trait. This would be useful for efficient bitbanging, PWM, etc.
I will begin with simple sketch and we will see where it will lead.
pub struct Microseconds(/*What should go here? Maybe `pub u32` is fine?*/);
pub enum PinState {
High,
Low,
}
pub trait WaveGen {
fn generate<I: Clone + IntoIterator<Item=Microseconds>>(&mut self, pin: Pin, initial_state: PinState, delays: I, repeat_count: u32);
}
The implementor should set the pin into state defined by initial_state, then wait for duration specified by item from delays and toggle the pin after each item.
I'd love to implement some drivers for wireless sockets I have.