Main Site Documentation

How to determine board type in code


I want my program to run on a Domiino and a Mini/Panda.

I’ve added both assemblies, how do I check which board its running on to set PINs?


I’ve been looking at this…

It seems that GHIElectronics.NETMF.FEZ_Type is just an enumeraton

But GHIElectronics.NETMF.System.SystemModelType returns USBizi 100 pin or 144 pin. Will this do you.

Cheers Ian


I dont think it will help, heres the problem.

If your app references both Domino and Panda assemblies, the following line of code does not know which FEZ_Pin to reference

statusLED = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.An5, true);


So, I think there needs to be an if/switch statement, to say, if app is running on Domino use PIN_X and if app is running on Panda use PIN_Y.

I’ve seen this done before just can’t remember where?

Might it be a compiler directive statement or something??


As far as I know the GHI demo uses this method too. But they use it for emx/chipworkx?


That won’t matter, will it? If you’ve found out whether its a 100 or 144 pin you’ll just double up on the initailisation’s. I thought that was what you were going todo.

Its a shame we can’t conditionally include an assembly.

Actually we can… just have the board specific data in two classes DOM.cs and PAN.cs and create the class according to board type.

GHIElectronics.NETMF.System.getSystemType() will return the board type, and then include the class to which is relevant.

Cheers Ian


Is it something like this…

if (FEZ.FEZ_System.GetSystemType() == FEZ_Type.Domino)
   _spi = new SPI(new SPI.Configuration((Cpu.Pin)FEZ_Pin.Digital.UEXT10, false, 0, 0, true, true, 200,SPI.SPI_module.SPI2));
else if (FEZ.FEZ_System.GetSystemType() == FEZ_Type.Mini)
   _spi = new SPI(new SPI.Configuration((Cpu.Pin)FEZ_Pin.Digital.UEXT10, false, 0, 0, true, true, 100,SPI.SPI_module.SPI1));
   throw new Exception("Unknown System Type!");


@ Sam You will still need the correct references… Class 1 will use FEZPanda_GHIElectronics.NETMF.FEZ reference and class 2 will use FEZDomino_GHIElectronics.NETMF.FEZ reference.

Otherwise the pins will be enumerated incorrectly.

Cheers Ian


This is the problem, if you reference both domino and panda dll’s, the FEZ_Pin become ambiguous?

How do you get around this, without having two different apps, one for domino and one for panda?


These are not intended to be used together… To solve this, as Ian said, there is GHIElectronics.NETMF.System.getSystemType().

if(GHIElectronics.NETMF.System.getSystemType() == USBizi144) // Domino
InputPort p = new InputPort(DOMINO_FEZ_PIN,…)
else if(GHIElectronics.NETMF.System.getSystemType() == USBizi100) // Panda
InputPort p = new InputPort(PANDA_FEZ_PIN,…)


To get the pin numbers, for FEZ Domio add the FEZ Domino reference. Then right click on FEZ_PIN and select go to definition.
Under it, you will see the internal definitions:

In Domino:
"public enum Digital
LDR = 0,
UEXT6 = 1,…etc"
Copy this and paste in your code. Rename the enum to DOMINO_FEZ_PIN or anything you like and so on…


I agreed!

Thanks Mike. A new things to learn everyday! :slight_smile: