示例#1
0
        public static void Main()
        {
            // Defining two 74HC165s daisychained on the SPI bus, pin 10 as latchpin
            Ic74hc165 IcInChain = new Ic74hc165(SPI_Devices.SPI1, Pins.GPIO_PIN_D10, 2);

            // Defining two 74HC595s daisychained on the SPI bus, pin 9 as latchpin
            Ic74hc595 IcOutChain = new Ic74hc595(SPI_Devices.SPI1, Pins.GPIO_PIN_D9, 2);

            // Defines all 16 leds
            for (uint Counter = 0; Counter < 16; ++Counter)
            {
                Leds[Counter] = IcOutChain.Pins[Counter];
            }

            // Defines all 16 buttons
            IIRQPort[] Buttons = new IIRQPort[16];
            for (uint Counter = 0; Counter < 16; ++Counter)
            {
                Buttons[Counter] = IcInChain.Pins[Counter];
                Buttons[Counter].OnStateChange += new StateChange(Program_OnStateChange);
                Buttons[Counter].ID = Counter.ToString();
            }

            // Enables interrupts
            IcInChain.EnableInterrupts();

            // Wait infinite; let the events to their jobs
            Thread.Sleep(Timeout.Infinite);
        }