lpc82x_pac/adc0/
trm.rs

1#[doc = "Register `TRM` reader"]
2pub struct R(crate::R<TRM_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<TRM_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<TRM_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<TRM_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `TRM` writer"]
17pub struct W(crate::W<TRM_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<TRM_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<TRM_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<TRM_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "2.4V to 3.6V Vdd range: This bit MUST be set to '1' if operation below 2.7V is to be used. Failure to set this bit will result in invalid ADC results. Note: This bit will not be spec'd on parts that do not support operation below 2.7V\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum VRANGE_A {
40    #[doc = "0: High voltage"]
41    HIGH_VOLTAGE = 0,
42    #[doc = "1: Low voltage"]
43    LOW_VOLTAGE = 1,
44}
45impl From<VRANGE_A> for bool {
46    #[inline(always)]
47    fn from(variant: VRANGE_A) -> Self {
48        variant as u8 != 0
49    }
50}
51#[doc = "Field `VRANGE` reader - 2.4V to 3.6V Vdd range: This bit MUST be set to '1' if operation below 2.7V is to be used. Failure to set this bit will result in invalid ADC results. Note: This bit will not be spec'd on parts that do not support operation below 2.7V"]
52pub struct VRANGE_R(crate::FieldReader<bool, VRANGE_A>);
53impl VRANGE_R {
54    pub(crate) fn new(bits: bool) -> Self {
55        VRANGE_R(crate::FieldReader::new(bits))
56    }
57    #[doc = r"Get enumerated values variant"]
58    #[inline(always)]
59    pub fn variant(&self) -> VRANGE_A {
60        match self.bits {
61            false => VRANGE_A::HIGH_VOLTAGE,
62            true => VRANGE_A::LOW_VOLTAGE,
63        }
64    }
65    #[doc = "Checks if the value of the field is `HIGH_VOLTAGE`"]
66    #[inline(always)]
67    pub fn is_high_voltage(&self) -> bool {
68        **self == VRANGE_A::HIGH_VOLTAGE
69    }
70    #[doc = "Checks if the value of the field is `LOW_VOLTAGE`"]
71    #[inline(always)]
72    pub fn is_low_voltage(&self) -> bool {
73        **self == VRANGE_A::LOW_VOLTAGE
74    }
75}
76impl core::ops::Deref for VRANGE_R {
77    type Target = crate::FieldReader<bool, VRANGE_A>;
78    #[inline(always)]
79    fn deref(&self) -> &Self::Target {
80        &self.0
81    }
82}
83#[doc = "Field `VRANGE` writer - 2.4V to 3.6V Vdd range: This bit MUST be set to '1' if operation below 2.7V is to be used. Failure to set this bit will result in invalid ADC results. Note: This bit will not be spec'd on parts that do not support operation below 2.7V"]
84pub struct VRANGE_W<'a> {
85    w: &'a mut W,
86}
87impl<'a> VRANGE_W<'a> {
88    #[doc = r"Writes `variant` to the field"]
89    #[inline(always)]
90    pub fn variant(self, variant: VRANGE_A) -> &'a mut W {
91        self.bit(variant.into())
92    }
93    #[doc = "High voltage"]
94    #[inline(always)]
95    pub fn high_voltage(self) -> &'a mut W {
96        self.variant(VRANGE_A::HIGH_VOLTAGE)
97    }
98    #[doc = "Low voltage"]
99    #[inline(always)]
100    pub fn low_voltage(self) -> &'a mut W {
101        self.variant(VRANGE_A::LOW_VOLTAGE)
102    }
103    #[doc = r"Sets the field bit"]
104    #[inline(always)]
105    pub fn set_bit(self) -> &'a mut W {
106        self.bit(true)
107    }
108    #[doc = r"Clears the field bit"]
109    #[inline(always)]
110    pub fn clear_bit(self) -> &'a mut W {
111        self.bit(false)
112    }
113    #[doc = r"Writes raw bits to the field"]
114    #[inline(always)]
115    pub fn bit(self, value: bool) -> &'a mut W {
116        self.w.bits = (self.w.bits & !(0x01 << 5)) | ((value as u32 & 0x01) << 5);
117        self.w
118    }
119}
120impl R {
121    #[doc = "Bit 5 - 2.4V to 3.6V Vdd range: This bit MUST be set to '1' if operation below 2.7V is to be used. Failure to set this bit will result in invalid ADC results. Note: This bit will not be spec'd on parts that do not support operation below 2.7V"]
122    #[inline(always)]
123    pub fn vrange(&self) -> VRANGE_R {
124        VRANGE_R::new(((self.bits >> 5) & 0x01) != 0)
125    }
126}
127impl W {
128    #[doc = "Bit 5 - 2.4V to 3.6V Vdd range: This bit MUST be set to '1' if operation below 2.7V is to be used. Failure to set this bit will result in invalid ADC results. Note: This bit will not be spec'd on parts that do not support operation below 2.7V"]
129    #[inline(always)]
130    pub fn vrange(&mut self) -> VRANGE_W {
131        VRANGE_W { w: self }
132    }
133    #[doc = "Writes raw bits to the register."]
134    #[inline(always)]
135    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
136        self.0.bits(bits);
137        self
138    }
139}
140#[doc = "ADC Startup 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 [trm](index.html) module"]
141pub struct TRM_SPEC;
142impl crate::RegisterSpec for TRM_SPEC {
143    type Ux = u32;
144}
145#[doc = "`read()` method returns [trm::R](R) reader structure"]
146impl crate::Readable for TRM_SPEC {
147    type Reader = R;
148}
149#[doc = "`write(|w| ..)` method takes [trm::W](W) writer structure"]
150impl crate::Writable for TRM_SPEC {
151    type Writer = W;
152}
153#[doc = "`reset()` method sets TRM to value 0"]
154impl crate::Resettable for TRM_SPEC {
155    #[inline(always)]
156    fn reset_value() -> Self::Ux {
157        0
158    }
159}