Ejemplo n.º 1
0
 public InterruptPort(IO60P16Module parentModule, IOPin pin, ResistorMode resistorMode, InterruptMode interruptMode)
     : base(parentModule, pin)
 {
     Resistor = resistorMode;
     Interrupt = interruptMode;
     EnableInterrupt();
 }
Ejemplo n.º 2
0
 public InterruptPort(Cpu.Pin portId, bool glitchFilter, ResistorMode resistor, InterruptMode interrupt)
     : base(portId, glitchFilter, resistor, interrupt)
 {
     //m_threadSpawn = null;
     //m_callbacks = null;
     GPIOManager.Instance.SetPortType(portId, PortType.INTERRUPT);
     GPIOManager.Instance.SetEdge(portId, interrupt);
 }
Ejemplo n.º 3
0
 public DigitalFrequencyInput(Cpu.Pin pin, bool glitchFilter, ResistorMode resistorMode, InterruptMode interruptMode)
     : base(pin, glitchFilter, resistorMode, interruptMode)
 {
     dataPoints = new System.Collections.Hashtable(20);
     base.EnableInterrupt();
     base.OnInterrupt += new NativeEventHandler(DigitalFrequencyInput_OnInterrupt);
     loopThread = new Thread(new ThreadStart(ThreadLoop));
     loopThread.Start();
 }
Ejemplo n.º 4
0
        public NativeDigitalInput(Socket socket, Socket.Pin pin, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, Module module, Cpu.Pin cpuPin)
        {
            if (cpuPin == Cpu.Pin.GPIO_NONE)
            {
                // this is a mainboard error but should not happen since we check for this, but it doesnt hurt to double-check
                throw Socket.InvalidSocketException.FunctionalityException(socket, "DigitalInput");
            }

            _port = new InputPort(cpuPin, glitchFilterMode == GlitchFilterMode.On, (Port.ResistorMode)resistorMode);
        }
Ejemplo n.º 5
0
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <param name="socket">The socket for the digital input interface.</param>
        /// <param name="pin">The pin used by the digital input interface.</param>
        /// <param name="glitchFilterMode">
        ///  A value from the <see cref="GlitchFilterMode"/> enumeration that specifies 
        ///  whether to enable the glitch filter on this digital input interface.
        /// </param>
        /// <param name="resistorMode">
        ///  A value from the <see cref="ResistorMode"/> enumeration that establishes a default state for the digital input interface. N.B. .NET Gadgeteer mainboards are only required to support ResistorMode.PullUp on interruptable GPIOs and are never required to support ResistorMode.PullDown; consider putting the resistor on the module itself.
        /// </param>
        /// <param name="module">The module using this interface, which can be null if unspecified.</param>
        public DigitalInput(Socket socket, Socket.Pin pin, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, Module module)
        {
            this.port = new InputPort(socket.ReservePin(pin, module), glitchFilterMode == GlitchFilterMode.On, (Port.ResistorMode)resistorMode);

            if (this.port == null)
            {
                // this is a mainboard error but should not happen since we check for this, but it doesnt hurt to double-check
                throw new Socket.InvalidSocketException("Socket " + socket + " has an error with its Digital Input functionality. Please try a different socket.");
            }
        }
Ejemplo n.º 6
0
        public NativeDigitalIO(Socket socket, Socket.Pin pin, bool initialState, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, Module module, Hardware.Cpu.Pin cpuPin)
        {
            if (cpuPin == Hardware.Cpu.Pin.GPIO_NONE)
            {
                // this is a mainboard error but should not happen since we check for this, but it doesnt hurt to double-check
                throw Socket.InvalidSocketException.FunctionalityException(socket, "DigitalIO");
            }

            _port = new Hardware.TristatePort(cpuPin, initialState, glitchFilterMode == GlitchFilterMode.On, (Hardware.Port.ResistorMode)resistorMode);
        }
