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

i.MX RT 10xx LPI2C Possible Bug #3658

Open
brghena opened this issue Sep 7, 2023 · 1 comment
Open

i.MX RT 10xx LPI2C Possible Bug #3658

brghena opened this issue Sep 7, 2023 · 1 comment

Comments

@brghena
Copy link
Contributor

brghena commented Sep 7, 2023

In the start_read() function in the lpi2c implementation for the i.MX RT 10xx, there are two probable bugs.

First, the MTDR::CMD.val() is set to "100" instead of "0b100". This doesn't match the implementation of the start_write() function above. I suspect it's an error.

Second, the MTDR::DATA.val() is set to (self.slave_address.get() << 1 + 1) as u32. The order of operations here applies the "+" first, then the bit shift. I believe the intent was to shift the address up one bit, then apply a 1 as the new least-significant bit to denote an I2C read operation, that would properly be written as ((self.slave_address.get() << 1) + 1) as u32.

Relevant lines of code (after the clippy pass from #3637) are here:

fn start_read(&self) {
self.rx_position.set(0);
// setting slave address
self.registers.mier.modify(MIER::EPIE::CLEAR);
self.registers.mtdr.write(
MTDR::CMD.val(100) + MTDR::DATA.val((self.slave_address.get() << (1 + 1)) as u32),
);
self.registers.mcfgr1.modify(MCFGR1::PINCFG::CLEAR);
self.registers
.mier
.modify(MIER::NDIE::SET + MIER::EPIE::SET + MIER::RDIE::SET);
}
}

@alexandruradovici can you confirm or reject whether this is an issue?

@alexandruradovici
Copy link
Contributor

@valexandru can you take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants