mimxrt685s_pac/adc0/
stat.rs

1#[doc = "Register `STAT` reader"]
2pub type R = crate::R<StatSpec>;
3#[doc = "Register `STAT` writer"]
4pub type W = crate::W<StatSpec>;
5#[doc = "Result FIFO Ready Flag\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum Rdy {
9    #[doc = "0: Result FIFO data level not above watermark level."]
10    Rdy0 = 0,
11    #[doc = "1: Result FIFO holding data above watermark level."]
12    Rdy1 = 1,
13}
14impl From<Rdy> for bool {
15    #[inline(always)]
16    fn from(variant: Rdy) -> Self {
17        variant as u8 != 0
18    }
19}
20#[doc = "Field `RDY` reader - Result FIFO Ready Flag"]
21pub type RdyR = crate::BitReader<Rdy>;
22impl RdyR {
23    #[doc = "Get enumerated values variant"]
24    #[inline(always)]
25    pub const fn variant(&self) -> Rdy {
26        match self.bits {
27            false => Rdy::Rdy0,
28            true => Rdy::Rdy1,
29        }
30    }
31    #[doc = "Result FIFO data level not above watermark level."]
32    #[inline(always)]
33    pub fn is_rdy_0(&self) -> bool {
34        *self == Rdy::Rdy0
35    }
36    #[doc = "Result FIFO holding data above watermark level."]
37    #[inline(always)]
38    pub fn is_rdy_1(&self) -> bool {
39        *self == Rdy::Rdy1
40    }
41}
42#[doc = "Result FIFO Overflow Flag\n\nValue on reset: 0"]
43#[cfg_attr(feature = "defmt", derive(defmt::Format))]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45pub enum Fof {
46    #[doc = "0: No result FIFO overflow has occurred since the last time the flag was cleared."]
47    Fof0 = 0,
48    #[doc = "1: At least one result FIFO overflow has occurred since the last time the flag was cleared."]
49    Fof1 = 1,
50}
51impl From<Fof> for bool {
52    #[inline(always)]
53    fn from(variant: Fof) -> Self {
54        variant as u8 != 0
55    }
56}
57#[doc = "Field `FOF` reader - Result FIFO Overflow Flag"]
58pub type FofR = crate::BitReader<Fof>;
59impl FofR {
60    #[doc = "Get enumerated values variant"]
61    #[inline(always)]
62    pub const fn variant(&self) -> Fof {
63        match self.bits {
64            false => Fof::Fof0,
65            true => Fof::Fof1,
66        }
67    }
68    #[doc = "No result FIFO overflow has occurred since the last time the flag was cleared."]
69    #[inline(always)]
70    pub fn is_fof_0(&self) -> bool {
71        *self == Fof::Fof0
72    }
73    #[doc = "At least one result FIFO overflow has occurred since the last time the flag was cleared."]
74    #[inline(always)]
75    pub fn is_fof_1(&self) -> bool {
76        *self == Fof::Fof1
77    }
78}
79#[doc = "Field `FOF` writer - Result FIFO Overflow Flag"]
80pub type FofW<'a, REG> = crate::BitWriter1C<'a, REG, Fof>;
81impl<'a, REG> FofW<'a, REG>
82where
83    REG: crate::Writable + crate::RegisterSpec,
84{
85    #[doc = "No result FIFO overflow has occurred since the last time the flag was cleared."]
86    #[inline(always)]
87    pub fn fof_0(self) -> &'a mut crate::W<REG> {
88        self.variant(Fof::Fof0)
89    }
90    #[doc = "At least one result FIFO overflow has occurred since the last time the flag was cleared."]
91    #[inline(always)]
92    pub fn fof_1(self) -> &'a mut crate::W<REG> {
93        self.variant(Fof::Fof1)
94    }
95}
96#[doc = "Trigger Active\n\nValue on reset: 0"]
97#[cfg_attr(feature = "defmt", derive(defmt::Format))]
98#[derive(Clone, Copy, Debug, PartialEq, Eq)]
99#[repr(u8)]
100pub enum Trgact {
101    #[doc = "0: Command (sequence) associated with Trigger 0 currently being executed."]
102    Trgact0 = 0,
103    #[doc = "1: Command (sequence) associated with Trigger 1 currently being executed."]
104    Trgact1 = 1,
105    #[doc = "15: Command (sequence) associated with Trigger 15 currently being executed."]
106    Trgact15 = 15,
107}
108impl From<Trgact> for u8 {
109    #[inline(always)]
110    fn from(variant: Trgact) -> Self {
111        variant as _
112    }
113}
114impl crate::FieldSpec for Trgact {
115    type Ux = u8;
116}
117impl crate::IsEnum for Trgact {}
118#[doc = "Field `TRGACT` reader - Trigger Active"]
119pub type TrgactR = crate::FieldReader<Trgact>;
120impl TrgactR {
121    #[doc = "Get enumerated values variant"]
122    #[inline(always)]
123    pub const fn variant(&self) -> Option<Trgact> {
124        match self.bits {
125            0 => Some(Trgact::Trgact0),
126            1 => Some(Trgact::Trgact1),
127            15 => Some(Trgact::Trgact15),
128            _ => None,
129        }
130    }
131    #[doc = "Command (sequence) associated with Trigger 0 currently being executed."]
132    #[inline(always)]
133    pub fn is_trgact_0(&self) -> bool {
134        *self == Trgact::Trgact0
135    }
136    #[doc = "Command (sequence) associated with Trigger 1 currently being executed."]
137    #[inline(always)]
138    pub fn is_trgact_1(&self) -> bool {
139        *self == Trgact::Trgact1
140    }
141    #[doc = "Command (sequence) associated with Trigger 15 currently being executed."]
142    #[inline(always)]
143    pub fn is_trgact_15(&self) -> bool {
144        *self == Trgact::Trgact15
145    }
146}
147#[doc = "Command Active\n\nValue on reset: 0"]
148#[cfg_attr(feature = "defmt", derive(defmt::Format))]
149#[derive(Clone, Copy, Debug, PartialEq, Eq)]
150#[repr(u8)]
151pub enum Cmdact {
152    #[doc = "0: No command is currently in progress."]
153    Cmdact0 = 0,
154    #[doc = "1: Command 1 currently being executed."]
155    Cmdact1 = 1,
156    #[doc = "2: Command 2 currently being executed."]
157    Cmdact2 = 2,
158    #[doc = "15: Command 15 currently being executed."]
159    Cmdact15 = 15,
160}
161impl From<Cmdact> for u8 {
162    #[inline(always)]
163    fn from(variant: Cmdact) -> Self {
164        variant as _
165    }
166}
167impl crate::FieldSpec for Cmdact {
168    type Ux = u8;
169}
170impl crate::IsEnum for Cmdact {}
171#[doc = "Field `CMDACT` reader - Command Active"]
172pub type CmdactR = crate::FieldReader<Cmdact>;
173impl CmdactR {
174    #[doc = "Get enumerated values variant"]
175    #[inline(always)]
176    pub const fn variant(&self) -> Option<Cmdact> {
177        match self.bits {
178            0 => Some(Cmdact::Cmdact0),
179            1 => Some(Cmdact::Cmdact1),
180            2 => Some(Cmdact::Cmdact2),
181            15 => Some(Cmdact::Cmdact15),
182            _ => None,
183        }
184    }
185    #[doc = "No command is currently in progress."]
186    #[inline(always)]
187    pub fn is_cmdact_0(&self) -> bool {
188        *self == Cmdact::Cmdact0
189    }
190    #[doc = "Command 1 currently being executed."]
191    #[inline(always)]
192    pub fn is_cmdact_1(&self) -> bool {
193        *self == Cmdact::Cmdact1
194    }
195    #[doc = "Command 2 currently being executed."]
196    #[inline(always)]
197    pub fn is_cmdact_2(&self) -> bool {
198        *self == Cmdact::Cmdact2
199    }
200    #[doc = "Command 15 currently being executed."]
201    #[inline(always)]
202    pub fn is_cmdact_15(&self) -> bool {
203        *self == Cmdact::Cmdact15
204    }
205}
206impl R {
207    #[doc = "Bit 0 - Result FIFO Ready Flag"]
208    #[inline(always)]
209    pub fn rdy(&self) -> RdyR {
210        RdyR::new((self.bits & 1) != 0)
211    }
212    #[doc = "Bit 1 - Result FIFO Overflow Flag"]
213    #[inline(always)]
214    pub fn fof(&self) -> FofR {
215        FofR::new(((self.bits >> 1) & 1) != 0)
216    }
217    #[doc = "Bits 16:19 - Trigger Active"]
218    #[inline(always)]
219    pub fn trgact(&self) -> TrgactR {
220        TrgactR::new(((self.bits >> 16) & 0x0f) as u8)
221    }
222    #[doc = "Bits 24:27 - Command Active"]
223    #[inline(always)]
224    pub fn cmdact(&self) -> CmdactR {
225        CmdactR::new(((self.bits >> 24) & 0x0f) as u8)
226    }
227}
228#[cfg(feature = "debug")]
229impl core::fmt::Debug for R {
230    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
231        f.debug_struct("STAT")
232            .field("rdy", &self.rdy())
233            .field("fof", &self.fof())
234            .field("trgact", &self.trgact())
235            .field("cmdact", &self.cmdact())
236            .finish()
237    }
238}
239impl W {
240    #[doc = "Bit 1 - Result FIFO Overflow Flag"]
241    #[inline(always)]
242    pub fn fof(&mut self) -> FofW<StatSpec> {
243        FofW::new(self, 1)
244    }
245}
246#[doc = "ADC Status Register\n\nYou can [`read`](crate::Reg::read) this register and get [`stat::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`stat::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
247pub struct StatSpec;
248impl crate::RegisterSpec for StatSpec {
249    type Ux = u32;
250}
251#[doc = "`read()` method returns [`stat::R`](R) reader structure"]
252impl crate::Readable for StatSpec {}
253#[doc = "`write(|w| ..)` method takes [`stat::W`](W) writer structure"]
254impl crate::Writable for StatSpec {
255    type Safety = crate::Unsafe;
256    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
257    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0x02;
258}
259#[doc = "`reset()` method sets STAT to value 0"]
260impl crate::Resettable for StatSpec {
261    const RESET_VALUE: u32 = 0;
262}