stm32wb_pac/usb/
count4_rx.rs

1#[doc = "Reader of register COUNT4_RX"]
2pub type R = crate::R<u16, super::COUNT4_RX>;
3#[doc = "Writer for register COUNT4_RX"]
4pub type W = crate::W<u16, super::COUNT4_RX>;
5#[doc = "Register COUNT4_RX `reset()`'s with value 0"]
6impl crate::ResetValue for super::COUNT4_RX {
7    type Type = u16;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `COUNT4_RX`"]
14pub type COUNT4_RX_R = crate::R<u16, u16>;
15#[doc = "Reader of field `NUM_BLOCK`"]
16pub type NUM_BLOCK_R = crate::R<u8, u8>;
17#[doc = "Write proxy for field `NUM_BLOCK`"]
18pub struct NUM_BLOCK_W<'a> {
19    w: &'a mut W,
20}
21impl<'a> NUM_BLOCK_W<'a> {
22    #[doc = r"Writes raw bits to the field"]
23    #[inline(always)]
24    pub unsafe fn bits(self, value: u8) -> &'a mut W {
25        self.w.bits = (self.w.bits & !(0x1f << 10)) | (((value as u16) & 0x1f) << 10);
26        self.w
27    }
28}
29#[doc = "Reader of field `BL_SIZE`"]
30pub type BL_SIZE_R = crate::R<bool, bool>;
31#[doc = "Write proxy for field `BL_SIZE`"]
32pub struct BL_SIZE_W<'a> {
33    w: &'a mut W,
34}
35impl<'a> BL_SIZE_W<'a> {
36    #[doc = r"Sets the field bit"]
37    #[inline(always)]
38    pub fn set_bit(self) -> &'a mut W {
39        self.bit(true)
40    }
41    #[doc = r"Clears the field bit"]
42    #[inline(always)]
43    pub fn clear_bit(self) -> &'a mut W {
44        self.bit(false)
45    }
46    #[doc = r"Writes raw bits to the field"]
47    #[inline(always)]
48    pub fn bit(self, value: bool) -> &'a mut W {
49        self.w.bits = (self.w.bits & !(0x01 << 15)) | (((value as u16) & 0x01) << 15);
50        self.w
51    }
52}
53impl R {
54    #[doc = "Bits 0:9 - Reception byte count"]
55    #[inline(always)]
56    pub fn count4_rx(&self) -> COUNT4_RX_R {
57        COUNT4_RX_R::new((self.bits & 0x03ff) as u16)
58    }
59    #[doc = "Bits 10:14 - Number of blocks"]
60    #[inline(always)]
61    pub fn num_block(&self) -> NUM_BLOCK_R {
62        NUM_BLOCK_R::new(((self.bits >> 10) & 0x1f) as u8)
63    }
64    #[doc = "Bit 15 - Block size"]
65    #[inline(always)]
66    pub fn bl_size(&self) -> BL_SIZE_R {
67        BL_SIZE_R::new(((self.bits >> 15) & 0x01) != 0)
68    }
69}
70impl W {
71    #[doc = "Bits 10:14 - Number of blocks"]
72    #[inline(always)]
73    pub fn num_block(&mut self) -> NUM_BLOCK_W {
74        NUM_BLOCK_W { w: self }
75    }
76    #[doc = "Bit 15 - Block size"]
77    #[inline(always)]
78    pub fn bl_size(&mut self) -> BL_SIZE_W {
79        BL_SIZE_W { w: self }
80    }
81}