Skip to content

I2C address used in STM32-i2c drivers #296

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

Open
Blast545 opened this issue Feb 12, 2019 · 4 comments
Open

I2C address used in STM32-i2c drivers #296

Blast545 opened this issue Feb 12, 2019 · 4 comments
Assignees

Comments

@Blast545
Copy link

Hello, when using I2C boards to communicate in "Master_Request_Write" and "Master_Request_Read" functions, the I2C address used is taken using the following function:

Address_to_use := UInt8 (Addr) and 2#1#;

This takes the upper 7 bits of the Addr. I think the standard is using the lower 7 bits of the address field, at least for most of "open source" sensors/boards, most of them come with the address written in the lower 7 bits in hexadecimal.

So, it is not like the library it is not working at this point, but it does not follow what I think is an I2C standard. I think there could be two approaches to "solve" this issue:

  1. Maybe writing an additional description in the I2C functions that the user should be using: Master_Transmit, Master_Receive, Mem_Write and Mem_Read. Maybe putting this info in the description of the package?

  2. Changing the function to shift_left the register address before taking the and/or operations, and updating the I2C address of the already written components. I think this one will require as well some sort of informative text, as some people working already with these libraries might be used to the current state of the library.

Let me know what you think, and thanks for your time!

@Fabien-Chouteau
Copy link
Member

Thank you @Blast545, we are indeed not compatible with the most common practice.

I am in favor of changing this, but it will have an impact on the existing projects.

@Blast545
Copy link
Author

Yes, I thought the same, changing the library as it is now, might affect the library current users that know how it works.

Eventually users with a problem like the one I had, just need to use a Shift_Left function to solve the problem, so maybe finding a good way to let them know that they have to be careful about this is enough.

@pat-rogers
Copy link
Contributor

pat-rogers commented Mar 4, 2019 via email

@RREE
Copy link
Contributor

RREE commented Mar 21, 2022

I have just learned the hard way that ADL expects the I2C address in the upper 7 bits of a byte. Most libraries that I know and explaining internet ressource simply use the value range 8 .. 16#77# (https://i2cdevices.org/addresses)
BTW the interface cannot distinguish between the 7bit address 16#44# and the 10bit address 16#44#. Both values are valid in the two address spaces

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

No branches or pull requests

4 participants