Main Site Documentation

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


#1

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 https://github.com/Gravicode/GadgeteerToTinyCLR , this project will be dedicated to the .NET gadgeteer fans :wink:


Want to help with Gadgeteer?
#2

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


#3

Some correction to update bootloader.
[ul]Download G400 bootloader installer (make sure 2016 SDK is install with g400 Tools).
Copy
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]


#4

@ Bauland - Thanks for the correction…

More Drivers for Gadgeteer TinyCLR:
Tunes
DisplayT35
LEDStrip
Joystick

Serial Camera L1 - failed… (need more time)

source code here : https://github.com/Gravicode/GadgeteerToTinyCLR


#5

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)
-CharacterDisplay
-CurrentACS712
-Gyro
-RotaryH1

source code here : https://github.com/Gravicode/GadgeteerToTinyCLR

Note:
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


#6

New drivers…

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

get: https://github.com/Gravicode/GadgeteerToTinyCLR


#7

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


#8

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: https://github.com/Gravicode/GadgeteerToTinyCLR


#9

@ mifmasterz - bug?


#10

@ 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 ?


#11

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


#12

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

SDCard

WifiRS21

USBHost

ENC28


#13

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);
            _resetPin.SetDriveMode(GpioPinDriveMode.Output);

            _backlightPin = controller.OpenPin(digitalBackLightPin4);
            _backlightPin.SetDriveMode(GpioPinDriveMode.Output);

            _rsPin = controller.OpenPin(digitalRsPin5);
            _rsPin.SetDriveMode(GpioPinDriveMode.Output);

            //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);

            Reset();
...

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] ####
   


#14

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


#15

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);
            ControlPin.SetDriveMode(GpioPinDriveMode.Output);

            ResetPin = gpio.OpenPin(G80.GpioPin.PE12);
            ResetPin.SetDriveMode(GpioPinDriveMode.Output);

            BacklightPin = gpio.OpenPin(G80.GpioPin.PC7);
            BacklightPin.SetDriveMode(GpioPinDriveMode.Output);

            // 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);
                }
            }

            Reset();
            Initialize();
            Backlight = true;
        }

   



#16

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.


#17

@ 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 : https://www.ghielectronics.com/community/forum/topic?id=18613&page=2
but it’s still returning “Setting the display configuration failed”


#18

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

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


#19

@ 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 &&


#20

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