Main Site Documentation

Netduino 3


#1

I try a simple blinking app on netduino 3:

static void Main()
        {
            GpioPin _led = GpioController.GetDefault().OpenPin(32+13, GpioSharingMode.Exclusive);
            _led.SetDriveMode(GpioPinDriveMode.Output);
            while (true)
            {
                _led.Write(GpioPinValue.High);
                Thread.Sleep(200);
                _led.Write(GpioPinValue.Low);
                Thread.Sleep(800);
            }
        }

But I’m not sure of pinout for led or pwr_led. If someone has them … I think led is pa10 (so pin 10) and power_led is pc13 (so pin 32+13). But nothing happens. I’m wrong with assumed pin number ?


#2

Would anything in here help?


#3

How about this?

namespace GHIElectronics.TinyCLR.Pins {
    /// <summary>Board definition for the Netduino3.</summary>
    public static class Netduino3 {
        /// <summary>GPIO pin definitions.</summary>
        public static class GpioPin {

            /// <summary>Debug LED definition</summary>
            public const int Led = STM32F4.GpioPin.PA10;
            public const int PowerLed = STM32F4.GpioPin.PC13;

            /// <summary>SD Card Dectect definition</summary>
            public const int SdCardDetect = STM32F4.GpioPin.PB2;
            public const int SdCardPwrCtrl = STM32F4.GpioPin.PB1;
            
            /// <summary>GPIO pin.</summary>
            public const int D0 = STM32F4.GpioPin.PC7;
            /// <summary>GPIO pin.</summary>
            public const int D1 = STM32F4.GpioPin.PC6;
            /// <summary>GPIO pin.</summary>
            public const int D2 = STM32F4.GpioPin.PA3;
            /// <summary>GPIO pin.</summary>
            public const int D3 = STM32F4.GpioPin.PA2;
            /// <summary>GPIO pin.</summary>
            public const int D4 = STM32F4.GpioPin.PB12;
            /// <summary>GPIO pin.</summary>
            public const int D5 = STM32F4.GpioPin.PB8;
            /// <summary>GPIO pin.</summary>
            public const int D6 = STM32F4.GpioPin.PB9;
            /// <summary>GPIO pin.</summary>
            public const int D7 = STM32F4.GpioPin.PA1;
            /// <summary>GPIO pin.</summary>
            public const int D8 = STM32F4.GpioPin.PA0;
            /// <summary>GPIO pin.</summary>
            public const int D9 = STM32F4.GpioPin.PE5;
            /// <summary>GPIO pin.</summary>
            public const int D10 = STM32F4.GpioPin.PB10;
            /// <summary>GPIO pin.</summary>
            public const int D11 = STM32F4.GpioPin.PB15;
            /// <summary>GPIO pin.</summary>
            public const int D12 = STM32F4.GpioPin.PB14;
            /// <summary>GPIO pin.</summary>
            public const int D13 = STM32F4.GpioPin.PB13;
            /// <summary>GPIO pin.</summary>
            public const int A0 = STM32F4.GpioPin.PC0;
            /// <summary>GPIO pin.</summary>
            public const int A1 = STM32F4.GpioPin.PC1;
            /// <summary>GPIO pin.</summary>
            public const int A2 = STM32F4.GpioPin.PC2;
            /// <summary>GPIO pin.</summary>
            public const int A3 = STM32F4.GpioPin.PC3;
            /// <summary>GPIO pin.</summary>
            public const int A4 = STM32F4.GpioPin.PC4;
            /// <summary>GPIO pin.</summary>
            public const int A5 = STM32F4.GpioPin.PC5;

            /// <summary>Socket definition.</summary>
            public static class GoPort1 {
                /// <summary>Pin definition.</summary>
                public const int Pin3 = STM32F4.GpioPin.PD13;
                /// <summary>Pin definition.</summary>
                public const int Pin4 = STM32F4.GpioPin.PD8;
                /// <summary>Pin definition.</summary>
                public const int Pin5 = STM32F4.GpioPin.PD9;
                /// <summary>Pin definition.</summary>
                public const int Pin6 = STM32F4.GpioPin.PD0;
                /// <summary>LED definition.</summary>
                public const int Led = STM32F4.GpioPin.PE9;
                /// <summary>Power On definition.</summary>
                public const int PwrOn = STM32F4.GpioPin.PD7;
            }

            /// <summary>Socket definition.</summary>
            public static class GoPort2 {
                /// <summary>Pin definition.</summary>
                public const int Pin3 = STM32F4.GpioPin.PD14;
                /// <summary>Pin definition.</summary>
                public const int Pin4 = STM32F4.GpioPin.PE8;
                /// <summary>Pin definition.</summary>
                public const int Pin5 = STM32F4.GpioPin.PE7;
                /// <summary>Pin definition.</summary>
                public const int Pin6 = STM32F4.GpioPin.PD1;
                /// <summary>LED definition.</summary>
                public const int Led = STM32F4.GpioPin.PE11;
                /// <summary>Power On definition.</summary>
                public const int PwrOn = STM32F4.GpioPin.PD10;
            }

