Make FT4222 I2C master clock frequency configurable#2558
Merged
Conversation
Copilot
AI
changed the title
[WIP] Add public method to set I2C clock frequency to 100Kbps
Make FT4222 I2C master clock frequency configurable
Jun 2, 2026
Contributor
|
@copilot address the errors that caused the tests to fail |
Contributor
Author
Fixed in af the latest commit — there was a stray duplicate closing brace in |
raffaeler
approved these changes
Jun 2, 2026
raffaeler
left a comment
Contributor
There was a problem hiding this comment.
This implementation looks reasonable to me
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes the FT4222 I2C master clock frequency configurable instead of being hard-coded to 400, enabling scenarios like running the bus at 100 (within the LibFT4222-supported range of 60–3400).
Changes:
- Added frequency range constants plus an optional
i2cMasterFrequencyKbpsconstructor parameter toFt4222I2cBus, surfaced viaI2cMasterFrequencyKbps. - Added
Ft4222Device.I2cBusFrequencyKbps(defaulting to 400) and forwarded it when creating theFt4222I2cBus. - Documented how to configure the frequency in the FT4222 README.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/devices/Ft4222/Ft4222I2cBus.cs | Adds configurable I2C master init frequency with validation and a readable property. |
| src/devices/Ft4222/Ft4222Device.cs | Exposes bus-frequency configuration on the public device wrapper and forwards it into bus creation. |
| src/devices/Ft4222/README.md | Documents how to set the I2C bus frequency before creating the bus. |
pgrawehr
reviewed
Jun 6, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
raffaeler
approved these changes
Jun 14, 2026
Contributor
|
@copilot fix the compilation errors |
Contributor
Author
pgrawehr
approved these changes
Jun 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The FT4222 I2C master clock frequency was hard-coded to 400 kbps in
Ft4222I2cBus, with no public way to change it (e.g. to 100 kbps). Per the LibFT4222 user guide,FT4222_I2CMaster_Initsupports speeds from 60 to 3400 kbps.Changes
Ft4222I2cBus: Replaced the private400constant with publicDefault/Minimum/Maximum(400/60/3400) constants. MadeFt4222I2cBuspublic so those constants are part of the public API. Added constructor overloads for the default and explicit frequency cases, validating the range and surfacing the selected value via a read-onlyI2cMasterFrequencyKbpsproperty.Ft4222Device: Added a publicI2cBusFrequencyKbpsproperty (default 400 kbps), forwarded toFt4222I2cBusinCreateI2cBusCore.Usage
Values outside 60–3400 kbps throw
ArgumentOutOfRangeException. Existing callers are unaffected since the default preserves the prior 400 kbps behavior, and the constructor overload pair avoids relying on a default argument for compatibility.