Пример #1
0
        internal SpiDevice GetActiveDevice()
        {
            SpiDevice device = null;

            for (int i = 0; i < _devices.Count; i++)
            {
                SpiDevice deviceT = _devices[i];

                if (deviceT.IsActive)
                {
                    if (device != null)
                    {
                        if (_nullDevice.DisplayWarning || Emulator.Verbose)
                        {
                            Trace.WriteLine("Warning: multiple SpiDevices are active on the SpiBus");
                            _nullDevice.TurnOffWarning();
                        }
                    }

                    device = deviceT;
                }
            }

            if (device == null)
            {
                if (_nullDevice.DisplayWarning || Emulator.Verbose)
                {
                    Trace.WriteLine("Warning: no SpiDevice is active on the SpiBus");
                    _nullDevice.TurnOffWarning();
                }

                device = _nullDevice;
            }

            return(device);
        }