            /// <summary>Socket definition.</summary>
            public static class GoPort3 {
                /// <summary>Pin definition.</summary>
                public const int Pin3 = STM32F4.GpioPin.PD15;
                /// <summary>Pin definition.</summary>
                public const int Pin4 = STM32F4.GpioPin.PE1;
                /// <summary>Pin definition.</summary>
                public const int Pin5 = STM32F4.GpioPin.PE0;
                /// <summary>Pin definition.</summary>
                public const int Pin6 = STM32F4.GpioPin.PD2;
                /// <summary>LED definition.</summary>
                public const int Led = STM32F4.GpioPin.PB0;
                /// <summary>Power On definition.</summary>
                public const int PwrOn = STM32F4.GpioPin.PE14;
            }
        }

        /// <summary>Analog channel definition.</summary>
        public static class AdcChannel {
            /// <summary>Pin definition.</summary>
            public const int A0 = STM32F4.AdcChannel.Channel10;
            /// <summary>Pin definition.</summary>
            public const int A1 = STM32F4.AdcChannel.Channel11;
            /// <summary>Pin definition.</summary>
            public const int A2 = STM32F4.AdcChannel.Channel12;
            /// <summary>Pin definition.</summary>
            public const int A3 = STM32F4.AdcChannel.Channel13;
            /// <summary>Pin definition.</summary>
            public const int A4 = STM32F4.AdcChannel.Channel14;
            /// <summary>Pin definition.</summary>
            public const int A5 = STM32F4.AdcChannel.Channel15;      
        }

        /// <summary>Uart port definition.</summary>
        public static class UartPort {

            /// <summary>Socket definition.</summary>
            public const string GoPort1 = STM32F4.UartPort.Usart3;
            /// <summary>Socket definition.</summary>
            public const string GoPort2 = STM32F4.UartPort.Uart7;
            /// <summary>Socket definition.</summary>
            public const string GoPort3 = STM32F4.UartPort.Uart8;

            /// <summary>UART D0 (RX) and D1 (TX).</summary>
            public const string Uart6 = STM32F4.UartPort.Uart6;
        }

        /// <summary>SPI Bus definition.</summary>
        public static class SpiBus {

            /// <summary>Socket definition.</summary>
            public const string GoPort1 = STM32F4.SpiBus.Spi4;
            public const string GoPort2 = STM32F4.SpiBus.Spi4;
            public const string GoPort3 = STM32F4.SpiBus.Spi4;
            public const string Spi2 = STM32F4.SpiBus.Spi2;          
        }
    }
}

#4

and see this please http://docs.ghielectronics.com/tinyclr/tutorials/gpio.html


#5

You are the man :nerd: I do not care what @Gary_Beaver says!


#6

did you tried

using System;
using System.Threading;
using GHIElectronics.TinyCLR.Devices.Gpio;

class Program
{
static void Main()
{
GpioPin led = GpioController.GetDefault().OpenPin(45); //your call is different there
//PC13 = equivalent 216+13 for power led or pa10 = 016+10 = 10 for led
led.SetDriveMode(GpioPinDriveMode.Output);

    while(true)
    {
        led.Write(GpioPinValue.High);
        Thread.Sleep(100);
        led.Write(GpioPinValue.Low);
        Thread.Sleep(100);
    }
}

}


#7

Thanks for all responses, but no one is going in the right direction … And before saying what has happened, I would like you all know that the first one who is laughing … is in right direction !
To test netduino, I’ve created two projects in same solution, and blinking project is second project. I forget to set this as startup project, so when pressing start debug, Nothing is blinking led !!!

I’m just an idiot !:confused:


#8

@valon_hoti_gmail_com : For power_led: pc13 --> 32+13 or 2*16+13 or 45 is same value !


#9

(your code)
GpioPin _led = GpioController.GetDefault().OpenPin(32+13, GpioSharingMode.Exclusive);

code i provided
GpioPin led = GpioController.GetDefault().OpenPin(45); //there no GpioSharingMode.Exclusive you applied


#10

GpioSharingMode.Exclusive or GpioSharingMode.Shared or nothing doesn’t change behaviour with just a blinking led.
But I admit that when I read your previous message, I was thinking that change you talk was from value and not sharing mode.


#11

Where can I find definition for STM32F4 class ?


#12

in Device/Netduino3/DeviceSelector.h


#13

For managed code, I would say. I know I can rewrite it but if it is already written, I would prefer to copy it ! :slight_smile:


#14

for netduino 3 check GREG above have posted link

otherwise i have writted it for nucleo so you cold modify for yourselves

https://github.com/valoni/TinyCLR-Ports/blob/master/Devices/NUCLEO411RET6/Helps/csharp/STM32F411NUCLEO.cs


#15

It is included in the coming 0.6 release


#16

@Gus_Issa

did is include Nucleo STM32F411RET6 or just official GHI Electronics officially supported files


#17

It is the master STM32F4 file to cover everything. It is Generic and should be the base for everything STM32, including nucleo and discovery.