Skip to content

Adding FT200X - #2628

Open
Ellerbach wants to merge 3 commits into
mainfrom
add-FT200X
Open

Ellerbach wants to merge 3 commits into
mainfrom
add-FT200X

Conversation

@Ellerbach

@Ellerbach Ellerbach commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Adding FT200X. This is a client I2C device from FTDI.
Adjusted the FTCommon project as there are more FTDI which can be setup as I2C client.
Added tests.
Added a sample with a fake temperature sensor. Make a real test with a real I2C master.

TEST: Sensor ID, TX=00 00 00 00
PASS: Sensor ID, RX=00 00 20 01
TEST: Enable measurements, TX=01 02 00 01
PASS: Enable measurements, RX=00 02 00 01
TEST: Configuration enabled, TX=00 02 00 00
PASS: Configuration enabled, RX=00 02 00 01
TEST: Temperature = 23.50 C, TX=00 01 00 00
PASS: Temperature = 23.50 C, RX=00 01 09 2E
TEST: Disable measurements, TX=01 02 00 00
PASS: Disable measurements, RX=00 02 00 00
TEST: Configuration disabled, TX=00 02 00 00
PASS: Configuration disabled, RX=00 02 00 00
TEST: Temperature disabled, TX=00 01 00 00
PASS: Temperature disabled, RX=05 01 00 00
TEST: ID readable while disabled, TX=00 00 00 00
PASS: ID readable while disabled, RX=00 00 20 01
TEST: Reject configuration 2, TX=01 02 00 02
PASS: Reject configuration 2, RX=04 02 00 00
TEST: Invalid write leaves disabled, TX=00 02 00 00
PASS: Invalid write leaves disabled, RX=00 02 00 00
TEST: Re-enable measurements, TX=01 02 00 01
PASS: Re-enable measurements, RX=00 02 00 01
TEST: Temperature restored, TX=00 01 00 00
PASS: Temperature restored, RX=00 01 09 2E
TEST: Reject configuration high byte, TX=01 02 01 00
PASS: Reject configuration high byte, RX=04 02 00 00
TEST: Invalid write leaves enabled, TX=00 02 00 00
PASS: Invalid write leaves enabled, RX=00 02 00 01
TEST: Reject ID write, TX=01 00 FF FF
PASS: Reject ID write, RX=03 00 00 00
TEST: Reject temperature write, TX=01 01 00 00
PASS: Reject temperature write, RX=03 01 00 00
TEST: Reject unknown read register, TX=00 03 00 00
PASS: Reject unknown read register, RX=02 03 00 00
TEST: Reject unknown write register, TX=01 FF 00 01
PASS: Reject unknown write register, RX=02 FF 00 00
TEST: Reject invalid command, TX=02 02 00 00
PASS: Reject invalid command, RX=01 02 00 00
TEST: Command error precedes register error, TX=FF FF FF FF
PASS: Command error precedes register error, RX=01 FF 00 00
TEST: Reject ID read payload, TX=00 00 00 01
PASS: Reject ID read payload, RX=04 00 00 00
TEST: Reject temperature read payload, TX=00 01 00 01
PASS: Reject temperature read payload, RX=04 01 00 00
TEST: Reject configuration read high byte, TX=00 02 01 00
PASS: Reject configuration read high byte, RX=04 02 00 00
TEST: Final configuration enabled, TX=00 02 00 00
PASS: Final configuration enabled, RX=00 02 00 01
TEST: Final ID unchanged, TX=00 00 00 00
PASS: Final ID unchanged, RX=00 00 20 01
TEST: Final temperature unchanged, TX=00 01 00 00
PASS: Final temperature unchanged, RX=00 01 09 2E
Microsoft Reviewers: Open in CodeFlow

@Ellerbach
Ellerbach requested a balanced review from Copilot October 20, 2026 11:58
@dotnet-policy-service dotnet-policy-service Bot added the area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio label Oct 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The test compilation blocker needs correction, and persistent MTP programming requires hardware-backed human validation.

1 open issue
What changed in this PR

Adds an FT200X I2C slave binding using shared FTDI infrastructure.

Changes:

  • Adds USB FIFO access and explicit persistent address programming.
  • Extends shared FT-X transport and configuration support.
  • Adds tests, documentation, and a simulated temperature-sensor sample.
File Description
src/​devices/​FtCommon/​IFtXSeriesI2cSlaveTransport.cs Defines configuration operations.
src/​devices/​FtCommon/​IFtI2cSlaveTransport.cs Defines FIFO transport operations.
src/​devices/​FtCommon/​FtXSeriesI2cSlaveTransport.cs Implements native transport access.
src/​devices/​FtCommon/​FtXSeriesEeprom.cs Models FT-X configuration layout.
src/​devices/​FtCommon/​FtXSeriesConfiguration.cs Validates and compares configuration snapshots.
src/​devices/​FtCommon/​FtFunction.cs Adds native configuration and opening APIs.
src/​devices/​FtCommon/​FtEepromHeader.cs Models the common configuration header.
src/​devices/​FtCommon/​FtCommon.projitems Includes shared implementation files.
src/​devices/​FtCommon/​FtCommon.cs Handles enumeration failures.
src/​devices/​Ft200X/​tests/​TemperatureSensorTests.cs Tests sensor protocol behavior.
src/​devices/​Ft200X/​tests/​FtXSeriesConfigurationTests.cs Tests configuration copying and comparison.
src/​devices/​Ft200X/​tests/​Ft200XDeviceTests.cs Tests binding behavior and lifetime.
src/​devices/​Ft200X/​tests/​Ft200X.Tests.csproj Adds the test project.
src/​devices/​Ft200X/​samples/​TemperatureSensor.cs Implements the simulated sensor protocol.
src/​devices/​Ft200X/​samples/​Program.cs Demonstrates transfers and configuration.
src/​devices/​Ft200X/​samples/​Ft200X.sample.csproj Adds the sample project.
src/​devices/​Ft200X/​README.md Documents wiring, usage, and programming precautions.
src/​devices/​Ft200X/​Ft200XDevice.cs Implements the public binding.
src/​devices/​Ft200X/​Ft200X.slnx Groups development projects.
src/​devices/​Ft200X/​Ft200X.csproj Configures the binding project.
src/​devices/​Ft200X/​category.txt Categorizes the binding.

Review effort: Balanced

Comment thread src/devices/Ft200X/tests/Ft200XDeviceTests.cs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
/// Represents the native FT_EEPROM_X_SERIES layout, including its separately aligned common header.
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 4)]
internal struct FtXSeriesEeprom

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would ask the Copilot to provide the explicit offsets.
Inverting two of them screws up everything

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! And added the source as well of the struct in the intellisense struct somments. I made it for the 2 new ones.

@pgrawehr pgrawehr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Seems useful to simulate I2C devices for testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants