Esempio n. 1
0
        public static void Run()
        {
            var servo = new ServoController(Pins.GPIO_PIN_D9, 600, 3000);

            var button = new InterruptPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);

            button.OnInterrupt += (data1, data2, time) =>
            {
                //servo.Duration = 1500;
                if (data2 == 1)
                {
                    servo.Rotate(100);
                }
                else
                {
                    servo.Rotate(0);
                }
            };

            while (Debugger.IsAttached)
            {
                Thread.Sleep(1000);
            }

            button.Dispose();
            servo.Dispose();
        }
Esempio n. 2
0
 protected override void Dispose(bool disposing)
 {
     // high level objects
     FatFs.Dispose();
     UsartPort.Dispose();
     I2cPort.Dispose();
     AnalogChannels.Dispose();
     AnalogChannels = null;
     Counters.Dispose();
     Counters = null;
     // lower level objects
     StopInterruptMonitor();
     Spi.Dispose();
     GoBusIrqPort.Dispose();
     SendContext.Dispose();
     ReceiveContext.Dispose();
     Timers.Clear();
     Timers        = null;
     Gpios         = null;
     _spiRxBuffer  = null;
     GoBusIrqEvent = null;
     InterruptCounterMonitorTerminateEvent = null;
     SetSocketPowerState(false);
     base.Dispose(disposing);
 }
Esempio n. 3
0
 protected void Dispose(bool disposing)
 {
     if (null != _fifoPort)
     {
         _fifoPort.Dispose(); _fifoPort = null;
     }
     if (null != _fifopInterrupt)
     {
         _fifopInterrupt.Dispose(); _fifopInterrupt = null;
     }
     if (null != _sfdInterrupt)
     {
         _sfdInterrupt.Dispose(); _sfdInterrupt = null;
     }
     if (null != _resetPort)
     {
         _resetPort.Dispose(); _resetPort = null;
     }
     if (null != _ccaPort)
     {
         _ccaPort.Dispose(); _ccaPort = null;
     }
     if (null != _powerPort)
     {
         _powerPort.Dispose(); _powerPort = null;
     }
     if (null != _spi)
     {
         lock (_spi)
         {
             _spi.Dispose();
             _spi = null;
         }
     }
 }
Esempio n. 4
0
 /// <summary>
 ///     Configure the interrupts for the ADXL362.
 /// </summary>
 /// <remark>
 ///     Set the interrupt mask for interrupt pins 1 and 2 and connect Netduino
 ///     pins to the interrupt pins on the ADXL362 if requested.
 ///
 ///     Interrupts can be disabled by passing 0 for the interrupt maps.  It is also
 ///     possible to disconnect the Netduino and ADXL362 by setting the interrupt pin
 ///     to GPIO_NONE.
 /// </remark>
 /// <param name="interruptMap1">Bit mask for interrupt pin 1</param>
 /// <param name="interruptPin1">Pin connected to interrupt pin 1 on the ADXL362.</param>
 /// <param name="interruptMap2">Bit mask for interrupt pin 2</param>
 /// <param name="interruptPin2">Pin connected to interrupt pin 2 on the ADXL362.</param>
 public void ConfigureInterrupts(byte interruptMap1, Cpu.Pin interruptPin1, byte interruptMap2 = 0, Cpu.Pin interruptPin2 = Cpu.Pin.GPIO_NONE)
 {
     _interrupt1?.Dispose();
     _interrupt2?.Dispose();
     _adxl362.WriteBytes(new byte[] { Command.WriteRegister, interruptMap1, interruptMap2 });
     if (interruptPin1 != Cpu.Pin.GPIO_NONE)
     {
         _interrupt1 = new InterruptPort(interruptPin1, false, MapResistorMode((interruptMap1 & 0xf0) > 0),
                                         MapInterruptMode((interruptMap1 & 0xf0) > 0));
         _interrupt1.OnInterrupt += SensorInterrupt;
     }
     else
     {
         _interrupt1 = null;
     }
     if (interruptPin2 != Cpu.Pin.GPIO_NONE)
     {
         _interrupt2 = new InterruptPort(interruptPin1, false, MapResistorMode((interruptMap2 & 0xf0) > 0),
                                         MapInterruptMode((interruptMap2 & 0xf0) > 0));
         _interrupt2.OnInterrupt += SensorInterrupt;
     }
     else
     {
         _interrupt2 = null;
     }
 }
Esempio n. 5
0
 public void Dispose()
 {
     if (_interruptCreatedInternally)
     {
         InterruptPort?.Dispose();
         InterruptPort = null;
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Releases resources used by a serial port.
 /// </summary>
 public override void Dispose()
 {
     if (_busy != null)
     {
         _busy.Dispose();                // release the hardware flow control pin, if used
     }
     base.Dispose();
 }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         // dispose managed resources
         port.Dispose();
     }
     // free native resources
 }
Esempio n. 8
0
            public Axis(Cpu.Pin pin, Cpu.AnalogChannel analogChannel, double voltage)
            {
                _voltage = voltage;

                var ax = new InterruptPort(pin, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);

                ax.Dispose();

                _analogInput = new AnalogInput(analogChannel);
            }
Esempio n. 9
0
        public void Dispose()
        {
            lock (_syncRoot)
            {
                _disposing = true;

                _trigger.Dispose();
                _echo.Dispose();
            }
        }
