atsam4e16e_pac/can1/
mmr3.rs

1#[doc = "Register `MMR3` reader"]
2pub struct R(crate::R<MMR3_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<MMR3_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<MMR3_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<MMR3_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `MMR3` writer"]
17pub struct W(crate::W<MMR3_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<MMR3_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<MMR3_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<MMR3_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `MTIMEMARK` reader - Mailbox Timemark"]
38pub type MTIMEMARK_R = crate::FieldReader<u16, u16>;
39#[doc = "Field `MTIMEMARK` writer - Mailbox Timemark"]
40pub type MTIMEMARK_W<'a, const O: u8> = crate::FieldWriter<'a, u32, MMR3_SPEC, u16, u16, 16, O>;
41#[doc = "Field `PRIOR` reader - Mailbox Priority"]
42pub type PRIOR_R = crate::FieldReader<u8, u8>;
43#[doc = "Field `PRIOR` writer - Mailbox Priority"]
44pub type PRIOR_W<'a, const O: u8> = crate::FieldWriter<'a, u32, MMR3_SPEC, u8, u8, 4, O>;
45#[doc = "Field `MOT` reader - Mailbox Object Type"]
46pub type MOT_R = crate::FieldReader<u8, MOT_A>;
47#[doc = "Mailbox Object Type\n\nValue on reset: 0"]
48#[derive(Clone, Copy, Debug, PartialEq, Eq)]
49#[repr(u8)]
50pub enum MOT_A {
51    #[doc = "0: Mailbox is disabled. This prevents receiving or transmitting any messages with this mailbox."]
52    MB_DISABLED = 0,
53    #[doc = "1: Reception Mailbox. Mailbox is configured for reception. If a message is received while the mailbox data register is full, it is discarded."]
54    MB_RX = 1,
55    #[doc = "2: Reception mailbox with overwrite. Mailbox is configured for reception. If a message is received while the mailbox is full, it overwrites the previous message."]
56    MB_RX_OVERWRITE = 2,
57    #[doc = "3: Transmit mailbox. Mailbox is configured for transmission."]
58    MB_TX = 3,
59    #[doc = "4: Consumer Mailbox. Mailbox is configured in reception but behaves as a Transmit Mailbox, i.e., it sends a remote frame and waits for an answer."]
60    MB_CONSUMER = 4,
61    #[doc = "5: Producer Mailbox. Mailbox is configured in transmission but also behaves like a reception mailbox, i.e., it waits to receive a Remote Frame before sending its contents."]
62    MB_PRODUCER = 5,
63}
64impl From<MOT_A> for u8 {
65    #[inline(always)]
66    fn from(variant: MOT_A) -> Self {
67        variant as _
68    }
69}
70impl MOT_R {
71    #[doc = "Get enumerated values variant"]
72    #[inline(always)]
73    pub fn variant(&self) -> Option<MOT_A> {
74        match self.bits {
75            0 => Some(MOT_A::MB_DISABLED),
76            1 => Some(MOT_A::MB_RX),
77            2 => Some(MOT_A::MB_RX_OVERWRITE),
78            3 => Some(MOT_A::MB_TX),
79            4 => Some(MOT_A::MB_CONSUMER),
80            5 => Some(MOT_A::MB_PRODUCER),
81            _ => None,
82        }
83    }
84    #[doc = "Checks if the value of the field is `MB_DISABLED`"]
85    #[inline(always)]
86    pub fn is_mb_disabled(&self) -> bool {
87        *self == MOT_A::MB_DISABLED
88    }
89    #[doc = "Checks if the value of the field is `MB_RX`"]
90    #[inline(always)]
91    pub fn is_mb_rx(&self) -> bool {
92        *self == MOT_A::MB_RX
93    }
94    #[doc = "Checks if the value of the field is `MB_RX_OVERWRITE`"]
95    #[inline(always)]
96    pub fn is_mb_rx_overwrite(&self) -> bool {
97        *self == MOT_A::MB_RX_OVERWRITE
98    }
99    #[doc = "Checks if the value of the field is `MB_TX`"]
100    #[inline(always)]
101    pub fn is_mb_tx(&self) -> bool {
102        *self == MOT_A::MB_TX
103    }
104    #[doc = "Checks if the value of the field is `MB_CONSUMER`"]
105    #[inline(always)]
106    pub fn is_mb_consumer(&self) -> bool {
107        *self == MOT_A::MB_CONSUMER
108    }
109    #[doc = "Checks if the value of the field is `MB_PRODUCER`"]
110    #[inline(always)]
111    pub fn is_mb_producer(&self) -> bool {
112        *self == MOT_A::MB_PRODUCER
113    }
114}
115#[doc = "Field `MOT` writer - Mailbox Object Type"]
116pub type MOT_W<'a, const O: u8> = crate::FieldWriter<'a, u32, MMR3_SPEC, u8, MOT_A, 3, O>;
117impl<'a, const O: u8> MOT_W<'a, O> {
118    #[doc = "Mailbox is disabled. This prevents receiving or transmitting any messages with this mailbox."]
119    #[inline(always)]
120    pub fn mb_disabled(self) -> &'a mut W {
121        self.variant(MOT_A::MB_DISABLED)
122    }
123    #[doc = "Reception Mailbox. Mailbox is configured for reception. If a message is received while the mailbox data register is full, it is discarded."]
124    #[inline(always)]
125    pub fn mb_rx(self) -> &'a mut W {
126        self.variant(MOT_A::MB_RX)
127    }
128    #[doc = "Reception mailbox with overwrite. Mailbox is configured for reception. If a message is received while the mailbox is full, it overwrites the previous message."]
129    #[inline(always)]
130    pub fn mb_rx_overwrite(self) -> &'a mut W {
131        self.variant(MOT_A::MB_RX_OVERWRITE)
132    }
133    #[doc = "Transmit mailbox. Mailbox is configured for transmission."]
134    #[inline(always)]
135    pub fn mb_tx(self) -> &'a mut W {
136        self.variant(MOT_A::MB_TX)
137    }
138    #[doc = "Consumer Mailbox. Mailbox is configured in reception but behaves as a Transmit Mailbox, i.e., it sends a remote frame and waits for an answer."]
139    #[inline(always)]
140    pub fn mb_consumer(self) -> &'a mut W {
141        self.variant(MOT_A::MB_CONSUMER)
142    }
143    #[doc = "Producer Mailbox. Mailbox is configured in transmission but also behaves like a reception mailbox, i.e., it waits to receive a Remote Frame before sending its contents."]
144    #[inline(always)]
145    pub fn mb_producer(self) -> &'a mut W {
146        self.variant(MOT_A::MB_PRODUCER)
147    }
148}
149impl R {
150    #[doc = "Bits 0:15 - Mailbox Timemark"]
151    #[inline(always)]
152    pub fn mtimemark(&self) -> MTIMEMARK_R {
153        MTIMEMARK_R::new((self.bits & 0xffff) as u16)
154    }
155    #[doc = "Bits 16:19 - Mailbox Priority"]
156    #[inline(always)]
157    pub fn prior(&self) -> PRIOR_R {
158        PRIOR_R::new(((self.bits >> 16) & 0x0f) as u8)
159    }
160    #[doc = "Bits 24:26 - Mailbox Object Type"]
161    #[inline(always)]
162    pub fn mot(&self) -> MOT_R {
163        MOT_R::new(((self.bits >> 24) & 7) as u8)
164    }
165}
166impl W {
167    #[doc = "Bits 0:15 - Mailbox Timemark"]
168    #[inline(always)]
169    #[must_use]
170    pub fn mtimemark(&mut self) -> MTIMEMARK_W<0> {
171        MTIMEMARK_W::new(self)
172    }
173    #[doc = "Bits 16:19 - Mailbox Priority"]
174    #[inline(always)]
175    #[must_use]
176    pub fn prior(&mut self) -> PRIOR_W<16> {
177        PRIOR_W::new(self)
178    }
179    #[doc = "Bits 24:26 - Mailbox Object Type"]
180    #[inline(always)]
181    #[must_use]
182    pub fn mot(&mut self) -> MOT_W<24> {
183        MOT_W::new(self)
184    }
185    #[doc = "Writes raw bits to the register."]
186    #[inline(always)]
187    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
188        self.0.bits(bits);
189        self
190    }
191}
192#[doc = "Mailbox Mode Register (MB = 3)\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 [mmr3](index.html) module"]
193pub struct MMR3_SPEC;
194impl crate::RegisterSpec for MMR3_SPEC {
195    type Ux = u32;
196}
197#[doc = "`read()` method returns [mmr3::R](R) reader structure"]
198impl crate::Readable for MMR3_SPEC {
199    type Reader = R;
200}
201#[doc = "`write(|w| ..)` method takes [mmr3::W](W) writer structure"]
202impl crate::Writable for MMR3_SPEC {
203    type Writer = W;
204    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
205    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
206}
207#[doc = "`reset()` method sets MMR3 to value 0"]
208impl crate::Resettable for MMR3_SPEC {
209    const RESET_VALUE: Self::Ux = 0;
210}