From 2cfdcc6771958b510f770e28651b869c52b8c943 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Thu, 25 Jul 2019 16:51:09 -0400 Subject: Update PCKSIZE for correct BYTE_COUNT offset and length. --- usbh/src/pipe/pck_size.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'usbh') diff --git a/usbh/src/pipe/pck_size.rs b/usbh/src/pipe/pck_size.rs index 5133005..d8fb4cb 100644 --- a/usbh/src/pipe/pck_size.rs +++ b/usbh/src/pipe/pck_size.rs @@ -73,11 +73,13 @@ impl R { MultiPacketSizeR(bits) } + // Documentation is wrong on this field. Actually 14 bits from + // offset 0. pub fn byte_count(&self) -> ByteCountR { let bits = { - const POS: u8 = 8; - const MASK: u32 = 0x3f; - ((self.bits >> POS) & MASK) as u8 + const POS: u8 = 0; + const MASK: u32 = 0x3fff; + ((self.bits >> POS) & MASK) as u16 }; ByteCountR(bits) @@ -205,9 +207,9 @@ impl MultiPacketSizeR { /// sent in the last OUT or SETUP transaction for an OUT pipe, or of /// the number of bytes to be received in the next IN transaction for /// an input pipe. -pub(crate) struct ByteCountR(u8); +pub(crate) struct ByteCountR(u16); impl ByteCountR { - pub fn bits(&self) -> u8 { + pub fn bits(&self) -> u16 { self.0 } } @@ -350,9 +352,11 @@ pub(crate) struct ByteCountW<'a> { w: &'a mut W, } impl<'a> ByteCountW<'a> { - pub unsafe fn bits(self, v: u8) -> &'a mut W { - const POS: u8 = 8; - const MASK: u8 = 0x3f; + // Documentation is wrong on this field. Actually 14 bits from + // offset 0. + pub unsafe fn bits(self, v: u16) -> &'a mut W { + const POS: u8 = 0; + const MASK: u16 = 0x3fff; self.w.bits &= !((MASK as u32) << POS); self.w.bits |= ((v & MASK) as u32) << POS; self.w -- cgit v1.2.3