Esempio n. 10
0
 public void Dispose() {
     Spi.Dispose();
     GoBusIrqPort.Dispose();
     SendContext.Dispose();
     ReceiveContext.Dispose();
     _spiRxBuffer = null;
     WidgetClicked = null;
     Touch = null;
     RegisteredWidgets = null;
     GoBusIrqEvent = null;
 }
        public void Dispose()
        {
            _isDisposed = true;

            _interruptPin.Dispose();
            _spi.Dispose();
            _chipSelectPin.Dispose();

            // abort our data received event-raising thread
            _notifyDataReceivedWaitHandle.Set();
        }
Esempio n. 12
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                // clean up any managed code objects
                _interruptPort.Dispose();
            }
            // clean up any unmanaged code objects

            // dispose of our base object
            base.Dispose(disposing);
        }
Esempio n. 13
0
 public void Dispose()
 {
     Debug.Print("LidarReader Dispose");
     if (_oport != null)
     {
         _oport.Dispose();
     }
     if (_inport != null)
     {
         _inport.Dispose();
     }
 }
 public void Dispose()
 {
     myInputPort.Dispose();
     myInterruptPort.Dispose();
     myOutputPort.Dispose();
     myI2CDevice.Dispose();
     mySPI.Dispose();
     myTristatePort.Dispose();
     mySerialPort.Dispose();
     Dispose(true);
     GC.SuppressFinalize(this);
 }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         // dispose managed resources
         if (port != null)
         {
             port.Dispose();
             port = null;
         }
     }
     // free native resources
 }
Esempio n. 16
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         // Dispose managed resources.
         if (m_port != null)
         {
             m_port.Dispose();
             m_port = null;
         }
     }
     // Free native resources.
 }
Esempio n. 17
0
 protected override void Dispose(bool disposing)
 {
     Spi.Dispose();
     GoBusIrqPort.Dispose();
     SendContext.Dispose();
     ReceiveContext.Dispose();
     _spiRxBuffer      = null;
     WidgetClicked     = null;
     Touch             = null;
     RegisteredWidgets = null;
     GoBusIrqEvent     = null;
     SetSocketPowerState(false);
     base.Dispose(disposing);
 }
Esempio n. 18
0
 protected void Dispose(bool disposing)
 {
     if (!disposed)
     {
         try
         {
             portIn.Dispose();
             portOut.Dispose();
         }
         finally
         {
             disposed = true;
         }
     }
 }
 /// <summary>
 /// Sends a reset pulse on the daisylink chain.  This resets all DaisyLink nodes to INIT state, that is, waiting for a DaisyLink message.
 /// </summary>
 /// <remarks>
 /// It is recommended to reboot the mainboard after calling this method because communication to the DaisyLink nodes will fail.
 /// </remarks>
 internal void SendResetPulse()
 {
     lock (portLock)
     {
         if (daisyLinkInterruptPort != null)
         {
             daisyLinkInterruptPort.DisableInterrupt();
             daisyLinkInterruptPort.Dispose();       // Ask hardware drivers to unreserve this pin
             daisyLinkInterruptPort = null;
         }
         if (daisyLinkResetPort == null)
         {
             daisyLinkResetPort = new TristatePort(daisyLinkCpuPin, false, false, Port.ResistorMode.PullUp);
         }
         daisyLinkResetPort.Active = true;       // Should drive the neighbor bus high
         Thread.Sleep(2);                        // 2 milliseconds is definitely more than 1 ms
         daisyLinkResetPort.Active = false;      // Pull-downs should take the neighbor bus back low
         daisyLinkResetPort.Dispose();           // Remove this pin from the hardware's reserved pin list
         daisyLinkResetPort = null;
     }
 }
        static void Main(string[] args)
        {
            SPI           SPIport = new Microsoft.SPOT.Hardware.SPI(new Microsoft.SPOT.Hardware.SPI.Configuration(Cpu.Pin.GPIO_NONE, false, 0, 0, false, true, 2000, SPI.SPI_module.SPI1));
            OutputPort    nCE     = new OutputPort(Cpu.Pin.GPIO_Pin2, true);
            InterruptPort nINT    = new InterruptPort(Cpu.Pin.GPIO_Pin4, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);

            NRF24L01Plus n = new NRF24L01Plus();

            n.Initialize(SPIport, nCE, nINT);

            byte[] address = n.GetAddress(AddressSlot.Zero, 5);
            Console.WriteLine("First Address: " + ByteArrayToHexString(address));

            byte[] b = new byte[] { 0x04, 0x09, 0x02, 0x03, 0x04 };
            n.SetAddress(AddressSlot.Zero, b, false);

            address = n.GetAddress(AddressSlot.Zero, 5);
            Console.WriteLine("Second Address: " + ByteArrayToHexString(address));

            nCE.Dispose();
            nINT.Dispose();
        }
Esempio n. 21
0
 public void Dispose()
 {
     _echoPin.Dispose();
     _triggerPin.Dispose();
 }
Esempio n. 22
0
 public override void Dispose()
 {
     _port.Dispose();
 }
Esempio n. 23
0
 protected override void DisposeManagedResources()
 {
     _interrupt.Dispose();
     _onInterrupt = null;
 }
 public void Dispose()
 {
     _receiverPort.Dispose();
 }
Esempio n. 25
0
 private void DestroyActivity()
 {
     inputStart.Dispose();
     inputLoss.Dispose();
     inputFinish.Dispose();
 }