Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- using GoBus;
- using Microsoft.SPOT;
- using Microsoft.SPOT.Hardware;
- namespace ProtoModule_Test
- {
- public class Program
- {
- public static void Main()
- {
- ProtoModule PM = new ProtoModule();
- Thread.Sleep(Timeout.Infinite);
- }
- }
- public class ProtoModule : GoModule
- {
- private Guid _guid = new Guid(new byte[] {0x07, 0x22, 0x075, 0x073, 0x52, 0xA5, 0x48, 0x24, 0xBC, 0xC2, 0x55, 0x2F, 0x69, 0x88, 0xED, 0x3E});
- private SPI _spi;
- private SPI.Configuration _spiConfig;
- private InterruptPort _irqPort;
- public ProtoModule()
- {
- GoSocket[] sockets = base.GetSocketsByUniqueId(this._guid);
- if(sockets.Length < 1)
- {
- throw new Exception("Unable to find ProtoModule");
- }
- this.Initialize(sockets[0]);
- }
- private void Initialize(GoSocket socket)
- {
- Cpu.Pin socketGpioPin;
- SPI.SPI_module socketSpiModule;
- Cpu.Pin socketSpiSlaveSelectPin;
- if (!base.BindSocket(socket, this._guid))
- {
- throw new ArgumentException();
- }
- socket.GetPhysicalResources(out socketGpioPin, out socketSpiModule, out socketSpiSlaveSelectPin);
- this._spiConfig = new SPI.Configuration(socketSpiSlaveSelectPin, false, 0, 0, false, false, 500, socketSpiModule);
- this._spi = new SPI(this._spiConfig);
- this._irqPort = new InterruptPort(socketGpioPin, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);
- this._irqPort.OnInterrupt += _irqPort_OnInterrupt;
- }
- private void _irqPort_OnInterrupt(uint d1, uint d2, DateTime ts)
- {
- Debug.Print(ts.ToString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment