-
Notifications
You must be signed in to change notification settings - Fork 609
Description
TL;DR Reading more than 1 byte using the FT232H I2C bus result in a bus lock. The single byte reads work as expected.
I am writing a program to control a test bench which is equipped with several IO expanders (PCA9554), a temperature sensor SHT31 and and ADC (ADS7828). The bench is connected to the PC via a FT232H based cable. I am able to interact with the IOEXPs just fine, but when I need to read a temperature or an ADC channel the bus stalls. I investigated further on the ADC side and found that reading more than 1 byte results in a unusable bus.
The reading process is simple: write the channel you want to read, then read 2 bytes.
The hardware has been validated with a nucleo, which works as expected:
The above Logic2 captures are available: ft232h_dotnet.zip.
Steps to reproduce
Since the ADS7828 is not available in the library, I wrote my driver. I guess you can try to read more than 1 byte from any device and get the same issue.
public short Read(InputMultiplexer ch)
{
Span<byte> writeBuff = stackalloc byte[1]
{
ChannelToByte(ch)
};
Span<byte> readBuff = stackalloc byte[2];
i2cDevice.WriteRead(writeBuff, readBuff);
return BinaryPrimitives.ReadInt16BigEndian(readBuff);
}Expected behavior
It should be possible to read more than 1 byte while using the FT232H binding.
Versions used
dotnet --info
.NET SDK:
Version: 7.0.101
Commit: bb24aafa11
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.101\
Host:
Version: 7.0.1
Architecture: x64
Commit: 97203d38ba
.NET SDKs installed:
7.0.101 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
System.Device.Gpio2.3.0-prerelease.22520.10Iot.Device.Bindings2.3.0-prerelease.22520.10