How to deploy TinyCLR to FEZ Raptor and porting the Gadgeteer modules drivers to TinyCLR

Hello friends,

In this video I will show you how to deploy TinyCLR to the Fez Raptor.

please join me to port all of gadgeteer modules drivers to TinyCLR, I have setup the code repository in , this project will be dedicated to the .NET gadgeteer fans :wink:


Great. Glad to see Gadgeteer working with VS2017, thanks to TinyCLR OS :slight_smile:

1 Like

Some correction to update bootloader.
[ul]Download G400 bootloader installer (make sure 2016 SDK is install with g400 Tools).
G400 Bootloader.2.0.2.bin in G400 bootlader installer directory.
Update Bootloader.tcl file with new name: replace booloader.bin with G400 Bootloader.2.0.2.bin.
Connect pin 8 on socket 3 to ground. Press reset and after 3 sec remove connection on this pin.
Open a command line (for me, it can’t work when just launch Flash booloader.bat with double-click on it) and launch .bat file.
Wait some minutes until Bootloader complete message appears.[/ul]


@ Bauland - Thanks for the correction…

More Drivers for Gadgeteer TinyCLR:

Serial Camera L1 - failed… (need more time)

source code here : [url][/url]


More drivers today for Gadgeteer TinyCLR…
-DisplayNHVN (new haven module) - I use Dave touch controller driver for the capacitive touch, thanks mate :wink:
-AccelG248 (accelerometer)

source code here : GitHub - Gravicode/GadgeteerToTinyCLR: This is our effort to port gadgeteer modules/mainboards to TinyCLR

Serial Camera L1 : I need to wait for the next TinyCLR release because there is a few methods/properties that doesn’t have an implementation in Serial Communication Class


New drivers…

-PulseOximeter (waiting for serial com. implementation ready)
-Motor Driver L298
-Pulse Count

get: GitHub - Gravicode/GadgeteerToTinyCLR: This is our effort to port gadgeteer modules/mainboards to TinyCLR

1 Like

This reminds me of the request of getting a shared open source repository of drivers somewhere on github, is anyone digging into that? :whistle:

Today’s update…

more drivers…
-MaxO (there is a bug when initialize the SPI, please help)
-Xbee Adapter (waiting for serial com. impl. completed)
-Touch C8
-Breakout TB10

get: GitHub - Gravicode/GadgeteerToTinyCLR: This is our effort to port gadgeteer modules/mainboards to TinyCLR


@ mifmasterz - bug?

@ Gus - yes, bug in my code, when I try to create spi device from id : ‘SPI1’. I have tried spi mode 0 to spi mode 3, I got the same error. suggestion ?

@ mifmasterz - please provide simple code that isolates that one issue.

this is my last commit while waiting for the next TinyCLR release… (and I need your help to fix driver for MaxO and VideoOut)

more drivers:
-Relay X1
-VideoOut (I have got a problem when calling setdisplayconfiguration) -> if (ud != 0x55 && ud != 0x54) this.ErrorPrint(“Setting the display configuration failed.”); Can I configure SDA and SCL pins manually with TinyCLR ? )
-CellularRadio (waiting for serial com. implementation and PPPSerialModem)
-RFID (waiting for serial com. implementation complete)

I can’t continue to these modules till usb host, filesystem, networking are ready






I’ve bug in initialize SPI to, but maybe I initialize it wrong way:

        public DisplayN18(string spiControllerName, int digitalResetPin3, int digitalBackLightPin4, int digitalRsPin5, int digitalCsPin6)
            _orientation = DisplayOrientation.Normal;

            _byteArray = new byte[1];
            _shortArray = new ushort[2];
            _isBgr = true;

            var controller = GpioController.GetDefault();

            _resetPin = controller.OpenPin(digitalResetPin3);

            _backlightPin = controller.OpenPin(digitalBackLightPin4);

            _rsPin = controller.OpenPin(digitalRsPin5);

            //spiConfig = new GTI.SpiConfiguration(false, 0, 0, false, true, 12000);
            //netMFSpiConfig = new SPI.Configuration(this.socket.CpuPins[6], spiConfig.IsChipSelectActiveHigh, spiConfig.ChipSelectSetupTime, spiConfig.ChipSelectHoldTime, spiConfig.IsClockIdleHigh, spiConfig.IsClockSamplingEdgeRising, spiConfig.ClockRateKHz, this.socket.SPIModule);
            //spi = GTI.SpiFactory.Create(this.socket, spiConfig, GTI.SpiSharing.Shared, this.socket, Socket.Pin.Six, this);

            var settings = new SpiConnectionSettings(1)
                ClockFrequency = 10000000, // 10 000 kHz
                Mode = SpiMode.Mode0,
                SharingMode = SpiSharingMode.Shared
            //clock polarity = false, clock phase = true                                  

            string spiAqs = SpiDevice.GetDeviceSelector(spiControllerName);
            var devicesInfo = DeviceInformation.FindAll(spiAqs);
            _dev = SpiDevice.FromId(devicesInfo[0].Id, settings);


Exception raises on line:

 _dev = SpiDevice.FromId(devicesInfo[0].Id, settings);

with following message:

 #### Exception System.ArgumentException - 0x00000000 (1) ####
    #### Message: 
    #### GHIElectronics.TinyCLR.Devices.Spi.SpiDevice::FromId [IP: 002b] ####

I’ve forget to say that I’m using FEZ Spider II with N18 on socket 6.

Here is how I am initializing a ST7735 display same as the N18 . In my code, I an using fixed pins and SPI2 but you can modify to accommodate your configuration.

        public ST7735()
            var gpio = GpioController.GetDefault();

            ControlPin = gpio.OpenPin(G80.GpioPin.PE10);

            ResetPin = gpio.OpenPin(G80.GpioPin.PE12);

            BacklightPin = gpio.OpenPin(G80.GpioPin.PC7);

            // Initialize SPI
            var spiConnectionSettings = new SpiConnectionSettings(G80.GpioPin.PD10) { ClockFrequency = 48000000, Mode = SpiMode.Mode3, DataBitLength = 8, SharingMode = SpiSharingMode.Shared };

            var devices = DeviceInformation.FindAll();

            for (var x = 0; x < devices.Length; x++)
                if (devices[x].Id == "SPI2")
                    Spi = SpiDevice.FromId(devices[x].Id, spiConnectionSettings);

            Backlight = true;



Thank you very much, my mistakes were to not define DataBitLength and to initialize SpiConnectionSettings with 0 (in NETMF, it must be 0).
Now it’s working.

1 Like

@ Bauland - Thanks, now MaxO driver is working as expected :wink:

Video Out, I have ported from the latest driver as John suggest in this post :
but it’s still returning “Setting the display configuration failed”


@ Bauland - Thanks, now MaxO driver is working as expected ;)[/quote]
Good news !

Sorry but I don’t own this module to help you.

@ mifmasterz

Take a look at your code at Line 197. Put in a breakpoint at this line and see what the value of ud is.

In line 198, you are testing for ud to be not both equal to either 0x55 and 0x54.

 if (ud != 0x55 && ud != 0x54)
                this.ErrorPrint("Setting the display configuration failed.");

This will always return true as a single byte cannot be both two values at once. Perhaps you mean to be testing with a Logical OR || rather than a Logical AND &&

@ scardinale - A variable can be not equal to two different values. It can’t be equal to two different values.