-
Notifications
You must be signed in to change notification settings - Fork 1
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
SNS - I2C ToF #26
base: main
Are you sure you want to change the base?
SNS - I2C ToF #26
Conversation
Datasheet available here for the VL6180V1 ToF Sensor: https://www.st.com/en/imaging-and-photonics-solutions/vl6180.html#overview |
A lot of these functions were implemented using the 'example code' provided in the VL6180 application sheet: https://www.st.com/resource/en/application_note/an4545-vl6180x-basic-ranging-application-note-stmicroelectronics.pdf TODO:
|
Tests are failing though, not sure why
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very nearly done now! The tests aren't working properly (not sure why). A few comments here to fix and think about the API. Apart from those functionality points, would be good to add Rust doc comments to all of your functions
// Check that the sensor has powered up | ||
// Note: the sensor will either need to be power cycled or the SYS_FRESH_OUT_RESET register will need to be written to 0x01 if it has already been configured | ||
let mut boot_status = i2c | ||
.read_byte_16(device_address, SYSTEM_FRESH_OUT_OF_RESET) | ||
.unwrap_or_default(); | ||
while boot_status != 1 { | ||
boot_status = i2c | ||
.read_byte_16(device_address, SYSTEM_FRESH_OUT_OF_RESET) | ||
.unwrap_or_default(); | ||
} | ||
defmt::info!("ToF sensor booted"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about this again: To take advantage of the SYSTEM_FRESH_OUT_OF_RESET
register, you could just check if it is configured and if it is, skip initialising all of the registers (just extract that logic into an init_sensor
(or similar) function
initial commit for time of flight sensor code, hope the folder structure is okay