Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split COMMAND register for I2C #261

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions common_patches/i2c0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
COMD%s:
playfulFence marked this conversation as resolved.
Show resolved Hide resolved
_delete: ["COMMAND"]
_add:
OPCODE:
description: "Opcode part of command %s. 0: RSTART, 1: WRITE, 2: READ, 3: STOP, 4: END."
jessebraham marked this conversation as resolved.
Show resolved Hide resolved
bitOffset: 11
bitWidth: 3
access: read-write
ACK_VALUE:
description: "Acknowledge value for command %s."
playfulFence marked this conversation as resolved.
Show resolved Hide resolved
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
playfulFence marked this conversation as resolved.
Show resolved Hide resolved
86 changes: 75 additions & 11 deletions esp32/src/i2c0/comd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,55 @@
pub type R = crate::R<COMD_SPEC>;
#[doc = "Register `COMD%s` writer"]
pub type W = crate::W<COMD_SPEC>;
#[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<u16>;
#[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)]
Expand All @@ -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<COMD_SPEC> {
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<COMD_SPEC> {
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<COMD_SPEC> {
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<COMD_SPEC> {
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<COMD_SPEC> {
COMMAND_W::new(self, 0)
pub fn opcode(&mut self) -> OPCODE_W<COMD_SPEC> {
OPCODE_W::new(self, 11)
}
#[doc = "Bit 31 - When command0 is done in I2C Master mode this bit changes to high level."]
#[inline(always)]
Expand Down
2 changes: 2 additions & 0 deletions esp32/svd/patches/esp32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ I2C0:
_modify:
INT_STATUS:
name: INT_ST
_include:
- ../../../common_patches/i2c0.yaml
jessebraham marked this conversation as resolved.
Show resolved Hide resolved

RTC_I2C:
_modify:
Expand Down
86 changes: 75 additions & 11 deletions esp32c2/src/i2c0/comd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,55 @@
pub type R = crate::R<COMD_SPEC>;
#[doc = "Register `COMD%s` writer"]
pub type W = crate::W<COMD_SPEC>;
#[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<u16>;
#[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)]
Expand All @@ -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<COMD_SPEC> {
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<COMD_SPEC> {
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<COMD_SPEC> {
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<COMD_SPEC> {
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<COMD_SPEC> {
COMMAND_W::new(self, 0)
pub fn opcode(&mut self) -> OPCODE_W<COMD_SPEC> {
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)]
Expand Down
4 changes: 3 additions & 1 deletion esp32c2/svd/patches/esp32c2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
86 changes: 75 additions & 11 deletions esp32c3/src/i2c0/comd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,55 @@
pub type R = crate::R<COMD_SPEC>;
#[doc = "Register `COMD%s` writer"]
pub type W = crate::W<COMD_SPEC>;
#[doc = "Field `COMMAND` reader - reg_command"]
pub type COMMAND_R = crate::FieldReader<u16>;
#[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)]
Expand All @@ -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<COMD_SPEC> {
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<COMD_SPEC> {
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<COMD_SPEC> {
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<COMD_SPEC> {
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<COMD_SPEC> {
COMMAND_W::new(self, 0)
pub fn opcode(&mut self) -> OPCODE_W<COMD_SPEC> {
OPCODE_W::new(self, 11)
}
#[doc = "Bit 31 - reg_command_done"]
#[inline(always)]
Expand Down
2 changes: 2 additions & 0 deletions esp32c3/svd/patches/esp32c3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading