Skip to content

Commit

Permalink
Added auto-detection of current configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
bcr committed Jan 9, 2011
1 parent 5a61c26 commit 9aa0d92
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion FpgaFlashLoader/FpgaFlashLoader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,31 @@ private class ShieldConfiguration
OnboardLedPin = FezConstants.LED
};

private static ShieldConfiguration CurrentShieldConfiguration = FezShieldConfiguration;
private static ShieldConfiguration CurrentShieldConfiguration = null;

// SetupCurrentShieldConfiguration is a little fragile -- it uses
// SetupCurrentShieldConfiguration.SystemInfo.OEMString to try and
// figure out which configuration to use. If that string isn't
// handled, you will not survive.

private static void SetupCurrentShieldConfiguration()
{
var solutionVendorInfo = SystemInfo.OEMString;

switch (solutionVendorInfo)
{
case "GHI Electronics, LLC":
CurrentShieldConfiguration = FezShieldConfiguration;
break;

case "Netduino by Secret Labs LLC":
CurrentShieldConfiguration = NetduinoShieldConfiguration;
break;

default:
break;
}
}

public static IEnumerator GetResources()
{
Expand Down Expand Up @@ -121,6 +145,8 @@ public UploadStatusIndicator(Cpu.Pin redLedPin, Cpu.Pin greenLedPin)

public static void Main()
{
SetupCurrentShieldConfiguration();

OutputPort onboardLed = new OutputPort(CurrentShieldConfiguration.OnboardLedPin, true);

SPI.Configuration spiConfig = new SPI.Configuration(
Expand Down

0 comments on commit 9aa0d92

Please sign in to comment.