1#[doc = "Register `EMR` reader"]
2pub type R = crate::R<EmrSpec>;
3#[doc = "Register `EMR` writer"]
4pub type W = crate::W<EmrSpec>;
5#[doc = "Comparison Mode\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u8)]
8pub enum Cmpmode {
9 #[doc = "0: Generates an event when the converted data is lower than the low threshold of the window."]
10 Low = 0,
11 #[doc = "1: Generates an event when the converted data is higher than the high threshold of the window."]
12 High = 1,
13 #[doc = "2: Generates an event when the converted data is in the comparison window."]
14 In = 2,
15 #[doc = "3: Generates an event when the converted data is out of the comparison window."]
16 Out = 3,
17}
18impl From<Cmpmode> for u8 {
19 #[inline(always)]
20 fn from(variant: Cmpmode) -> Self {
21 variant as _
22 }
23}
24impl crate::FieldSpec for Cmpmode {
25 type Ux = u8;
26}
27impl crate::IsEnum for Cmpmode {}
28#[doc = "Field `CMPMODE` reader - Comparison Mode"]
29pub type CmpmodeR = crate::FieldReader<Cmpmode>;
30impl CmpmodeR {
31 #[doc = "Get enumerated values variant"]
32 #[inline(always)]
33 pub const fn variant(&self) -> Cmpmode {
34 match self.bits {
35 0 => Cmpmode::Low,
36 1 => Cmpmode::High,
37 2 => Cmpmode::In,
38 3 => Cmpmode::Out,
39 _ => unreachable!(),
40 }
41 }
42 #[doc = "Generates an event when the converted data is lower than the low threshold of the window."]
43 #[inline(always)]
44 pub fn is_low(&self) -> bool {
45 *self == Cmpmode::Low
46 }
47 #[doc = "Generates an event when the converted data is higher than the high threshold of the window."]
48 #[inline(always)]
49 pub fn is_high(&self) -> bool {
50 *self == Cmpmode::High
51 }
52 #[doc = "Generates an event when the converted data is in the comparison window."]
53 #[inline(always)]
54 pub fn is_in(&self) -> bool {
55 *self == Cmpmode::In
56 }
57 #[doc = "Generates an event when the converted data is out of the comparison window."]
58 #[inline(always)]
59 pub fn is_out(&self) -> bool {
60 *self == Cmpmode::Out
61 }
62}
63#[doc = "Field `CMPMODE` writer - Comparison Mode"]
64pub type CmpmodeW<'a, REG> = crate::FieldWriter<'a, REG, 2, Cmpmode, crate::Safe>;
65impl<'a, REG> CmpmodeW<'a, REG>
66where
67 REG: crate::Writable + crate::RegisterSpec,
68 REG::Ux: From<u8>,
69{
70 #[doc = "Generates an event when the converted data is lower than the low threshold of the window."]
71 #[inline(always)]
72 pub fn low(self) -> &'a mut crate::W<REG> {
73 self.variant(Cmpmode::Low)
74 }
75 #[doc = "Generates an event when the converted data is higher than the high threshold of the window."]
76 #[inline(always)]
77 pub fn high(self) -> &'a mut crate::W<REG> {
78 self.variant(Cmpmode::High)
79 }
80 #[doc = "Generates an event when the converted data is in the comparison window."]
81 #[inline(always)]
82 pub fn in_(self) -> &'a mut crate::W<REG> {
83 self.variant(Cmpmode::In)
84 }
85 #[doc = "Generates an event when the converted data is out of the comparison window."]
86 #[inline(always)]
87 pub fn out(self) -> &'a mut crate::W<REG> {
88 self.variant(Cmpmode::Out)
89 }
90}
91#[doc = "Field `CMPSEL` reader - Comparison Selected Channel"]
92pub type CmpselR = crate::FieldReader;
93#[doc = "Field `CMPSEL` writer - Comparison Selected Channel"]
94pub type CmpselW<'a, REG> = crate::FieldWriter<'a, REG, 4>;
95#[doc = "Field `CMPALL` reader - Compare All Channels"]
96pub type CmpallR = crate::BitReader;
97#[doc = "Field `CMPALL` writer - Compare All Channels"]
98pub type CmpallW<'a, REG> = crate::BitWriter<'a, REG>;
99#[doc = "Field `TAG` reader - TAG of the ADC_LDCR register"]
100pub type TagR = crate::BitReader;
101#[doc = "Field `TAG` writer - TAG of the ADC_LDCR register"]
102pub type TagW<'a, REG> = crate::BitWriter<'a, REG>;
103impl R {
104 #[doc = "Bits 0:1 - Comparison Mode"]
105 #[inline(always)]
106 pub fn cmpmode(&self) -> CmpmodeR {
107 CmpmodeR::new((self.bits & 3) as u8)
108 }
109 #[doc = "Bits 4:7 - Comparison Selected Channel"]
110 #[inline(always)]
111 pub fn cmpsel(&self) -> CmpselR {
112 CmpselR::new(((self.bits >> 4) & 0x0f) as u8)
113 }
114 #[doc = "Bit 9 - Compare All Channels"]
115 #[inline(always)]
116 pub fn cmpall(&self) -> CmpallR {
117 CmpallR::new(((self.bits >> 9) & 1) != 0)
118 }
119 #[doc = "Bit 24 - TAG of the ADC_LDCR register"]
120 #[inline(always)]
121 pub fn tag(&self) -> TagR {
122 TagR::new(((self.bits >> 24) & 1) != 0)
123 }
124}
125impl W {
126 #[doc = "Bits 0:1 - Comparison Mode"]
127 #[inline(always)]
128 #[must_use]
129 pub fn cmpmode(&mut self) -> CmpmodeW<EmrSpec> {
130 CmpmodeW::new(self, 0)
131 }
132 #[doc = "Bits 4:7 - Comparison Selected Channel"]
133 #[inline(always)]
134 #[must_use]
135 pub fn cmpsel(&mut self) -> CmpselW<EmrSpec> {
136 CmpselW::new(self, 4)
137 }
138 #[doc = "Bit 9 - Compare All Channels"]
139 #[inline(always)]
140 #[must_use]
141 pub fn cmpall(&mut self) -> CmpallW<EmrSpec> {
142 CmpallW::new(self, 9)
143 }
144 #[doc = "Bit 24 - TAG of the ADC_LDCR register"]
145 #[inline(always)]
146 #[must_use]
147 pub fn tag(&mut self) -> TagW<EmrSpec> {
148 TagW::new(self, 24)
149 }
150}
151#[doc = "Extended Mode Register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`emr::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 [`emr::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
152pub struct EmrSpec;
153impl crate::RegisterSpec for EmrSpec {
154 type Ux = u32;
155}
156#[doc = "`read()` method returns [`emr::R`](R) reader structure"]
157impl crate::Readable for EmrSpec {}
158#[doc = "`write(|w| ..)` method takes [`emr::W`](W) writer structure"]
159impl crate::Writable for EmrSpec {
160 type Safety = crate::Unsafe;
161 const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
162 const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
163}
164#[doc = "`reset()` method sets EMR to value 0"]
165impl crate::Resettable for EmrSpec {
166 const RESET_VALUE: u32 = 0;
167}