1414 * Date Changed By Details of change
1515 * 08 May 2013 Daniel Riches Corrected c library mappings for I2C and SPI, added this header
1616 *
17+ ************************************************************************************************
18+ * Changelog
19+ * Date Changed By Details of change
20+ * 23 Nov 2013 Gerhard de Clercq Changed digitalread to return int and implemented wiringPiISR
21+ *
1722 ************************************************************************************************/
1823using System ;
1924using System . Collections . Generic ;
@@ -53,7 +58,7 @@ public class GPIO
5358 public static extern void digitalWriteByte ( int value ) ;
5459
5560 [ DllImport ( "libwiringPi.so" , EntryPoint = "digitalReadGpio" ) ] //Uses Gpio pin numbers
56- public static extern void digitalRead ( int pin ) ;
61+ public static extern int digitalRead ( int pin ) ;
5762
5863 [ DllImport ( "libwiringPi.so" , EntryPoint = "pullUpDnControlGpio" ) ] //Uses Gpio pin numbers
5964 public static extern void pullUpDnControl ( int pin , int pud ) ;
@@ -83,9 +88,9 @@ public enum GPIOpinmode
8388 }
8489 }
8590
86- /// <summary>
87- /// Provides use of the Timing functions such as delays
88- /// </summary>
91+ /// <summary>
92+ /// Provides use of the Timing functions such as delays
93+ /// </summary>
8994 public class Timing
9095 {
9196 [ DllImport ( "libwiringPi.so" , EntryPoint = "millis" ) ]
@@ -98,9 +103,9 @@ public class Timing
98103 public static extern void delayMicroseconds ( uint howLong ) ;
99104 }
100105
101- /// <summary>
102- /// Provides access to the Thread priority and interrupts for IO
103- /// </summary>
106+ /// <summary>
107+ /// Provides access to the Thread priority and interrupts for IO
108+ /// </summary>
104109 public class PiThreadInterrupts
105110 {
106111 [ DllImport ( "libwiringPi.so" , EntryPoint = "piHiPri" ) ]
@@ -109,7 +114,19 @@ public class PiThreadInterrupts
109114 [ DllImport ( "libwiringPi.so" , EntryPoint = "waitForInterrupt" ) ]
110115 public static extern int waitForInterrupt ( int pin , int timeout ) ;
111116
112- //static extern int wiringPiISR(int pin, int edgeType,
117+ //This is the C# equivelant to "void (*function)(void))" required by wiringPi to define a callback method
118+ public delegate void ISRCallback ( ) ;
119+
120+ [ DllImport ( "libwiringPi.so" , EntryPoint = "wiringPiISR" ) ]
121+ public static extern int wiringPiISR ( int pin , int mode , ISRCallback method ) ;
122+
123+ public enum InterruptLevels
124+ {
125+ INT_EDGE_SETUP = 0 ,
126+ INT_EDGE_FALLING = 1 ,
127+ INT_EDGE_RISING = 2 ,
128+ INT_EDGE_BOTH = 3
129+ }
113130
114131 //static extern int piThreadCreate(string name);
115132 }
0 commit comments