atsame70q21/mcan0/
mcan_tscc.rs1#[doc = "Register `MCAN_TSCC` reader"]
2pub struct R(crate::R<MCAN_TSCC_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<MCAN_TSCC_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<MCAN_TSCC_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<MCAN_TSCC_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `MCAN_TSCC` writer"]
17pub struct W(crate::W<MCAN_TSCC_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<MCAN_TSCC_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_TSCC_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<MCAN_TSCC_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Timestamp Select\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum TSS_A {
41 #[doc = "0: Timestamp counter value always 0x0000"]
42 ALWAYS_0 = 0,
43 #[doc = "1: Timestamp counter value incremented according to TCP"]
44 TCP_INC = 1,
45 #[doc = "2: External timestamp counter value used"]
46 EXT_TIMESTAMP = 2,
47}
48impl From<TSS_A> for u8 {
49 #[inline(always)]
50 fn from(variant: TSS_A) -> Self {
51 variant as _
52 }
53}
54#[doc = "Field `TSS` reader - Timestamp Select"]
55pub struct TSS_R(crate::FieldReader<u8, TSS_A>);
56impl TSS_R {
57 #[inline(always)]
58 pub(crate) fn new(bits: u8) -> Self {
59 TSS_R(crate::FieldReader::new(bits))
60 }
61 #[doc = r"Get enumerated values variant"]
62 #[inline(always)]
63 pub fn variant(&self) -> Option<TSS_A> {
64 match self.bits {
65 0 => Some(TSS_A::ALWAYS_0),
66 1 => Some(TSS_A::TCP_INC),
67 2 => Some(TSS_A::EXT_TIMESTAMP),
68 _ => None,
69 }
70 }
71 #[doc = "Checks if the value of the field is `ALWAYS_0`"]
72 #[inline(always)]
73 pub fn is_always_0(&self) -> bool {
74 **self == TSS_A::ALWAYS_0
75 }
76 #[doc = "Checks if the value of the field is `TCP_INC`"]
77 #[inline(always)]
78 pub fn is_tcp_inc(&self) -> bool {
79 **self == TSS_A::TCP_INC
80 }
81 #[doc = "Checks if the value of the field is `EXT_TIMESTAMP`"]
82 #[inline(always)]
83 pub fn is_ext_timestamp(&self) -> bool {
84 **self == TSS_A::EXT_TIMESTAMP
85 }
86}
87impl core::ops::Deref for TSS_R {
88 type Target = crate::FieldReader<u8, TSS_A>;
89 #[inline(always)]
90 fn deref(&self) -> &Self::Target {
91 &self.0
92 }
93}
94#[doc = "Field `TSS` writer - Timestamp Select"]
95pub struct TSS_W<'a> {
96 w: &'a mut W,
97}
98impl<'a> TSS_W<'a> {
99 #[doc = r"Writes `variant` to the field"]
100 #[inline(always)]
101 pub fn variant(self, variant: TSS_A) -> &'a mut W {
102 unsafe { self.bits(variant.into()) }
103 }
104 #[doc = "Timestamp counter value always 0x0000"]
105 #[inline(always)]
106 pub fn always_0(self) -> &'a mut W {
107 self.variant(TSS_A::ALWAYS_0)
108 }
109 #[doc = "Timestamp counter value incremented according to TCP"]
110 #[inline(always)]
111 pub fn tcp_inc(self) -> &'a mut W {
112 self.variant(TSS_A::TCP_INC)
113 }
114 #[doc = "External timestamp counter value used"]
115 #[inline(always)]
116 pub fn ext_timestamp(self) -> &'a mut W {
117 self.variant(TSS_A::EXT_TIMESTAMP)
118 }
119 #[doc = r"Writes raw bits to the field"]
120 #[inline(always)]
121 pub unsafe fn bits(self, value: u8) -> &'a mut W {
122 self.w.bits = (self.w.bits & !0x03) | (value as u32 & 0x03);
123 self.w
124 }
125}
126#[doc = "Field `TCP` reader - Timestamp Counter Prescaler"]
127pub struct TCP_R(crate::FieldReader<u8, u8>);
128impl TCP_R {
129 #[inline(always)]
130 pub(crate) fn new(bits: u8) -> Self {
131 TCP_R(crate::FieldReader::new(bits))
132 }
133}
134impl core::ops::Deref for TCP_R {
135 type Target = crate::FieldReader<u8, u8>;
136 #[inline(always)]
137 fn deref(&self) -> &Self::Target {
138 &self.0
139 }
140}
141#[doc = "Field `TCP` writer - Timestamp Counter Prescaler"]
142pub struct TCP_W<'a> {
143 w: &'a mut W,
144}
145impl<'a> TCP_W<'a> {
146 #[doc = r"Writes raw bits to the field"]
147 #[inline(always)]
148 pub unsafe fn bits(self, value: u8) -> &'a mut W {
149 self.w.bits = (self.w.bits & !(0x0f << 16)) | ((value as u32 & 0x0f) << 16);
150 self.w
151 }
152}
153impl R {
154 #[doc = "Bits 0:1 - Timestamp Select"]
155 #[inline(always)]
156 pub fn tss(&self) -> TSS_R {
157 TSS_R::new((self.bits & 0x03) as u8)
158 }
159 #[doc = "Bits 16:19 - Timestamp Counter Prescaler"]
160 #[inline(always)]
161 pub fn tcp(&self) -> TCP_R {
162 TCP_R::new(((self.bits >> 16) & 0x0f) as u8)
163 }
164}
165impl W {
166 #[doc = "Bits 0:1 - Timestamp Select"]
167 #[inline(always)]
168 pub fn tss(&mut self) -> TSS_W {
169 TSS_W { w: self }
170 }
171 #[doc = "Bits 16:19 - Timestamp Counter Prescaler"]
172 #[inline(always)]
173 pub fn tcp(&mut self) -> TCP_W {
174 TCP_W { w: self }
175 }
176 #[doc = "Writes raw bits to the register."]
177 #[inline(always)]
178 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
179 self.0.bits(bits);
180 self
181 }
182}
183#[doc = "Timestamp Counter 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_tscc](index.html) module"]
184pub struct MCAN_TSCC_SPEC;
185impl crate::RegisterSpec for MCAN_TSCC_SPEC {
186 type Ux = u32;
187}
188#[doc = "`read()` method returns [mcan_tscc::R](R) reader structure"]
189impl crate::Readable for MCAN_TSCC_SPEC {
190 type Reader = R;
191}
192#[doc = "`write(|w| ..)` method takes [mcan_tscc::W](W) writer structure"]
193impl crate::Writable for MCAN_TSCC_SPEC {
194 type Writer = W;
195}
196#[doc = "`reset()` method sets MCAN_TSCC to value 0"]
197impl crate::Resettable for MCAN_TSCC_SPEC {
198 #[inline(always)]
199 fn reset_value() -> Self::Ux {
200 0
201 }
202}