avr_device/devices/atmega328p/adc/
adcsrb.rs

1#[doc = "Register `ADCSRB` reader"]
2pub struct R(crate::R<ADCSRB_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<ADCSRB_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<ADCSRB_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<ADCSRB_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `ADCSRB` writer"]
17pub struct W(crate::W<ADCSRB_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<ADCSRB_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<ADCSRB_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<ADCSRB_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `ADTS` reader - ADC Auto Trigger Source bits"]
38pub type ADTS_R = crate::FieldReader<u8, ADTS_A>;
39#[doc = "ADC Auto Trigger Source bits\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum ADTS_A {
43    #[doc = "0: Free Running mode"]
44    VAL_0X00 = 0,
45    #[doc = "1: Analog Comparator"]
46    VAL_0X01 = 1,
47    #[doc = "2: External Interrupt Request 0"]
48    VAL_0X02 = 2,
49    #[doc = "3: Timer/Counter0 Compare Match A"]
50    VAL_0X03 = 3,
51    #[doc = "4: Timer/Counter0 Overflow"]
52    VAL_0X04 = 4,
53    #[doc = "5: Timer/Counter1 Compare Match B"]
54    VAL_0X05 = 5,
55    #[doc = "6: Timer/Counter1 Overflow"]
56    VAL_0X06 = 6,
57    #[doc = "7: Timer/Counter1 Capture Event"]
58    VAL_0X07 = 7,
59}
60impl From<ADTS_A> for u8 {
61    #[inline(always)]
62    fn from(variant: ADTS_A) -> Self {
63        variant as _
64    }
65}
66impl ADTS_R {
67    #[doc = "Get enumerated values variant"]
68    #[inline(always)]
69    pub fn variant(&self) -> ADTS_A {
70        match self.bits {
71            0 => ADTS_A::VAL_0X00,
72            1 => ADTS_A::VAL_0X01,
73            2 => ADTS_A::VAL_0X02,
74            3 => ADTS_A::VAL_0X03,
75            4 => ADTS_A::VAL_0X04,
76            5 => ADTS_A::VAL_0X05,
77            6 => ADTS_A::VAL_0X06,
78            7 => ADTS_A::VAL_0X07,
79            _ => unreachable!(),
80        }
81    }
82    #[doc = "Checks if the value of the field is `VAL_0X00`"]
83    #[inline(always)]
84    pub fn is_val_0x00(&self) -> bool {
85        *self == ADTS_A::VAL_0X00
86    }
87    #[doc = "Checks if the value of the field is `VAL_0X01`"]
88    #[inline(always)]
89    pub fn is_val_0x01(&self) -> bool {
90        *self == ADTS_A::VAL_0X01
91    }
92    #[doc = "Checks if the value of the field is `VAL_0X02`"]
93    #[inline(always)]
94    pub fn is_val_0x02(&self) -> bool {
95        *self == ADTS_A::VAL_0X02
96    }
97    #[doc = "Checks if the value of the field is `VAL_0X03`"]
98    #[inline(always)]
99    pub fn is_val_0x03(&self) -> bool {
100        *self == ADTS_A::VAL_0X03
101    }
102    #[doc = "Checks if the value of the field is `VAL_0X04`"]
103    #[inline(always)]
104    pub fn is_val_0x04(&self) -> bool {
105        *self == ADTS_A::VAL_0X04
106    }
107    #[doc = "Checks if the value of the field is `VAL_0X05`"]
108    #[inline(always)]
109    pub fn is_val_0x05(&self) -> bool {
110        *self == ADTS_A::VAL_0X05
111    }
112    #[doc = "Checks if the value of the field is `VAL_0X06`"]
113    #[inline(always)]
114    pub fn is_val_0x06(&self) -> bool {
115        *self == ADTS_A::VAL_0X06
116    }
117    #[doc = "Checks if the value of the field is `VAL_0X07`"]
118    #[inline(always)]
119    pub fn is_val_0x07(&self) -> bool {
120        *self == ADTS_A::VAL_0X07
121    }
122}
123#[doc = "Field `ADTS` writer - ADC Auto Trigger Source bits"]
124pub type ADTS_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, ADCSRB_SPEC, u8, ADTS_A, 3, O>;
125impl<'a, const O: u8> ADTS_W<'a, O> {
126    #[doc = "Free Running mode"]
127    #[inline(always)]
128    pub fn val_0x00(self) -> &'a mut W {
129        self.variant(ADTS_A::VAL_0X00)
130    }
131    #[doc = "Analog Comparator"]
132    #[inline(always)]
133    pub fn val_0x01(self) -> &'a mut W {
134        self.variant(ADTS_A::VAL_0X01)
135    }
136    #[doc = "External Interrupt Request 0"]
137    #[inline(always)]
138    pub fn val_0x02(self) -> &'a mut W {
139        self.variant(ADTS_A::VAL_0X02)
140    }
141    #[doc = "Timer/Counter0 Compare Match A"]
142    #[inline(always)]
143    pub fn val_0x03(self) -> &'a mut W {
144        self.variant(ADTS_A::VAL_0X03)
145    }
146    #[doc = "Timer/Counter0 Overflow"]
147    #[inline(always)]
148    pub fn val_0x04(self) -> &'a mut W {
149        self.variant(ADTS_A::VAL_0X04)
150    }
151    #[doc = "Timer/Counter1 Compare Match B"]
152    #[inline(always)]
153    pub fn val_0x05(self) -> &'a mut W {
154        self.variant(ADTS_A::VAL_0X05)
155    }
156    #[doc = "Timer/Counter1 Overflow"]
157    #[inline(always)]
158    pub fn val_0x06(self) -> &'a mut W {
159        self.variant(ADTS_A::VAL_0X06)
160    }
161    #[doc = "Timer/Counter1 Capture Event"]
162    #[inline(always)]
163    pub fn val_0x07(self) -> &'a mut W {
164        self.variant(ADTS_A::VAL_0X07)
165    }
166}
167#[doc = "Field `ACME` reader - No Description."]
168pub type ACME_R = crate::BitReader<bool>;
169#[doc = "Field `ACME` writer - No Description."]
170pub type ACME_W<'a, const O: u8> = crate::BitWriter<'a, u8, ADCSRB_SPEC, bool, O>;
171impl R {
172    #[doc = "Bits 0:2 - ADC Auto Trigger Source bits"]
173    #[inline(always)]
174    pub fn adts(&self) -> ADTS_R {
175        ADTS_R::new(self.bits & 7)
176    }
177    #[doc = "Bit 6 - No Description."]
178    #[inline(always)]
179    pub fn acme(&self) -> ACME_R {
180        ACME_R::new(((self.bits >> 6) & 1) != 0)
181    }
182}
183impl W {
184    #[doc = "Bits 0:2 - ADC Auto Trigger Source bits"]
185    #[inline(always)]
186    #[must_use]
187    pub fn adts(&mut self) -> ADTS_W<0> {
188        ADTS_W::new(self)
189    }
190    #[doc = "Bit 6 - No Description."]
191    #[inline(always)]
192    #[must_use]
193    pub fn acme(&mut self) -> ACME_W<6> {
194        ACME_W::new(self)
195    }
196    #[doc = "Writes raw bits to the register."]
197    #[inline(always)]
198    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
199        self.0.bits(bits);
200        self
201    }
202}
203#[doc = "The ADC Control and Status register B\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 [adcsrb](index.html) module"]
204pub struct ADCSRB_SPEC;
205impl crate::RegisterSpec for ADCSRB_SPEC {
206    type Ux = u8;
207}
208#[doc = "`read()` method returns [adcsrb::R](R) reader structure"]
209impl crate::Readable for ADCSRB_SPEC {
210    type Reader = R;
211}
212#[doc = "`write(|w| ..)` method takes [adcsrb::W](W) writer structure"]
213impl crate::Writable for ADCSRB_SPEC {
214    type Writer = W;
215    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
216    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
217}
218#[doc = "`reset()` method sets ADCSRB to value 0"]
219impl crate::Resettable for ADCSRB_SPEC {
220    const RESET_VALUE: Self::Ux = 0;
221}