How to determine the processor type that NETMF/TinyCLROS is running on

How to determine the processor type that NETMF/TinyCLROS is running on?

I’m writing a software SPI class. I’m trying to make is auto detect the type of processor that its on, so that when the user specifies SPI1, it will lookup the clock and data pins for that port per device. How do I know in code if the device I’m running on is a G120 or a G80?

1 Like

I have been begging for this! We need to strike to make this happen :sunglasses:


Would this be something to start with?

using System.Runtime.InteropServices;
> string s = DeviceInformation.DeviceName + " Version: " + DeviceInformation.Version.ToString();

> Debug.WriteLineIf(true, DeviceInformation.ManufacturerName);
> Debug.WriteLineIf(true, "Device: " + DeviceInformation.DeviceName + " Version: " +    DeviceInformation.Version.ToString());

> Debug.WriteLineIf(true, DeviceInformation.ManufacturerName.ToString() );

This only works on NETMF.

@willgeorge What assembly is that in?

I added the using System.Runtime.Interop services but the dev environment has no idea what DeviceInformation class is.

Going to see if this works when I go in to work later.


Noticed it when browsing the GHI hardware object model

That has a remark for the enum “to get the system model type…”

@willgeorge is correct for TinyCLR. For NETMF, @trent1098s found the correct way. The GHI.Processor.DeviceType enum value can be tested against Microsoft.SPOT.Hardware.SystemInfo.SystemID.Model.



I used it on a BrainPad Rev 1.2
I was using TinyCLR_0.5.0

Some version of NetMF may have a way but I could not find it.

The NETMF call I posted earlier this morning works fine

public class PinConfig 
    public Cpu.Pin InterruptPin1;
    public Cpu.Pin InterruptPin2;

public PinConfig(GHI.Processor.DeviceType mcu)
    switch (mcu)
        case GHI.Processor.DeviceType.G30:
                InterruptPin1 = GHI.Pins.G30.Gpio.PB2;
                InterruptPin2 = GHI.Pins.G30.Gpio.PB12;
        case GHI.Processor.DeviceType.G80:
                InterruptPin1 = GHI.Pins.G80.Gpio.PA10;
                InterruptPin2 = GHI.Pins.G80.Gpio.PC12;

Then later…

    GHI.Processor.DeviceType mcu = (GHI.Processor.DeviceType)Microsoft.SPOT.Hardware.SystemInfo.SystemID.Model;

    PinConfig = new PinConfig(mcu);

    //This will change depending on your particular MCU
    InterruptPort InterruptBankA = new InterruptPort(PinConfig.InterruptPin1, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);
    InterruptBankA.OnInterrupt += GPIOInterrupt;
    InterruptPort InterruptBankB = new InterruptPort(PinConfig.InterruptPin2, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);
    InterruptBankB.OnInterrupt += GPIOInterrupt;
1 Like

In TinyClr, when I retrieve version it is a ulong (1536 in dec). How to interpret this value ?

As bytes. 1536 dec is 0x000600 hex. This will likely change in a future release.

1 Like