Ejemplo n.º 7
0
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <param name="socket">The socket for the digital input interface.</param>
        /// <param name="pin">The pin used by the digital input interface.</param>
        /// <param name="glitchFilterMode">
        ///  A value from the <see cref="GlitchFilterMode"/> enumeration that specifies 
        ///  whether to enable the glitch filter on this digital input interface.
        /// </param>
        /// <param name="resistorMode">
        ///  A value from the <see cref="ResistorMode"/> enumeration that establishes a default state for the digital input interface. N.B. .NET Gadgeteer mainboards are only required to support ResistorMode.PullUp on interruptable GPIOs and are never required to support ResistorMode.PullDown; consider putting the resistor on the module itself.
        /// </param>
        /// <param name="module">The module using this interface, which can be null if unspecified.</param>
        public DigitalInput(Socket socket, Socket.Pin pin, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, Module module)
        {
            Cpu.Pin reservedPin = socket.ReservePin(pin, module);

            // native implementation is preferred to an indirected one
            if (reservedPin == Cpu.Pin.GPIO_NONE && socket.DigitalInputIndirector != null)
                Interface = socket.DigitalInputIndirector(socket, pin, glitchFilterMode, resistorMode, module);

            else
                Interface = new NativeDigitalInput(socket, pin, glitchFilterMode, resistorMode, module, reservedPin);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates an instance of <see cref="DigitalIO" /> for the given socket and pin number.
        /// </summary>
        /// <param name="socket">The socket for the digital input/output interface.</param>
        /// <param name="pin">The pin used by the digital input/output interface.</param>
        /// <param name="initialState">
        ///  The initial state to set on the digital input/output interface port.  
        ///  This value becomes effective as soon as the port is enabled as an output port.
        /// </param>
        /// <param name="glitchFilterMode">
        ///  A value from the <see cref="GlitchFilterMode"/> enumeration that specifies 
        ///  whether to enable the glitch filter on this digital input/output interface.
        /// </param>
        /// <param name="resistorMode">
        ///  A value from the <see cref="ResistorMode"/> enumeration that establishes a default state for the digital input/output interface. N.B. .NET Gadgeteer mainboards are only required to support ResistorMode.PullUp on interruptable GPIOs and are never required to support ResistorMode.PullDown; consider putting the resistor on the module itself.
        /// </param>
        /// <param name="module">The module using this interface, which can be null if unspecified.</param>
        /// <returns>An instance of <see cref="DigitalIO" /> for the given socket and pin number.</returns>
        public static DigitalIO Create(Socket socket, Socket.Pin pin, bool initialState, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, Module module)
        {
            Cpu.Pin reservedPin = socket.ReservePin(pin, module);

            // native implementation is preferred to an indirected one
            if (reservedPin == Cpu.Pin.GPIO_NONE && socket.DigitalIOIndirector != null)
                return socket.DigitalIOIndirector(socket, pin, initialState, glitchFilterMode, resistorMode, module);

            else
                return new NativeDigitalIO(socket, pin, initialState, glitchFilterMode, resistorMode, module, reservedPin);        
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates an instance of <see cref="InterruptInput" /> for the given socket and pin number.
        /// </summary>
        /// <param name="socket">The socket for the interrupt input interface.</param>
        /// <param name="pin">The pin used by the interrupt input interface.</param>
        /// <param name="glitchFilterMode">
        ///  A value from the <see cref="GlitchFilterMode"/> enumeration that specifies 
        ///  whether to enable the glitch filter on this interrupt input interface.
        /// </param>
        /// <param name="resistorMode">
        ///  A value from the <see cref="ResistorMode"/> enumeration that establishes a default state for the interrupt input interface. N.B. .NET Gadgeteer mainboards are only required to support ResistorMode.PullUp on interruptable GPIOs and are never required to support ResistorMode.PullDown; consider putting the resistor on the module itself.
        /// </param>
        /// <param name="interruptMode">
        ///  A value from the <see cref="InterruptMode"/> enumeration that establishes the requisite conditions 
        ///  for the interface port to generate an interrupt.
        /// </param>
        /// <param name="module">The module using this interrupt input interface, which can be null if unspecified.</param>
        /// <returns>An instance of <see cref="InterruptInput" /> for the given socket and pin number.</returns>
        public static InterruptInput Create(Socket socket, Socket.Pin pin, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, InterruptMode interruptMode, Module module)
        {
            Cpu.Pin reservedPin = socket.ReservePin(pin, module);

            // native implementation is preferred to an indirected one
            if (reservedPin == Cpu.Pin.GPIO_NONE && socket.InterruptIndirector != null)
                return socket.InterruptIndirector(socket, pin, glitchFilterMode, resistorMode, interruptMode, module);

            else
                return new NativeInterruptInput(socket, pin, glitchFilterMode, resistorMode, interruptMode, module, reservedPin);
        }
Ejemplo n.º 10
0
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <param name="socket">The socket for the interrupt input interface.</param>
        /// <param name="pin">The pin used by the interrupt input interface.</param>
        /// <param name="glitchFilterMode">
        ///  A value from the <see cref="GlitchFilterMode"/> enumeration that specifies 
        ///  whether to enable the glitch filter on this interrupt input interface.
        /// </param>
        /// <param name="resistorMode">
        ///  A value from the <see cref="ResistorMode"/> enumeration that establishes a default state for the interrupt input interface. N.B. .NET Gadgeteer mainboards are only required to support ResistorMode.PullUp on interruptable GPIOs and are never required to support ResistorMode.PullDown; consider putting the resistor on the module itself.
        /// </param>
        /// <param name="interruptMode">
        ///  A value from the <see cref="InterruptMode"/> enumeration that establishes the requisite conditions 
        ///  for the interface port to generate an interrupt.
        /// </param>
        /// <param name="module">The module using this interrupt input interface, which can be null if unspecified.</param>
        public InterruptInput(Socket socket, Socket.Pin pin, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, InterruptMode interruptMode, Module module)
        {
            this.port = new InterruptPort(socket.ReservePin(pin, module), glitchFilterMode == GlitchFilterMode.On, (Port.ResistorMode)resistorMode, (Port.InterruptMode)interruptMode);

            if (this.port == null)
            {
                // this is a mainboard error but should not happen since we check for this, but it doesnt hurt to double-check
                throw new Socket.InvalidSocketException("Socket " + socket + " has an error with its Interrupt Input functionality. Please try a different socket.");
            }

            this.SynchronousUnsafeEventInvocation = false;
            this.port.OnInterrupt += new NativeEventHandler(this._port_OnInterrupt);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Create a new Parallax PIR object connected to an input pin and IO Device.
 /// </summary>
 /// <param name="device"></param>
 /// <param name="inputPin"></param>
 public ParallaxPir(IIODevice device, IPin pin, InterruptMode interruptMode, ResistorMode resistorMode, int debounceDuration = 20, int glitchFilterCycleCount = 0) :
     this(device.CreateDigitalInputPort(pin, interruptMode, resistorMode, debounceDuration, glitchFilterCycleCount))
 {
 }
Ejemplo n.º 12
0
 public InputPort(Cpu.Pin portId, bool glitchFilter, ResistorMode resistor)
     : base(portId, glitchFilter, resistor, InterruptMode.InterruptNone)
 {
 }
Ejemplo n.º 13
0
 protected InputPort(Cpu.Pin portId, bool glitchFilter, ResistorMode resistor, InterruptMode interruptMode)
     : base(portId, glitchFilter, resistor, interruptMode)
 {
     GPIOManager.Instance.SetPortType(portId, PortType.INPUT);
 }
Ejemplo n.º 14
0
 protected Port(Cpu.Pin portId, bool initialState, bool glitchFilter, ResistorMode resistor)
 {
     this.Id = portId;
     throw new NotImplementedException();
 }
Ejemplo n.º 15
0
 extern protected Port(Cpu.Pin portId, bool glitchFilter, ResistorMode resistor, InterruptMode interruptMode);
Ejemplo n.º 16
0
 public InputPort(Cpu.Pin portId, bool glitchFilter, ResistorMode resistor)
     : base(portId, glitchFilter, resistor, InterruptMode.InterruptNone)
 {
     GPIOManager.GetInstance().SetPortType(portId, PortType.INPUT);
 }
Ejemplo n.º 17
0
 protected Port(Cpu.Pin portId, bool initialState, bool glitchFilter, ResistorMode resistor)
 {
     this.Id = portId;
     //throw new NotImplementedException();
     GPIOManager.Instance.Export(portId);
 }
Ejemplo n.º 18
0
 protected InputPort(Cpu.Pin portId, bool initialState, bool glitchFilter, ResistorMode resistor)
     : base(portId, initialState, glitchFilter, resistor)
 {
 }
        public NativeDigitalIO(Socket socket, Socket.Pin pin, bool initialState, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, Module module, Cpu.Pin cpuPin)
        {
            if (cpuPin == Cpu.Pin.GPIO_NONE)
            {
                // this is a mainboard error but should not happen since we check for this, but it doesnt hurt to double-check
                throw Socket.InvalidSocketException.FunctionalityException(socket, "DigitalIO");
            }

            _port = new TristatePort(cpuPin, initialState, glitchFilterMode == GlitchFilterMode.On, (Port.ResistorMode)resistorMode);
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="parentModule">The module to which this port belongs.</param>
 /// <param name="pin">The pin ID that this port represents.</param>
 /// <param name="resistorMode">The resistor mode to assign to the pin.</param>
 protected Port(IO60P16Module parentModule, IOPin pin, ResistorMode resistorMode)
     : this(parentModule, pin)
 {
     Resistor = resistorMode;
 }
Ejemplo n.º 21
0
 public CamPositionSensor(Cpu.Pin pin, bool glitchFilter, ResistorMode resistorMode, InterruptMode interruptMode)
     : base(pin, glitchFilter, resistorMode, interruptMode)
 {
 }
Ejemplo n.º 22
0
 public TristatePort(Cpu.Pin portId, bool initialState, bool glitchFilter, ResistorMode resistor)
     : base(portId, initialState, glitchFilter, resistor)
 {
 }
Ejemplo n.º 23
0
 public Tachometer(Cpu.Pin pin, bool glitchFilter, ResistorMode resistorMode, InterruptMode interruptMode)
     : base(pin, glitchFilter, resistorMode, interruptMode)
 {
 }
Ejemplo n.º 24
0
 public IDigitalInputPort CreateDigitalInputPort(IPin pin, InterruptMode interruptMode = InterruptMode.None, ResistorMode resistorMode = ResistorMode.Disabled, int debounceDuration = 0, int glitchFilterCycleCount = 0)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 25
0
 public Tachometer(Cpu.Pin pin, bool glitchFilter, ResistorMode resistorMode, InterruptMode interruptMode)
     : base(pin, glitchFilter, resistorMode, interruptMode)
 {
 }
Ejemplo n.º 26
0
        //--//

        protected Port(Cpu.Pin portId, bool glitchFilter, ResistorMode resistor, InterruptMode interruptMode)
        {
            this.Id = portId;
            GPIOManager.GetInstance().Export(portId);
        }
        /// <summary>
        /// Creates an instance of <see cref="DigitalIO" /> for the given socket and pin number.
        /// </summary>
        /// <param name="socket">The socket for the digital input/output interface.</param>
        /// <param name="pin">The pin used by the digital input/output interface.</param>
        /// <param name="initialState">
        ///  The initial state to set on the digital input/output interface port.
        ///  This value becomes effective as soon as the port is enabled as an output port.
        /// </param>
        /// <param name="glitchFilterMode">
        ///  A value from the <see cref="GlitchFilterMode"/> enumeration that specifies
        ///  whether to enable the glitch filter on this digital input/output interface.
        /// </param>
        /// <param name="resistorMode">
        ///  A value from the <see cref="ResistorMode"/> enumeration that establishes a default state for the digital input/output interface. N.B. .NET Gadgeteer mainboards are only required to support ResistorMode.PullUp on interruptable GPIOs and are never required to support ResistorMode.PullDown; consider putting the resistor on the module itself.
        /// </param>
        /// <param name="module">The module using this interface, which can be null if unspecified.</param>
        /// <returns>An instance of <see cref="DigitalIO" /> for the given socket and pin number.</returns>
        public static DigitalIO Create(Socket socket, Socket.Pin pin, bool initialState, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, Module module)
        {
            Cpu.Pin reservedPin = socket.ReservePin(pin, module);

            // native implementation is preferred to an indirected one
            if (reservedPin == Cpu.Pin.GPIO_NONE && socket.DigitalIOIndirector != null)
            {
                return(socket.DigitalIOIndirector(socket, pin, initialState, glitchFilterMode, resistorMode, module));
            }

            else
            {
                return(new NativeDigitalIO(socket, pin, initialState, glitchFilterMode, resistorMode, module, reservedPin));
            }
        }
Ejemplo n.º 28
0
 protected OutputPort(Cpu.Pin portId, bool initialState, bool glitchFilter, ResistorMode resistor)
     : base(portId, initialState, glitchFilter, resistor)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 29
0
 public InterruptWrapper(Cpu.Pin pin, bool glitchFilter, ResistorMode resistorMode)
     : base(pin, glitchFilter, resistorMode, InterruptMode.InterruptEdgeBoth)
 {
 }
Ejemplo n.º 30
0
        //--//

        protected Port(Cpu.Pin portId, bool glitchFilter, ResistorMode resistor, InterruptMode interruptMode)
        {
            this.Id = portId;
            GPIOManager.Instance.Export(portId);
        }
Ejemplo n.º 31
0
 protected InputPort(Cpu.Pin portId, bool glitchFilter, ResistorMode resistor, InterruptMode interruptMode)
     : base(portId, glitchFilter, resistor, interruptMode)
 {
 }
Ejemplo n.º 32
0
 public InputPort(Cpu.Pin portId, bool glitchFilter, ResistorMode resistor)
     : base(portId, glitchFilter, resistor, InterruptMode.InterruptNone)
 {
     GPIOManager.Instance.SetPortType(portId, PortType.INPUT);
 }
Ejemplo n.º 33
0
 protected LED(Cpu.Pin portId, bool initialState, bool glitchFilter, ResistorMode resistorMode)
     : base(portId, initialState, glitchFilter, resistorMode)
 {
 }
Ejemplo n.º 34
0
 protected OutputPort(Cpu.Pin portId, bool initialState, bool glitchFilter, ResistorMode resistor)
     : base(portId, initialState, glitchFilter, resistor)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 35
0
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <param name="socket">The socket for the interrupt input interface.</param>
        /// <param name="pin">The pin used by the interrupt input interface.</param>
        /// <param name="glitchFilterMode">
        ///  A value from the <see cref="GlitchFilterMode"/> enumeration that specifies
        ///  whether to enable the glitch filter on this interrupt input interface.
        /// </param>
        /// <param name="resistorMode">
        ///  A value from the <see cref="ResistorMode"/> enumeration that establishes a default state for the interrupt input interface. N.B. .NET Gadgeteer mainboards are only required to support ResistorMode.PullUp on interruptable GPIOs and are never required to support ResistorMode.PullDown; consider putting the resistor on the module itself.
        /// </param>
        /// <param name="interruptMode">
        ///  A value from the <see cref="InterruptMode"/> enumeration that establishes the requisite conditions
        ///  for the interface port to generate an interrupt.
        /// </param>
        /// <param name="module">The module using this interrupt input interface, which can be null if unspecified.</param>
        public InterruptInput(Socket socket, Socket.Pin pin, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, InterruptMode interruptMode, Module module)
        {
            Cpu.Pin reservedPin = socket.ReservePin(pin, module);

            // native implementation is preferred to an indirected one
            if (reservedPin == Cpu.Pin.GPIO_NONE && socket.InterruptIndirector != null)
            {
                Interface = socket.InterruptIndirector(socket, pin, glitchFilterMode, resistorMode, interruptMode, module);
            }

            else
            {
                Interface = new NativeInterruptInput(socket, pin, glitchFilterMode, resistorMode, interruptMode, module, reservedPin);
            }
        }
Ejemplo n.º 36
0
 extern protected Port(Cpu.Pin portId, bool initialState, bool glitchFilter, ResistorMode resistor);
Ejemplo n.º 37
0
 public InterruptWrapper(Cpu.Pin pin, bool glitchFilter, ResistorMode resistorMode)
     : base(pin, glitchFilter, resistorMode, InterruptMode.InterruptEdgeBoth)
 {
 }
Ejemplo n.º 38
0
 extern protected Port(Cpu.Pin portId, bool glitchFilter, ResistorMode resistor, InterruptMode interruptMode);
Ejemplo n.º 39
0
        //--//

        public InterruptPort(Cpu.Pin portId, bool glitchFilter, ResistorMode resistor, InterruptMode interrupt)
            : base(portId, glitchFilter, resistor, interrupt)
        {
            m_threadSpawn = null;
            m_callbacks   = null;
        }
Ejemplo n.º 40
0
 extern protected Port(Cpu.Pin portId, bool initialState, bool glitchFilter, ResistorMode resistor);
Ejemplo n.º 41
0
 public InputPort(Cpu.Pin portId, bool glitchFilter, ResistorMode resistor)
     : base(portId, glitchFilter, resistor, InterruptMode.InterruptNone)
 {
 }
        /// <summary>
        /// Instantiates a new RotaryEncoder on the specified pins that has an integrated button.
        /// </summary>
        /// <param name="aPhasePin"></param>
        /// <param name="bPhasePin"></param>
        /// <param name="buttonPin"></param>
        /// <param name="resistor"></param>
        /// <param name="debounceDuration"></param>
        public RotaryEncoderWithButton(IIODevice device, IPin aPhasePin, IPin bPhasePin, IPin buttonPin, ResistorMode resistor = ResistorMode.PullDown, int debounceDuration = 20)
            : base(device, aPhasePin, bPhasePin)
        {
            _button = new PushButton(device, buttonPin, resistor, debounceDuration);

            _button.Clicked      += ButtonClicked;
            _button.PressEnded   += ButtonPressEnded;
            _button.PressStarted += ButtonPressStarted;
        }
Ejemplo n.º 43
0
 protected InputPort(Cpu.Pin portId, bool glitchFilter, ResistorMode resistor, InterruptMode interruptMode)
     : base(portId, glitchFilter, resistor, interruptMode)
 {
 }
Ejemplo n.º 44
0
        public NativeInterruptInput(Socket socket, Socket.Pin pin, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, InterruptMode interruptMode, Module module, Cpu.Pin cpuPin)
        {
            if (cpuPin == Cpu.Pin.GPIO_NONE)
            {
                // this is a mainboard error but should not happen since we check for this, but it doesnt hurt to double-check
                throw Socket.InvalidSocketException.FunctionalityException(socket, "InterruptInput");
            }

            _port = new InterruptPort(cpuPin, glitchFilterMode == GlitchFilterMode.On, (Port.ResistorMode)resistorMode, (Port.InterruptMode)interruptMode);
        }
Ejemplo n.º 45
0
 protected OutputPort(Cpu.Pin portId, bool initialState, bool glitchFilter, ResistorMode resistor)
     : base(portId, initialState, glitchFilter, resistor)
 {
 }
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <param name="socket">The socket for the interrupt input interface.</param>
        /// <param name="pin">The pin used by the interrupt input interface.</param>
        /// <param name="glitchFilterMode">
        ///  A value from the <see cref="GlitchFilterMode"/> enumeration that specifies
        ///  whether to enable the glitch filter on this interrupt input interface.
        /// </param>
        /// <param name="resistorMode">
        ///  A value from the <see cref="ResistorMode"/> enumeration that establishes a default state for the interrupt input interface. N.B. .NET Gadgeteer mainboards are only required to support ResistorMode.PullUp on interruptable GPIOs and are never required to support ResistorMode.PullDown; consider putting the resistor on the module itself.
        /// </param>
        /// <param name="interruptMode">
        ///  A value from the <see cref="InterruptMode"/> enumeration that establishes the requisite conditions
        ///  for the interface port to generate an interrupt.
        /// </param>
        /// <param name="module">The module using this interrupt input interface, which can be null if unspecified.</param>
        public InterruptInput(Socket socket, Socket.Pin pin, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, InterruptMode interruptMode, Module module)
        {
            this.port = new InterruptPort(socket.ReservePin(pin, module), glitchFilterMode == GlitchFilterMode.On, (Port.ResistorMode)resistorMode, (Port.InterruptMode)interruptMode);

            if (this.port == null)
            {
                // this is a mainboard error but should not happen since we check for this, but it doesnt hurt to double-check
                throw new Socket.InvalidSocketException("Socket " + socket + " has an error with its Interrupt Input functionality. Please try a different socket.");
            }

            this.SynchronousUnsafeEventInvocation = false;
            this.port.OnInterrupt += new NativeEventHandler(this._port_OnInterrupt);
        }
Ejemplo n.º 47
0
 public TristatePort(Cpu.Pin portId, bool initialState, bool glitchFilter, ResistorMode resistor)
     : base(portId, initialState, glitchFilter, resistor)
 {
 }
Ejemplo n.º 48
0
        /// <summary>
        /// Creates a new DipSwitch connected to the specified switchPins, with the InterruptMode and ResisterMode specified by the type parameters.
        /// </summary>
        /// <param name="device"></param>
        /// <param name="switchPins"></param>
        /// <param name="interruptMode"></param>
        /// <param name="resistorMode"></param>
        /// <param name="debounceDuration"></param>
        /// <param name="glitchFilterCycleCount"></param>
        public DipSwitch(IIODevice device, IPin[] switchPins, InterruptMode interruptMode, ResistorMode resistorMode, int debounceDuration = 20, int glitchFilterCycleCount = 0)
        {
            Switches = new ISwitch[switchPins.Length];

            for (int i = 0; i < switchPins.Length; i++)
            {
                Switches[i] = new SpstSwitch(device, switchPins[i], interruptMode, resistorMode, debounceDuration, glitchFilterCycleCount);
                int index = i;
                Switches[i].Changed += (s, e) => HandleSwitchChanged(index);
            }
        }
Ejemplo n.º 49
0
        //--//

        public InterruptPort(Cpu.Pin portId, bool glitchFilter, ResistorMode resistor, InterruptMode interrupt)
            : base(portId, glitchFilter, resistor, interrupt)
        {
            m_threadSpawn = null;
            m_callbacks = null;
        }
Ejemplo n.º 50
0
 public IBiDirectionalPort CreateBiDirectionalPort(IPin pin, bool initialState = false, bool glitchFilter = false, InterruptMode interruptMode = InterruptMode.None, ResistorMode resistorMode = ResistorMode.Disabled, PortDirectionType initialDirection = PortDirectionType.Input)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 51
0
 protected LED(Cpu.Pin portId, bool initialState, bool glitchFilter, ResistorMode resistorMode)
     :base(portId, initialState, glitchFilter, resistorMode)
 {
     
 }
Ejemplo n.º 52
0
 protected OutputPort(Cpu.Pin portId, bool initialState, bool glitchFilter, ResistorMode resistor)
     : base(portId, initialState, glitchFilter, resistor)
 {
     //throw new NotImplementedException();
     GPIOManager.Instance.SetPortType(portId, PortType.OUTPUT);
 }
Ejemplo n.º 53
0
 protected OutputPort(Cpu.Pin portId, bool initialState, bool glitchFilter, ResistorMode resistor)
 {
 }
Ejemplo n.º 54
0
 protected Port(Cpu.Pin portId, bool initialState, bool glitchFilter, ResistorMode resistor)
 {
     this.Id = portId;
     throw new NotImplementedException();
 }
Ejemplo n.º 55
0
 public InterruptPort(Cpu.Pin portId, bool glitchFilter, ResistorMode resistor, InterruptMode interrupt)
     : base(portId, glitchFilter, resistor)
 {
 }
Ejemplo n.º 56
0
 protected InputPort(Cpu.Pin portId, bool glitchFilter, ResistorMode resistor, InterruptMode interruptMode)
     : base(portId, glitchFilter, resistor, interruptMode)
 {
     GPIOManager.GetInstance().SetPortType(portId, PortType.INPUT);
 }
Ejemplo n.º 57
0
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <param name="socket">The socket for the digital input interface.</param>
        /// <param name="pin">The pin used by the digital input interface.</param>
        /// <param name="glitchFilterMode">
        ///  A value from the <see cref="GlitchFilterMode"/> enumeration that specifies
        ///  whether to enable the glitch filter on this digital input interface.
        /// </param>
        /// <param name="resistorMode">
        ///  A value from the <see cref="ResistorMode"/> enumeration that establishes a default state for the digital input interface. N.B. .NET Gadgeteer mainboards are only required to support ResistorMode.PullUp on interruptable GPIOs and are never required to support ResistorMode.PullDown; consider putting the resistor on the module itself.
        /// </param>
        /// <param name="module">The module using this interface, which can be null if unspecified.</param>
        public DigitalInput(Socket socket, Socket.Pin pin, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, Module module)
        {
            this.port = new InputPort(socket.ReservePin(pin, module), glitchFilterMode == GlitchFilterMode.On, (Port.ResistorMode)resistorMode);

            if (this.port == null)
            {
                // this is a mainboard error but should not happen since we check for this, but it doesnt hurt to double-check
                throw new Socket.InvalidSocketException("Socket " + socket + " has an error with its Digital Input functionality. Please try a different socket.");
            }
        }
Ejemplo n.º 58
0
 public TristatePort(Cpu.Pin portId, bool initialState, bool glitchFilter, ResistorMode resistor)
     : base(portId, initialState, glitchFilter, resistor)
 {
     GPIOManager.GetInstance().SetPortType(portId, PortType.INPUT);
     active = false;
     this.InitialState = initialState;
     this.firstTimeOutput = true;
 }
Ejemplo n.º 59
0
 public CamPositionSensor(Cpu.Pin pin, bool glitchFilter, ResistorMode resistorMode, InterruptMode interruptMode)
     : base(pin, glitchFilter, resistorMode, interruptMode)
 {
 }