Beispiel #1
0
            /// <summary>
            /// Writes the state of the pin
            /// </summary>
            /// <param name="state">The state to set the pin to. High (true) or low (false)</param>
            public void Write(Boolean state)
            {
                if (!_io60p16.IsPinReserved(_portId, _pinId))
                {
                    throw new Exception("This pin has already been reset or has not been initialized.");// reserve already
                }

                if (state)
                {
                    _io60p16.MakePinHigh(_portId, _pinId);
                }
                else
                {
                    _io60p16.MakePinLow(_portId, _pinId);
                }
            }
Beispiel #2
0
            /// <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();
            }
Beispiel #3
0
            /// <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);
                }
            }