Skip to content

Use of Interrupts #1

@proggn

Description

@proggn

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions