aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2019-07-27 21:43:04 -0400
committerBrian Cully <bjc@kublai.com>2019-07-27 21:43:04 -0400
commit268062bd6cfb7ec5c4f4548eaefb0e615ac627b7 (patch)
tree69dac5c1d192006ff1b3b915d83ba044d8fb650a
parent59ffeec652f56f9eed0a26d1caaa892f47be18fd (diff)
downloadsamd21-demo-268062bd6cfb7ec5c4f4548eaefb0e615ac627b7.tar.gz
samd21-demo-268062bd6cfb7ec5c4f4548eaefb0e615ac627b7.zip
Put size assertions in pcksize writers.
-rw-r--r--usbh/src/pipe/pck_size.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/usbh/src/pipe/pck_size.rs b/usbh/src/pipe/pck_size.rs
index d8fb4cb..9648381 100644
--- a/usbh/src/pipe/pck_size.rs
+++ b/usbh/src/pipe/pck_size.rs
@@ -340,6 +340,8 @@ pub(crate) struct MultiPacketSizeW<'a> {
}
impl<'a> MultiPacketSizeW<'a> {
pub unsafe fn bits(self, v: u16) -> &'a mut W {
+ assert!(v < 16_384);
+
const POS: u8 = 14;
const MASK: u16 = 0x3fff;
self.w.bits &= !((MASK as u32) << POS);
@@ -355,6 +357,8 @@ impl<'a> ByteCountW<'a> {
// Documentation is wrong on this field. Actually 14 bits from
// offset 0.
pub unsafe fn bits(self, v: u16) -> &'a mut W {
+ assert!(v < 16_384);
+
const POS: u8 = 0;
const MASK: u16 = 0x3fff;
self.w.bits &= !((MASK as u32) << POS);