ra4m1/can0/
mb_dl.rs

1#[doc = "Register `MB%s_DL` reader"]
2pub struct R(crate::R<MB_DL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<MB_DL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<MB_DL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<MB_DL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `MB%s_DL` writer"]
17pub struct W(crate::W<MB_DL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<MB_DL_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<MB_DL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<MB_DL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `DLC` reader - Data Length Code"]
38pub type DLC_R = crate::FieldReader<u8, DLC_A>;
39#[doc = "Data Length Code\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum DLC_A {
43    #[doc = "0: Data length = 0 byte"]
44    _0000 = 0,
45    #[doc = "1: Data length = 1 byte"]
46    _0001 = 1,
47    #[doc = "2: Data length = 2 bytes"]
48    _0010 = 2,
49    #[doc = "3: Data length = 3 bytes"]
50    _0011 = 3,
51    #[doc = "4: Data length = 4 bytes"]
52    _0100 = 4,
53    #[doc = "5: Data length = 5 bytes"]
54    _0101 = 5,
55    #[doc = "6: Data length = 6 bytes"]
56    _0110 = 6,
57    #[doc = "7: Data length = 7 bytes"]
58    _0111 = 7,
59}
60impl From<DLC_A> for u8 {
61    #[inline(always)]
62    fn from(variant: DLC_A) -> Self {
63        variant as _
64    }
65}
66impl DLC_R {
67    #[doc = "Get enumerated values variant"]
68    #[inline(always)]
69    pub fn variant(&self) -> Option<DLC_A> {
70        match self.bits {
71            0 => Some(DLC_A::_0000),
72            1 => Some(DLC_A::_0001),
73            2 => Some(DLC_A::_0010),
74            3 => Some(DLC_A::_0011),
75            4 => Some(DLC_A::_0100),
76            5 => Some(DLC_A::_0101),
77            6 => Some(DLC_A::_0110),
78            7 => Some(DLC_A::_0111),
79            _ => None,
80        }
81    }
82    #[doc = "Checks if the value of the field is `_0000`"]
83    #[inline(always)]
84    pub fn is_0000(&self) -> bool {
85        *self == DLC_A::_0000
86    }
87    #[doc = "Checks if the value of the field is `_0001`"]
88    #[inline(always)]
89    pub fn is_0001(&self) -> bool {
90        *self == DLC_A::_0001
91    }
92    #[doc = "Checks if the value of the field is `_0010`"]
93    #[inline(always)]
94    pub fn is_0010(&self) -> bool {
95        *self == DLC_A::_0010
96    }
97    #[doc = "Checks if the value of the field is `_0011`"]
98    #[inline(always)]
99    pub fn is_0011(&self) -> bool {
100        *self == DLC_A::_0011
101    }
102    #[doc = "Checks if the value of the field is `_0100`"]
103    #[inline(always)]
104    pub fn is_0100(&self) -> bool {
105        *self == DLC_A::_0100
106    }
107    #[doc = "Checks if the value of the field is `_0101`"]
108    #[inline(always)]
109    pub fn is_0101(&self) -> bool {
110        *self == DLC_A::_0101
111    }
112    #[doc = "Checks if the value of the field is `_0110`"]
113    #[inline(always)]
114    pub fn is_0110(&self) -> bool {
115        *self == DLC_A::_0110
116    }
117    #[doc = "Checks if the value of the field is `_0111`"]
118    #[inline(always)]
119    pub fn is_0111(&self) -> bool {
120        *self == DLC_A::_0111
121    }
122}
123#[doc = "Field `DLC` writer - Data Length Code"]
124pub type DLC_W<'a, const O: u8> = crate::FieldWriter<'a, u16, MB_DL_SPEC, u8, DLC_A, 4, O>;
125impl<'a, const O: u8> DLC_W<'a, O> {
126    #[doc = "Data length = 0 byte"]
127    #[inline(always)]
128    pub fn _0000(self) -> &'a mut W {
129        self.variant(DLC_A::_0000)
130    }
131    #[doc = "Data length = 1 byte"]
132    #[inline(always)]
133    pub fn _0001(self) -> &'a mut W {
134        self.variant(DLC_A::_0001)
135    }
136    #[doc = "Data length = 2 bytes"]
137    #[inline(always)]
138    pub fn _0010(self) -> &'a mut W {
139        self.variant(DLC_A::_0010)
140    }
141    #[doc = "Data length = 3 bytes"]
142    #[inline(always)]
143    pub fn _0011(self) -> &'a mut W {
144        self.variant(DLC_A::_0011)
145    }
146    #[doc = "Data length = 4 bytes"]
147    #[inline(always)]
148    pub fn _0100(self) -> &'a mut W {
149        self.variant(DLC_A::_0100)
150    }
151    #[doc = "Data length = 5 bytes"]
152    #[inline(always)]
153    pub fn _0101(self) -> &'a mut W {
154        self.variant(DLC_A::_0101)
155    }
156    #[doc = "Data length = 6 bytes"]
157    #[inline(always)]
158    pub fn _0110(self) -> &'a mut W {
159        self.variant(DLC_A::_0110)
160    }
161    #[doc = "Data length = 7 bytes"]
162    #[inline(always)]
163    pub fn _0111(self) -> &'a mut W {
164        self.variant(DLC_A::_0111)
165    }
166}
167impl R {
168    #[doc = "Bits 0:3 - Data Length Code"]
169    #[inline(always)]
170    pub fn dlc(&self) -> DLC_R {
171        DLC_R::new((self.bits & 0x0f) as u8)
172    }
173}
174impl W {
175    #[doc = "Bits 0:3 - Data Length Code"]
176    #[inline(always)]
177    #[must_use]
178    pub fn dlc(&mut self) -> DLC_W<0> {
179        DLC_W::new(self)
180    }
181    #[doc = "Writes raw bits to the register."]
182    #[inline(always)]
183    pub unsafe fn bits(&mut self, bits: u16) -> &mut Self {
184        self.0.bits(bits);
185        self
186    }
187}
188#[doc = "Mailbox Register\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [mb_dl](index.html) module"]
189pub struct MB_DL_SPEC;
190impl crate::RegisterSpec for MB_DL_SPEC {
191    type Ux = u16;
192}
193#[doc = "`read()` method returns [mb_dl::R](R) reader structure"]
194impl crate::Readable for MB_DL_SPEC {
195    type Reader = R;
196}
197#[doc = "`write(|w| ..)` method takes [mb_dl::W](W) writer structure"]
198impl crate::Writable for MB_DL_SPEC {
199    type Writer = W;
200    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
201    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
202}
203#[doc = "`reset()` method sets MB%s_DL to value 0"]
204impl crate::Resettable for MB_DL_SPEC {
205    const RESET_VALUE: Self::Ux = 0;
206}