Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of Interrupts #1

Open
proggn opened this issue Sep 5, 2013 · 1 comment
Open

Use of Interrupts #1

proggn opened this issue Sep 5, 2013 · 1 comment

Comments

@proggn
Copy link

proggn commented Sep 5, 2013

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));

@danriches
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants