Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 165 additions & 0 deletions src/devices/Ft232H/Ft2232HDevice.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Iot.Device.Common;
using Iot.Device.FtCommon;

namespace Iot.Device.Ft2232H
{
/// <summary>
/// FT232H Device
/// </summary>
public class Ft2232HDevice : Ftx232HDevice
{
/// <summary>
/// Gets all the FT2232H connected
/// </summary>
/// <returns>A list of FT2232H</returns>
public static List<Ft2232HDevice> GetFt2232H()
{
List<Ft2232HDevice> ft2232s = new List<Ft2232HDevice>();
var devices = FtCommon.FtCommon.GetDevices(new FtDeviceType[] { FtDeviceType.Ft2232H });
foreach (var device in devices)
{
ft2232s.Add(new Ft2232HDevice(device));
}

return ft2232s;
}

/// <summary>
/// Gets the pin number from a string
/// </summary>
/// <param name="pin">A string</param>
/// <returns>The pin number, -1 in case it's not found.</returns>
/// <remarks>Valid pins are ADBUS0 to 7, D0 to 7, ACBUS0 to 7, C0 to 7,
/// TCK, SK, CLK, MOSI, MISO, SDA, TDI, DI, TDO, DO,
/// TMS, CS, GPIOL0 to 3, GPIOH0 to 7</remarks>
public static int GetPinNumberFromString(string pin)
{
pin = pin.ToUpper();
switch (pin)
{
case "ADBUS0":
case "BDBUS0":
case "D0":
case "TCK":
case "SK":
case "CLK":
case "SDL":
return 0;
case "ADBUS1":
case "BDBUS1":
case "D1":
case "DO":
case "TDI":
case "SDA":
case "MOSI":
return 1;
case "ADBUS2":
case "BDBUS2":
case "D2":
case "DI":
case "TDO":
case "MISO":
return 2;
case "ADBUS3":
case "BDBUS3":
case "D3":
case "TMS":
case "CS":
return 3;
case "ADBUS4":
case "BDBUS4":
case "D4":
case "GPIOL0":
return 4;
case "ADBUS5":
case "BDBUS5":
case "D5":
case "GPIOL1":
return 5;
case "ADBUS6":
case "BDBUS6":
case "D6":
case "GPIOL2":
return 6;
case "ADBUS7":
case "BDBUS7":
case "D7":
case "GPIOL3":
return 7;
case "ACBUS0":
case "BCBUS0":
case "C0":
case "GPIOH0":
return 8;
case "ACBUS1":
case "BCBUS1":
case "C1":
case "GPIOH1":
return 9;
case "ACBUS2":
case "BCBUS2":
case "C2":
case "GPIOH2":
return 10;
case "ACBUS3":
case "BCBUS3":
case "C3":
case "GPIOH3":
return 11;
case "ACBUS4":
case "BCBUS4":
case "C4":
case "GPIOH4":
return 12;
case "ACBUS5":
case "BCBUS5":
case "C5":
case "GPIOH5":
return 13;
case "ACBUS6":
case "BCBUS6":
case "C6":
case "GPIOH6":
return 14;
case "ACBUS7":
case "BCBUS7":
case "C7":
case "GPIOH7":
return 15;
default:
return -1;
}
}

/// <summary>
/// Instantiates a FT2232H device object.
/// </summary>
/// <param name="flags">Indicates device state.</param>
/// <param name="type">Indicates the device type.</param>
/// <param name="id">The Vendor ID and Product ID of the device.</param>
/// <param name="locId">The physical location identifier of the device.</param>
/// <param name="serialNumber">The device serial number.</param>
/// <param name="description">The device description.</param>
public Ft2232HDevice(FtFlag flags, FtDeviceType type, uint id, uint locId, string serialNumber, string description)
: base(flags, type, id, locId, serialNumber, description)
{
}

/// <summary>
/// Instantiates a FT2232H device object.
/// </summary>
/// <param name="ftDevice">a FT Device</param>
public Ft2232HDevice(FtDevice ftDevice)
: base(ftDevice.Flags, ftDevice.Type, ftDevice.Id, ftDevice.LocId, ftDevice.SerialNumber, ftDevice.Description)
{
}
}
}
3 changes: 3 additions & 0 deletions src/devices/Ft232H/Ft232H.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
</PropertyGroup>

<ItemGroup>
<Compile Include="Ft2232HDevice.cs" />
<Compile Include="Ft232HDevice.cs" />
<Compile Include="Ft232HGpio.cs" />
<Compile Include="Ft232HI2c.cs" />
<Compile Include="Ft232HI2cBus.cs" />
<Compile Include="Ft232HSpi.cs" />
<Compile Include="Ft4232HDevice.cs" />
<Compile Include="Ftx232HDevice.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
19 changes: 13 additions & 6 deletions src/devices/Ft232H/Ft232H.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31515.178
# Visual Studio Version 17
VisualStudioVersion = 17.4.33205.214
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ft232H", "Ft232H.csproj", "{41A5516C-6799-4642-B20D-BEC14CF0B742}"
EndProject
Expand All @@ -17,11 +17,9 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "FtCommon", "..\FtCommon\FtC
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Board", "..\Board\Board.csproj", "{DF7F5D81-1F96-46A6-AB39-977A8522F6FA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tsl256x", "..\Tsl256x\Tsl256x.csproj", "{72A779D8-444D-4273-A759-652B71F76B60}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\FtCommon\FtCommon.projitems*{2f022801-b558-4395-a995-ef10628447b4}*SharedItemsImports = 13
..\FtCommon\FtCommon.projitems*{41a5516c-6799-4642-b20d-bec14cf0b742}*SharedItemsImports = 5
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Expand All @@ -43,6 +41,10 @@ Global
{DF7F5D81-1F96-46A6-AB39-977A8522F6FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DF7F5D81-1F96-46A6-AB39-977A8522F6FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DF7F5D81-1F96-46A6-AB39-977A8522F6FA}.Release|Any CPU.Build.0 = Release|Any CPU
{72A779D8-444D-4273-A759-652B71F76B60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{72A779D8-444D-4273-A759-652B71F76B60}.Debug|Any CPU.Build.0 = Debug|Any CPU
{72A779D8-444D-4273-A759-652B71F76B60}.Release|Any CPU.ActiveCfg = Release|Any CPU
{72A779D8-444D-4273-A759-652B71F76B60}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -52,8 +54,13 @@ Global
{7CC23CB9-7276-418B-8085-AA06AD7AC63B} = {D476679D-EBC5-406A-B293-93A65C8B58ED}
{2F022801-B558-4395-A995-EF10628447B4} = {07E992C0-1091-4A40-B1A0-71878D58140F}
{DF7F5D81-1F96-46A6-AB39-977A8522F6FA} = {07E992C0-1091-4A40-B1A0-71878D58140F}
{72A779D8-444D-4273-A759-652B71F76B60} = {D476679D-EBC5-406A-B293-93A65C8B58ED}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {ECE390DE-F924-422E-8D21-ABB498BA0D20}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\FtCommon\FtCommon.projitems*{2f022801-b558-4395-a995-ef10628447b4}*SharedItemsImports = 13
..\FtCommon\FtCommon.projitems*{41a5516c-6799-4642-b20d-bec14cf0b742}*SharedItemsImports = 5
EndGlobalSection
EndGlobal
Loading