api: add i2c master/slave support | examples: add i2c master/slave samples #523
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Adds new I2C master/slave api to libtock-rs. The changes were tested using the samples running on 2x Particle Boron boards. Where one was a master and the other was a slave device, that would ping-pong data across. Additional testing was performed by communicating with an MCP9808 device as an I2C bus Master.
Building and Testing
The samples can be built by running the below from the top-dir:
After flashing each sample to the respective master and slave device. The following serial output can be observed. Note you may have to reset the devices after flashing.
Master Log (i2c_master_write_read.rs)
Slave Log (i2c_slave_send_recv.rs)
NOTE: These are two different logs, so the bytes aren't matched... I only have one UART converter >,>
TODO/Help
This api is all synchronous, we need to look at adding async support. It looks like we need to improve the kernel
i2c_master_slave_driver.rs
for this, as it seems to support only a single subscriber currently. What's a good place to get started? Or is there something I missed here?Cheers