-
Notifications
You must be signed in to change notification settings - Fork 606
Improve FT232H, add FT2232H and FT4232H #2019
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3a7373a
adjusting
Ellerbach 39a95e1
adding sample
Ellerbach 24af456
Merge branch 'main' of https://github.com/dotnet/iot into improve-ft232h
Ellerbach 4f40d2b
Adding support for FT2232H and FT4232H
Ellerbach 274aab3
fix doc nit
Ellerbach e28e990
adjusting comments
Ellerbach 0b05135
distinct elements in FtCommon only
Ellerbach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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) | ||
{ | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.