Skip to main content

mcxa_pac/i3c0/
mdynaddr.rs

1#[doc = "Register `MDYNADDR` reader"]
2pub type R = crate::R<MdynaddrSpec>;
3#[doc = "Register `MDYNADDR` writer"]
4pub type W = crate::W<MdynaddrSpec>;
5#[doc = "Dynamic Address Valid\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum Davalid {
9    #[doc = "0: No valid DA assigned"]
10    NoValid = 0,
11    #[doc = "1: Valid DA assigned"]
12    Valid = 1,
13}
14impl From<Davalid> for bool {
15    #[inline(always)]
16    fn from(variant: Davalid) -> Self {
17        variant as u8 != 0
18    }
19}
20#[doc = "Field `DAVALID` reader - Dynamic Address Valid"]
21pub type DavalidR = crate::BitReader<Davalid>;
22impl DavalidR {
23    #[doc = "Get enumerated values variant"]
24    #[inline(always)]
25    pub const fn variant(&self) -> Davalid {
26        match self.bits {
27            false => Davalid::NoValid,
28            true => Davalid::Valid,
29        }
30    }
31    #[doc = "No valid DA assigned"]
32    #[inline(always)]
33    pub fn is_no_valid(&self) -> bool {
34        *self == Davalid::NoValid
35    }
36    #[doc = "Valid DA assigned"]
37    #[inline(always)]
38    pub fn is_valid(&self) -> bool {
39        *self == Davalid::Valid
40    }
41}
42#[doc = "Field `DAVALID` writer - Dynamic Address Valid"]
43pub type DavalidW<'a, REG> = crate::BitWriter<'a, REG, Davalid>;
44impl<'a, REG> DavalidW<'a, REG>
45where
46    REG: crate::Writable + crate::RegisterSpec,
47{
48    #[doc = "No valid DA assigned"]
49    #[inline(always)]
50    pub fn no_valid(self) -> &'a mut crate::W<REG> {
51        self.variant(Davalid::NoValid)
52    }
53    #[doc = "Valid DA assigned"]
54    #[inline(always)]
55    pub fn valid(self) -> &'a mut crate::W<REG> {
56        self.variant(Davalid::Valid)
57    }
58}
59#[doc = "Field `DADDR` reader - Dynamic Address"]
60pub type DaddrR = crate::FieldReader;
61#[doc = "Field `DADDR` writer - Dynamic Address"]
62pub type DaddrW<'a, REG> = crate::FieldWriter<'a, REG, 7>;
63impl R {
64    #[doc = "Bit 0 - Dynamic Address Valid"]
65    #[inline(always)]
66    pub fn davalid(&self) -> DavalidR {
67        DavalidR::new((self.bits & 1) != 0)
68    }
69    #[doc = "Bits 1:7 - Dynamic Address"]
70    #[inline(always)]
71    pub fn daddr(&self) -> DaddrR {
72        DaddrR::new(((self.bits >> 1) & 0x7f) as u8)
73    }
74}
75#[cfg(feature = "debug")]
76impl core::fmt::Debug for R {
77    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
78        f.debug_struct("MDYNADDR")
79            .field("davalid", &self.davalid())
80            .field("daddr", &self.daddr())
81            .finish()
82    }
83}
84impl W {
85    #[doc = "Bit 0 - Dynamic Address Valid"]
86    #[inline(always)]
87    pub fn davalid(&mut self) -> DavalidW<'_, MdynaddrSpec> {
88        DavalidW::new(self, 0)
89    }
90    #[doc = "Bits 1:7 - Dynamic Address"]
91    #[inline(always)]
92    pub fn daddr(&mut self) -> DaddrW<'_, MdynaddrSpec> {
93        DaddrW::new(self, 1)
94    }
95}
96#[doc = "Controller Dynamic Address\n\nYou can [`read`](crate::Reg::read) this register and get [`mdynaddr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`mdynaddr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
97pub struct MdynaddrSpec;
98impl crate::RegisterSpec for MdynaddrSpec {
99    type Ux = u32;
100}
101#[doc = "`read()` method returns [`mdynaddr::R`](R) reader structure"]
102impl crate::Readable for MdynaddrSpec {}
103#[doc = "`write(|w| ..)` method takes [`mdynaddr::W`](W) writer structure"]
104impl crate::Writable for MdynaddrSpec {
105    type Safety = crate::Unsafe;
106}
107#[doc = "`reset()` method sets MDYNADDR to value 0"]
108impl crate::Resettable for MdynaddrSpec {}