atsame70q20/mcan0/
mcan_txesc.rs

1#[doc = "Register `MCAN_TXESC` reader"]
2pub struct R(crate::R<MCAN_TXESC_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<MCAN_TXESC_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<MCAN_TXESC_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<MCAN_TXESC_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `MCAN_TXESC` writer"]
17pub struct W(crate::W<MCAN_TXESC_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<MCAN_TXESC_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<MCAN_TXESC_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<MCAN_TXESC_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Tx Buffer Data Field Size\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum TBDS_A {
41    #[doc = "0: 8-byte data field"]
42    _8_BYTE = 0,
43    #[doc = "1: 12-byte data field"]
44    _12_BYTE = 1,
45    #[doc = "2: 16-byte data field"]
46    _16_BYTE = 2,
47    #[doc = "3: 20-byte data field"]
48    _20_BYTE = 3,
49    #[doc = "4: 24-byte data field"]
50    _24_BYTE = 4,
51    #[doc = "5: 32-byte data field"]
52    _32_BYTE = 5,
53    #[doc = "6: 48- byte data field"]
54    _48_BYTE = 6,
55    #[doc = "7: 64-byte data field"]
56    _64_BYTE = 7,
57}
58impl From<TBDS_A> for u8 {
59    #[inline(always)]
60    fn from(variant: TBDS_A) -> Self {
61        variant as _
62    }
63}
64#[doc = "Field `TBDS` reader - Tx Buffer Data Field Size"]
65pub struct TBDS_R(crate::FieldReader<u8, TBDS_A>);
66impl TBDS_R {
67    #[inline(always)]
68    pub(crate) fn new(bits: u8) -> Self {
69        TBDS_R(crate::FieldReader::new(bits))
70    }
71    #[doc = r"Get enumerated values variant"]
72    #[inline(always)]
73    pub fn variant(&self) -> TBDS_A {
74        match self.bits {
75            0 => TBDS_A::_8_BYTE,
76            1 => TBDS_A::_12_BYTE,
77            2 => TBDS_A::_16_BYTE,
78            3 => TBDS_A::_20_BYTE,
79            4 => TBDS_A::_24_BYTE,
80            5 => TBDS_A::_32_BYTE,
81            6 => TBDS_A::_48_BYTE,
82            7 => TBDS_A::_64_BYTE,
83            _ => unreachable!(),
84        }
85    }
86    #[doc = "Checks if the value of the field is `_8_BYTE`"]
87    #[inline(always)]
88    pub fn is_8_byte(&self) -> bool {
89        **self == TBDS_A::_8_BYTE
90    }
91    #[doc = "Checks if the value of the field is `_12_BYTE`"]
92    #[inline(always)]
93    pub fn is_12_byte(&self) -> bool {
94        **self == TBDS_A::_12_BYTE
95    }
96    #[doc = "Checks if the value of the field is `_16_BYTE`"]
97    #[inline(always)]
98    pub fn is_16_byte(&self) -> bool {
99        **self == TBDS_A::_16_BYTE
100    }
101    #[doc = "Checks if the value of the field is `_20_BYTE`"]
102    #[inline(always)]
103    pub fn is_20_byte(&self) -> bool {
104        **self == TBDS_A::_20_BYTE
105    }
106    #[doc = "Checks if the value of the field is `_24_BYTE`"]
107    #[inline(always)]
108    pub fn is_24_byte(&self) -> bool {
109        **self == TBDS_A::_24_BYTE
110    }
111    #[doc = "Checks if the value of the field is `_32_BYTE`"]
112    #[inline(always)]
113    pub fn is_32_byte(&self) -> bool {
114        **self == TBDS_A::_32_BYTE
115    }
116    #[doc = "Checks if the value of the field is `_48_BYTE`"]
117    #[inline(always)]
118    pub fn is_48_byte(&self) -> bool {
119        **self == TBDS_A::_48_BYTE
120    }
121    #[doc = "Checks if the value of the field is `_64_BYTE`"]
122    #[inline(always)]
123    pub fn is_64_byte(&self) -> bool {
124        **self == TBDS_A::_64_BYTE
125    }
126}
127impl core::ops::Deref for TBDS_R {
128    type Target = crate::FieldReader<u8, TBDS_A>;
129    #[inline(always)]
130    fn deref(&self) -> &Self::Target {
131        &self.0
132    }
133}
134#[doc = "Field `TBDS` writer - Tx Buffer Data Field Size"]
135pub struct TBDS_W<'a> {
136    w: &'a mut W,
137}
138impl<'a> TBDS_W<'a> {
139    #[doc = r"Writes `variant` to the field"]
140    #[inline(always)]
141    pub fn variant(self, variant: TBDS_A) -> &'a mut W {
142        self.bits(variant.into())
143    }
144    #[doc = "8-byte data field"]
145    #[inline(always)]
146    pub fn _8_byte(self) -> &'a mut W {
147        self.variant(TBDS_A::_8_BYTE)
148    }
149    #[doc = "12-byte data field"]
150    #[inline(always)]
151    pub fn _12_byte(self) -> &'a mut W {
152        self.variant(TBDS_A::_12_BYTE)
153    }
154    #[doc = "16-byte data field"]
155    #[inline(always)]
156    pub fn _16_byte(self) -> &'a mut W {
157        self.variant(TBDS_A::_16_BYTE)
158    }
159    #[doc = "20-byte data field"]
160    #[inline(always)]
161    pub fn _20_byte(self) -> &'a mut W {
162        self.variant(TBDS_A::_20_BYTE)
163    }
164    #[doc = "24-byte data field"]
165    #[inline(always)]
166    pub fn _24_byte(self) -> &'a mut W {
167        self.variant(TBDS_A::_24_BYTE)
168    }
169    #[doc = "32-byte data field"]
170    #[inline(always)]
171    pub fn _32_byte(self) -> &'a mut W {
172        self.variant(TBDS_A::_32_BYTE)
173    }
174    #[doc = "48- byte data field"]
175    #[inline(always)]
176    pub fn _48_byte(self) -> &'a mut W {
177        self.variant(TBDS_A::_48_BYTE)
178    }
179    #[doc = "64-byte data field"]
180    #[inline(always)]
181    pub fn _64_byte(self) -> &'a mut W {
182        self.variant(TBDS_A::_64_BYTE)
183    }
184    #[doc = r"Writes raw bits to the field"]
185    #[inline(always)]
186    pub fn bits(self, value: u8) -> &'a mut W {
187        self.w.bits = (self.w.bits & !0x07) | (value as u32 & 0x07);
188        self.w
189    }
190}
191impl R {
192    #[doc = "Bits 0:2 - Tx Buffer Data Field Size"]
193    #[inline(always)]
194    pub fn tbds(&self) -> TBDS_R {
195        TBDS_R::new((self.bits & 0x07) as u8)
196    }
197}
198impl W {
199    #[doc = "Bits 0:2 - Tx Buffer Data Field Size"]
200    #[inline(always)]
201    pub fn tbds(&mut self) -> TBDS_W {
202        TBDS_W { w: self }
203    }
204    #[doc = "Writes raw bits to the register."]
205    #[inline(always)]
206    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
207        self.0.bits(bits);
208        self
209    }
210}
211#[doc = "Transmit Buffer Element Size Configuration 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 [mcan_txesc](index.html) module"]
212pub struct MCAN_TXESC_SPEC;
213impl crate::RegisterSpec for MCAN_TXESC_SPEC {
214    type Ux = u32;
215}
216#[doc = "`read()` method returns [mcan_txesc::R](R) reader structure"]
217impl crate::Readable for MCAN_TXESC_SPEC {
218    type Reader = R;
219}
220#[doc = "`write(|w| ..)` method takes [mcan_txesc::W](W) writer structure"]
221impl crate::Writable for MCAN_TXESC_SPEC {
222    type Writer = W;
223}
224#[doc = "`reset()` method sets MCAN_TXESC to value 0"]
225impl crate::Resettable for MCAN_TXESC_SPEC {
226    #[inline(always)]
227    fn reset_value() -> Self::Ux {
228        0
229    }
230}