From cfa9f36e3a1ce9ec90205d44ef245e51eb362ec7 Mon Sep 17 00:00:00 2001 From: Kirill Mikhailov Date: Tue, 16 Jul 2024 15:49:50 +0200 Subject: [PATCH 1/2] Split `COMMAND` register for `I2C` --- common_patches/i2c0.yaml | 28 +++++++++++ esp32/src/i2c0/comd.rs | 86 ++++++++++++++++++++++++++++---- esp32/svd/patches/esp32.yaml | 2 + esp32c2/src/i2c0/comd.rs | 86 ++++++++++++++++++++++++++++---- esp32c2/svd/patches/esp32c2.yaml | 4 +- esp32c3/src/i2c0/comd.rs | 86 ++++++++++++++++++++++++++++---- esp32c3/svd/patches/esp32c3.yaml | 2 + esp32c6/src/i2c0/comd.rs | 86 ++++++++++++++++++++++++++++---- esp32c6/svd/patches/esp32c6.yaml | 2 + esp32h2/src/i2c0/comd.rs | 86 ++++++++++++++++++++++++++++---- esp32h2/svd/patches/esp32h2.yaml | 2 + esp32p4/src/i2c0/comd.rs | 86 ++++++++++++++++++++++++++++---- esp32p4/svd/patches/esp32p4.yaml | 4 ++ esp32s2/src/i2c0/comd.rs | 86 ++++++++++++++++++++++++++++---- esp32s2/svd/patches/esp32s2.yaml | 2 + esp32s3/src/i2c0/comd.rs | 86 ++++++++++++++++++++++++++++---- esp32s3/svd/patches/esp32s3.yaml | 4 +- 17 files changed, 648 insertions(+), 90 deletions(-) create mode 100644 common_patches/i2c0.yaml diff --git a/common_patches/i2c0.yaml b/common_patches/i2c0.yaml new file mode 100644 index 0000000000..c932f0b9b5 --- /dev/null +++ b/common_patches/i2c0.yaml @@ -0,0 +1,28 @@ +COMD%s: + _delete: ["COMMAND"] + _add: + OPCODE: + description: "Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END." + bitOffset: 11 + bitWidth: 3 + access: read-write + ACK_VALUE: + description: "Acknowledge value for command %s." + bitOffset: 10 + bitWidth: 1 + access: read-write + ACK_EXP: + description: "Acknowledge expected for command %s." + bitOffset: 9 + bitWidth: 1 + access: read-write + ACK_CHECK_EN: + description: "Acknowledge check enable for command %s." + bitOffset: 8 + bitWidth: 1 + access: read-write + BYTE_NUM: + description: "Number of bytes to be sent or received for command %s." + bitOffset: 0 + bitWidth: 8 + access: read-write \ No newline at end of file diff --git a/esp32/src/i2c0/comd.rs b/esp32/src/i2c0/comd.rs index 71bd8f23c5..703ba5a014 100644 --- a/esp32/src/i2c0/comd.rs +++ b/esp32/src/i2c0/comd.rs @@ -2,19 +2,55 @@ pub type R = crate::R; #[doc = "Register `COMD%s` writer"] pub type W = crate::W; -#[doc = "Field `COMMAND` reader - This is the content of command0. It consists of three part. op_code is the command 0: RSTART 1: WRITE 2: READ 3: STOP . 4:END. Byte_num represent the number of data need to be send or data need to be received. ack_check_en ack_exp and ack value are used to control the ack bit."] -pub type COMMAND_R = crate::FieldReader; -#[doc = "Field `COMMAND` writer - This is the content of command0. It consists of three part. op_code is the command 0: RSTART 1: WRITE 2: READ 3: STOP . 4:END. Byte_num represent the number of data need to be send or data need to be received. ack_check_en ack_exp and ack value are used to control the ack bit."] -pub type COMMAND_W<'a, REG> = crate::FieldWriter<'a, REG, 14, u16>; +#[doc = "Field `BYTE_NUM` reader - Number of bytes to be sent or received for command %s."] +pub type BYTE_NUM_R = crate::FieldReader; +#[doc = "Field `BYTE_NUM` writer - Number of bytes to be sent or received for command %s."] +pub type BYTE_NUM_W<'a, REG> = crate::FieldWriter<'a, REG, 8>; +#[doc = "Field `ACK_CHECK_EN` reader - Acknowledge check enable for command %s."] +pub type ACK_CHECK_EN_R = crate::BitReader; +#[doc = "Field `ACK_CHECK_EN` writer - Acknowledge check enable for command %s."] +pub type ACK_CHECK_EN_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `ACK_EXP` reader - Acknowledge expected for command %s."] +pub type ACK_EXP_R = crate::BitReader; +#[doc = "Field `ACK_EXP` writer - Acknowledge expected for command %s."] +pub type ACK_EXP_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `ACK_VALUE` reader - Acknowledge value for command %s."] +pub type ACK_VALUE_R = crate::BitReader; +#[doc = "Field `ACK_VALUE` writer - Acknowledge value for command %s."] +pub type ACK_VALUE_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `OPCODE` reader - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] +pub type OPCODE_R = crate::FieldReader; +#[doc = "Field `OPCODE` writer - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] +pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3>; #[doc = "Field `COMMAND_DONE` reader - When command0 is done in I2C Master mode this bit changes to high level."] pub type COMMAND_DONE_R = crate::BitReader; #[doc = "Field `COMMAND_DONE` writer - When command0 is done in I2C Master mode this bit changes to high level."] pub type COMMAND_DONE_W<'a, REG> = crate::BitWriter<'a, REG>; impl R { - #[doc = "Bits 0:13 - This is the content of command0. It consists of three part. op_code is the command 0: RSTART 1: WRITE 2: READ 3: STOP . 4:END. Byte_num represent the number of data need to be send or data need to be received. ack_check_en ack_exp and ack value are used to control the ack bit."] + #[doc = "Bits 0:7 - Number of bytes to be sent or received for command %s."] #[inline(always)] - pub fn command(&self) -> COMMAND_R { - COMMAND_R::new((self.bits & 0x3fff) as u16) + pub fn byte_num(&self) -> BYTE_NUM_R { + BYTE_NUM_R::new((self.bits & 0xff) as u8) + } + #[doc = "Bit 8 - Acknowledge check enable for command %s."] + #[inline(always)] + pub fn ack_check_en(&self) -> ACK_CHECK_EN_R { + ACK_CHECK_EN_R::new(((self.bits >> 8) & 1) != 0) + } + #[doc = "Bit 9 - Acknowledge expected for command %s."] + #[inline(always)] + pub fn ack_exp(&self) -> ACK_EXP_R { + ACK_EXP_R::new(((self.bits >> 9) & 1) != 0) + } + #[doc = "Bit 10 - Acknowledge value for command %s."] + #[inline(always)] + pub fn ack_value(&self) -> ACK_VALUE_R { + ACK_VALUE_R::new(((self.bits >> 10) & 1) != 0) + } + #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[inline(always)] + pub fn opcode(&self) -> OPCODE_R { + OPCODE_R::new(((self.bits >> 11) & 7) as u8) } #[doc = "Bit 31 - When command0 is done in I2C Master mode this bit changes to high level."] #[inline(always)] @@ -26,17 +62,45 @@ impl R { impl core::fmt::Debug for R { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("COMD") - .field("command", &self.command()) .field("command_done", &self.command_done()) + .field("opcode", &self.opcode()) + .field("ack_value", &self.ack_value()) + .field("ack_exp", &self.ack_exp()) + .field("ack_check_en", &self.ack_check_en()) + .field("byte_num", &self.byte_num()) .finish() } } impl W { - #[doc = "Bits 0:13 - This is the content of command0. It consists of three part. op_code is the command 0: RSTART 1: WRITE 2: READ 3: STOP . 4:END. Byte_num represent the number of data need to be send or data need to be received. ack_check_en ack_exp and ack value are used to control the ack bit."] + #[doc = "Bits 0:7 - Number of bytes to be sent or received for command %s."] + #[inline(always)] + #[must_use] + pub fn byte_num(&mut self) -> BYTE_NUM_W { + BYTE_NUM_W::new(self, 0) + } + #[doc = "Bit 8 - Acknowledge check enable for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_check_en(&mut self) -> ACK_CHECK_EN_W { + ACK_CHECK_EN_W::new(self, 8) + } + #[doc = "Bit 9 - Acknowledge expected for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_exp(&mut self) -> ACK_EXP_W { + ACK_EXP_W::new(self, 9) + } + #[doc = "Bit 10 - Acknowledge value for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_value(&mut self) -> ACK_VALUE_W { + ACK_VALUE_W::new(self, 10) + } + #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] #[inline(always)] #[must_use] - pub fn command(&mut self) -> COMMAND_W { - COMMAND_W::new(self, 0) + pub fn opcode(&mut self) -> OPCODE_W { + OPCODE_W::new(self, 11) } #[doc = "Bit 31 - When command0 is done in I2C Master mode this bit changes to high level."] #[inline(always)] diff --git a/esp32/svd/patches/esp32.yaml b/esp32/svd/patches/esp32.yaml index 96d1eb707f..c2f1764e2e 100644 --- a/esp32/svd/patches/esp32.yaml +++ b/esp32/svd/patches/esp32.yaml @@ -4,6 +4,8 @@ I2C0: _modify: INT_STATUS: name: INT_ST + _include: + - ../../../common_patches/i2c0.yaml RTC_I2C: _modify: diff --git a/esp32c2/src/i2c0/comd.rs b/esp32c2/src/i2c0/comd.rs index a041cb10fa..30756dfe6e 100644 --- a/esp32c2/src/i2c0/comd.rs +++ b/esp32c2/src/i2c0/comd.rs @@ -2,19 +2,55 @@ pub type R = crate::R; #[doc = "Register `COMD%s` writer"] pub type W = crate::W; -#[doc = "Field `COMMAND` reader - This is the content of command 0. It consists of three parts: op_code is the command, 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END. Byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more Information."] -pub type COMMAND_R = crate::FieldReader; -#[doc = "Field `COMMAND` writer - This is the content of command 0. It consists of three parts: op_code is the command, 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END. Byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more Information."] -pub type COMMAND_W<'a, REG> = crate::FieldWriter<'a, REG, 14, u16>; +#[doc = "Field `BYTE_NUM` reader - Number of bytes to be sent or received for command %s."] +pub type BYTE_NUM_R = crate::FieldReader; +#[doc = "Field `BYTE_NUM` writer - Number of bytes to be sent or received for command %s."] +pub type BYTE_NUM_W<'a, REG> = crate::FieldWriter<'a, REG, 8>; +#[doc = "Field `ACK_CHECK_EN` reader - Acknowledge check enable for command %s."] +pub type ACK_CHECK_EN_R = crate::BitReader; +#[doc = "Field `ACK_CHECK_EN` writer - Acknowledge check enable for command %s."] +pub type ACK_CHECK_EN_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `ACK_EXP` reader - Acknowledge expected for command %s."] +pub type ACK_EXP_R = crate::BitReader; +#[doc = "Field `ACK_EXP` writer - Acknowledge expected for command %s."] +pub type ACK_EXP_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `ACK_VALUE` reader - Acknowledge value for command %s."] +pub type ACK_VALUE_R = crate::BitReader; +#[doc = "Field `ACK_VALUE` writer - Acknowledge value for command %s."] +pub type ACK_VALUE_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `OPCODE` reader - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] +pub type OPCODE_R = crate::FieldReader; +#[doc = "Field `OPCODE` writer - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] +pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3>; #[doc = "Field `COMMAND_DONE` reader - When command 0 is done in I2C Master mode, this bit changes to high level."] pub type COMMAND_DONE_R = crate::BitReader; #[doc = "Field `COMMAND_DONE` writer - When command 0 is done in I2C Master mode, this bit changes to high level."] pub type COMMAND_DONE_W<'a, REG> = crate::BitWriter<'a, REG>; impl R { - #[doc = "Bits 0:13 - This is the content of command 0. It consists of three parts: op_code is the command, 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END. Byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more Information."] + #[doc = "Bits 0:7 - Number of bytes to be sent or received for command %s."] #[inline(always)] - pub fn command(&self) -> COMMAND_R { - COMMAND_R::new((self.bits & 0x3fff) as u16) + pub fn byte_num(&self) -> BYTE_NUM_R { + BYTE_NUM_R::new((self.bits & 0xff) as u8) + } + #[doc = "Bit 8 - Acknowledge check enable for command %s."] + #[inline(always)] + pub fn ack_check_en(&self) -> ACK_CHECK_EN_R { + ACK_CHECK_EN_R::new(((self.bits >> 8) & 1) != 0) + } + #[doc = "Bit 9 - Acknowledge expected for command %s."] + #[inline(always)] + pub fn ack_exp(&self) -> ACK_EXP_R { + ACK_EXP_R::new(((self.bits >> 9) & 1) != 0) + } + #[doc = "Bit 10 - Acknowledge value for command %s."] + #[inline(always)] + pub fn ack_value(&self) -> ACK_VALUE_R { + ACK_VALUE_R::new(((self.bits >> 10) & 1) != 0) + } + #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[inline(always)] + pub fn opcode(&self) -> OPCODE_R { + OPCODE_R::new(((self.bits >> 11) & 7) as u8) } #[doc = "Bit 31 - When command 0 is done in I2C Master mode, this bit changes to high level."] #[inline(always)] @@ -26,17 +62,45 @@ impl R { impl core::fmt::Debug for R { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("COMD") - .field("command", &self.command()) .field("command_done", &self.command_done()) + .field("opcode", &self.opcode()) + .field("ack_value", &self.ack_value()) + .field("ack_exp", &self.ack_exp()) + .field("ack_check_en", &self.ack_check_en()) + .field("byte_num", &self.byte_num()) .finish() } } impl W { - #[doc = "Bits 0:13 - This is the content of command 0. It consists of three parts: op_code is the command, 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END. Byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more Information."] + #[doc = "Bits 0:7 - Number of bytes to be sent or received for command %s."] + #[inline(always)] + #[must_use] + pub fn byte_num(&mut self) -> BYTE_NUM_W { + BYTE_NUM_W::new(self, 0) + } + #[doc = "Bit 8 - Acknowledge check enable for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_check_en(&mut self) -> ACK_CHECK_EN_W { + ACK_CHECK_EN_W::new(self, 8) + } + #[doc = "Bit 9 - Acknowledge expected for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_exp(&mut self) -> ACK_EXP_W { + ACK_EXP_W::new(self, 9) + } + #[doc = "Bit 10 - Acknowledge value for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_value(&mut self) -> ACK_VALUE_W { + ACK_VALUE_W::new(self, 10) + } + #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] #[inline(always)] #[must_use] - pub fn command(&mut self) -> COMMAND_W { - COMMAND_W::new(self, 0) + pub fn opcode(&mut self) -> OPCODE_W { + OPCODE_W::new(self, 11) } #[doc = "Bit 31 - When command 0 is done in I2C Master mode, this bit changes to high level."] #[inline(always)] diff --git a/esp32c2/svd/patches/esp32c2.yaml b/esp32c2/svd/patches/esp32c2.yaml index a752d8558f..abdf49fd9d 100644 --- a/esp32c2/svd/patches/esp32c2.yaml +++ b/esp32c2/svd/patches/esp32c2.yaml @@ -22,7 +22,9 @@ I2C0: _modify: INT_STATUS: name: INT_ST - + _include: + - ../../../common_patches/i2c0.yaml + RTC_CNTL: _include: ../../../common_patches/rtc_cntl_int_strip.yaml diff --git a/esp32c3/src/i2c0/comd.rs b/esp32c3/src/i2c0/comd.rs index ee15e62561..9e3fc62c82 100644 --- a/esp32c3/src/i2c0/comd.rs +++ b/esp32c3/src/i2c0/comd.rs @@ -2,19 +2,55 @@ pub type R = crate::R; #[doc = "Register `COMD%s` writer"] pub type W = crate::W; -#[doc = "Field `COMMAND` reader - reg_command"] -pub type COMMAND_R = crate::FieldReader; -#[doc = "Field `COMMAND` writer - reg_command"] -pub type COMMAND_W<'a, REG> = crate::FieldWriter<'a, REG, 14, u16>; +#[doc = "Field `BYTE_NUM` reader - Number of bytes to be sent or received for command %s."] +pub type BYTE_NUM_R = crate::FieldReader; +#[doc = "Field `BYTE_NUM` writer - Number of bytes to be sent or received for command %s."] +pub type BYTE_NUM_W<'a, REG> = crate::FieldWriter<'a, REG, 8>; +#[doc = "Field `ACK_CHECK_EN` reader - Acknowledge check enable for command %s."] +pub type ACK_CHECK_EN_R = crate::BitReader; +#[doc = "Field `ACK_CHECK_EN` writer - Acknowledge check enable for command %s."] +pub type ACK_CHECK_EN_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `ACK_EXP` reader - Acknowledge expected for command %s."] +pub type ACK_EXP_R = crate::BitReader; +#[doc = "Field `ACK_EXP` writer - Acknowledge expected for command %s."] +pub type ACK_EXP_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `ACK_VALUE` reader - Acknowledge value for command %s."] +pub type ACK_VALUE_R = crate::BitReader; +#[doc = "Field `ACK_VALUE` writer - Acknowledge value for command %s."] +pub type ACK_VALUE_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `OPCODE` reader - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] +pub type OPCODE_R = crate::FieldReader; +#[doc = "Field `OPCODE` writer - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] +pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3>; #[doc = "Field `COMMAND_DONE` reader - reg_command_done"] pub type COMMAND_DONE_R = crate::BitReader; #[doc = "Field `COMMAND_DONE` writer - reg_command_done"] pub type COMMAND_DONE_W<'a, REG> = crate::BitWriter<'a, REG>; impl R { - #[doc = "Bits 0:13 - reg_command"] + #[doc = "Bits 0:7 - Number of bytes to be sent or received for command %s."] #[inline(always)] - pub fn command(&self) -> COMMAND_R { - COMMAND_R::new((self.bits & 0x3fff) as u16) + pub fn byte_num(&self) -> BYTE_NUM_R { + BYTE_NUM_R::new((self.bits & 0xff) as u8) + } + #[doc = "Bit 8 - Acknowledge check enable for command %s."] + #[inline(always)] + pub fn ack_check_en(&self) -> ACK_CHECK_EN_R { + ACK_CHECK_EN_R::new(((self.bits >> 8) & 1) != 0) + } + #[doc = "Bit 9 - Acknowledge expected for command %s."] + #[inline(always)] + pub fn ack_exp(&self) -> ACK_EXP_R { + ACK_EXP_R::new(((self.bits >> 9) & 1) != 0) + } + #[doc = "Bit 10 - Acknowledge value for command %s."] + #[inline(always)] + pub fn ack_value(&self) -> ACK_VALUE_R { + ACK_VALUE_R::new(((self.bits >> 10) & 1) != 0) + } + #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[inline(always)] + pub fn opcode(&self) -> OPCODE_R { + OPCODE_R::new(((self.bits >> 11) & 7) as u8) } #[doc = "Bit 31 - reg_command_done"] #[inline(always)] @@ -26,17 +62,45 @@ impl R { impl core::fmt::Debug for R { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("COMD") - .field("command", &self.command()) .field("command_done", &self.command_done()) + .field("opcode", &self.opcode()) + .field("ack_value", &self.ack_value()) + .field("ack_exp", &self.ack_exp()) + .field("ack_check_en", &self.ack_check_en()) + .field("byte_num", &self.byte_num()) .finish() } } impl W { - #[doc = "Bits 0:13 - reg_command"] + #[doc = "Bits 0:7 - Number of bytes to be sent or received for command %s."] + #[inline(always)] + #[must_use] + pub fn byte_num(&mut self) -> BYTE_NUM_W { + BYTE_NUM_W::new(self, 0) + } + #[doc = "Bit 8 - Acknowledge check enable for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_check_en(&mut self) -> ACK_CHECK_EN_W { + ACK_CHECK_EN_W::new(self, 8) + } + #[doc = "Bit 9 - Acknowledge expected for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_exp(&mut self) -> ACK_EXP_W { + ACK_EXP_W::new(self, 9) + } + #[doc = "Bit 10 - Acknowledge value for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_value(&mut self) -> ACK_VALUE_W { + ACK_VALUE_W::new(self, 10) + } + #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] #[inline(always)] #[must_use] - pub fn command(&mut self) -> COMMAND_W { - COMMAND_W::new(self, 0) + pub fn opcode(&mut self) -> OPCODE_W { + OPCODE_W::new(self, 11) } #[doc = "Bit 31 - reg_command_done"] #[inline(always)] diff --git a/esp32c3/svd/patches/esp32c3.yaml b/esp32c3/svd/patches/esp32c3.yaml index 4e58dfe841..ec7a52fc98 100644 --- a/esp32c3/svd/patches/esp32c3.yaml +++ b/esp32c3/svd/patches/esp32c3.yaml @@ -16,6 +16,8 @@ I2C0: _modify: INT_STATUS: name: INT_ST + _include: + - ../../../common_patches/i2c0.yaml RTC_CNTL: _include: ../../../common_patches/rtc_cntl_int_strip.yaml diff --git a/esp32c6/src/i2c0/comd.rs b/esp32c6/src/i2c0/comd.rs index a041cb10fa..30756dfe6e 100644 --- a/esp32c6/src/i2c0/comd.rs +++ b/esp32c6/src/i2c0/comd.rs @@ -2,19 +2,55 @@ pub type R = crate::R; #[doc = "Register `COMD%s` writer"] pub type W = crate::W; -#[doc = "Field `COMMAND` reader - This is the content of command 0. It consists of three parts: op_code is the command, 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END. Byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more Information."] -pub type COMMAND_R = crate::FieldReader; -#[doc = "Field `COMMAND` writer - This is the content of command 0. It consists of three parts: op_code is the command, 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END. Byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more Information."] -pub type COMMAND_W<'a, REG> = crate::FieldWriter<'a, REG, 14, u16>; +#[doc = "Field `BYTE_NUM` reader - Number of bytes to be sent or received for command %s."] +pub type BYTE_NUM_R = crate::FieldReader; +#[doc = "Field `BYTE_NUM` writer - Number of bytes to be sent or received for command %s."] +pub type BYTE_NUM_W<'a, REG> = crate::FieldWriter<'a, REG, 8>; +#[doc = "Field `ACK_CHECK_EN` reader - Acknowledge check enable for command %s."] +pub type ACK_CHECK_EN_R = crate::BitReader; +#[doc = "Field `ACK_CHECK_EN` writer - Acknowledge check enable for command %s."] +pub type ACK_CHECK_EN_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `ACK_EXP` reader - Acknowledge expected for command %s."] +pub type ACK_EXP_R = crate::BitReader; +#[doc = "Field `ACK_EXP` writer - Acknowledge expected for command %s."] +pub type ACK_EXP_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `ACK_VALUE` reader - Acknowledge value for command %s."] +pub type ACK_VALUE_R = crate::BitReader; +#[doc = "Field `ACK_VALUE` writer - Acknowledge value for command %s."] +pub type ACK_VALUE_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `OPCODE` reader - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] +pub type OPCODE_R = crate::FieldReader; +#[doc = "Field `OPCODE` writer - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] +pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3>; #[doc = "Field `COMMAND_DONE` reader - When command 0 is done in I2C Master mode, this bit changes to high level."] pub type COMMAND_DONE_R = crate::BitReader; #[doc = "Field `COMMAND_DONE` writer - When command 0 is done in I2C Master mode, this bit changes to high level."] pub type COMMAND_DONE_W<'a, REG> = crate::BitWriter<'a, REG>; impl R { - #[doc = "Bits 0:13 - This is the content of command 0. It consists of three parts: op_code is the command, 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END. Byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more Information."] + #[doc = "Bits 0:7 - Number of bytes to be sent or received for command %s."] #[inline(always)] - pub fn command(&self) -> COMMAND_R { - COMMAND_R::new((self.bits & 0x3fff) as u16) + pub fn byte_num(&self) -> BYTE_NUM_R { + BYTE_NUM_R::new((self.bits & 0xff) as u8) + } + #[doc = "Bit 8 - Acknowledge check enable for command %s."] + #[inline(always)] + pub fn ack_check_en(&self) -> ACK_CHECK_EN_R { + ACK_CHECK_EN_R::new(((self.bits >> 8) & 1) != 0) + } + #[doc = "Bit 9 - Acknowledge expected for command %s."] + #[inline(always)] + pub fn ack_exp(&self) -> ACK_EXP_R { + ACK_EXP_R::new(((self.bits >> 9) & 1) != 0) + } + #[doc = "Bit 10 - Acknowledge value for command %s."] + #[inline(always)] + pub fn ack_value(&self) -> ACK_VALUE_R { + ACK_VALUE_R::new(((self.bits >> 10) & 1) != 0) + } + #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[inline(always)] + pub fn opcode(&self) -> OPCODE_R { + OPCODE_R::new(((self.bits >> 11) & 7) as u8) } #[doc = "Bit 31 - When command 0 is done in I2C Master mode, this bit changes to high level."] #[inline(always)] @@ -26,17 +62,45 @@ impl R { impl core::fmt::Debug for R { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("COMD") - .field("command", &self.command()) .field("command_done", &self.command_done()) + .field("opcode", &self.opcode()) + .field("ack_value", &self.ack_value()) + .field("ack_exp", &self.ack_exp()) + .field("ack_check_en", &self.ack_check_en()) + .field("byte_num", &self.byte_num()) .finish() } } impl W { - #[doc = "Bits 0:13 - This is the content of command 0. It consists of three parts: op_code is the command, 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END. Byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more Information."] + #[doc = "Bits 0:7 - Number of bytes to be sent or received for command %s."] + #[inline(always)] + #[must_use] + pub fn byte_num(&mut self) -> BYTE_NUM_W { + BYTE_NUM_W::new(self, 0) + } + #[doc = "Bit 8 - Acknowledge check enable for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_check_en(&mut self) -> ACK_CHECK_EN_W { + ACK_CHECK_EN_W::new(self, 8) + } + #[doc = "Bit 9 - Acknowledge expected for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_exp(&mut self) -> ACK_EXP_W { + ACK_EXP_W::new(self, 9) + } + #[doc = "Bit 10 - Acknowledge value for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_value(&mut self) -> ACK_VALUE_W { + ACK_VALUE_W::new(self, 10) + } + #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] #[inline(always)] #[must_use] - pub fn command(&mut self) -> COMMAND_W { - COMMAND_W::new(self, 0) + pub fn opcode(&mut self) -> OPCODE_W { + OPCODE_W::new(self, 11) } #[doc = "Bit 31 - When command 0 is done in I2C Master mode, this bit changes to high level."] #[inline(always)] diff --git a/esp32c6/svd/patches/esp32c6.yaml b/esp32c6/svd/patches/esp32c6.yaml index c9c70754b0..61589ff477 100644 --- a/esp32c6/svd/patches/esp32c6.yaml +++ b/esp32c6/svd/patches/esp32c6.yaml @@ -23,6 +23,8 @@ I2C0: _modify: INT_STATUS: name: INT_ST + _include: + - ../../../common_patches/i2c0.yaml GPIO: _modify: diff --git a/esp32h2/src/i2c0/comd.rs b/esp32h2/src/i2c0/comd.rs index a041cb10fa..30756dfe6e 100644 --- a/esp32h2/src/i2c0/comd.rs +++ b/esp32h2/src/i2c0/comd.rs @@ -2,19 +2,55 @@ pub type R = crate::R; #[doc = "Register `COMD%s` writer"] pub type W = crate::W; -#[doc = "Field `COMMAND` reader - This is the content of command 0. It consists of three parts: op_code is the command, 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END. Byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more Information."] -pub type COMMAND_R = crate::FieldReader; -#[doc = "Field `COMMAND` writer - This is the content of command 0. It consists of three parts: op_code is the command, 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END. Byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more Information."] -pub type COMMAND_W<'a, REG> = crate::FieldWriter<'a, REG, 14, u16>; +#[doc = "Field `BYTE_NUM` reader - Number of bytes to be sent or received for command %s."] +pub type BYTE_NUM_R = crate::FieldReader; +#[doc = "Field `BYTE_NUM` writer - Number of bytes to be sent or received for command %s."] +pub type BYTE_NUM_W<'a, REG> = crate::FieldWriter<'a, REG, 8>; +#[doc = "Field `ACK_CHECK_EN` reader - Acknowledge check enable for command %s."] +pub type ACK_CHECK_EN_R = crate::BitReader; +#[doc = "Field `ACK_CHECK_EN` writer - Acknowledge check enable for command %s."] +pub type ACK_CHECK_EN_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `ACK_EXP` reader - Acknowledge expected for command %s."] +pub type ACK_EXP_R = crate::BitReader; +#[doc = "Field `ACK_EXP` writer - Acknowledge expected for command %s."] +pub type ACK_EXP_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `ACK_VALUE` reader - Acknowledge value for command %s."] +pub type ACK_VALUE_R = crate::BitReader; +#[doc = "Field `ACK_VALUE` writer - Acknowledge value for command %s."] +pub type ACK_VALUE_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `OPCODE` reader - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] +pub type OPCODE_R = crate::FieldReader; +#[doc = "Field `OPCODE` writer - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] +pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3>; #[doc = "Field `COMMAND_DONE` reader - When command 0 is done in I2C Master mode, this bit changes to high level."] pub type COMMAND_DONE_R = crate::BitReader; #[doc = "Field `COMMAND_DONE` writer - When command 0 is done in I2C Master mode, this bit changes to high level."] pub type COMMAND_DONE_W<'a, REG> = crate::BitWriter<'a, REG>; impl R { - #[doc = "Bits 0:13 - This is the content of command 0. It consists of three parts: op_code is the command, 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END. Byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more Information."] + #[doc = "Bits 0:7 - Number of bytes to be sent or received for command %s."] #[inline(always)] - pub fn command(&self) -> COMMAND_R { - COMMAND_R::new((self.bits & 0x3fff) as u16) + pub fn byte_num(&self) -> BYTE_NUM_R { + BYTE_NUM_R::new((self.bits & 0xff) as u8) + } + #[doc = "Bit 8 - Acknowledge check enable for command %s."] + #[inline(always)] + pub fn ack_check_en(&self) -> ACK_CHECK_EN_R { + ACK_CHECK_EN_R::new(((self.bits >> 8) & 1) != 0) + } + #[doc = "Bit 9 - Acknowledge expected for command %s."] + #[inline(always)] + pub fn ack_exp(&self) -> ACK_EXP_R { + ACK_EXP_R::new(((self.bits >> 9) & 1) != 0) + } + #[doc = "Bit 10 - Acknowledge value for command %s."] + #[inline(always)] + pub fn ack_value(&self) -> ACK_VALUE_R { + ACK_VALUE_R::new(((self.bits >> 10) & 1) != 0) + } + #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[inline(always)] + pub fn opcode(&self) -> OPCODE_R { + OPCODE_R::new(((self.bits >> 11) & 7) as u8) } #[doc = "Bit 31 - When command 0 is done in I2C Master mode, this bit changes to high level."] #[inline(always)] @@ -26,17 +62,45 @@ impl R { impl core::fmt::Debug for R { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("COMD") - .field("command", &self.command()) .field("command_done", &self.command_done()) + .field("opcode", &self.opcode()) + .field("ack_value", &self.ack_value()) + .field("ack_exp", &self.ack_exp()) + .field("ack_check_en", &self.ack_check_en()) + .field("byte_num", &self.byte_num()) .finish() } } impl W { - #[doc = "Bits 0:13 - This is the content of command 0. It consists of three parts: op_code is the command, 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END. Byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more Information."] + #[doc = "Bits 0:7 - Number of bytes to be sent or received for command %s."] + #[inline(always)] + #[must_use] + pub fn byte_num(&mut self) -> BYTE_NUM_W { + BYTE_NUM_W::new(self, 0) + } + #[doc = "Bit 8 - Acknowledge check enable for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_check_en(&mut self) -> ACK_CHECK_EN_W { + ACK_CHECK_EN_W::new(self, 8) + } + #[doc = "Bit 9 - Acknowledge expected for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_exp(&mut self) -> ACK_EXP_W { + ACK_EXP_W::new(self, 9) + } + #[doc = "Bit 10 - Acknowledge value for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_value(&mut self) -> ACK_VALUE_W { + ACK_VALUE_W::new(self, 10) + } + #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] #[inline(always)] #[must_use] - pub fn command(&mut self) -> COMMAND_W { - COMMAND_W::new(self, 0) + pub fn opcode(&mut self) -> OPCODE_W { + OPCODE_W::new(self, 11) } #[doc = "Bit 31 - When command 0 is done in I2C Master mode, this bit changes to high level."] #[inline(always)] diff --git a/esp32h2/svd/patches/esp32h2.yaml b/esp32h2/svd/patches/esp32h2.yaml index 104e0e64ac..770d18ed79 100644 --- a/esp32h2/svd/patches/esp32h2.yaml +++ b/esp32h2/svd/patches/esp32h2.yaml @@ -23,6 +23,8 @@ I2C0: _modify: INT_STATUS: name: INT_ST + _include: + - ../../../common_patches/i2c0.yaml HP_APM,LP_APM: _include: ../../../common_patches/hp_apm.yaml diff --git a/esp32p4/src/i2c0/comd.rs b/esp32p4/src/i2c0/comd.rs index de40c30d99..643b4a9117 100644 --- a/esp32p4/src/i2c0/comd.rs +++ b/esp32p4/src/i2c0/comd.rs @@ -2,19 +2,55 @@ pub type R = crate::R; #[doc = "Register `COMD%s` writer"] pub type W = crate::W; -#[doc = "Field `COMMAND` reader - Configures command 0. It consists of three parts: op_code is the command, 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END. Byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more information."] -pub type COMMAND_R = crate::FieldReader; -#[doc = "Field `COMMAND` writer - Configures command 0. It consists of three parts: op_code is the command, 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END. Byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more information."] -pub type COMMAND_W<'a, REG> = crate::FieldWriter<'a, REG, 14, u16>; +#[doc = "Field `BYTE_NUM` reader - Number of bytes to be sent or received for command %s."] +pub type BYTE_NUM_R = crate::FieldReader; +#[doc = "Field `BYTE_NUM` writer - Number of bytes to be sent or received for command %s."] +pub type BYTE_NUM_W<'a, REG> = crate::FieldWriter<'a, REG, 8>; +#[doc = "Field `ACK_CHECK_EN` reader - Acknowledge check enable for command %s."] +pub type ACK_CHECK_EN_R = crate::BitReader; +#[doc = "Field `ACK_CHECK_EN` writer - Acknowledge check enable for command %s."] +pub type ACK_CHECK_EN_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `ACK_EXP` reader - Acknowledge expected for command %s."] +pub type ACK_EXP_R = crate::BitReader; +#[doc = "Field `ACK_EXP` writer - Acknowledge expected for command %s."] +pub type ACK_EXP_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `ACK_VALUE` reader - Acknowledge value for command %s."] +pub type ACK_VALUE_R = crate::BitReader; +#[doc = "Field `ACK_VALUE` writer - Acknowledge value for command %s."] +pub type ACK_VALUE_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `OPCODE` reader - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] +pub type OPCODE_R = crate::FieldReader; +#[doc = "Field `OPCODE` writer - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] +pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3>; #[doc = "Field `COMMAND_DONE` reader - Represents whether command 0 is done in I2C Master mode. 0: Not done 1: Done"] pub type COMMAND_DONE_R = crate::BitReader; #[doc = "Field `COMMAND_DONE` writer - Represents whether command 0 is done in I2C Master mode. 0: Not done 1: Done"] pub type COMMAND_DONE_W<'a, REG> = crate::BitWriter<'a, REG>; impl R { - #[doc = "Bits 0:13 - Configures command 0. It consists of three parts: op_code is the command, 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END. Byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more information."] + #[doc = "Bits 0:7 - Number of bytes to be sent or received for command %s."] #[inline(always)] - pub fn command(&self) -> COMMAND_R { - COMMAND_R::new((self.bits & 0x3fff) as u16) + pub fn byte_num(&self) -> BYTE_NUM_R { + BYTE_NUM_R::new((self.bits & 0xff) as u8) + } + #[doc = "Bit 8 - Acknowledge check enable for command %s."] + #[inline(always)] + pub fn ack_check_en(&self) -> ACK_CHECK_EN_R { + ACK_CHECK_EN_R::new(((self.bits >> 8) & 1) != 0) + } + #[doc = "Bit 9 - Acknowledge expected for command %s."] + #[inline(always)] + pub fn ack_exp(&self) -> ACK_EXP_R { + ACK_EXP_R::new(((self.bits >> 9) & 1) != 0) + } + #[doc = "Bit 10 - Acknowledge value for command %s."] + #[inline(always)] + pub fn ack_value(&self) -> ACK_VALUE_R { + ACK_VALUE_R::new(((self.bits >> 10) & 1) != 0) + } + #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[inline(always)] + pub fn opcode(&self) -> OPCODE_R { + OPCODE_R::new(((self.bits >> 11) & 7) as u8) } #[doc = "Bit 31 - Represents whether command 0 is done in I2C Master mode. 0: Not done 1: Done"] #[inline(always)] @@ -26,17 +62,45 @@ impl R { impl core::fmt::Debug for R { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("COMD") - .field("command", &self.command()) .field("command_done", &self.command_done()) + .field("opcode", &self.opcode()) + .field("ack_value", &self.ack_value()) + .field("ack_exp", &self.ack_exp()) + .field("ack_check_en", &self.ack_check_en()) + .field("byte_num", &self.byte_num()) .finish() } } impl W { - #[doc = "Bits 0:13 - Configures command 0. It consists of three parts: op_code is the command, 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END. Byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more information."] + #[doc = "Bits 0:7 - Number of bytes to be sent or received for command %s."] + #[inline(always)] + #[must_use] + pub fn byte_num(&mut self) -> BYTE_NUM_W { + BYTE_NUM_W::new(self, 0) + } + #[doc = "Bit 8 - Acknowledge check enable for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_check_en(&mut self) -> ACK_CHECK_EN_W { + ACK_CHECK_EN_W::new(self, 8) + } + #[doc = "Bit 9 - Acknowledge expected for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_exp(&mut self) -> ACK_EXP_W { + ACK_EXP_W::new(self, 9) + } + #[doc = "Bit 10 - Acknowledge value for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_value(&mut self) -> ACK_VALUE_W { + ACK_VALUE_W::new(self, 10) + } + #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] #[inline(always)] #[must_use] - pub fn command(&mut self) -> COMMAND_W { - COMMAND_W::new(self, 0) + pub fn opcode(&mut self) -> OPCODE_W { + OPCODE_W::new(self, 11) } #[doc = "Bit 31 - Represents whether command 0 is done in I2C Master mode. 0: Not done 1: Done"] #[inline(always)] diff --git a/esp32p4/svd/patches/esp32p4.yaml b/esp32p4/svd/patches/esp32p4.yaml index b680c8e478..aaf69408b2 100644 --- a/esp32p4/svd/patches/esp32p4.yaml +++ b/esp32p4/svd/patches/esp32p4.yaml @@ -47,6 +47,10 @@ LP_ANA: COMD?: {} _include: ../../../common_patches/int_strip.yaml +I2C0: + _include: + - ../../../common_patches/i2c0.yaml + SPI[01]: _strip: SPI_MEM_ "*": diff --git a/esp32s2/src/i2c0/comd.rs b/esp32s2/src/i2c0/comd.rs index c0713d4087..30756dfe6e 100644 --- a/esp32s2/src/i2c0/comd.rs +++ b/esp32s2/src/i2c0/comd.rs @@ -2,19 +2,55 @@ pub type R = crate::R; #[doc = "Register `COMD%s` writer"] pub type W = crate::W; -#[doc = "Field `COMMAND` reader - This is the content of command 0. It consists of three parts: op_code is the command, 0: RSTART. 1: WRITE. 2: READ. 3: STOP. 4: END. byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more information."] -pub type COMMAND_R = crate::FieldReader; -#[doc = "Field `COMMAND` writer - This is the content of command 0. It consists of three parts: op_code is the command, 0: RSTART. 1: WRITE. 2: READ. 3: STOP. 4: END. byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more information."] -pub type COMMAND_W<'a, REG> = crate::FieldWriter<'a, REG, 14, u16>; +#[doc = "Field `BYTE_NUM` reader - Number of bytes to be sent or received for command %s."] +pub type BYTE_NUM_R = crate::FieldReader; +#[doc = "Field `BYTE_NUM` writer - Number of bytes to be sent or received for command %s."] +pub type BYTE_NUM_W<'a, REG> = crate::FieldWriter<'a, REG, 8>; +#[doc = "Field `ACK_CHECK_EN` reader - Acknowledge check enable for command %s."] +pub type ACK_CHECK_EN_R = crate::BitReader; +#[doc = "Field `ACK_CHECK_EN` writer - Acknowledge check enable for command %s."] +pub type ACK_CHECK_EN_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `ACK_EXP` reader - Acknowledge expected for command %s."] +pub type ACK_EXP_R = crate::BitReader; +#[doc = "Field `ACK_EXP` writer - Acknowledge expected for command %s."] +pub type ACK_EXP_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `ACK_VALUE` reader - Acknowledge value for command %s."] +pub type ACK_VALUE_R = crate::BitReader; +#[doc = "Field `ACK_VALUE` writer - Acknowledge value for command %s."] +pub type ACK_VALUE_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `OPCODE` reader - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] +pub type OPCODE_R = crate::FieldReader; +#[doc = "Field `OPCODE` writer - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] +pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3>; #[doc = "Field `COMMAND_DONE` reader - When command 0 is done in I2C Master mode, this bit changes to high level."] pub type COMMAND_DONE_R = crate::BitReader; #[doc = "Field `COMMAND_DONE` writer - When command 0 is done in I2C Master mode, this bit changes to high level."] pub type COMMAND_DONE_W<'a, REG> = crate::BitWriter<'a, REG>; impl R { - #[doc = "Bits 0:13 - This is the content of command 0. It consists of three parts: op_code is the command, 0: RSTART. 1: WRITE. 2: READ. 3: STOP. 4: END. byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more information."] + #[doc = "Bits 0:7 - Number of bytes to be sent or received for command %s."] #[inline(always)] - pub fn command(&self) -> COMMAND_R { - COMMAND_R::new((self.bits & 0x3fff) as u16) + pub fn byte_num(&self) -> BYTE_NUM_R { + BYTE_NUM_R::new((self.bits & 0xff) as u8) + } + #[doc = "Bit 8 - Acknowledge check enable for command %s."] + #[inline(always)] + pub fn ack_check_en(&self) -> ACK_CHECK_EN_R { + ACK_CHECK_EN_R::new(((self.bits >> 8) & 1) != 0) + } + #[doc = "Bit 9 - Acknowledge expected for command %s."] + #[inline(always)] + pub fn ack_exp(&self) -> ACK_EXP_R { + ACK_EXP_R::new(((self.bits >> 9) & 1) != 0) + } + #[doc = "Bit 10 - Acknowledge value for command %s."] + #[inline(always)] + pub fn ack_value(&self) -> ACK_VALUE_R { + ACK_VALUE_R::new(((self.bits >> 10) & 1) != 0) + } + #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[inline(always)] + pub fn opcode(&self) -> OPCODE_R { + OPCODE_R::new(((self.bits >> 11) & 7) as u8) } #[doc = "Bit 31 - When command 0 is done in I2C Master mode, this bit changes to high level."] #[inline(always)] @@ -26,17 +62,45 @@ impl R { impl core::fmt::Debug for R { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("COMD") - .field("command", &self.command()) .field("command_done", &self.command_done()) + .field("opcode", &self.opcode()) + .field("ack_value", &self.ack_value()) + .field("ack_exp", &self.ack_exp()) + .field("ack_check_en", &self.ack_check_en()) + .field("byte_num", &self.byte_num()) .finish() } } impl W { - #[doc = "Bits 0:13 - This is the content of command 0. It consists of three parts: op_code is the command, 0: RSTART. 1: WRITE. 2: READ. 3: STOP. 4: END. byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more information."] + #[doc = "Bits 0:7 - Number of bytes to be sent or received for command %s."] + #[inline(always)] + #[must_use] + pub fn byte_num(&mut self) -> BYTE_NUM_W { + BYTE_NUM_W::new(self, 0) + } + #[doc = "Bit 8 - Acknowledge check enable for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_check_en(&mut self) -> ACK_CHECK_EN_W { + ACK_CHECK_EN_W::new(self, 8) + } + #[doc = "Bit 9 - Acknowledge expected for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_exp(&mut self) -> ACK_EXP_W { + ACK_EXP_W::new(self, 9) + } + #[doc = "Bit 10 - Acknowledge value for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_value(&mut self) -> ACK_VALUE_W { + ACK_VALUE_W::new(self, 10) + } + #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] #[inline(always)] #[must_use] - pub fn command(&mut self) -> COMMAND_W { - COMMAND_W::new(self, 0) + pub fn opcode(&mut self) -> OPCODE_W { + OPCODE_W::new(self, 11) } #[doc = "Bit 31 - When command 0 is done in I2C Master mode, this bit changes to high level."] #[inline(always)] diff --git a/esp32s2/svd/patches/esp32s2.yaml b/esp32s2/svd/patches/esp32s2.yaml index 2b4b2e080a..2a9528e6e9 100644 --- a/esp32s2/svd/patches/esp32s2.yaml +++ b/esp32s2/svd/patches/esp32s2.yaml @@ -68,6 +68,8 @@ I2C0: _modify: INT_STATUS: name: INT_ST + _include: + - ../../../common_patches/i2c0.yaml RTC_CNTL: _modify: diff --git a/esp32s3/src/i2c0/comd.rs b/esp32s3/src/i2c0/comd.rs index c706c2b8e1..30756dfe6e 100644 --- a/esp32s3/src/i2c0/comd.rs +++ b/esp32s3/src/i2c0/comd.rs @@ -2,19 +2,55 @@ pub type R = crate::R; #[doc = "Register `COMD%s` writer"] pub type W = crate::W; -#[doc = "Field `COMMAND` reader - This is the content of command 0. It consists of three parts: op_code is the command, 0: RSTART; 1: WRITE; 2: READ; 3: STOP; 4: END. Byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more Information."] -pub type COMMAND_R = crate::FieldReader; -#[doc = "Field `COMMAND` writer - This is the content of command 0. It consists of three parts: op_code is the command, 0: RSTART; 1: WRITE; 2: READ; 3: STOP; 4: END. Byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more Information."] -pub type COMMAND_W<'a, REG> = crate::FieldWriter<'a, REG, 14, u16>; +#[doc = "Field `BYTE_NUM` reader - Number of bytes to be sent or received for command %s."] +pub type BYTE_NUM_R = crate::FieldReader; +#[doc = "Field `BYTE_NUM` writer - Number of bytes to be sent or received for command %s."] +pub type BYTE_NUM_W<'a, REG> = crate::FieldWriter<'a, REG, 8>; +#[doc = "Field `ACK_CHECK_EN` reader - Acknowledge check enable for command %s."] +pub type ACK_CHECK_EN_R = crate::BitReader; +#[doc = "Field `ACK_CHECK_EN` writer - Acknowledge check enable for command %s."] +pub type ACK_CHECK_EN_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `ACK_EXP` reader - Acknowledge expected for command %s."] +pub type ACK_EXP_R = crate::BitReader; +#[doc = "Field `ACK_EXP` writer - Acknowledge expected for command %s."] +pub type ACK_EXP_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `ACK_VALUE` reader - Acknowledge value for command %s."] +pub type ACK_VALUE_R = crate::BitReader; +#[doc = "Field `ACK_VALUE` writer - Acknowledge value for command %s."] +pub type ACK_VALUE_W<'a, REG> = crate::BitWriter<'a, REG>; +#[doc = "Field `OPCODE` reader - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] +pub type OPCODE_R = crate::FieldReader; +#[doc = "Field `OPCODE` writer - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] +pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3>; #[doc = "Field `COMMAND_DONE` reader - When command 0 is done in I2C Master mode, this bit changes to high level."] pub type COMMAND_DONE_R = crate::BitReader; #[doc = "Field `COMMAND_DONE` writer - When command 0 is done in I2C Master mode, this bit changes to high level."] pub type COMMAND_DONE_W<'a, REG> = crate::BitWriter<'a, REG>; impl R { - #[doc = "Bits 0:13 - This is the content of command 0. It consists of three parts: op_code is the command, 0: RSTART; 1: WRITE; 2: READ; 3: STOP; 4: END. Byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more Information."] + #[doc = "Bits 0:7 - Number of bytes to be sent or received for command %s."] #[inline(always)] - pub fn command(&self) -> COMMAND_R { - COMMAND_R::new((self.bits & 0x3fff) as u16) + pub fn byte_num(&self) -> BYTE_NUM_R { + BYTE_NUM_R::new((self.bits & 0xff) as u8) + } + #[doc = "Bit 8 - Acknowledge check enable for command %s."] + #[inline(always)] + pub fn ack_check_en(&self) -> ACK_CHECK_EN_R { + ACK_CHECK_EN_R::new(((self.bits >> 8) & 1) != 0) + } + #[doc = "Bit 9 - Acknowledge expected for command %s."] + #[inline(always)] + pub fn ack_exp(&self) -> ACK_EXP_R { + ACK_EXP_R::new(((self.bits >> 9) & 1) != 0) + } + #[doc = "Bit 10 - Acknowledge value for command %s."] + #[inline(always)] + pub fn ack_value(&self) -> ACK_VALUE_R { + ACK_VALUE_R::new(((self.bits >> 10) & 1) != 0) + } + #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[inline(always)] + pub fn opcode(&self) -> OPCODE_R { + OPCODE_R::new(((self.bits >> 11) & 7) as u8) } #[doc = "Bit 31 - When command 0 is done in I2C Master mode, this bit changes to high level."] #[inline(always)] @@ -26,17 +62,45 @@ impl R { impl core::fmt::Debug for R { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("COMD") - .field("command", &self.command()) .field("command_done", &self.command_done()) + .field("opcode", &self.opcode()) + .field("ack_value", &self.ack_value()) + .field("ack_exp", &self.ack_exp()) + .field("ack_check_en", &self.ack_check_en()) + .field("byte_num", &self.byte_num()) .finish() } } impl W { - #[doc = "Bits 0:13 - This is the content of command 0. It consists of three parts: op_code is the command, 0: RSTART; 1: WRITE; 2: READ; 3: STOP; 4: END. Byte_num represents the number of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the ACK bit. See I2C cmd structure for more Information."] + #[doc = "Bits 0:7 - Number of bytes to be sent or received for command %s."] + #[inline(always)] + #[must_use] + pub fn byte_num(&mut self) -> BYTE_NUM_W { + BYTE_NUM_W::new(self, 0) + } + #[doc = "Bit 8 - Acknowledge check enable for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_check_en(&mut self) -> ACK_CHECK_EN_W { + ACK_CHECK_EN_W::new(self, 8) + } + #[doc = "Bit 9 - Acknowledge expected for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_exp(&mut self) -> ACK_EXP_W { + ACK_EXP_W::new(self, 9) + } + #[doc = "Bit 10 - Acknowledge value for command %s."] + #[inline(always)] + #[must_use] + pub fn ack_value(&mut self) -> ACK_VALUE_W { + ACK_VALUE_W::new(self, 10) + } + #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] #[inline(always)] #[must_use] - pub fn command(&mut self) -> COMMAND_W { - COMMAND_W::new(self, 0) + pub fn opcode(&mut self) -> OPCODE_W { + OPCODE_W::new(self, 11) } #[doc = "Bit 31 - When command 0 is done in I2C Master mode, this bit changes to high level."] #[inline(always)] diff --git a/esp32s3/svd/patches/esp32s3.yaml b/esp32s3/svd/patches/esp32s3.yaml index 9a3178d890..7c9d43dcbe 100644 --- a/esp32s3/svd/patches/esp32s3.yaml +++ b/esp32s3/svd/patches/esp32s3.yaml @@ -32,7 +32,9 @@ I2C0: _modify: INT_STATUS: name: INT_ST - _include: ../../../common_patches/int_strip.yaml + _include: + - ../../../common_patches/int_strip.yaml + - ../../../common_patches/i2c0.yaml RTC_I2C: CMD*: From a89ce85aae79a1537a2902cb57161f7f1fdd4598 Mon Sep 17 00:00:00 2001 From: Kirill Mikhailov Date: Wed, 17 Jul 2024 12:59:05 +0200 Subject: [PATCH 2/2] Addressing reviews --- common_patches/i2c0.yaml | 61 ++++++++++++---------- esp32/src/i2c0/comd.rs | 108 ++++++++++++++++++++++++++++++++++++--- esp32c2/src/i2c0/comd.rs | 108 ++++++++++++++++++++++++++++++++++++--- esp32c3/src/i2c0/comd.rs | 108 ++++++++++++++++++++++++++++++++++++--- esp32c6/src/i2c0/comd.rs | 108 ++++++++++++++++++++++++++++++++++++--- esp32h2/src/i2c0/comd.rs | 108 ++++++++++++++++++++++++++++++++++++--- esp32p4/src/i2c0/comd.rs | 108 ++++++++++++++++++++++++++++++++++++--- esp32s2/src/i2c0/comd.rs | 108 ++++++++++++++++++++++++++++++++++++--- esp32s3/src/i2c0/comd.rs | 108 ++++++++++++++++++++++++++++++++++++--- 9 files changed, 850 insertions(+), 75 deletions(-) diff --git a/common_patches/i2c0.yaml b/common_patches/i2c0.yaml index c932f0b9b5..783805d302 100644 --- a/common_patches/i2c0.yaml +++ b/common_patches/i2c0.yaml @@ -1,28 +1,35 @@ COMD%s: - _delete: ["COMMAND"] - _add: - OPCODE: - description: "Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END." - bitOffset: 11 - bitWidth: 3 - access: read-write - ACK_VALUE: - description: "Acknowledge value for command %s." - bitOffset: 10 - bitWidth: 1 - access: read-write - ACK_EXP: - description: "Acknowledge expected for command %s." - bitOffset: 9 - bitWidth: 1 - access: read-write - ACK_CHECK_EN: - description: "Acknowledge check enable for command %s." - bitOffset: 8 - bitWidth: 1 - access: read-write - BYTE_NUM: - description: "Number of bytes to be sent or received for command %s." - bitOffset: 0 - bitWidth: 8 - access: read-write \ No newline at end of file + _delete: ["COMMAND"] + _add: + OPCODE: + description: "Opcode part of command %s." + bitOffset: 11 + bitWidth: 3 + access: read-write + ACK_VALUE: + description: "Acknowledge value for command %s." + bitOffset: 10 + bitWidth: 1 + access: read-write + ACK_EXP: + description: "Acknowledge expected for command %s." + bitOffset: 9 + bitWidth: 1 + access: read-write + ACK_CHECK_EN: + description: "Acknowledge check enable for command %s." + bitOffset: 8 + bitWidth: 1 + access: read-write + BYTE_NUM: + description: "Number of bytes to be sent or received for command %s." + bitOffset: 0 + bitWidth: 8 + access: read-write + OPCODE: + _name: Opcode + Rstart: [0, RSTART opcode] + Write: [1, WRITE opcode] + Read: [2, READ opcode] + Stop: [3, STOP opcode] + End: [4, END opcode] \ No newline at end of file diff --git a/esp32/src/i2c0/comd.rs b/esp32/src/i2c0/comd.rs index 703ba5a014..34e71d2194 100644 --- a/esp32/src/i2c0/comd.rs +++ b/esp32/src/i2c0/comd.rs @@ -18,10 +18,106 @@ pub type ACK_EXP_W<'a, REG> = crate::BitWriter<'a, REG>; pub type ACK_VALUE_R = crate::BitReader; #[doc = "Field `ACK_VALUE` writer - Acknowledge value for command %s."] pub type ACK_VALUE_W<'a, REG> = crate::BitWriter<'a, REG>; -#[doc = "Field `OPCODE` reader - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] -pub type OPCODE_R = crate::FieldReader; -#[doc = "Field `OPCODE` writer - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] -pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3>; +#[doc = "Opcode part of command %s.\n\nValue on reset: 0"] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[repr(u8)] +pub enum OPCODE { + #[doc = "0: RSTART opcode"] + Rstart = 0, + #[doc = "1: WRITE opcode"] + Write = 1, + #[doc = "2: READ opcode"] + Read = 2, + #[doc = "3: STOP opcode"] + Stop = 3, + #[doc = "4: END opcode"] + End = 4, +} +impl From for u8 { + #[inline(always)] + fn from(variant: OPCODE) -> Self { + variant as _ + } +} +impl crate::FieldSpec for OPCODE { + type Ux = u8; +} +impl crate::IsEnum for OPCODE {} +#[doc = "Field `OPCODE` reader - Opcode part of command %s."] +pub type OPCODE_R = crate::FieldReader; +impl OPCODE_R { + #[doc = "Get enumerated values variant"] + #[inline(always)] + pub const fn variant(&self) -> Option { + match self.bits { + 0 => Some(OPCODE::Rstart), + 1 => Some(OPCODE::Write), + 2 => Some(OPCODE::Read), + 3 => Some(OPCODE::Stop), + 4 => Some(OPCODE::End), + _ => None, + } + } + #[doc = "RSTART opcode"] + #[inline(always)] + pub fn is_rstart(&self) -> bool { + *self == OPCODE::Rstart + } + #[doc = "WRITE opcode"] + #[inline(always)] + pub fn is_write(&self) -> bool { + *self == OPCODE::Write + } + #[doc = "READ opcode"] + #[inline(always)] + pub fn is_read(&self) -> bool { + *self == OPCODE::Read + } + #[doc = "STOP opcode"] + #[inline(always)] + pub fn is_stop(&self) -> bool { + *self == OPCODE::Stop + } + #[doc = "END opcode"] + #[inline(always)] + pub fn is_end(&self) -> bool { + *self == OPCODE::End + } +} +#[doc = "Field `OPCODE` writer - Opcode part of command %s."] +pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3, OPCODE>; +impl<'a, REG> OPCODE_W<'a, REG> +where + REG: crate::Writable + crate::RegisterSpec, + REG::Ux: From, +{ + #[doc = "RSTART opcode"] + #[inline(always)] + pub fn rstart(self) -> &'a mut crate::W { + self.variant(OPCODE::Rstart) + } + #[doc = "WRITE opcode"] + #[inline(always)] + pub fn write(self) -> &'a mut crate::W { + self.variant(OPCODE::Write) + } + #[doc = "READ opcode"] + #[inline(always)] + pub fn read(self) -> &'a mut crate::W { + self.variant(OPCODE::Read) + } + #[doc = "STOP opcode"] + #[inline(always)] + pub fn stop(self) -> &'a mut crate::W { + self.variant(OPCODE::Stop) + } + #[doc = "END opcode"] + #[inline(always)] + pub fn end(self) -> &'a mut crate::W { + self.variant(OPCODE::End) + } +} #[doc = "Field `COMMAND_DONE` reader - When command0 is done in I2C Master mode this bit changes to high level."] pub type COMMAND_DONE_R = crate::BitReader; #[doc = "Field `COMMAND_DONE` writer - When command0 is done in I2C Master mode this bit changes to high level."] @@ -47,7 +143,7 @@ impl R { pub fn ack_value(&self) -> ACK_VALUE_R { ACK_VALUE_R::new(((self.bits >> 10) & 1) != 0) } - #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[doc = "Bits 11:13 - Opcode part of command %s."] #[inline(always)] pub fn opcode(&self) -> OPCODE_R { OPCODE_R::new(((self.bits >> 11) & 7) as u8) @@ -96,7 +192,7 @@ impl W { pub fn ack_value(&mut self) -> ACK_VALUE_W { ACK_VALUE_W::new(self, 10) } - #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[doc = "Bits 11:13 - Opcode part of command %s."] #[inline(always)] #[must_use] pub fn opcode(&mut self) -> OPCODE_W { diff --git a/esp32c2/src/i2c0/comd.rs b/esp32c2/src/i2c0/comd.rs index 30756dfe6e..bda2cbe5c2 100644 --- a/esp32c2/src/i2c0/comd.rs +++ b/esp32c2/src/i2c0/comd.rs @@ -18,10 +18,106 @@ pub type ACK_EXP_W<'a, REG> = crate::BitWriter<'a, REG>; pub type ACK_VALUE_R = crate::BitReader; #[doc = "Field `ACK_VALUE` writer - Acknowledge value for command %s."] pub type ACK_VALUE_W<'a, REG> = crate::BitWriter<'a, REG>; -#[doc = "Field `OPCODE` reader - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] -pub type OPCODE_R = crate::FieldReader; -#[doc = "Field `OPCODE` writer - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] -pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3>; +#[doc = "Opcode part of command %s.\n\nValue on reset: 0"] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[repr(u8)] +pub enum OPCODE { + #[doc = "0: RSTART opcode"] + Rstart = 0, + #[doc = "1: WRITE opcode"] + Write = 1, + #[doc = "2: READ opcode"] + Read = 2, + #[doc = "3: STOP opcode"] + Stop = 3, + #[doc = "4: END opcode"] + End = 4, +} +impl From for u8 { + #[inline(always)] + fn from(variant: OPCODE) -> Self { + variant as _ + } +} +impl crate::FieldSpec for OPCODE { + type Ux = u8; +} +impl crate::IsEnum for OPCODE {} +#[doc = "Field `OPCODE` reader - Opcode part of command %s."] +pub type OPCODE_R = crate::FieldReader; +impl OPCODE_R { + #[doc = "Get enumerated values variant"] + #[inline(always)] + pub const fn variant(&self) -> Option { + match self.bits { + 0 => Some(OPCODE::Rstart), + 1 => Some(OPCODE::Write), + 2 => Some(OPCODE::Read), + 3 => Some(OPCODE::Stop), + 4 => Some(OPCODE::End), + _ => None, + } + } + #[doc = "RSTART opcode"] + #[inline(always)] + pub fn is_rstart(&self) -> bool { + *self == OPCODE::Rstart + } + #[doc = "WRITE opcode"] + #[inline(always)] + pub fn is_write(&self) -> bool { + *self == OPCODE::Write + } + #[doc = "READ opcode"] + #[inline(always)] + pub fn is_read(&self) -> bool { + *self == OPCODE::Read + } + #[doc = "STOP opcode"] + #[inline(always)] + pub fn is_stop(&self) -> bool { + *self == OPCODE::Stop + } + #[doc = "END opcode"] + #[inline(always)] + pub fn is_end(&self) -> bool { + *self == OPCODE::End + } +} +#[doc = "Field `OPCODE` writer - Opcode part of command %s."] +pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3, OPCODE>; +impl<'a, REG> OPCODE_W<'a, REG> +where + REG: crate::Writable + crate::RegisterSpec, + REG::Ux: From, +{ + #[doc = "RSTART opcode"] + #[inline(always)] + pub fn rstart(self) -> &'a mut crate::W { + self.variant(OPCODE::Rstart) + } + #[doc = "WRITE opcode"] + #[inline(always)] + pub fn write(self) -> &'a mut crate::W { + self.variant(OPCODE::Write) + } + #[doc = "READ opcode"] + #[inline(always)] + pub fn read(self) -> &'a mut crate::W { + self.variant(OPCODE::Read) + } + #[doc = "STOP opcode"] + #[inline(always)] + pub fn stop(self) -> &'a mut crate::W { + self.variant(OPCODE::Stop) + } + #[doc = "END opcode"] + #[inline(always)] + pub fn end(self) -> &'a mut crate::W { + self.variant(OPCODE::End) + } +} #[doc = "Field `COMMAND_DONE` reader - When command 0 is done in I2C Master mode, this bit changes to high level."] pub type COMMAND_DONE_R = crate::BitReader; #[doc = "Field `COMMAND_DONE` writer - When command 0 is done in I2C Master mode, this bit changes to high level."] @@ -47,7 +143,7 @@ impl R { pub fn ack_value(&self) -> ACK_VALUE_R { ACK_VALUE_R::new(((self.bits >> 10) & 1) != 0) } - #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[doc = "Bits 11:13 - Opcode part of command %s."] #[inline(always)] pub fn opcode(&self) -> OPCODE_R { OPCODE_R::new(((self.bits >> 11) & 7) as u8) @@ -96,7 +192,7 @@ impl W { pub fn ack_value(&mut self) -> ACK_VALUE_W { ACK_VALUE_W::new(self, 10) } - #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[doc = "Bits 11:13 - Opcode part of command %s."] #[inline(always)] #[must_use] pub fn opcode(&mut self) -> OPCODE_W { diff --git a/esp32c3/src/i2c0/comd.rs b/esp32c3/src/i2c0/comd.rs index 9e3fc62c82..0f2aff8852 100644 --- a/esp32c3/src/i2c0/comd.rs +++ b/esp32c3/src/i2c0/comd.rs @@ -18,10 +18,106 @@ pub type ACK_EXP_W<'a, REG> = crate::BitWriter<'a, REG>; pub type ACK_VALUE_R = crate::BitReader; #[doc = "Field `ACK_VALUE` writer - Acknowledge value for command %s."] pub type ACK_VALUE_W<'a, REG> = crate::BitWriter<'a, REG>; -#[doc = "Field `OPCODE` reader - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] -pub type OPCODE_R = crate::FieldReader; -#[doc = "Field `OPCODE` writer - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] -pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3>; +#[doc = "Opcode part of command %s.\n\nValue on reset: 0"] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[repr(u8)] +pub enum OPCODE { + #[doc = "0: RSTART opcode"] + Rstart = 0, + #[doc = "1: WRITE opcode"] + Write = 1, + #[doc = "2: READ opcode"] + Read = 2, + #[doc = "3: STOP opcode"] + Stop = 3, + #[doc = "4: END opcode"] + End = 4, +} +impl From for u8 { + #[inline(always)] + fn from(variant: OPCODE) -> Self { + variant as _ + } +} +impl crate::FieldSpec for OPCODE { + type Ux = u8; +} +impl crate::IsEnum for OPCODE {} +#[doc = "Field `OPCODE` reader - Opcode part of command %s."] +pub type OPCODE_R = crate::FieldReader; +impl OPCODE_R { + #[doc = "Get enumerated values variant"] + #[inline(always)] + pub const fn variant(&self) -> Option { + match self.bits { + 0 => Some(OPCODE::Rstart), + 1 => Some(OPCODE::Write), + 2 => Some(OPCODE::Read), + 3 => Some(OPCODE::Stop), + 4 => Some(OPCODE::End), + _ => None, + } + } + #[doc = "RSTART opcode"] + #[inline(always)] + pub fn is_rstart(&self) -> bool { + *self == OPCODE::Rstart + } + #[doc = "WRITE opcode"] + #[inline(always)] + pub fn is_write(&self) -> bool { + *self == OPCODE::Write + } + #[doc = "READ opcode"] + #[inline(always)] + pub fn is_read(&self) -> bool { + *self == OPCODE::Read + } + #[doc = "STOP opcode"] + #[inline(always)] + pub fn is_stop(&self) -> bool { + *self == OPCODE::Stop + } + #[doc = "END opcode"] + #[inline(always)] + pub fn is_end(&self) -> bool { + *self == OPCODE::End + } +} +#[doc = "Field `OPCODE` writer - Opcode part of command %s."] +pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3, OPCODE>; +impl<'a, REG> OPCODE_W<'a, REG> +where + REG: crate::Writable + crate::RegisterSpec, + REG::Ux: From, +{ + #[doc = "RSTART opcode"] + #[inline(always)] + pub fn rstart(self) -> &'a mut crate::W { + self.variant(OPCODE::Rstart) + } + #[doc = "WRITE opcode"] + #[inline(always)] + pub fn write(self) -> &'a mut crate::W { + self.variant(OPCODE::Write) + } + #[doc = "READ opcode"] + #[inline(always)] + pub fn read(self) -> &'a mut crate::W { + self.variant(OPCODE::Read) + } + #[doc = "STOP opcode"] + #[inline(always)] + pub fn stop(self) -> &'a mut crate::W { + self.variant(OPCODE::Stop) + } + #[doc = "END opcode"] + #[inline(always)] + pub fn end(self) -> &'a mut crate::W { + self.variant(OPCODE::End) + } +} #[doc = "Field `COMMAND_DONE` reader - reg_command_done"] pub type COMMAND_DONE_R = crate::BitReader; #[doc = "Field `COMMAND_DONE` writer - reg_command_done"] @@ -47,7 +143,7 @@ impl R { pub fn ack_value(&self) -> ACK_VALUE_R { ACK_VALUE_R::new(((self.bits >> 10) & 1) != 0) } - #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[doc = "Bits 11:13 - Opcode part of command %s."] #[inline(always)] pub fn opcode(&self) -> OPCODE_R { OPCODE_R::new(((self.bits >> 11) & 7) as u8) @@ -96,7 +192,7 @@ impl W { pub fn ack_value(&mut self) -> ACK_VALUE_W { ACK_VALUE_W::new(self, 10) } - #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[doc = "Bits 11:13 - Opcode part of command %s."] #[inline(always)] #[must_use] pub fn opcode(&mut self) -> OPCODE_W { diff --git a/esp32c6/src/i2c0/comd.rs b/esp32c6/src/i2c0/comd.rs index 30756dfe6e..bda2cbe5c2 100644 --- a/esp32c6/src/i2c0/comd.rs +++ b/esp32c6/src/i2c0/comd.rs @@ -18,10 +18,106 @@ pub type ACK_EXP_W<'a, REG> = crate::BitWriter<'a, REG>; pub type ACK_VALUE_R = crate::BitReader; #[doc = "Field `ACK_VALUE` writer - Acknowledge value for command %s."] pub type ACK_VALUE_W<'a, REG> = crate::BitWriter<'a, REG>; -#[doc = "Field `OPCODE` reader - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] -pub type OPCODE_R = crate::FieldReader; -#[doc = "Field `OPCODE` writer - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] -pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3>; +#[doc = "Opcode part of command %s.\n\nValue on reset: 0"] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[repr(u8)] +pub enum OPCODE { + #[doc = "0: RSTART opcode"] + Rstart = 0, + #[doc = "1: WRITE opcode"] + Write = 1, + #[doc = "2: READ opcode"] + Read = 2, + #[doc = "3: STOP opcode"] + Stop = 3, + #[doc = "4: END opcode"] + End = 4, +} +impl From for u8 { + #[inline(always)] + fn from(variant: OPCODE) -> Self { + variant as _ + } +} +impl crate::FieldSpec for OPCODE { + type Ux = u8; +} +impl crate::IsEnum for OPCODE {} +#[doc = "Field `OPCODE` reader - Opcode part of command %s."] +pub type OPCODE_R = crate::FieldReader; +impl OPCODE_R { + #[doc = "Get enumerated values variant"] + #[inline(always)] + pub const fn variant(&self) -> Option { + match self.bits { + 0 => Some(OPCODE::Rstart), + 1 => Some(OPCODE::Write), + 2 => Some(OPCODE::Read), + 3 => Some(OPCODE::Stop), + 4 => Some(OPCODE::End), + _ => None, + } + } + #[doc = "RSTART opcode"] + #[inline(always)] + pub fn is_rstart(&self) -> bool { + *self == OPCODE::Rstart + } + #[doc = "WRITE opcode"] + #[inline(always)] + pub fn is_write(&self) -> bool { + *self == OPCODE::Write + } + #[doc = "READ opcode"] + #[inline(always)] + pub fn is_read(&self) -> bool { + *self == OPCODE::Read + } + #[doc = "STOP opcode"] + #[inline(always)] + pub fn is_stop(&self) -> bool { + *self == OPCODE::Stop + } + #[doc = "END opcode"] + #[inline(always)] + pub fn is_end(&self) -> bool { + *self == OPCODE::End + } +} +#[doc = "Field `OPCODE` writer - Opcode part of command %s."] +pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3, OPCODE>; +impl<'a, REG> OPCODE_W<'a, REG> +where + REG: crate::Writable + crate::RegisterSpec, + REG::Ux: From, +{ + #[doc = "RSTART opcode"] + #[inline(always)] + pub fn rstart(self) -> &'a mut crate::W { + self.variant(OPCODE::Rstart) + } + #[doc = "WRITE opcode"] + #[inline(always)] + pub fn write(self) -> &'a mut crate::W { + self.variant(OPCODE::Write) + } + #[doc = "READ opcode"] + #[inline(always)] + pub fn read(self) -> &'a mut crate::W { + self.variant(OPCODE::Read) + } + #[doc = "STOP opcode"] + #[inline(always)] + pub fn stop(self) -> &'a mut crate::W { + self.variant(OPCODE::Stop) + } + #[doc = "END opcode"] + #[inline(always)] + pub fn end(self) -> &'a mut crate::W { + self.variant(OPCODE::End) + } +} #[doc = "Field `COMMAND_DONE` reader - When command 0 is done in I2C Master mode, this bit changes to high level."] pub type COMMAND_DONE_R = crate::BitReader; #[doc = "Field `COMMAND_DONE` writer - When command 0 is done in I2C Master mode, this bit changes to high level."] @@ -47,7 +143,7 @@ impl R { pub fn ack_value(&self) -> ACK_VALUE_R { ACK_VALUE_R::new(((self.bits >> 10) & 1) != 0) } - #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[doc = "Bits 11:13 - Opcode part of command %s."] #[inline(always)] pub fn opcode(&self) -> OPCODE_R { OPCODE_R::new(((self.bits >> 11) & 7) as u8) @@ -96,7 +192,7 @@ impl W { pub fn ack_value(&mut self) -> ACK_VALUE_W { ACK_VALUE_W::new(self, 10) } - #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[doc = "Bits 11:13 - Opcode part of command %s."] #[inline(always)] #[must_use] pub fn opcode(&mut self) -> OPCODE_W { diff --git a/esp32h2/src/i2c0/comd.rs b/esp32h2/src/i2c0/comd.rs index 30756dfe6e..bda2cbe5c2 100644 --- a/esp32h2/src/i2c0/comd.rs +++ b/esp32h2/src/i2c0/comd.rs @@ -18,10 +18,106 @@ pub type ACK_EXP_W<'a, REG> = crate::BitWriter<'a, REG>; pub type ACK_VALUE_R = crate::BitReader; #[doc = "Field `ACK_VALUE` writer - Acknowledge value for command %s."] pub type ACK_VALUE_W<'a, REG> = crate::BitWriter<'a, REG>; -#[doc = "Field `OPCODE` reader - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] -pub type OPCODE_R = crate::FieldReader; -#[doc = "Field `OPCODE` writer - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] -pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3>; +#[doc = "Opcode part of command %s.\n\nValue on reset: 0"] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[repr(u8)] +pub enum OPCODE { + #[doc = "0: RSTART opcode"] + Rstart = 0, + #[doc = "1: WRITE opcode"] + Write = 1, + #[doc = "2: READ opcode"] + Read = 2, + #[doc = "3: STOP opcode"] + Stop = 3, + #[doc = "4: END opcode"] + End = 4, +} +impl From for u8 { + #[inline(always)] + fn from(variant: OPCODE) -> Self { + variant as _ + } +} +impl crate::FieldSpec for OPCODE { + type Ux = u8; +} +impl crate::IsEnum for OPCODE {} +#[doc = "Field `OPCODE` reader - Opcode part of command %s."] +pub type OPCODE_R = crate::FieldReader; +impl OPCODE_R { + #[doc = "Get enumerated values variant"] + #[inline(always)] + pub const fn variant(&self) -> Option { + match self.bits { + 0 => Some(OPCODE::Rstart), + 1 => Some(OPCODE::Write), + 2 => Some(OPCODE::Read), + 3 => Some(OPCODE::Stop), + 4 => Some(OPCODE::End), + _ => None, + } + } + #[doc = "RSTART opcode"] + #[inline(always)] + pub fn is_rstart(&self) -> bool { + *self == OPCODE::Rstart + } + #[doc = "WRITE opcode"] + #[inline(always)] + pub fn is_write(&self) -> bool { + *self == OPCODE::Write + } + #[doc = "READ opcode"] + #[inline(always)] + pub fn is_read(&self) -> bool { + *self == OPCODE::Read + } + #[doc = "STOP opcode"] + #[inline(always)] + pub fn is_stop(&self) -> bool { + *self == OPCODE::Stop + } + #[doc = "END opcode"] + #[inline(always)] + pub fn is_end(&self) -> bool { + *self == OPCODE::End + } +} +#[doc = "Field `OPCODE` writer - Opcode part of command %s."] +pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3, OPCODE>; +impl<'a, REG> OPCODE_W<'a, REG> +where + REG: crate::Writable + crate::RegisterSpec, + REG::Ux: From, +{ + #[doc = "RSTART opcode"] + #[inline(always)] + pub fn rstart(self) -> &'a mut crate::W { + self.variant(OPCODE::Rstart) + } + #[doc = "WRITE opcode"] + #[inline(always)] + pub fn write(self) -> &'a mut crate::W { + self.variant(OPCODE::Write) + } + #[doc = "READ opcode"] + #[inline(always)] + pub fn read(self) -> &'a mut crate::W { + self.variant(OPCODE::Read) + } + #[doc = "STOP opcode"] + #[inline(always)] + pub fn stop(self) -> &'a mut crate::W { + self.variant(OPCODE::Stop) + } + #[doc = "END opcode"] + #[inline(always)] + pub fn end(self) -> &'a mut crate::W { + self.variant(OPCODE::End) + } +} #[doc = "Field `COMMAND_DONE` reader - When command 0 is done in I2C Master mode, this bit changes to high level."] pub type COMMAND_DONE_R = crate::BitReader; #[doc = "Field `COMMAND_DONE` writer - When command 0 is done in I2C Master mode, this bit changes to high level."] @@ -47,7 +143,7 @@ impl R { pub fn ack_value(&self) -> ACK_VALUE_R { ACK_VALUE_R::new(((self.bits >> 10) & 1) != 0) } - #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[doc = "Bits 11:13 - Opcode part of command %s."] #[inline(always)] pub fn opcode(&self) -> OPCODE_R { OPCODE_R::new(((self.bits >> 11) & 7) as u8) @@ -96,7 +192,7 @@ impl W { pub fn ack_value(&mut self) -> ACK_VALUE_W { ACK_VALUE_W::new(self, 10) } - #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[doc = "Bits 11:13 - Opcode part of command %s."] #[inline(always)] #[must_use] pub fn opcode(&mut self) -> OPCODE_W { diff --git a/esp32p4/src/i2c0/comd.rs b/esp32p4/src/i2c0/comd.rs index 643b4a9117..42d05c9d71 100644 --- a/esp32p4/src/i2c0/comd.rs +++ b/esp32p4/src/i2c0/comd.rs @@ -18,10 +18,106 @@ pub type ACK_EXP_W<'a, REG> = crate::BitWriter<'a, REG>; pub type ACK_VALUE_R = crate::BitReader; #[doc = "Field `ACK_VALUE` writer - Acknowledge value for command %s."] pub type ACK_VALUE_W<'a, REG> = crate::BitWriter<'a, REG>; -#[doc = "Field `OPCODE` reader - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] -pub type OPCODE_R = crate::FieldReader; -#[doc = "Field `OPCODE` writer - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] -pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3>; +#[doc = "Opcode part of command %s.\n\nValue on reset: 0"] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[repr(u8)] +pub enum OPCODE { + #[doc = "0: RSTART opcode"] + Rstart = 0, + #[doc = "1: WRITE opcode"] + Write = 1, + #[doc = "2: READ opcode"] + Read = 2, + #[doc = "3: STOP opcode"] + Stop = 3, + #[doc = "4: END opcode"] + End = 4, +} +impl From for u8 { + #[inline(always)] + fn from(variant: OPCODE) -> Self { + variant as _ + } +} +impl crate::FieldSpec for OPCODE { + type Ux = u8; +} +impl crate::IsEnum for OPCODE {} +#[doc = "Field `OPCODE` reader - Opcode part of command %s."] +pub type OPCODE_R = crate::FieldReader; +impl OPCODE_R { + #[doc = "Get enumerated values variant"] + #[inline(always)] + pub const fn variant(&self) -> Option { + match self.bits { + 0 => Some(OPCODE::Rstart), + 1 => Some(OPCODE::Write), + 2 => Some(OPCODE::Read), + 3 => Some(OPCODE::Stop), + 4 => Some(OPCODE::End), + _ => None, + } + } + #[doc = "RSTART opcode"] + #[inline(always)] + pub fn is_rstart(&self) -> bool { + *self == OPCODE::Rstart + } + #[doc = "WRITE opcode"] + #[inline(always)] + pub fn is_write(&self) -> bool { + *self == OPCODE::Write + } + #[doc = "READ opcode"] + #[inline(always)] + pub fn is_read(&self) -> bool { + *self == OPCODE::Read + } + #[doc = "STOP opcode"] + #[inline(always)] + pub fn is_stop(&self) -> bool { + *self == OPCODE::Stop + } + #[doc = "END opcode"] + #[inline(always)] + pub fn is_end(&self) -> bool { + *self == OPCODE::End + } +} +#[doc = "Field `OPCODE` writer - Opcode part of command %s."] +pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3, OPCODE>; +impl<'a, REG> OPCODE_W<'a, REG> +where + REG: crate::Writable + crate::RegisterSpec, + REG::Ux: From, +{ + #[doc = "RSTART opcode"] + #[inline(always)] + pub fn rstart(self) -> &'a mut crate::W { + self.variant(OPCODE::Rstart) + } + #[doc = "WRITE opcode"] + #[inline(always)] + pub fn write(self) -> &'a mut crate::W { + self.variant(OPCODE::Write) + } + #[doc = "READ opcode"] + #[inline(always)] + pub fn read(self) -> &'a mut crate::W { + self.variant(OPCODE::Read) + } + #[doc = "STOP opcode"] + #[inline(always)] + pub fn stop(self) -> &'a mut crate::W { + self.variant(OPCODE::Stop) + } + #[doc = "END opcode"] + #[inline(always)] + pub fn end(self) -> &'a mut crate::W { + self.variant(OPCODE::End) + } +} #[doc = "Field `COMMAND_DONE` reader - Represents whether command 0 is done in I2C Master mode. 0: Not done 1: Done"] pub type COMMAND_DONE_R = crate::BitReader; #[doc = "Field `COMMAND_DONE` writer - Represents whether command 0 is done in I2C Master mode. 0: Not done 1: Done"] @@ -47,7 +143,7 @@ impl R { pub fn ack_value(&self) -> ACK_VALUE_R { ACK_VALUE_R::new(((self.bits >> 10) & 1) != 0) } - #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[doc = "Bits 11:13 - Opcode part of command %s."] #[inline(always)] pub fn opcode(&self) -> OPCODE_R { OPCODE_R::new(((self.bits >> 11) & 7) as u8) @@ -96,7 +192,7 @@ impl W { pub fn ack_value(&mut self) -> ACK_VALUE_W { ACK_VALUE_W::new(self, 10) } - #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[doc = "Bits 11:13 - Opcode part of command %s."] #[inline(always)] #[must_use] pub fn opcode(&mut self) -> OPCODE_W { diff --git a/esp32s2/src/i2c0/comd.rs b/esp32s2/src/i2c0/comd.rs index 30756dfe6e..bda2cbe5c2 100644 --- a/esp32s2/src/i2c0/comd.rs +++ b/esp32s2/src/i2c0/comd.rs @@ -18,10 +18,106 @@ pub type ACK_EXP_W<'a, REG> = crate::BitWriter<'a, REG>; pub type ACK_VALUE_R = crate::BitReader; #[doc = "Field `ACK_VALUE` writer - Acknowledge value for command %s."] pub type ACK_VALUE_W<'a, REG> = crate::BitWriter<'a, REG>; -#[doc = "Field `OPCODE` reader - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] -pub type OPCODE_R = crate::FieldReader; -#[doc = "Field `OPCODE` writer - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] -pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3>; +#[doc = "Opcode part of command %s.\n\nValue on reset: 0"] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[repr(u8)] +pub enum OPCODE { + #[doc = "0: RSTART opcode"] + Rstart = 0, + #[doc = "1: WRITE opcode"] + Write = 1, + #[doc = "2: READ opcode"] + Read = 2, + #[doc = "3: STOP opcode"] + Stop = 3, + #[doc = "4: END opcode"] + End = 4, +} +impl From for u8 { + #[inline(always)] + fn from(variant: OPCODE) -> Self { + variant as _ + } +} +impl crate::FieldSpec for OPCODE { + type Ux = u8; +} +impl crate::IsEnum for OPCODE {} +#[doc = "Field `OPCODE` reader - Opcode part of command %s."] +pub type OPCODE_R = crate::FieldReader; +impl OPCODE_R { + #[doc = "Get enumerated values variant"] + #[inline(always)] + pub const fn variant(&self) -> Option { + match self.bits { + 0 => Some(OPCODE::Rstart), + 1 => Some(OPCODE::Write), + 2 => Some(OPCODE::Read), + 3 => Some(OPCODE::Stop), + 4 => Some(OPCODE::End), + _ => None, + } + } + #[doc = "RSTART opcode"] + #[inline(always)] + pub fn is_rstart(&self) -> bool { + *self == OPCODE::Rstart + } + #[doc = "WRITE opcode"] + #[inline(always)] + pub fn is_write(&self) -> bool { + *self == OPCODE::Write + } + #[doc = "READ opcode"] + #[inline(always)] + pub fn is_read(&self) -> bool { + *self == OPCODE::Read + } + #[doc = "STOP opcode"] + #[inline(always)] + pub fn is_stop(&self) -> bool { + *self == OPCODE::Stop + } + #[doc = "END opcode"] + #[inline(always)] + pub fn is_end(&self) -> bool { + *self == OPCODE::End + } +} +#[doc = "Field `OPCODE` writer - Opcode part of command %s."] +pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3, OPCODE>; +impl<'a, REG> OPCODE_W<'a, REG> +where + REG: crate::Writable + crate::RegisterSpec, + REG::Ux: From, +{ + #[doc = "RSTART opcode"] + #[inline(always)] + pub fn rstart(self) -> &'a mut crate::W { + self.variant(OPCODE::Rstart) + } + #[doc = "WRITE opcode"] + #[inline(always)] + pub fn write(self) -> &'a mut crate::W { + self.variant(OPCODE::Write) + } + #[doc = "READ opcode"] + #[inline(always)] + pub fn read(self) -> &'a mut crate::W { + self.variant(OPCODE::Read) + } + #[doc = "STOP opcode"] + #[inline(always)] + pub fn stop(self) -> &'a mut crate::W { + self.variant(OPCODE::Stop) + } + #[doc = "END opcode"] + #[inline(always)] + pub fn end(self) -> &'a mut crate::W { + self.variant(OPCODE::End) + } +} #[doc = "Field `COMMAND_DONE` reader - When command 0 is done in I2C Master mode, this bit changes to high level."] pub type COMMAND_DONE_R = crate::BitReader; #[doc = "Field `COMMAND_DONE` writer - When command 0 is done in I2C Master mode, this bit changes to high level."] @@ -47,7 +143,7 @@ impl R { pub fn ack_value(&self) -> ACK_VALUE_R { ACK_VALUE_R::new(((self.bits >> 10) & 1) != 0) } - #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[doc = "Bits 11:13 - Opcode part of command %s."] #[inline(always)] pub fn opcode(&self) -> OPCODE_R { OPCODE_R::new(((self.bits >> 11) & 7) as u8) @@ -96,7 +192,7 @@ impl W { pub fn ack_value(&mut self) -> ACK_VALUE_W { ACK_VALUE_W::new(self, 10) } - #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[doc = "Bits 11:13 - Opcode part of command %s."] #[inline(always)] #[must_use] pub fn opcode(&mut self) -> OPCODE_W { diff --git a/esp32s3/src/i2c0/comd.rs b/esp32s3/src/i2c0/comd.rs index 30756dfe6e..bda2cbe5c2 100644 --- a/esp32s3/src/i2c0/comd.rs +++ b/esp32s3/src/i2c0/comd.rs @@ -18,10 +18,106 @@ pub type ACK_EXP_W<'a, REG> = crate::BitWriter<'a, REG>; pub type ACK_VALUE_R = crate::BitReader; #[doc = "Field `ACK_VALUE` writer - Acknowledge value for command %s."] pub type ACK_VALUE_W<'a, REG> = crate::BitWriter<'a, REG>; -#[doc = "Field `OPCODE` reader - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] -pub type OPCODE_R = crate::FieldReader; -#[doc = "Field `OPCODE` writer - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] -pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3>; +#[doc = "Opcode part of command %s.\n\nValue on reset: 0"] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[repr(u8)] +pub enum OPCODE { + #[doc = "0: RSTART opcode"] + Rstart = 0, + #[doc = "1: WRITE opcode"] + Write = 1, + #[doc = "2: READ opcode"] + Read = 2, + #[doc = "3: STOP opcode"] + Stop = 3, + #[doc = "4: END opcode"] + End = 4, +} +impl From for u8 { + #[inline(always)] + fn from(variant: OPCODE) -> Self { + variant as _ + } +} +impl crate::FieldSpec for OPCODE { + type Ux = u8; +} +impl crate::IsEnum for OPCODE {} +#[doc = "Field `OPCODE` reader - Opcode part of command %s."] +pub type OPCODE_R = crate::FieldReader; +impl OPCODE_R { + #[doc = "Get enumerated values variant"] + #[inline(always)] + pub const fn variant(&self) -> Option { + match self.bits { + 0 => Some(OPCODE::Rstart), + 1 => Some(OPCODE::Write), + 2 => Some(OPCODE::Read), + 3 => Some(OPCODE::Stop), + 4 => Some(OPCODE::End), + _ => None, + } + } + #[doc = "RSTART opcode"] + #[inline(always)] + pub fn is_rstart(&self) -> bool { + *self == OPCODE::Rstart + } + #[doc = "WRITE opcode"] + #[inline(always)] + pub fn is_write(&self) -> bool { + *self == OPCODE::Write + } + #[doc = "READ opcode"] + #[inline(always)] + pub fn is_read(&self) -> bool { + *self == OPCODE::Read + } + #[doc = "STOP opcode"] + #[inline(always)] + pub fn is_stop(&self) -> bool { + *self == OPCODE::Stop + } + #[doc = "END opcode"] + #[inline(always)] + pub fn is_end(&self) -> bool { + *self == OPCODE::End + } +} +#[doc = "Field `OPCODE` writer - Opcode part of command %s."] +pub type OPCODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3, OPCODE>; +impl<'a, REG> OPCODE_W<'a, REG> +where + REG: crate::Writable + crate::RegisterSpec, + REG::Ux: From, +{ + #[doc = "RSTART opcode"] + #[inline(always)] + pub fn rstart(self) -> &'a mut crate::W { + self.variant(OPCODE::Rstart) + } + #[doc = "WRITE opcode"] + #[inline(always)] + pub fn write(self) -> &'a mut crate::W { + self.variant(OPCODE::Write) + } + #[doc = "READ opcode"] + #[inline(always)] + pub fn read(self) -> &'a mut crate::W { + self.variant(OPCODE::Read) + } + #[doc = "STOP opcode"] + #[inline(always)] + pub fn stop(self) -> &'a mut crate::W { + self.variant(OPCODE::Stop) + } + #[doc = "END opcode"] + #[inline(always)] + pub fn end(self) -> &'a mut crate::W { + self.variant(OPCODE::End) + } +} #[doc = "Field `COMMAND_DONE` reader - When command 0 is done in I2C Master mode, this bit changes to high level."] pub type COMMAND_DONE_R = crate::BitReader; #[doc = "Field `COMMAND_DONE` writer - When command 0 is done in I2C Master mode, this bit changes to high level."] @@ -47,7 +143,7 @@ impl R { pub fn ack_value(&self) -> ACK_VALUE_R { ACK_VALUE_R::new(((self.bits >> 10) & 1) != 0) } - #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[doc = "Bits 11:13 - Opcode part of command %s."] #[inline(always)] pub fn opcode(&self) -> OPCODE_R { OPCODE_R::new(((self.bits >> 11) & 7) as u8) @@ -96,7 +192,7 @@ impl W { pub fn ack_value(&mut self) -> ACK_VALUE_W { ACK_VALUE_W::new(self, 10) } - #[doc = "Bits 11:13 - Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."] + #[doc = "Bits 11:13 - Opcode part of command %s."] #[inline(always)] #[must_use] pub fn opcode(&mut self) -> OPCODE_W {