Merge #247 247: Document several factors constraining `libtock_core`'s design. r=hudson-ayers a=jrvanwhy This Design Considerations document outlines a number of considerations that affect the design of `libtock_core` which do not impact most Rust projects. It is intended to help onboard new contributors and to remind long-term contributors of constraints that other `libtock_core` clients have. [Rendered document](https://github.com/jrvanwhy/libtock-rs/blob/design-doc/doc/DesignConsiderations.md) Co-authored-by: Johnathan Van Why <jrvanwhy@google.com>
diff --git a/src/sensors/ninedof.rs b/src/sensors/ninedof.rs index b5e7191..f5c0197 100644 --- a/src/sensors/ninedof.rs +++ b/src/sensors/ninedof.rs
@@ -47,6 +47,14 @@ Ok(res.res.get()) } + pub fn read_gyroscope(&mut self) -> TockResult<NinedofReading> { + let res: CbData = Default::default(); + subscribe(Self::cb, unsafe { mem::transmute(&res) })?; + start_gyroscope_reading()?; + unsafe { executor::block_on(futures::wait_until(|| res.ready.get())) }; + Ok(res.res.get()) + } + extern "C" fn cb(x: usize, y: usize, z: usize, ptr: usize) { let res: &CbData = unsafe { mem::transmute(ptr) }; res.res.set(NinedofReading { @@ -72,3 +80,8 @@ syscalls::command(DRIVER_NUM, 100, 0, 0)?; Ok(()) } + +pub fn start_gyroscope_reading() -> TockResult<()> { + syscalls::command(DRIVER_NUM, 200, 0, 0)?; + Ok(()) +}
diff --git a/tock b/tock index 9f40864..e8d0a28 160000 --- a/tock +++ b/tock
@@ -1 +1 @@ -Subproject commit 9f408649ce25f46f0dd49dae7f1a0a9849cae2af +Subproject commit e8d0a28d86897c91b6747be357abfcfa7e86688f