Esempio n. 1
0
        /// <summary>
        /// A private callback function called when there is an interrupt generated from the sensor
        /// </summary>
        private void ADXL345_Interrupt_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            // Read the interrupt source register to see what caused the event
            var source = (InterruptSource)ReadRegister(RegisterMap.INT_SOURCE);

            if ((source & InterruptSource.FREE_FALL) == InterruptSource.FREE_FALL)
            {
                var onFf = OnFreefall;
                onFf(this, null);
            }

            if ((source & InterruptSource.DOUBLE_TAP) == InterruptSource.DOUBLE_TAP)
            {
                var onDt = OnDoubleTap;
                onDt(this, null);
                return;
            }

            if ((source & InterruptSource.SINGLE_TAP) == InterruptSource.SINGLE_TAP)
            {
                var onSt = OnSingleTap;
                onSt(this, null);
            }

            _int1.ClearInterrupt();
        }
Esempio n. 2
0
 static void prevButton_OnInterrupt(uint data1, uint data2, DateTime time)
 {
     _ledIndex--;
     ChangeLed();
     Send(_ledIndex.ToString() + "\r\n");
     _prevButton.ClearInterrupt();
 }
        public OnOffDigitalSensorMgr(GHI.Processor.DeviceType deviceType, int socketNumber, int pDstOffset, string pDstStart, string pDstEnd, string pSensorLabel = "undef", string pSensorLocation = "undef", string pMeasuredQuantity = "undef", string pDestinationTable = "undef", string pChannel = "000")
        {
            if ((deviceType != GHI.Processor.DeviceType.EMX) && (deviceType != GHI.Processor.DeviceType.G120E))
            {
                throw new NotSupportedException("Mainboard is not supported");
            }

            dstOffset = pDstOffset;
            dstStart  = pDstStart;
            dstEnd    = pDstEnd;

            SensorLabel      = pSensorLabel;
            SensorLocation   = pSensorLocation;
            MeasuredQuantity = pMeasuredQuantity;
            DestinationTable = pDestinationTable;
            Channel          = pChannel;


            input = new InterruptPort(deviceType == GHI.Processor.DeviceType.EMX ? GHI.Pins.FEZSpider.Socket4.Pin4 : GHI.Pins.FEZSpiderII.Socket4.Pin3, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);

            input.ClearInterrupt();
            input.DisableInterrupt();
            _stopped         = true;
            ReadBurnerThread = new Thread(runReadBurnerThread);
            ReadBurnerThread.Start();
        }
 private void daisyLinkInterruptPort_OnInterrupt(uint data1, uint data2, DateTime time)
 {
     for (byte moduleIndex = 0; moduleIndex < NodeCount; moduleIndex++)
     {
         if (0 != (0x80 & ReadRegister((byte)(moduleIndex + StartAddress), (byte)DaisyLinkRegister.Config)))       // If this is the interrupting module
         {
             byte[] data = new byte[] { (byte)DaisyLinkRegister.Config, 0 };
             Write((byte)(moduleIndex + StartAddress), data);                    // Clear the interrupt on the module
             if (socketModuleList[moduleIndex] != null)
             {
                 socketModuleList[moduleIndex].OnDaisyLinkInterrupt(socketModuleList[moduleIndex]);              // Kick off user event (if any) for this module instance
             }
         }
     }
     daisyLinkInterruptPort.ClearInterrupt();
 }
Esempio n. 5
0
        private void port_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            _port.DisableInterrupt();

            if (data2 > 0)
            {
                OnPressed();
            }
            else
            {
                OnReleased();
            }

            _port.EnableInterrupt();
            _port.ClearInterrupt();
        }
Esempio n. 6
0
 private void port_OnInterrupt(uint port, uint state, DateTime time)
 {
     if (state == 0) // falling edge, end of pulse
     {
         int pulseWidth = (int)time.Ticks - _ticks;
         // valid for 20°C
         //int pulseWidthMilliSeconds = pulseWidth * 10 / 582;
         //valid for 24°C
         _pulseWidthMm = (int)(pulseWidth / 58);
         //Debug.Print("Distance = " + pulseWidthMm.ToString() + " mm.");
         //_callback(pulseWidthMm);
         _reset.Set();
     }
     else
     {
         _ticks = (int)time.Ticks;
     }
     _echoPin.ClearInterrupt();
 }
Esempio n. 7
0
        public static void Main()
        {
            var leds = new[]
            {
                new OutputPort(Stm32F4Discovery.LedPins.Green, true),
                new OutputPort(Stm32F4Discovery.LedPins.Orange, true),
                new OutputPort(Stm32F4Discovery.LedPins.Red, true),
                new OutputPort(Stm32F4Discovery.LedPins.Blue, true)
            };

            var rotator = new LedRotator(leds);

            DirectionLed.Write(rotator.Right);

            UserButton.OnInterrupt += (u, data2, time) =>
            {
                rotator.ChangeDirection();
                DirectionLed.Write(rotator.Right);
                UserButton.ClearInterrupt();
            };

            Blink(leds, 6);
            rotator.Run();
        }
Esempio n. 8
0
 private static void port_OnInterrupt(uint port, uint state, TimeSpan time)
 {
     Debug.Print("Pin=" + port + " State=" + state + " Time=" + time);
     interruptPort.ClearInterrupt();
 }
Esempio n. 9
0
 static void S0PulseReceived(uint data1, uint data2, DateTime time)
 {
     s0Counter++;
     s0Port.ClearInterrupt();
 }
Esempio n. 10
0
 private void OnGoBusIrq(UInt32 data1, UInt32 data2, DateTime timestamp)
 {
     GoBusIrqPort.ClearInterrupt();
     GoBusIrqEvent.Set();
 }
Esempio n. 11
0
 void DataReady_OnInterrupt(uint data1, uint data2, DateTime time)
 {
     Hardware.SPIBus.WriteRead(_spiConfig, new[] { Control.Read }, _rBuffer, 1);
     _dataReady.ClearInterrupt();
     _canSend = true;
 }
Esempio n. 12
0
 private void OnInterrupt(uint data1, uint data2, DateTime time)
 {
     listeners(data2 == 0, time);
     sensorPort.ClearInterrupt();
 }