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

Fix checking address on I2C transaction start/end #121

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

eldruin
Copy link
Contributor

@eldruin eldruin commented Aug 2, 2024

I have noticed that the addresses supplied in the transaction start/end are not checked. Hence this PR.
Although I am wondering now if the transaction start/end should have an address parameter at all. Maybe we should remove it altogether.

@dbrgn
Copy link
Owner

dbrgn commented Aug 2, 2024

Although I am wondering now if the transaction start/end should have an address parameter at all. Maybe we should remove it altogether.

How would you pass the address argument to the read/write functions in that case?

@eldruin
Copy link
Contributor Author

eldruin commented Aug 5, 2024

The address is already checked in the individual steps.

[ I2cTrans::transaction_start(ADDR),
  I2cTrans::write(ADDR, vec![0]),
  I2cTrans::read(ADDR, &mut data),
  I2cTrans::transaction_end(ADDR) ]

vs.

[ I2cTrans::transaction_start(),
  I2cTrans::write(ADDR, vec![0]),
  I2cTrans::read(ADDR, &mut data),
  I2cTrans::transaction_end() ]

@asasine
Copy link
Contributor

asasine commented Aug 5, 2024

Removing the address from the transaction start is opposite to how the underlying bus works for multiple operations. The address is sent as part of start/repeated start, and not as part of the write/read operations. If anything, the address should be only included in the starts and removed from everything else.

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

Successfully merging this pull request may close these issues.

3 participants