-
Notifications
You must be signed in to change notification settings - Fork 17
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
Changes to i2c master and slave to handle large data buffers #322
base: main
Are you sure you want to change the base?
Changes to i2c master and slave to handle large data buffers #322
Conversation
6656153
to
62d4d17
Compare
a4eb019
to
7d8ce43
Compare
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.
PR Overview
This PR updates the I2C master and slave implementations to support large DMA transfers by dividing data buffers into smaller, DMA-safe chunks. The changes include new chunking functions in both master and slave modules, an added constant for the maximum chunk size, and related updates to the Cargo configuration.
- Added write_chunks and read_chunks functions to I2C master to split large transfers.
- Updated the I2C slave’s response functions to process data in chunks.
- Introduced the MAX_I2C_CHUNK_SIZE constant and updated the Cargo config with a new executor arena size.
Reviewed Changes
File | Description |
---|---|
src/i2c/master.rs | Introduces chunked write/read functions and updates I2C traits. |
src/i2c/slave.rs | Implements chunking in slave response functions for write/read. |
examples/rt685s-evk/.cargo/config.toml | Updates Cargo config with linker args and executor arena size. |
src/i2c/mod.rs | Adds MAX_I2C_CHUNK_SIZE constant for DMA transfer size. |
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
@@ -761,6 +761,30 @@ impl<'a> I2cMaster<'a, Async> { | |||
) | |||
.await | |||
} | |||
|
|||
async fn write_chunks(&mut self, address: u16, write: &[u8]) -> Result<()> { |
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.
[nitpick] In write_chunks, when the write buffer is empty the function calls write_no_stop but does not return immediately. To improve clarity and control flow, consider returning immediately after handling the empty buffer.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
@@ -502,6 +502,24 @@ impl I2cSlave<'_, Async> { | |||
|
|||
/// Respond to write command from master | |||
pub async fn respond_to_write(&mut self, buf: &mut [u8]) -> Result<Response> { | |||
let mut xfer_count = 0; |
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.
[nitpick] In respond_to_write, the for loop returns as soon as a chunk yields a 'Complete' response, which may unintentionally skip processing remaining chunks. Review this behavior to ensure it meets the intended protocol for multi-chunk transactions.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
Since DMA only handles a maximum of 1024 bytes of data, i2c master and slave need to handle larger buffers by dividing them into chunks of smaller buffers.
The example also demonstrates how to handle both read and write operations for a large buffer.
Closes #255