Skip to main content

mcxa_pac/utick0/
cap.rs

1#[doc = "Register `CAP[%s]` reader"]
2pub type R = crate::R<CapSpec>;
3#[doc = "Field `CAP_VALUE` reader - Captured Value for the Related Capture Event"]
4pub type CapValueR = crate::FieldReader<u32>;
5#[doc = "Captured Value Valid Flag\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum Valid {
9    #[doc = "0: Valid value not captured"]
10    Notvalid = 0,
11    #[doc = "1: Valid value captured"]
12    Valid = 1,
13}
14impl From<Valid> for bool {
15    #[inline(always)]
16    fn from(variant: Valid) -> Self {
17        variant as u8 != 0
18    }
19}
20#[doc = "Field `VALID` reader - Captured Value Valid Flag"]
21pub type ValidR = crate::BitReader<Valid>;
22impl ValidR {
23    #[doc = "Get enumerated values variant"]
24    #[inline(always)]
25    pub const fn variant(&self) -> Valid {
26        match self.bits {
27            false => Valid::Notvalid,
28            true => Valid::Valid,
29        }
30    }
31    #[doc = "Valid value not captured"]
32    #[inline(always)]
33    pub fn is_notvalid(&self) -> bool {
34        *self == Valid::Notvalid
35    }
36    #[doc = "Valid value captured"]
37    #[inline(always)]
38    pub fn is_valid(&self) -> bool {
39        *self == Valid::Valid
40    }
41}
42impl R {
43    #[doc = "Bits 0:30 - Captured Value for the Related Capture Event"]
44    #[inline(always)]
45    pub fn cap_value(&self) -> CapValueR {
46        CapValueR::new(self.bits & 0x7fff_ffff)
47    }
48    #[doc = "Bit 31 - Captured Value Valid Flag"]
49    #[inline(always)]
50    pub fn valid(&self) -> ValidR {
51        ValidR::new(((self.bits >> 31) & 1) != 0)
52    }
53}
54#[cfg(feature = "debug")]
55impl core::fmt::Debug for R {
56    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
57        f.debug_struct("CAP")
58            .field("cap_value", &self.cap_value())
59            .field("valid", &self.valid())
60            .finish()
61    }
62}
63#[doc = "Capture\n\nYou can [`read`](crate::Reg::read) this register and get [`cap::R`](R). See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
64pub struct CapSpec;
65impl crate::RegisterSpec for CapSpec {
66    type Ux = u32;
67}
68#[doc = "`read()` method returns [`cap::R`](R) reader structure"]
69impl crate::Readable for CapSpec {}
70#[doc = "`reset()` method sets CAP[%s] to value 0"]
71impl crate::Resettable for CapSpec {}