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(); }
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); }
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; } } }
/// <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; } }
public void Dispose() { if (_interruptCreatedInternally) { InterruptPort?.Dispose(); InterruptPort = null; } }
/// <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 }
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); }
public void Dispose() { lock (_syncRoot) { _disposing = true; _trigger.Dispose(); _echo.Dispose(); } }
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(); }
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); }
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 }
protected virtual void Dispose(bool disposing) { if (disposing) { // Dispose managed resources. if (m_port != null) { m_port.Dispose(); m_port = null; } } // Free native resources. }
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); }
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(); }
public void Dispose() { _echoPin.Dispose(); _triggerPin.Dispose(); }
public override void Dispose() { _port.Dispose(); }
protected override void DisposeManagedResources() { _interrupt.Dispose(); _onInterrupt = null; }
public void Dispose() { _receiverPort.Dispose(); }
private void DestroyActivity() { inputStart.Dispose(); inputLoss.Dispose(); inputFinish.Dispose(); }