Merge #248

248: Add gyroscope read functionality to NinedofDriver r=jrvanwhy a=l162

Adds `read_gyroscope` to ninedof.

Co-authored-by: l162 <l162@hey.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(())
+}