/// <summary> Adds an interrupt to the given GPIO pin. </summary> /// <param name="Pin"> The pin to monitor. </param> /// <param name="InterruptType"> The type of edge to listen for. </param> /// <param name="Delegate"> The delegate to call when the given type of event happens. </param> internal static void AddInterrupt(int Pin, int InterruptType, InterruptCallback Delegate) { if (!Initialized) { throw new InvalidOperationException("Cannot perform GPIO operations until the system is initialized. Call RasperryPi.Initialize()."); } External.AddInterrupt(Pin, InterruptType, Delegate); }
/////////////////////////////////////////////////////////////////////// public void CheckCallbacks( Interpreter interpreter /* NOTE: Parent interpreter. */ ) { CheckDisposed(); if (interpreter == null) { return; } lock (interpreter.SyncRoot) /* TRANSACTIONAL */ { InterruptCallback oldInterruptCallback = interpreter.InterruptCallback; StringList arguments = CallbackArguments; if (arguments != null) /* NOTE: Enabled? */ { if (oldInterruptCallback != null) { return; } if (interruptCallback == null) { interruptCallback = new InterruptCallback( InterruptCallback); } } else { if (interruptCallback != null) { interruptCallback = null; } if (oldInterruptCallback == null) { return; } } interpreter.InterruptCallback = interruptCallback; } }
public static extern int InterruptServiceRoutine(int pin, int interruptType, InterruptCallback handler);
internal static extern int AddInterrupt(int Pin, int InterruptType, InterruptCallback Delegate);
private static extern int Ext_AddInterrupt(int Pin, int InterruptType, InterruptCallback Delegate);