Main Site Documentation

Writing my own class to match Header pin # with GPIO #


#1

I received my first Rhino, about a week ago and have not been able to even turn it on untill today and at first i was stumped when i would plug something into what i though was pin1 and nothing happened and looking at the brochure i realized the header numbers and pin numbers do not match and infact the are in some random order i am guessing for trace routing purposes , so i am trying to write a class that i could use to make my life simpler instead of ahving to go back and forth looking at the pin mapping.
but i am unsure how to go about it…
i want something along the lines of


public static class MyPins
{
public const Cpu.Pin StatusLED = Cpu.Pin.GPIO_Pin0;
public const Cpu.Pin UpButton = Cpu.Pin.GPIO_Pin1;
public const Cpu.Pin DowButton = Cpu.Pin.GPIO_Pin2;
public const Cpu.Pin Ser1Rx = Cpu.Pin. GPIO_Pin9;
public const Cpu.Pin Ser1Tx = Cpu.Pin. GPIO_Pin10;
}

but not exactly like that i do not want to have to type or paste this in every project i want to simply reference it as an assembly and use it like that …so how would i go about this…where to save it perhaps some insight on how the code might be structured


#2

If you look at how GHI define the pins then it might help. I copied their layout and adapted things. This is what I ended up with:

using System;
namespace GHIElectronics.NETMF.HEX
{
    public static class HEX_Pin
    {

        public enum AnalogIn
        {
            Servo4 = 0,
            Servo3 = 1,
            Servo2 = 2,
            Servo1 = 3,
        }

        public enum AnalogOut
        {
            Servo1 = 0,
        }

        public enum Digital
        {
            LDR = 0,
            Servo1 = 22,
            Servo2 = 24,
            Servo3 = 26,
            Servo4 = 28,
            Servo5 = 55,
            Servo6 = 53,
            Servo7 = 51,
            Servo8 = 52,
            Servo9 = 54,
            Servo10 = 1,
            Servo11 = 3,
            Servo12 = 5,
            Servo13 = 16,
            Servo14 = 14,
            Servo15 = 12,
            Servo16 = 10,
            Servo17 = 8,
            Servo18 = 6,

            Mode=4,

            FuelGauge=35,
            UServoB_OK=68,
            CHRG=69,
            I2C_INT=25,
            LED=57

        }


        public enum Interrupt
        {
            LDR = 0,
            Servo1 = 22,
            Servo2 = 24,
            Servo3 = 26,
            Servo4 = 28,
            Servo10 = 1,
            Servo11 = 3,
            Servo12 = 5,
            Servo13 = 16,
            Servo14 = 14,
            Servo15 = 12,
            Servo16 = 10,
            Servo17 = 8,
            Servo18 = 6,
            Mode = 4,
        }

        public enum PWM
        {
        }
    }
}

I’m not in front of my development PC so please excuse errors, but if you include a ref to GHI.Hardware.USBizi then you should have more or less the same type of class that gives you the pins for all the IOxx pins…