1#[doc = "Register `SNIFF_CTRL` reader"]
2pub type R = crate::R<SNIFF_CTRL_SPEC>;
3#[doc = "Register `SNIFF_CTRL` writer"]
4pub type W = crate::W<SNIFF_CTRL_SPEC>;
5#[doc = "Field `EN` reader - Enable sniffer"]
6pub type EN_R = crate::BitReader;
7#[doc = "Field `EN` writer - Enable sniffer"]
8pub type EN_W<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Field `DMACH` reader - DMA channel for Sniffer to observe"]
10pub type DMACH_R = crate::FieldReader;
11#[doc = "Field `DMACH` writer - DMA channel for Sniffer to observe"]
12pub type DMACH_W<'a, REG> = crate::FieldWriter<'a, REG, 4>;
13#[doc = "Field `CALC` reader - "]
14pub type CALC_R = crate::FieldReader<CALC_A>;
15#[doc = "
1617Value on reset: 0"]
18#[derive(Clone, Copy, Debug, PartialEq, Eq)]
19#[repr(u8)]
20pub enum CALC_A {
21#[doc = "0: Calculate a CRC-32 (IEEE802.3 polynomial)"]
22CRC32 = 0,
23#[doc = "1: Calculate a CRC-32 (IEEE802.3 polynomial) with bit reversed data"]
24CRC32R = 1,
25#[doc = "2: Calculate a CRC-16-CCITT"]
26CRC16 = 2,
27#[doc = "3: Calculate a CRC-16-CCITT with bit reversed data"]
28CRC16R = 3,
29#[doc = "14: XOR reduction over all data. == 1 if the total 1 population count is odd."]
30EVEN = 14,
31#[doc = "15: Calculate a simple 32-bit checksum (addition with a 32 bit accumulator)"]
32SUM = 15,
33}
34impl From<CALC_A> for u8 {
35#[inline(always)]
36fn from(variant: CALC_A) -> Self {
37 variant as _
38}
39}
40impl crate::FieldSpec for CALC_A {
41type Ux = u8;
42}
43impl CALC_R {
44#[doc = "Get enumerated values variant"]
45 #[inline(always)]
46pub const fn variant(&self) -> Option<CALC_A> {
47match self.bits {
480 => Some(CALC_A::CRC32),
491 => Some(CALC_A::CRC32R),
502 => Some(CALC_A::CRC16),
513 => Some(CALC_A::CRC16R),
5214 => Some(CALC_A::EVEN),
5315 => Some(CALC_A::SUM),
54_ => None,
55 }
56 }
57#[doc = "Calculate a CRC-32 (IEEE802.3 polynomial)"]
58 #[inline(always)]
59pub fn is_crc32(&self) -> bool {
60*self == CALC_A::CRC32
61 }
62#[doc = "Calculate a CRC-32 (IEEE802.3 polynomial) with bit reversed data"]
63 #[inline(always)]
64pub fn is_crc32r(&self) -> bool {
65*self == CALC_A::CRC32R
66 }
67#[doc = "Calculate a CRC-16-CCITT"]
68 #[inline(always)]
69pub fn is_crc16(&self) -> bool {
70*self == CALC_A::CRC16
71 }
72#[doc = "Calculate a CRC-16-CCITT with bit reversed data"]
73 #[inline(always)]
74pub fn is_crc16r(&self) -> bool {
75*self == CALC_A::CRC16R
76 }
77#[doc = "XOR reduction over all data. == 1 if the total 1 population count is odd."]
78 #[inline(always)]
79pub fn is_even(&self) -> bool {
80*self == CALC_A::EVEN
81 }
82#[doc = "Calculate a simple 32-bit checksum (addition with a 32 bit accumulator)"]
83 #[inline(always)]
84pub fn is_sum(&self) -> bool {
85*self == CALC_A::SUM
86 }
87}
88#[doc = "Field `CALC` writer - "]
89pub type CALC_W<'a, REG> = crate::FieldWriter<'a, REG, 4, CALC_A>;
90impl<'a, REG> CALC_W<'a, REG>
91where
92REG: crate::Writable + crate::RegisterSpec,
93 REG::Ux: From<u8>,
94{
95#[doc = "Calculate a CRC-32 (IEEE802.3 polynomial)"]
96 #[inline(always)]
97pub fn crc32(self) -> &'a mut crate::W<REG> {
98self.variant(CALC_A::CRC32)
99 }
100#[doc = "Calculate a CRC-32 (IEEE802.3 polynomial) with bit reversed data"]
101 #[inline(always)]
102pub fn crc32r(self) -> &'a mut crate::W<REG> {
103self.variant(CALC_A::CRC32R)
104 }
105#[doc = "Calculate a CRC-16-CCITT"]
106 #[inline(always)]
107pub fn crc16(self) -> &'a mut crate::W<REG> {
108self.variant(CALC_A::CRC16)
109 }
110#[doc = "Calculate a CRC-16-CCITT with bit reversed data"]
111 #[inline(always)]
112pub fn crc16r(self) -> &'a mut crate::W<REG> {
113self.variant(CALC_A::CRC16R)
114 }
115#[doc = "XOR reduction over all data. == 1 if the total 1 population count is odd."]
116 #[inline(always)]
117pub fn even(self) -> &'a mut crate::W<REG> {
118self.variant(CALC_A::EVEN)
119 }
120#[doc = "Calculate a simple 32-bit checksum (addition with a 32 bit accumulator)"]
121 #[inline(always)]
122pub fn sum(self) -> &'a mut crate::W<REG> {
123self.variant(CALC_A::SUM)
124 }
125}
126#[doc = "Field `BSWAP` reader - Locally perform a byte reverse on the sniffed data, before feeding into checksum.
127128 Note that the sniff hardware is downstream of the DMA channel byteswap performed in the read master: if channel CTRL_BSWAP and SNIFF_CTRL_BSWAP are both enabled, their effects cancel from the sniffer's point of view."]
129pub type BSWAP_R = crate::BitReader;
130#[doc = "Field `BSWAP` writer - Locally perform a byte reverse on the sniffed data, before feeding into checksum.
131132 Note that the sniff hardware is downstream of the DMA channel byteswap performed in the read master: if channel CTRL_BSWAP and SNIFF_CTRL_BSWAP are both enabled, their effects cancel from the sniffer's point of view."]
133pub type BSWAP_W<'a, REG> = crate::BitWriter<'a, REG>;
134#[doc = "Field `OUT_REV` reader - If set, the result appears bit-reversed when read. This does not affect the way the checksum is calculated; the result is transformed on-the-fly between the result register and the bus."]
135pub type OUT_REV_R = crate::BitReader;
136#[doc = "Field `OUT_REV` writer - If set, the result appears bit-reversed when read. This does not affect the way the checksum is calculated; the result is transformed on-the-fly between the result register and the bus."]
137pub type OUT_REV_W<'a, REG> = crate::BitWriter<'a, REG>;
138#[doc = "Field `OUT_INV` reader - If set, the result appears inverted (bitwise complement) when read. This does not affect the way the checksum is calculated; the result is transformed on-the-fly between the result register and the bus."]
139pub type OUT_INV_R = crate::BitReader;
140#[doc = "Field `OUT_INV` writer - If set, the result appears inverted (bitwise complement) when read. This does not affect the way the checksum is calculated; the result is transformed on-the-fly between the result register and the bus."]
141pub type OUT_INV_W<'a, REG> = crate::BitWriter<'a, REG>;
142impl R {
143#[doc = "Bit 0 - Enable sniffer"]
144 #[inline(always)]
145pub fn en(&self) -> EN_R {
146 EN_R::new((self.bits & 1) != 0)
147 }
148#[doc = "Bits 1:4 - DMA channel for Sniffer to observe"]
149 #[inline(always)]
150pub fn dmach(&self) -> DMACH_R {
151 DMACH_R::new(((self.bits >> 1) & 0x0f) as u8)
152 }
153#[doc = "Bits 5:8"]
154 #[inline(always)]
155pub fn calc(&self) -> CALC_R {
156 CALC_R::new(((self.bits >> 5) & 0x0f) as u8)
157 }
158#[doc = "Bit 9 - Locally perform a byte reverse on the sniffed data, before feeding into checksum.
159160 Note that the sniff hardware is downstream of the DMA channel byteswap performed in the read master: if channel CTRL_BSWAP and SNIFF_CTRL_BSWAP are both enabled, their effects cancel from the sniffer's point of view."]
161 #[inline(always)]
162pub fn bswap(&self) -> BSWAP_R {
163 BSWAP_R::new(((self.bits >> 9) & 1) != 0)
164 }
165#[doc = "Bit 10 - If set, the result appears bit-reversed when read. This does not affect the way the checksum is calculated; the result is transformed on-the-fly between the result register and the bus."]
166 #[inline(always)]
167pub fn out_rev(&self) -> OUT_REV_R {
168 OUT_REV_R::new(((self.bits >> 10) & 1) != 0)
169 }
170#[doc = "Bit 11 - If set, the result appears inverted (bitwise complement) when read. This does not affect the way the checksum is calculated; the result is transformed on-the-fly between the result register and the bus."]
171 #[inline(always)]
172pub fn out_inv(&self) -> OUT_INV_R {
173 OUT_INV_R::new(((self.bits >> 11) & 1) != 0)
174 }
175}
176impl W {
177#[doc = "Bit 0 - Enable sniffer"]
178 #[inline(always)]
179 #[must_use]
180pub fn en(&mut self) -> EN_W<SNIFF_CTRL_SPEC> {
181 EN_W::new(self, 0)
182 }
183#[doc = "Bits 1:4 - DMA channel for Sniffer to observe"]
184 #[inline(always)]
185 #[must_use]
186pub fn dmach(&mut self) -> DMACH_W<SNIFF_CTRL_SPEC> {
187 DMACH_W::new(self, 1)
188 }
189#[doc = "Bits 5:8"]
190 #[inline(always)]
191 #[must_use]
192pub fn calc(&mut self) -> CALC_W<SNIFF_CTRL_SPEC> {
193 CALC_W::new(self, 5)
194 }
195#[doc = "Bit 9 - Locally perform a byte reverse on the sniffed data, before feeding into checksum.
196197 Note that the sniff hardware is downstream of the DMA channel byteswap performed in the read master: if channel CTRL_BSWAP and SNIFF_CTRL_BSWAP are both enabled, their effects cancel from the sniffer's point of view."]
198 #[inline(always)]
199 #[must_use]
200pub fn bswap(&mut self) -> BSWAP_W<SNIFF_CTRL_SPEC> {
201 BSWAP_W::new(self, 9)
202 }
203#[doc = "Bit 10 - If set, the result appears bit-reversed when read. This does not affect the way the checksum is calculated; the result is transformed on-the-fly between the result register and the bus."]
204 #[inline(always)]
205 #[must_use]
206pub fn out_rev(&mut self) -> OUT_REV_W<SNIFF_CTRL_SPEC> {
207 OUT_REV_W::new(self, 10)
208 }
209#[doc = "Bit 11 - If set, the result appears inverted (bitwise complement) when read. This does not affect the way the checksum is calculated; the result is transformed on-the-fly between the result register and the bus."]
210 #[inline(always)]
211 #[must_use]
212pub fn out_inv(&mut self) -> OUT_INV_W<SNIFF_CTRL_SPEC> {
213 OUT_INV_W::new(self, 11)
214 }
215#[doc = r" Writes raw bits to the register."]
216 #[doc = r""]
217 #[doc = r" # Safety"]
218 #[doc = r""]
219 #[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
220 #[inline(always)]
221pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
222self.bits = bits;
223self
224}
225}
226#[doc = "Sniffer Control
227228You can [`read`](crate::generic::Reg::read) this register and get [`sniff_ctrl::R`](R). You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`sniff_ctrl::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
229pub struct SNIFF_CTRL_SPEC;
230impl crate::RegisterSpec for SNIFF_CTRL_SPEC {
231type Ux = u32;
232}
233#[doc = "`read()` method returns [`sniff_ctrl::R`](R) reader structure"]
234impl crate::Readable for SNIFF_CTRL_SPEC {}
235#[doc = "`write(|w| ..)` method takes [`sniff_ctrl::W`](W) writer structure"]
236impl crate::Writable for SNIFF_CTRL_SPEC {
237const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
238const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
239}
240#[doc = "`reset()` method sets SNIFF_CTRL to value 0"]
241impl crate::Resettable for SNIFF_CTRL_SPEC {
242const RESET_VALUE: u32 = 0;
243}