Skip to content
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

Proposed new I2C verb "i2c_repeated_transmit" #405

Closed
wants to merge 22 commits into from

Conversation

krogozinski
Copy link

I2C verb "i2c_repeated_transmit" conducts a write/read sequence a specified number of times.

Use case: many inertial sensors e.g .ST LSM6DS33, employ a FIFO that can be read at a pre-determined time interval or when a certain number of samples have been taken. In order to read and flush this buffer expediently, a fast sequence of I2C operations is required:

  • I2C write 1x byte with FIFO data register address (generally lower byte of two-byte word)
  • I2C read 2x bytes with FIFO low and FIFO high values
  • Repeat for number of words available in FIFO

A repeated transmit I2C verb could rapidly perform this sequence in comparison to a conventional I2CDevice.transmit(), which introduces USB latency between each write/read operation.

Example:

class LSM6DS33(I2CDevice, GreatFETSensor):
    ...
    def get_fifo_words(self, num_words):
        return (self.repeated_transmit(
            [self.REG_FIFO_DATA_OUT_L], # Bytes to write
            2,                          # Number of bytes to read
            num_words))                 # Number of write/read sequence transmissions
    ...

@antoinevg antoinevg self-requested a review January 12, 2023 11:13
@krogozinski
Copy link
Author

@antoinevg is there any appetite to add this new verb? If not, happy to close PR and maintain out-of-tree. Just FYI, I was also looking at implementing same functionality for SPI.

@antoinevg antoinevg self-assigned this Aug 22, 2023
@antoinevg
Copy link
Member

This looks great @krogozinski, thank you for contributing! I also think having the same functionality for SPI would be just as useful.

I'm definitely up for putting some time aside to help you get this landed!

@krogozinski
Copy link
Author

OK thanks, I should have some time this week to work on the SPI side. I'll make sure to clean up my git commit history before pushing the changes to my fork.

@antoinevg antoinevg marked this pull request as draft October 10, 2023 16:53
@krogozinski krogozinski deleted the i2c_dev branch February 28, 2024 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants