add qei trait and implementation

This commit is contained in:
xoviat
2021-03-11 16:25:38 -06:00
parent 16e00669ae
commit fa807d2f08
4 changed files with 111 additions and 0 deletions

View File

@ -9,5 +9,6 @@
pub mod delay;
pub mod flash;
pub mod gpio;
pub mod qei;
pub mod i2c;
pub mod uart;

14
embassy-traits/src/qei.rs Normal file
View File

@ -0,0 +1,14 @@
use core::future::Future;
use core::pin::Pin;
use embedded_hal::Direction;
// Wait for a specified number of rotations either up or down
pub trait WaitForRotate {
type RotateFuture<'a>: Future<Output = Direction> + 'a;
fn wait_for_rotate<'a>(
self: Pin<&'a mut Self>,
count_down: u16,
count_up: u16,
) -> Self::RotateFuture<'a>;
}