From 7966be1419d3eaa088ed83f95282383182585640 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Thu, 25 Jul 2019 09:40:31 -0400 Subject: Move USB host stuff to separate crate. --- app/src/usb/pipe/addr.rs | 87 ------------------------------------------------ 1 file changed, 87 deletions(-) delete mode 100644 app/src/usb/pipe/addr.rs (limited to 'app/src/usb/pipe/addr.rs') diff --git a/app/src/usb/pipe/addr.rs b/app/src/usb/pipe/addr.rs deleted file mode 100644 index 8b92177..0000000 --- a/app/src/usb/pipe/addr.rs +++ /dev/null @@ -1,87 +0,0 @@ -/// ยง 32.8.7.2 -/// Address of the Data Buffer. -/// -/// Offset: 0x00 & 0x10 -/// Reset: 0xxxxxxxxx -/// Property: NA -#[derive(Clone, Copy, Debug)] -#[repr(C)] -pub(crate) struct Addr(u32); - -pub(crate) struct R { - bits: u32, -} - -pub(crate) struct W { - bits: u32, -} - -impl Addr { - pub fn read(&self) -> R { - R { bits: self.0 } - } - - pub fn write(&mut self, f: F) - where - F: FnOnce(&mut W) -> &mut W, - { - let mut w = W { bits: self.0 }; - f(&mut w); - // Address must be 32-bit aligned. - assert!((w.bits & 0x3) == 0); - self.0 = w.bits; - } -} - -impl From for Addr { - fn from(v: u32) -> Self { - Self(v) - } -} - -impl R { - /// Value in raw bits. - pub fn bits(&self) -> u32 { - self.bits - } - - pub fn addr(&self) -> AddrR { - AddrR(self.bits) - } -} - -/// Data Pointer Address Value -/// -/// These bits define the data pointer address as an absolute double -/// word address in RAM. The two least significant bits must be zero -/// to ensure the descriptor is 32-bit aligned. -pub(crate) struct AddrR(u32); -impl AddrR { - pub fn bits(&self) -> u32 { - self.0 - } -} - -impl W { - /// Write raw bits. - pub unsafe fn bits(&mut self, v: u32) -> &mut Self { - self.bits = v; - self - } - - pub fn addr(&mut self) -> AddrW { - AddrW { w: self } - } -} - -pub(crate) struct AddrW<'a> { - w: &'a mut W, -} -impl<'a> AddrW<'a> { - pub unsafe fn bits(self, v: u32) -> &'a mut W { - self.w.bits = v; - self.w - } - - // TODO: "safe" method take a pointer instead of raw u32 -} -- cgit v1.2.3