atsamd51p/sercom0/i2cs/
ctrlb.rs

1#[doc = "Register `CTRLB` reader"]
2pub type R = crate::R<CtrlbSpec>;
3#[doc = "Register `CTRLB` writer"]
4pub type W = crate::W<CtrlbSpec>;
5#[doc = "Field `SMEN` reader - Smart Mode Enable"]
6pub type SmenR = crate::BitReader;
7#[doc = "Field `SMEN` writer - Smart Mode Enable"]
8pub type SmenW<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Field `GCMD` reader - PMBus Group Command"]
10pub type GcmdR = crate::BitReader;
11#[doc = "Field `GCMD` writer - PMBus Group Command"]
12pub type GcmdW<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Field `AACKEN` reader - Automatic Address Acknowledge"]
14pub type AackenR = crate::BitReader;
15#[doc = "Field `AACKEN` writer - Automatic Address Acknowledge"]
16pub type AackenW<'a, REG> = crate::BitWriter<'a, REG>;
17#[doc = "Address Mode\n\nValue on reset: 0"]
18#[derive(Clone, Copy, Debug, PartialEq, Eq)]
19#[repr(u8)]
20pub enum Amodeselect {
21    #[doc = "0: I2C Address mask"]
22    Mask = 0,
23    #[doc = "1: Two unique Addressess"]
24    _2Addresses = 1,
25    #[doc = "2: Address Range"]
26    Range = 2,
27}
28impl From<Amodeselect> for u8 {
29    #[inline(always)]
30    fn from(variant: Amodeselect) -> Self {
31        variant as _
32    }
33}
34impl crate::FieldSpec for Amodeselect {
35    type Ux = u8;
36}
37impl crate::IsEnum for Amodeselect {}
38#[doc = "Field `AMODE` reader - Address Mode"]
39pub type AmodeR = crate::FieldReader<Amodeselect>;
40impl AmodeR {
41    #[doc = "Get enumerated values variant"]
42    #[inline(always)]
43    pub const fn variant(&self) -> Option<Amodeselect> {
44        match self.bits {
45            0 => Some(Amodeselect::Mask),
46            1 => Some(Amodeselect::_2Addresses),
47            2 => Some(Amodeselect::Range),
48            _ => None,
49        }
50    }
51    #[doc = "I2C Address mask"]
52    #[inline(always)]
53    pub fn is_mask(&self) -> bool {
54        *self == Amodeselect::Mask
55    }
56    #[doc = "Two unique Addressess"]
57    #[inline(always)]
58    pub fn is_2_addresses(&self) -> bool {
59        *self == Amodeselect::_2Addresses
60    }
61    #[doc = "Address Range"]
62    #[inline(always)]
63    pub fn is_range(&self) -> bool {
64        *self == Amodeselect::Range
65    }
66}
67#[doc = "Field `AMODE` writer - Address Mode"]
68pub type AmodeW<'a, REG> = crate::FieldWriter<'a, REG, 2, Amodeselect>;
69impl<'a, REG> AmodeW<'a, REG>
70where
71    REG: crate::Writable + crate::RegisterSpec,
72    REG::Ux: From<u8>,
73{
74    #[doc = "I2C Address mask"]
75    #[inline(always)]
76    pub fn mask(self) -> &'a mut crate::W<REG> {
77        self.variant(Amodeselect::Mask)
78    }
79    #[doc = "Two unique Addressess"]
80    #[inline(always)]
81    pub fn _2_addresses(self) -> &'a mut crate::W<REG> {
82        self.variant(Amodeselect::_2Addresses)
83    }
84    #[doc = "Address Range"]
85    #[inline(always)]
86    pub fn range(self) -> &'a mut crate::W<REG> {
87        self.variant(Amodeselect::Range)
88    }
89}
90#[doc = "Field `CMD` reader - Command"]
91pub type CmdR = crate::FieldReader;
92#[doc = "Field `CMD` writer - Command"]
93pub type CmdW<'a, REG> = crate::FieldWriter<'a, REG, 2>;
94#[doc = "Field `ACKACT` reader - Acknowledge Action"]
95pub type AckactR = crate::BitReader;
96#[doc = "Field `ACKACT` writer - Acknowledge Action"]
97pub type AckactW<'a, REG> = crate::BitWriter<'a, REG>;
98impl R {
99    #[doc = "Bit 8 - Smart Mode Enable"]
100    #[inline(always)]
101    pub fn smen(&self) -> SmenR {
102        SmenR::new(((self.bits >> 8) & 1) != 0)
103    }
104    #[doc = "Bit 9 - PMBus Group Command"]
105    #[inline(always)]
106    pub fn gcmd(&self) -> GcmdR {
107        GcmdR::new(((self.bits >> 9) & 1) != 0)
108    }
109    #[doc = "Bit 10 - Automatic Address Acknowledge"]
110    #[inline(always)]
111    pub fn aacken(&self) -> AackenR {
112        AackenR::new(((self.bits >> 10) & 1) != 0)
113    }
114    #[doc = "Bits 14:15 - Address Mode"]
115    #[inline(always)]
116    pub fn amode(&self) -> AmodeR {
117        AmodeR::new(((self.bits >> 14) & 3) as u8)
118    }
119    #[doc = "Bits 16:17 - Command"]
120    #[inline(always)]
121    pub fn cmd(&self) -> CmdR {
122        CmdR::new(((self.bits >> 16) & 3) as u8)
123    }
124    #[doc = "Bit 18 - Acknowledge Action"]
125    #[inline(always)]
126    pub fn ackact(&self) -> AckactR {
127        AckactR::new(((self.bits >> 18) & 1) != 0)
128    }
129}
130impl W {
131    #[doc = "Bit 8 - Smart Mode Enable"]
132    #[inline(always)]
133    #[must_use]
134    pub fn smen(&mut self) -> SmenW<CtrlbSpec> {
135        SmenW::new(self, 8)
136    }
137    #[doc = "Bit 9 - PMBus Group Command"]
138    #[inline(always)]
139    #[must_use]
140    pub fn gcmd(&mut self) -> GcmdW<CtrlbSpec> {
141        GcmdW::new(self, 9)
142    }
143    #[doc = "Bit 10 - Automatic Address Acknowledge"]
144    #[inline(always)]
145    #[must_use]
146    pub fn aacken(&mut self) -> AackenW<CtrlbSpec> {
147        AackenW::new(self, 10)
148    }
149    #[doc = "Bits 14:15 - Address Mode"]
150    #[inline(always)]
151    #[must_use]
152    pub fn amode(&mut self) -> AmodeW<CtrlbSpec> {
153        AmodeW::new(self, 14)
154    }
155    #[doc = "Bits 16:17 - Command"]
156    #[inline(always)]
157    #[must_use]
158    pub fn cmd(&mut self) -> CmdW<CtrlbSpec> {
159        CmdW::new(self, 16)
160    }
161    #[doc = "Bit 18 - Acknowledge Action"]
162    #[inline(always)]
163    #[must_use]
164    pub fn ackact(&mut self) -> AckactW<CtrlbSpec> {
165        AckactW::new(self, 18)
166    }
167}
168#[doc = "I2CS Control B\n\nYou can [`read`](crate::Reg::read) this register and get [`ctrlb::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ctrlb::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
169pub struct CtrlbSpec;
170impl crate::RegisterSpec for CtrlbSpec {
171    type Ux = u32;
172}
173#[doc = "`read()` method returns [`ctrlb::R`](R) reader structure"]
174impl crate::Readable for CtrlbSpec {}
175#[doc = "`write(|w| ..)` method takes [`ctrlb::W`](W) writer structure"]
176impl crate::Writable for CtrlbSpec {
177    type Safety = crate::Unsafe;
178    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
179    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
180}
181#[doc = "`reset()` method sets CTRLB to value 0"]
182impl crate::Resettable for CtrlbSpec {
183    const RESET_VALUE: u32 = 0;
184}