esp8266/spi0/
spi_ext1.rs

1#[doc = "Register `SPI_EXT1` reader"]
2pub struct R(crate::R<SPI_EXT1_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<SPI_EXT1_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<SPI_EXT1_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<SPI_EXT1_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `SPI_EXT1` writer"]
17pub struct W(crate::W<SPI_EXT1_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<SPI_EXT1_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<SPI_EXT1_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<SPI_EXT1_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `erase_enable` reader - "]
38pub struct ERASE_ENABLE_R(crate::FieldReader<bool, bool>);
39impl ERASE_ENABLE_R {
40    #[inline(always)]
41    pub(crate) fn new(bits: bool) -> Self {
42        ERASE_ENABLE_R(crate::FieldReader::new(bits))
43    }
44}
45impl core::ops::Deref for ERASE_ENABLE_R {
46    type Target = crate::FieldReader<bool, bool>;
47    #[inline(always)]
48    fn deref(&self) -> &Self::Target {
49        &self.0
50    }
51}
52#[doc = "Field `erase_enable` writer - "]
53pub struct ERASE_ENABLE_W<'a> {
54    w: &'a mut W,
55}
56impl<'a> ERASE_ENABLE_W<'a> {
57    #[doc = r"Sets the field bit"]
58    #[inline(always)]
59    pub fn set_bit(self) -> &'a mut W {
60        self.bit(true)
61    }
62    #[doc = r"Clears the field bit"]
63    #[inline(always)]
64    pub fn clear_bit(self) -> &'a mut W {
65        self.bit(false)
66    }
67    #[doc = r"Writes raw bits to the field"]
68    #[inline(always)]
69    pub fn bit(self, value: bool) -> &'a mut W {
70        self.w.bits = (self.w.bits & !(1 << 31)) | ((value as u32 & 1) << 31);
71        self.w
72    }
73}
74#[doc = "Field `erase_shift` reader - "]
75pub struct ERASE_SHIFT_R(crate::FieldReader<u8, u8>);
76impl ERASE_SHIFT_R {
77    #[inline(always)]
78    pub(crate) fn new(bits: u8) -> Self {
79        ERASE_SHIFT_R(crate::FieldReader::new(bits))
80    }
81}
82impl core::ops::Deref for ERASE_SHIFT_R {
83    type Target = crate::FieldReader<u8, u8>;
84    #[inline(always)]
85    fn deref(&self) -> &Self::Target {
86        &self.0
87    }
88}
89#[doc = "Field `erase_shift` writer - "]
90pub struct ERASE_SHIFT_W<'a> {
91    w: &'a mut W,
92}
93impl<'a> ERASE_SHIFT_W<'a> {
94    #[doc = r"Writes raw bits to the field"]
95    #[inline(always)]
96    pub unsafe fn bits(self, value: u8) -> &'a mut W {
97        self.w.bits = (self.w.bits & !(0x0f << 16)) | ((value as u32 & 0x0f) << 16);
98        self.w
99    }
100}
101#[doc = "Field `erase_time` reader - "]
102pub struct ERASE_TIME_R(crate::FieldReader<u16, u16>);
103impl ERASE_TIME_R {
104    #[inline(always)]
105    pub(crate) fn new(bits: u16) -> Self {
106        ERASE_TIME_R(crate::FieldReader::new(bits))
107    }
108}
109impl core::ops::Deref for ERASE_TIME_R {
110    type Target = crate::FieldReader<u16, u16>;
111    #[inline(always)]
112    fn deref(&self) -> &Self::Target {
113        &self.0
114    }
115}
116#[doc = "Field `erase_time` writer - "]
117pub struct ERASE_TIME_W<'a> {
118    w: &'a mut W,
119}
120impl<'a> ERASE_TIME_W<'a> {
121    #[doc = r"Writes raw bits to the field"]
122    #[inline(always)]
123    pub unsafe fn bits(self, value: u16) -> &'a mut W {
124        self.w.bits = (self.w.bits & !0x0fff) | (value as u32 & 0x0fff);
125        self.w
126    }
127}
128impl R {
129    #[doc = "Bit 31"]
130    #[inline(always)]
131    pub fn erase_enable(&self) -> ERASE_ENABLE_R {
132        ERASE_ENABLE_R::new(((self.bits >> 31) & 1) != 0)
133    }
134    #[doc = "Bits 16:19"]
135    #[inline(always)]
136    pub fn erase_shift(&self) -> ERASE_SHIFT_R {
137        ERASE_SHIFT_R::new(((self.bits >> 16) & 0x0f) as u8)
138    }
139    #[doc = "Bits 0:11"]
140    #[inline(always)]
141    pub fn erase_time(&self) -> ERASE_TIME_R {
142        ERASE_TIME_R::new((self.bits & 0x0fff) as u16)
143    }
144}
145impl W {
146    #[doc = "Bit 31"]
147    #[inline(always)]
148    pub fn erase_enable(&mut self) -> ERASE_ENABLE_W {
149        ERASE_ENABLE_W { w: self }
150    }
151    #[doc = "Bits 16:19"]
152    #[inline(always)]
153    pub fn erase_shift(&mut self) -> ERASE_SHIFT_W {
154        ERASE_SHIFT_W { w: self }
155    }
156    #[doc = "Bits 0:11"]
157    #[inline(always)]
158    pub fn erase_time(&mut self) -> ERASE_TIME_W {
159        ERASE_TIME_W { w: self }
160    }
161    #[doc = "Writes raw bits to the register."]
162    #[inline(always)]
163    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
164        self.0.bits(bits);
165        self
166    }
167}
168#[doc = "\n\nThis register you can [`read`]
169(crate::generic::Reg::read), [`write_with_zero`]
170(crate::generic::Reg::write_with_zero), [`reset`]
171(crate::generic::Reg::reset), [`write`]
172(crate::generic::Reg::write), [`modify`]
173(crate::generic::Reg::modify). See [API]
174(https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [spi_ext1]
175(index.html) module"]
176pub struct SPI_EXT1_SPEC;
177impl crate::RegisterSpec for SPI_EXT1_SPEC {
178    type Ux = u32;
179}
180#[doc = "`read()` method returns [spi_ext1::R]
181(R) reader structure"]
182impl crate::Readable for SPI_EXT1_SPEC {
183    type Reader = R;
184}
185#[doc = "`write(|w| ..)` method takes [spi_ext1::W]
186(W) writer structure"]
187impl crate::Writable for SPI_EXT1_SPEC {
188    type Writer = W;
189}
190#[doc = "`reset()` method sets SPI_EXT1 to value 0"]
191impl crate::Resettable for SPI_EXT1_SPEC {
192    #[inline(always)]
193    fn reset_value() -> Self::Ux {
194        0
195    }
196}