avr_device/devices/attiny85/eeprom/
eecr.rs

1#[doc = "Register `EECR` reader"]
2pub struct R(crate::R<EECR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<EECR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<EECR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<EECR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `EECR` writer"]
17pub struct W(crate::W<EECR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<EECR_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<EECR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<EECR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `EERE` reader - EEPROM Read Enable"]
38pub type EERE_R = crate::BitReader<bool>;
39#[doc = "Field `EERE` writer - EEPROM Read Enable"]
40pub type EERE_W<'a, const O: u8> = crate::BitWriter<'a, u8, EECR_SPEC, bool, O>;
41#[doc = "Field `EEPE` reader - EEPROM Write Enable"]
42pub type EEPE_R = crate::BitReader<bool>;
43#[doc = "Field `EEPE` writer - EEPROM Write Enable"]
44pub type EEPE_W<'a, const O: u8> = crate::BitWriter<'a, u8, EECR_SPEC, bool, O>;
45#[doc = "Field `EEMPE` reader - EEPROM Master Write Enable"]
46pub type EEMPE_R = crate::BitReader<bool>;
47#[doc = "Field `EEMPE` writer - EEPROM Master Write Enable"]
48pub type EEMPE_W<'a, const O: u8> = crate::BitWriter<'a, u8, EECR_SPEC, bool, O>;
49#[doc = "Field `EERIE` reader - EEPROM Ready Interrupt Enable"]
50pub type EERIE_R = crate::BitReader<bool>;
51#[doc = "Field `EERIE` writer - EEPROM Ready Interrupt Enable"]
52pub type EERIE_W<'a, const O: u8> = crate::BitWriter<'a, u8, EECR_SPEC, bool, O>;
53#[doc = "Field `EEPM` reader - EEPROM Programming Mode Bits"]
54pub type EEPM_R = crate::FieldReader<u8, EEPM_A>;
55#[doc = "EEPROM Programming Mode Bits\n\nValue on reset: 0"]
56#[derive(Clone, Copy, Debug, PartialEq, Eq)]
57#[repr(u8)]
58pub enum EEPM_A {
59    #[doc = "0: Atomic (erase and write in one operation)"]
60    ATOMIC = 0,
61    #[doc = "1: Erase only"]
62    ERASE = 1,
63    #[doc = "2: Write only"]
64    WRITE = 2,
65}
66impl From<EEPM_A> for u8 {
67    #[inline(always)]
68    fn from(variant: EEPM_A) -> Self {
69        variant as _
70    }
71}
72impl EEPM_R {
73    #[doc = "Get enumerated values variant"]
74    #[inline(always)]
75    pub fn variant(&self) -> Option<EEPM_A> {
76        match self.bits {
77            0 => Some(EEPM_A::ATOMIC),
78            1 => Some(EEPM_A::ERASE),
79            2 => Some(EEPM_A::WRITE),
80            _ => None,
81        }
82    }
83    #[doc = "Checks if the value of the field is `ATOMIC`"]
84    #[inline(always)]
85    pub fn is_atomic(&self) -> bool {
86        *self == EEPM_A::ATOMIC
87    }
88    #[doc = "Checks if the value of the field is `ERASE`"]
89    #[inline(always)]
90    pub fn is_erase(&self) -> bool {
91        *self == EEPM_A::ERASE
92    }
93    #[doc = "Checks if the value of the field is `WRITE`"]
94    #[inline(always)]
95    pub fn is_write(&self) -> bool {
96        *self == EEPM_A::WRITE
97    }
98}
99#[doc = "Field `EEPM` writer - EEPROM Programming Mode Bits"]
100pub type EEPM_W<'a, const O: u8> = crate::FieldWriter<'a, u8, EECR_SPEC, u8, EEPM_A, 2, O>;
101impl<'a, const O: u8> EEPM_W<'a, O> {
102    #[doc = "Atomic (erase and write in one operation)"]
103    #[inline(always)]
104    pub fn atomic(self) -> &'a mut W {
105        self.variant(EEPM_A::ATOMIC)
106    }
107    #[doc = "Erase only"]
108    #[inline(always)]
109    pub fn erase(self) -> &'a mut W {
110        self.variant(EEPM_A::ERASE)
111    }
112    #[doc = "Write only"]
113    #[inline(always)]
114    pub fn write(self) -> &'a mut W {
115        self.variant(EEPM_A::WRITE)
116    }
117}
118impl R {
119    #[doc = "Bit 0 - EEPROM Read Enable"]
120    #[inline(always)]
121    pub fn eere(&self) -> EERE_R {
122        EERE_R::new((self.bits & 1) != 0)
123    }
124    #[doc = "Bit 1 - EEPROM Write Enable"]
125    #[inline(always)]
126    pub fn eepe(&self) -> EEPE_R {
127        EEPE_R::new(((self.bits >> 1) & 1) != 0)
128    }
129    #[doc = "Bit 2 - EEPROM Master Write Enable"]
130    #[inline(always)]
131    pub fn eempe(&self) -> EEMPE_R {
132        EEMPE_R::new(((self.bits >> 2) & 1) != 0)
133    }
134    #[doc = "Bit 3 - EEPROM Ready Interrupt Enable"]
135    #[inline(always)]
136    pub fn eerie(&self) -> EERIE_R {
137        EERIE_R::new(((self.bits >> 3) & 1) != 0)
138    }
139    #[doc = "Bits 4:5 - EEPROM Programming Mode Bits"]
140    #[inline(always)]
141    pub fn eepm(&self) -> EEPM_R {
142        EEPM_R::new((self.bits >> 4) & 3)
143    }
144}
145impl W {
146    #[doc = "Bit 0 - EEPROM Read Enable"]
147    #[inline(always)]
148    #[must_use]
149    pub fn eere(&mut self) -> EERE_W<0> {
150        EERE_W::new(self)
151    }
152    #[doc = "Bit 1 - EEPROM Write Enable"]
153    #[inline(always)]
154    #[must_use]
155    pub fn eepe(&mut self) -> EEPE_W<1> {
156        EEPE_W::new(self)
157    }
158    #[doc = "Bit 2 - EEPROM Master Write Enable"]
159    #[inline(always)]
160    #[must_use]
161    pub fn eempe(&mut self) -> EEMPE_W<2> {
162        EEMPE_W::new(self)
163    }
164    #[doc = "Bit 3 - EEPROM Ready Interrupt Enable"]
165    #[inline(always)]
166    #[must_use]
167    pub fn eerie(&mut self) -> EERIE_W<3> {
168        EERIE_W::new(self)
169    }
170    #[doc = "Bits 4:5 - EEPROM Programming Mode Bits"]
171    #[inline(always)]
172    #[must_use]
173    pub fn eepm(&mut self) -> EEPM_W<4> {
174        EEPM_W::new(self)
175    }
176    #[doc = "Writes raw bits to the register."]
177    #[inline(always)]
178    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
179        self.0.bits(bits);
180        self
181    }
182}
183#[doc = "EEPROM Control 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 [eecr](index.html) module"]
184pub struct EECR_SPEC;
185impl crate::RegisterSpec for EECR_SPEC {
186    type Ux = u8;
187}
188#[doc = "`read()` method returns [eecr::R](R) reader structure"]
189impl crate::Readable for EECR_SPEC {
190    type Reader = R;
191}
192#[doc = "`write(|w| ..)` method takes [eecr::W](W) writer structure"]
193impl crate::Writable for EECR_SPEC {
194    type Writer = W;
195    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
196    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
197}
198#[doc = "`reset()` method sets EECR to value 0"]
199impl crate::Resettable for EECR_SPEC {
200    const RESET_VALUE: Self::Ux = 0;
201}