WiringPi.Net icon indicating copy to clipboard operation
WiringPi.Net copied to clipboard

Use of Interrupts

Open proggn opened this issue 11 years ago • 1 comments

Nice work, I added the two interrupt methods, maybe you want to add them as well. Use the following to compile the base so: cc -shared wiringPi.o -o libwiringPi.so -lwiringPi

PiThreadInterrups Class: public enum Edge { INT_EDGE_SETUP = 0, INT_EDGE_FALLING = 1, INT_EDGE_RISING = 2, INT_EDGE_BOTH = 3}

PiThreadInterrupts Class: [DllImport("libwiringPi.so", EntryPoint = "waitForInterrupt")] ///Obsolete, use wiringPilSR public static extern int waitForInterrupt(int p_pin, int p_timeout);

[UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void InterruptCallback(); [DllImport("libwiringPi.so", EntryPoint = "wiringPiISR")] public static extern int wiringPiISR(int p_pin, int p_edgeType, [MarshalAs(UnmanagedType.FunctionPtr)] InterruptCallback p_callback);

Call: if(WiringPi.PiThreadInterrupts.waitForInterrupt(8, -1) > 0) //only works in Sys mode! (WiringPi.Init.WiringPiSetupSys();) { Console.WriteLine("interrupt"); }

WiringPi.PiThreadInterrupts.wiringPiISR(8, (int)WiringPi.PiThreadInterrupts.Edge.INT_EDGE_RISING, new WiringPi.PiThreadInterrupts.InterruptCallback(Callback));

proggn avatar Sep 05 '13 20:09 proggn

Nicely done, I'll add those over the next few days or so and update the repo. Many Thanks, Dan..

danriches avatar Sep 06 '13 13:09 danriches