esp32c3/i2c0/
comd.rs

1#[doc = "Register `COMD%s` reader"]
2pub type R = crate::R<COMD_SPEC>;
3#[doc = "Register `COMD%s` writer"]
4pub type W = crate::W<COMD_SPEC>;
5#[doc = "Field `BYTE_NUM` reader - Number of bytes to be sent or received for command %s."]
6pub type BYTE_NUM_R = crate::FieldReader;
7#[doc = "Field `BYTE_NUM` writer - Number of bytes to be sent or received for command %s."]
8pub type BYTE_NUM_W<'a, REG> = crate::FieldWriter<'a, REG, 8>;
9#[doc = "Field `ACK_CHECK_EN` reader - Acknowledge check enable for command %s."]
10pub type ACK_CHECK_EN_R = crate::BitReader;
11#[doc = "Field `ACK_CHECK_EN` writer - Acknowledge check enable for command %s."]
12pub type ACK_CHECK_EN_W<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Field `ACK_EXP` reader - Acknowledge expected for command %s."]
14pub type ACK_EXP_R = crate::BitReader;
15#[doc = "Field `ACK_EXP` writer - Acknowledge expected for command %s."]
16pub type ACK_EXP_W<'a, REG> = crate::BitWriter<'a, REG>;
17#[doc = "Field `ACK_VALUE` reader - Acknowledge value for command %s."]
18pub type ACK_VALUE_R = crate::BitReader;
19#[doc = "Field `ACK_VALUE` writer - Acknowledge value for command %s."]
20pub type ACK_VALUE_W<'a, REG> = crate::BitWriter<'a, REG>;
21#[doc = "Opcode part of command %s.\n\nValue on reset: 0"]
22#[cfg_attr(feature = "defmt", derive(defmt::Format))]
23#[derive(Clone, Copy, Debug, PartialEq, Eq)]
24#[repr(u8)]
25pub enum OPCODE {
26    #[doc = "1: WRITE opcode"]
27    Write = 1,
28    #[doc = "2: STOP opcode"]
29    Stop = 2,
30    #[doc = "3: READ opcode"]
31    Read = 3,
32    #[doc = "4: END opcode"]
33    End = 4,
34    #[doc = "6: RSTART opcode"]
35    Rstart = 6,
36}
37impl From<OPCODE> for u8 {
38    #[inline(always)]
39    fn from(variant: OPCODE) -> Self {
40        variant as _
41    }
42}
43impl crate::FieldSpec for OPCODE {
44    type Ux = u8;
45}
46impl crate::IsEnum for OPCODE {}
47#[doc = "Field `OPCODE` reader - Opcode part of command %s."]
48pub type OPCODE_R = crate::FieldReader<OPCODE>;
49impl OPCODE_R {
50    #[doc = "Get enumerated values variant"]
51    #[inline(always)]
52    pub const fn variant(&self) -> Option<OPCODE> {
53        match self.bits {
54            1 => Some(OPCODE::Write),
55            2 => Some(OPCODE::Stop),
56            3 => Some(OPCODE::Read),
57            4 => Some(OPCODE::End),
58            6 => Some(OPCODE::Rstart),
59            _ => None,
60        }
61    }
62    #[doc = "WRITE opcode"]
63    #[inline(always)]
64    pub fn is_write(&self) -> bool {
65        *self == OPCODE::Write
66    }
67    #[doc = "STOP opcode"]
68    #[inline(always)]
69    pub fn is_stop(&self) -> bool {
70        *self == OPCODE::Stop
71    }
72    #[doc = "READ opcode"]
73    #[inline(always)]
74    pub fn is_read(&self) -> bool {
75        *self == OPCODE::Read
76    }
77    #[doc = "END opcode"]
78    #[inline(always)]
79    pub fn is_end(&self) -> bool {
80        *self == OPCODE::End
81    }
82    #[doc = "RSTART opcode"]
83    #[inline(always)]
84    pub fn is_rstart(&self) -> bool {
85        *self == OPCODE::Rstart
86    }
87}
88#[doc = "Field `OPCODE` writer - Opcode part of command %s."]
89pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3, OPCODE>;
90impl<'a, REG> OPCODE_W<'a, REG>
91where
92    REG: crate::Writable + crate::RegisterSpec,
93    REG::Ux: From<u8>,
94{
95    #[doc = "WRITE opcode"]
96    #[inline(always)]
97    pub fn write(self) -> &'a mut crate::W<REG> {
98        self.variant(OPCODE::Write)
99    }
100    #[doc = "STOP opcode"]
101    #[inline(always)]
102    pub fn stop(self) -> &'a mut crate::W<REG> {
103        self.variant(OPCODE::Stop)
104    }
105    #[doc = "READ opcode"]
106    #[inline(always)]
107    pub fn read(self) -> &'a mut crate::W<REG> {
108        self.variant(OPCODE::Read)
109    }
110    #[doc = "END opcode"]
111    #[inline(always)]
112    pub fn end(self) -> &'a mut crate::W<REG> {
113        self.variant(OPCODE::End)
114    }
115    #[doc = "RSTART opcode"]
116    #[inline(always)]
117    pub fn rstart(self) -> &'a mut crate::W<REG> {
118        self.variant(OPCODE::Rstart)
119    }
120}
121#[doc = "Field `COMMAND_DONE` reader - reg_command_done"]
122pub type COMMAND_DONE_R = crate::BitReader;
123#[doc = "Field `COMMAND_DONE` writer - reg_command_done"]
124pub type COMMAND_DONE_W<'a, REG> = crate::BitWriter<'a, REG>;
125impl R {
126    #[doc = "Bits 0:7 - Number of bytes to be sent or received for command %s."]
127    #[inline(always)]
128    pub fn byte_num(&self) -> BYTE_NUM_R {
129        BYTE_NUM_R::new((self.bits & 0xff) as u8)
130    }
131    #[doc = "Bit 8 - Acknowledge check enable for command %s."]
132    #[inline(always)]
133    pub fn ack_check_en(&self) -> ACK_CHECK_EN_R {
134        ACK_CHECK_EN_R::new(((self.bits >> 8) & 1) != 0)
135    }
136    #[doc = "Bit 9 - Acknowledge expected for command %s."]
137    #[inline(always)]
138    pub fn ack_exp(&self) -> ACK_EXP_R {
139        ACK_EXP_R::new(((self.bits >> 9) & 1) != 0)
140    }
141    #[doc = "Bit 10 - Acknowledge value for command %s."]
142    #[inline(always)]
143    pub fn ack_value(&self) -> ACK_VALUE_R {
144        ACK_VALUE_R::new(((self.bits >> 10) & 1) != 0)
145    }
146    #[doc = "Bits 11:13 - Opcode part of command %s."]
147    #[inline(always)]
148    pub fn opcode(&self) -> OPCODE_R {
149        OPCODE_R::new(((self.bits >> 11) & 7) as u8)
150    }
151    #[doc = "Bit 31 - reg_command_done"]
152    #[inline(always)]
153    pub fn command_done(&self) -> COMMAND_DONE_R {
154        COMMAND_DONE_R::new(((self.bits >> 31) & 1) != 0)
155    }
156}
157#[cfg(feature = "impl-register-debug")]
158impl core::fmt::Debug for R {
159    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
160        f.debug_struct("COMD")
161            .field("command_done", &self.command_done())
162            .field("opcode", &self.opcode())
163            .field("ack_value", &self.ack_value())
164            .field("ack_exp", &self.ack_exp())
165            .field("ack_check_en", &self.ack_check_en())
166            .field("byte_num", &self.byte_num())
167            .finish()
168    }
169}
170impl W {
171    #[doc = "Bits 0:7 - Number of bytes to be sent or received for command %s."]
172    #[inline(always)]
173    pub fn byte_num(&mut self) -> BYTE_NUM_W<COMD_SPEC> {
174        BYTE_NUM_W::new(self, 0)
175    }
176    #[doc = "Bit 8 - Acknowledge check enable for command %s."]
177    #[inline(always)]
178    pub fn ack_check_en(&mut self) -> ACK_CHECK_EN_W<COMD_SPEC> {
179        ACK_CHECK_EN_W::new(self, 8)
180    }
181    #[doc = "Bit 9 - Acknowledge expected for command %s."]
182    #[inline(always)]
183    pub fn ack_exp(&mut self) -> ACK_EXP_W<COMD_SPEC> {
184        ACK_EXP_W::new(self, 9)
185    }
186    #[doc = "Bit 10 - Acknowledge value for command %s."]
187    #[inline(always)]
188    pub fn ack_value(&mut self) -> ACK_VALUE_W<COMD_SPEC> {
189        ACK_VALUE_W::new(self, 10)
190    }
191    #[doc = "Bits 11:13 - Opcode part of command %s."]
192    #[inline(always)]
193    pub fn opcode(&mut self) -> OPCODE_W<COMD_SPEC> {
194        OPCODE_W::new(self, 11)
195    }
196    #[doc = "Bit 31 - reg_command_done"]
197    #[inline(always)]
198    pub fn command_done(&mut self) -> COMMAND_DONE_W<COMD_SPEC> {
199        COMMAND_DONE_W::new(self, 31)
200    }
201}
202#[doc = "I2C_COMD%s_REG\n\nYou can [`read`](crate::Reg::read) this register and get [`comd::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`comd::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
203pub struct COMD_SPEC;
204impl crate::RegisterSpec for COMD_SPEC {
205    type Ux = u32;
206}
207#[doc = "`read()` method returns [`comd::R`](R) reader structure"]
208impl crate::Readable for COMD_SPEC {}
209#[doc = "`write(|w| ..)` method takes [`comd::W`](W) writer structure"]
210impl crate::Writable for COMD_SPEC {
211    type Safety = crate::Unsafe;
212    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
213    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
214}
215#[doc = "`reset()` method sets COMD%s to value 0"]
216impl crate::Resettable for COMD_SPEC {
217    const RESET_VALUE: u32 = 0;
218}