稍微学习一下如何添加中断服务程序。
IO双沿触发中断。
using System;
using System.Threading;using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.Gadgeteer;
namespace my_LED
{
public class my_led
{
static OutputPort lampOutport = new OutputPort((Cpu.Pin)
GHI.Hardware.G120.Pin.P1_15,true);
static InterruptPort switchInterrupt = new InterruptPort(
(Cpu.Pin)GHI.Hardware.G120.Pin.P2_10,
false,
Port.ResistorMode.PullUp,
Port.InterruptMode.InterruptEdgeBoth);
public static void Main()
{
switchInterrupt.OnInterrupt += new NativeEventHandler
(switchInterrupt_OnInterrupt);
while (true)
{
System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
}
}
static void switchInterrupt_OnInterrupt(uint data1, uint data2, DateTime time)
{
switch (data2)
{
case 0: lampOutport.Write(false); break;
case 1: lampOutport.Write(true); break;
default: break;
}
//throw new NotImplementedException();
}
}
}