atsam4n8c_pac/adc/
tempmr.rs1#[doc = "Register `TEMPMR` reader"]
2pub struct R(crate::R<TEMPMR_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<TEMPMR_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<TEMPMR_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<TEMPMR_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `TEMPMR` writer"]
17pub struct W(crate::W<TEMPMR_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<TEMPMR_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<TEMPMR_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<TEMPMR_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `TEMPON` reader - Temperature Sensor ON"]
38pub type TEMPON_R = crate::BitReader<bool>;
39#[doc = "Field `TEMPON` writer - Temperature Sensor ON"]
40pub type TEMPON_W<'a, const O: u8> = crate::BitWriter<'a, u32, TEMPMR_SPEC, bool, O>;
41#[doc = "Field `TEMPCMPMOD` reader - Temperature Comparison Mode"]
42pub type TEMPCMPMOD_R = crate::FieldReader<u8, TEMPCMPMOD_A>;
43#[doc = "Temperature Comparison Mode\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u8)]
46pub enum TEMPCMPMOD_A {
47 #[doc = "0: Generates an event when the converted data is lower than the low threshold of the window."]
48 LOW = 0,
49 #[doc = "1: Generates an event when the converted data is higher than the high threshold of the window."]
50 HIGH = 1,
51 #[doc = "2: Generates an event when the converted data is in the comparison window."]
52 IN = 2,
53 #[doc = "3: Generates an event when the converted data is out of the comparison window."]
54 OUT = 3,
55}
56impl From<TEMPCMPMOD_A> for u8 {
57 #[inline(always)]
58 fn from(variant: TEMPCMPMOD_A) -> Self {
59 variant as _
60 }
61}
62impl TEMPCMPMOD_R {
63 #[doc = "Get enumerated values variant"]
64 #[inline(always)]
65 pub fn variant(&self) -> TEMPCMPMOD_A {
66 match self.bits {
67 0 => TEMPCMPMOD_A::LOW,
68 1 => TEMPCMPMOD_A::HIGH,
69 2 => TEMPCMPMOD_A::IN,
70 3 => TEMPCMPMOD_A::OUT,
71 _ => unreachable!(),
72 }
73 }
74 #[doc = "Checks if the value of the field is `LOW`"]
75 #[inline(always)]
76 pub fn is_low(&self) -> bool {
77 *self == TEMPCMPMOD_A::LOW
78 }
79 #[doc = "Checks if the value of the field is `HIGH`"]
80 #[inline(always)]
81 pub fn is_high(&self) -> bool {
82 *self == TEMPCMPMOD_A::HIGH
83 }
84 #[doc = "Checks if the value of the field is `IN`"]
85 #[inline(always)]
86 pub fn is_in(&self) -> bool {
87 *self == TEMPCMPMOD_A::IN
88 }
89 #[doc = "Checks if the value of the field is `OUT`"]
90 #[inline(always)]
91 pub fn is_out(&self) -> bool {
92 *self == TEMPCMPMOD_A::OUT
93 }
94}
95#[doc = "Field `TEMPCMPMOD` writer - Temperature Comparison Mode"]
96pub type TEMPCMPMOD_W<'a, const O: u8> =
97 crate::FieldWriterSafe<'a, u32, TEMPMR_SPEC, u8, TEMPCMPMOD_A, 2, O>;
98impl<'a, const O: u8> TEMPCMPMOD_W<'a, O> {
99 #[doc = "Generates an event when the converted data is lower than the low threshold of the window."]
100 #[inline(always)]
101 pub fn low(self) -> &'a mut W {
102 self.variant(TEMPCMPMOD_A::LOW)
103 }
104 #[doc = "Generates an event when the converted data is higher than the high threshold of the window."]
105 #[inline(always)]
106 pub fn high(self) -> &'a mut W {
107 self.variant(TEMPCMPMOD_A::HIGH)
108 }
109 #[doc = "Generates an event when the converted data is in the comparison window."]
110 #[inline(always)]
111 pub fn in_(self) -> &'a mut W {
112 self.variant(TEMPCMPMOD_A::IN)
113 }
114 #[doc = "Generates an event when the converted data is out of the comparison window."]
115 #[inline(always)]
116 pub fn out(self) -> &'a mut W {
117 self.variant(TEMPCMPMOD_A::OUT)
118 }
119}
120impl R {
121 #[doc = "Bit 0 - Temperature Sensor ON"]
122 #[inline(always)]
123 pub fn tempon(&self) -> TEMPON_R {
124 TEMPON_R::new((self.bits & 1) != 0)
125 }
126 #[doc = "Bits 4:5 - Temperature Comparison Mode"]
127 #[inline(always)]
128 pub fn tempcmpmod(&self) -> TEMPCMPMOD_R {
129 TEMPCMPMOD_R::new(((self.bits >> 4) & 3) as u8)
130 }
131}
132impl W {
133 #[doc = "Bit 0 - Temperature Sensor ON"]
134 #[inline(always)]
135 #[must_use]
136 pub fn tempon(&mut self) -> TEMPON_W<0> {
137 TEMPON_W::new(self)
138 }
139 #[doc = "Bits 4:5 - Temperature Comparison Mode"]
140 #[inline(always)]
141 #[must_use]
142 pub fn tempcmpmod(&mut self) -> TEMPCMPMOD_W<4> {
143 TEMPCMPMOD_W::new(self)
144 }
145 #[doc = "Writes raw bits to the register."]
146 #[inline(always)]
147 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
148 self.0.bits(bits);
149 self
150 }
151}
152#[doc = "Temperature Sensor Mode 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 [tempmr](index.html) module"]
153pub struct TEMPMR_SPEC;
154impl crate::RegisterSpec for TEMPMR_SPEC {
155 type Ux = u32;
156}
157#[doc = "`read()` method returns [tempmr::R](R) reader structure"]
158impl crate::Readable for TEMPMR_SPEC {
159 type Reader = R;
160}
161#[doc = "`write(|w| ..)` method takes [tempmr::W](W) writer structure"]
162impl crate::Writable for TEMPMR_SPEC {
163 type Writer = W;
164 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
165 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
166}
167#[doc = "`reset()` method sets TEMPMR to value 0"]
168impl crate::Resettable for TEMPMR_SPEC {
169 const RESET_VALUE: Self::Ux = 0;
170}