public void Dispose() { if (BeagleBone.FastGPIO) { ((InputPortMM)this.InputPort).ClosePort(); ((InputPortMM)this.InputPort).Dispose(); } else { ((InputPortFS)this.InputPort).ClosePort(); ((InputPortFS)this.InputPort).Dispose(); } if (this.IntPortRise != null) { this.IntPortRise.DisableInterrupt(); this.IntPortRise.ClosePort(); this.IntPortRise.Dispose(); this.IntPortRise = null; } if (this.IntPortFall != null) { this.IntPortFall.DisableInterrupt(); this.IntPortFall.ClosePort(); this.IntPortFall.Dispose(); this.IntPortFall = null; } if (this.IntPortAny != null) { this.IntPortAny.DisableInterrupt(); this.IntPortAny.ClosePort(); this.IntPortAny.Dispose(); this.IntPortAny = null; } }
/// <summary> Registers a handler for the given type of interrupt on this pin. </summary> public void RegisterInterruptHandler(EventHandler <InputInterrupt> Handler, InterruptType Type) { switch (Type) { case InterruptType.RISING_EDGE: { if (this.IntPortRise == null) { this.IntPortRise = new InterruptPortMM(IO.BeagleBone.Pin.PinToGPIO(this.Pin), InterruptMode.InterruptEdgeLevelHigh); this.IntPortRise.EnableInterrupt(); this.IntPortRise.OnInterrupt += this.InterruptRising; } this.RisingHandlers += Handler; return; } case InterruptType.FALLING_EDGE: { if (this.IntPortFall == null) { this.IntPortFall = new InterruptPortMM(IO.BeagleBone.Pin.PinToGPIO(this.Pin), InterruptMode.InterruptEdgeLevelLow); this.IntPortFall.EnableInterrupt(); this.IntPortFall.OnInterrupt += this.InterruptFalling; } this.FallingHandlers += Handler; return; } case InterruptType.ANY_EDGE: { if (this.IntPortAny == null) { this.IntPortAny = new InterruptPortMM(IO.BeagleBone.Pin.PinToGPIO(this.Pin), InterruptMode.InterruptEdgeBoth); this.IntPortAny.EnableInterrupt(); this.IntPortAny.OnInterrupt += this.InterruptAny; } this.AnyHandlers += Handler; return; } } }