Example #1
0
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <remarks>This automatically checks that the socket supports Type A, and reserves the pin used.
        /// An exception will be thrown if there is a problem with these checks.</remarks>
        /// <param name="socket">The socket.</param>
        /// <param name="pin">The analog input pin to use.</param>
        /// <param name="module">The module using the socket, which can be null if unspecified.</param>
        public AnalogInput(Socket socket, Socket.Pin pin, Module module)
        {
            socket.EnsureTypeIsSupported('A', module);
            socket.ReservePin(pin, module);

            Cpu.AnalogChannel channel = Cpu.AnalogChannel.ANALOG_NONE;
            switch (pin)
            {
            case Socket.Pin.Three:
                channel = socket.AnalogInput3;
                break;

            case Socket.Pin.Four:
                channel = socket.AnalogInput4;
                break;

            case Socket.Pin.Five:
                channel = socket.AnalogInput5;
                break;
            }

            // native implementation is preferred to an indirected one
            if (channel == Cpu.AnalogChannel.ANALOG_NONE && socket.AnalogInputIndirector != null)
            {
                Interface = socket.AnalogInputIndirector(socket, pin, module);
            }

            else
            {
                Interface = new NativeAnalogInput(socket, pin, module, channel);
            }
        }
Example #2
0
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <remarks>This automatically checks that the socket supports Type A, and reserves the pin used.
        /// An exception will be thrown if there is a problem with these checks.</remarks>
        /// <param name="socket">The socket.</param>
        /// <param name="pin">The analog input pin to use.</param>
        /// <param name="module">The module using the socket, which can be null if unspecified.</param>
        public AnalogInput(Socket socket, Socket.Pin pin, Module module)
        {
            this.socket = socket;
            socket.EnsureTypeIsSupported('A', module);

            switch (pin)
            {
            case Socket.Pin.Three:
                ain = socket.AnalogInput3;
                break;

            case Socket.Pin.Four:
                ain = socket.AnalogInput4;
                break;

            case Socket.Pin.Five:
                ain = socket.AnalogInput5;
                break;

            default:
                if (module != null)
                {
                    throw new Socket.InvalidSocketException("Module " + module + " cannot use Analog Input interface on pin " + pin + " - pin must be in range 3 to 5.");
                }
                else
                {
                    throw new Socket.InvalidSocketException("Cannot use Analog Input interface on pin " + pin + " - pin must be in range 3 to 5.");
                }
            }

            if (ain == null)
            {
                // this is a mainboard error that should not happen (we already check for it in SocketInterfaces.RegisterSocket) but just in case...
                throw new Socket.InvalidSocketException("Socket " + socket + " has an error with its Analog Input functionality. Please try a different socket.");
            }

            socket.ReservePin(pin, module);
        }
Example #3
0
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <remarks>This automatically checks that the socket supports Type A, and reserves the pin used.
        /// An exception will be thrown if there is a problem with these checks.</remarks>
        /// <param name="socket">The socket.</param>
        /// <param name="pin">The analog input pin to use.</param>
        /// <param name="module">The module using the socket, which can be null if unspecified.</param>
        public AnalogInput(Socket socket, Socket.Pin pin, Module module)
        {
            socket.EnsureTypeIsSupported('A', module);
            socket.ReservePin(pin, module);

            Cpu.AnalogChannel channel = Cpu.AnalogChannel.ANALOG_NONE;
            switch (pin)
            {
                case Socket.Pin.Three:
                    channel = socket.AnalogInput3;
                    break;

                case Socket.Pin.Four:
                    channel = socket.AnalogInput4;
                    break;

                case Socket.Pin.Five:
                    channel = socket.AnalogInput5;
                    break;
            }

            // native implementation is preferred to an indirected one
            if (channel == Cpu.AnalogChannel.ANALOG_NONE && socket.AnalogInputIndirector != null)
                Interface = socket.AnalogInputIndirector(socket, pin, module);

            else
                Interface = new NativeAnalogInput(socket, pin, module, channel);
        }