aboutsummaryrefslogtreecommitdiffstats
path: root/usbh/src/pipe/addr.rs
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2019-08-04 14:19:25 -0400
committerBrian Cully <bjc@kublai.com>2019-08-04 14:19:25 -0400
commite405c474f5e0e94288191223de7ae0f31ae0b15f (patch)
tree4ca89a92f0c868eb8feae272513c1e924b834adc /usbh/src/pipe/addr.rs
parentabd478d9425dd2d4acd5b58202b1a95b73ff217b (diff)
downloadsamd21-demo-e405c474f5e0e94288191223de7ae0f31ae0b15f.tar.gz
samd21-demo-e405c474f5e0e94288191223de7ae0f31ae0b15f.zip
Migrate everything over to separate libraries.
* `usb-host` is the crate containing the HAL traits. * `bootkbd` is a crate for a bare-bones boot protocol keyboard driver. * `samd21-host` is a crate with an implementation of `usb-host` for a SAMD21 platform, with an example for the trinket-m0 which uses the `bootkbd` driver to print keyboard reports.
Diffstat (limited to 'usbh/src/pipe/addr.rs')
-rw-r--r--usbh/src/pipe/addr.rs98
1 files changed, 0 insertions, 98 deletions
diff --git a/usbh/src/pipe/addr.rs b/usbh/src/pipe/addr.rs
deleted file mode 100644
index aa26048..0000000
--- a/usbh/src/pipe/addr.rs
+++ /dev/null
@@ -1,98 +0,0 @@
-/// § 32.8.7.2
-/// Address of the Data Buffer.
-///
-/// Offset: 0x00 & 0x10
-/// Reset: 0xxxxxxxxx
-/// Property: NA
-#[derive(Clone, Copy, Debug)]
-#[repr(C, packed)]
-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<F>(&mut self, f: F)
- where
- F: FnOnce(&mut W) -> &mut W,
- {
- let mut w = W { bits: self.0 };
- f(&mut w);
- self.0 = w.bits;
- }
-
- pub fn modify<F>(&mut self, f: F)
- where
- for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W,
- {
- let r = R { bits: self.0 };
- let mut w = W { bits: self.0 };
- f(&r, &mut w);
- self.0 = w.bits;
- }
-}
-
-impl From<u32> 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 {
- // Address must be 32-bit aligned. cf §32.8.7.2 of SAMD21 data
- // sheet.
- assert!((v & 0x3) == 0);
- self.w.bits = v;
- self.w
- }
-
- // TODO: "safe" method take a pointer instead of raw u32
-}