public DigitalInputImplementation(byte pin, GTI.GlitchFilterMode glitchFilter, GTI.ResistorMode resistorMode, IO60P16 io60) { this.io60 = io60; this.pin = pin; this.io60.setIOMode(this.pin, IO60P16.IOState.Input, resistorMode); }
public InterruptInputImplementation(byte pin, GTI.GlitchFilterMode glitchFilter, GTI.ResistorMode resistorMode, GTI.InterruptMode interruptMode, IO60P16 io60) { this.io60 = io60; this.pin = pin; this.io60.setIOMode(this.pin, IO60P16.IOState.InputInterrupt, resistorMode); this.io60.registerInterruptHandler(this.pin, interruptMode, this.RaiseInterrupt); }
public DigitalIOImplementation(byte pin, bool initialState, GTI.GlitchFilterMode glitchFilter, GTI.ResistorMode resistorMode, IO60P16 io60) { this.io60 = io60; this.pin = pin; this.resistorMode = resistorMode; this.Mode = Socket.SocketInterfaces.IOMode.Input; this.io60.writeDigital(this.pin, initialState); }
public DigitalOutputImplementation(byte pin, bool initialState, IO60P16 io60) { this.io60 = io60; this.pin = pin; this.io60.setIOMode(this.pin, IO60P16.IOState.Output, GTI.ResistorMode.Disabled); this.Write(initialState); }
public DigitalIO(byte pin, bool initialState, GTI.GlitchFilterMode glitchFilter, GTI.ResistorMode resistorMode, IO60P16 io60) { this.io60 = io60; this.pin = pin; this.resistorMode = resistorMode; this.Mode = GTI.IOMode.Input; this.io60.WriteDigital(this.pin, initialState); }
/// <summary> /// Constructor /// </summary> /// <param name="io60p16">The IO60 the port is on.</param> /// <param name="pin">Pin to be created</param> /// <param name="resisterMode">Desired resistor mode for the pin to be constructed</param> public InputPort(IO60P16 io60p16, IOPin pin, ResistorMode resisterMode) { _io60p16 = io60p16; _portId = _io60p16.GetPortNumber(pin); _pinId = _io60p16.GetPinNumber(pin); if (_io60p16.IsPinReserved(_portId, _pinId)) { throw new Exception("This pin has already been reserved"); } _io60p16.MakePinInput(_portId, _pinId, resisterMode); _io60p16.port_reserve[_portId] |= (byte)(1 << _pinId); }
/// <summary>Constructs a new HubAP5 module.</summary> /// <param name="socketNumber">The socket that this module is plugged in to.</param> public HubAP5(int socketNumber) { Socket socket = Socket.GetSocket(socketNumber, true, this, null); socket.EnsureTypeIsSupported('I', this); this.io60 = new IO60P16(socket); this.ads = new ADS7830(socket); this.socketMap = new Hashtable(); this.typeMap = new string[8] { "AY", "AY", "Y", "PY", "PY", "PY", "PY", "PY" }; this.pinMap = new byte[56] { 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, //Socket 1 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, //Socket 2 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, //Socket 3 0x20, 0x21, 0x22, 0x23, 0x74, 0x75, 0x76, //Socket 4 0x14, 0x15, 0x16, 0x17, 0x71, 0x72, 0x73, //Socket 5 0x10, 0x11, 0x12, 0x13, 0x66, 0x67, 0x70, //Socket 6 0x04, 0x05, 0x06, 0x07, 0x63, 0x64, 0x65, //Socket 7 0x00, 0x01, 0x02, 0x03, 0x60, 0x61, 0x62 //Socket 8 }; for (int i = 0; i < 8; i++) { this.sockets[i] = Socket.SocketInterfaces.CreateUnnumberedSocket("Hub AP5 " + (i + 1).ToString()); this.sockets[i].SupportedTypes = this.typeMap[i].ToCharArray(); for (int j = 3; j <= 9; j++) { this.sockets[i].CpuPins[j] = Socket.UnnumberedPin; } this.socketMap[this.sockets[i].SocketNumber] = i; this.sockets[i].DigitalInputIndirector = (indirectedSocket, indirectedPin, glitchFilterMode, resistorMode, module) => new DigitalInputImplementation(this.GetPin(indirectedSocket, indirectedPin), glitchFilterMode, resistorMode, this.io60); this.sockets[i].DigitalOutputIndirector = (indirectedSocket, indirectedPin, initialState, module) => new DigitalOutputImplementation(this.GetPin(indirectedSocket, indirectedPin), initialState, this.io60); this.sockets[i].DigitalIOIndirector = (indirectedSocket, indirectedPin, initialState, glitchFilterMode, resistorMode, module) => new DigitalIOImplementation(this.GetPin(indirectedSocket, indirectedPin), initialState, glitchFilterMode, resistorMode, this.io60); this.sockets[i].AnalogInputIndirector = (indirectedSocket, indirectedPin, module) => new AnalogInputImplementation(this.GetPin(indirectedSocket, indirectedPin), this.ads, this.io60); this.sockets[i].PwmOutputIndirector = (indirectedSocket, indirectedPin, invert, module) => new PwmOutputImplementation(this.GetPin(indirectedSocket, indirectedPin), invert, this.io60); this.sockets[i].InterruptIndirector = (indirectedSocket, indirectedPin, glitchFilterMode, resistorMode, interruptMode, module) => new InterruptInputImplementation(this.GetPin(indirectedSocket, indirectedPin), glitchFilterMode, resistorMode, interruptMode, this.io60); Socket.SocketInterfaces.RegisterSocket(this.sockets[i]); } }
/// <summary> /// Constructor /// </summary> /// <param name="io60p16">The IO60 the port is on.</param> /// <param name="pin">The pin to be constructed</param> /// <param name="tickWidth">The desired width between ticks</param> public PWM(IO60P16 io60p16, PWMPin pin, TickWidth tickWidth) { _io60p16 = io60p16; _portId = _io60p16.GetPortNumber((IOPin)pin); _pinId = _io60p16.GetPinNumber((IOPin)pin); if (_io60p16.IsPinReserved(_portId, _pinId)) { throw new Exception("This pin has already been reserved");// reserve already } _io60p16.port_reserve[_portId] |= (byte)(1 << _pinId); _tickWidth = tickWidth; _io60p16.MakePinOutput(_portId, _pinId); _io60p16.MakePinHigh(_portId, _pinId); SetPWM(); }
public AnalogInputImplementation(byte pin, ADS7830 ads, IO60P16 io60) { this.ads = ads; this.io60 = io60; this.pin = pin; this.active = false; var channels = new byte[12] { 0x50, 0, 0x51, 1, 0x52, 2, 0x40, 3, 0x41, 4, 0x42, 5 }; for (int i = 0; i < 12; i += 2) { if (channels[i] == this.pin) { this.channel = channels[i + 1]; } } }
/// <summary> /// Constructor /// </summary> /// <param name="io60p16">The IO60 the port is on.</param> /// <param name="pin">Pin to be created</param> /// <param name="initialState">If the pin should be created and set high (true) or low (false)</param> public OutputPort(IO60P16 io60p16, IOPin pin, Boolean initialState) { _io60p16 = io60p16; _portId = _io60p16.GetPortNumber(pin); _pinId = _io60p16.GetPinNumber(pin); if (_io60p16.IsPinReserved(_portId, _pinId)) { throw new Exception("This pin has already been reserved"); } _io60p16.MakePinOutput(_portId, _pinId); _io60p16.port_reserve[_portId] |= (byte)(1 << _pinId); if (initialState) { _io60p16.MakePinHigh(_portId, _pinId); } else { _io60p16.MakePinLow(_portId, _pinId); } }
public PwmOutputImplementation(byte pin, bool invert, IO60P16 io60) { this.io60 = io60; this.pin = pin; this.isActive = false; }