-
Notifications
You must be signed in to change notification settings - Fork 45
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
I2C write_read() not woring correctly #25
Comments
To add a bit of background, we call the |
I did some testing with an I2C AT24C256 EEPROM and a logic analyzer. I wrote a simple program to read from an address which uses let mut data = [0];
i2c.write_read(address, &[0x00, 0x12], &mut data).unwrap(); (The memory addresses are two bytes here, not one as for the veml6030's "command" but that is not my point right now) Using the One can see clearly how the first one does not issue a STOP and does only a START repeat and in the second one the write and read are independent (as implemented here). The AT24C256 EEPROM accepts it either way, but VEML6030 and probably others do not. |
Yes, that is the classical combined write/read, which is what the |
@eldruin has created a Rust driver for the VEML60300 ambient light sensor that uses the embedded-hal traits.
At the lowest level of the driver are two functions
write_register()
andread_register()
defined as follows:In testing the code the function that writes to the registers in the VEML6030 is working as it is configuring the ambient light sensor and enabling it to collect samples.
When we try to read the raw data from the ambient light sensor using a function called
read_raw()
which simply calls theread_register()
function with the correct register offset it always returns 0.Within the test application if we replace the call to the drivers
read_raw()
function with the following:then correct data is being returned. If we split the write then read as:
then the value of
raw
is, again, always 0.The code is all cross compiled for an NXP i.MX6 running a custom Yocto Linux build with kernel version 4.14.98.
-Andy.
The text was updated successfully, but these errors were encountered: