public ushort ReadbackX1BRegister(ChannelAddress channelAddress)
 {
     using (_lockFactory.GetLock(LockType.CommandLock))
     {
         if (channelAddress < ChannelAddress.Dac0 || channelAddress > ChannelAddress.Dac39)
         {
             throw new ArgumentOutOfRangeException(nameof(channelAddress));
         }
         if (_evalBoard.DeviceState.UseRegisterCache &&
             _evalBoard.DeviceState.X1BRegisters[channelAddress.ToChannelNumber()].HasValue)
         {
             var deviceStateX1BRegister = _evalBoard.DeviceState.X1BRegisters[channelAddress.ToChannelNumber()];
             if (deviceStateX1BRegister != null)
             {
                 return(deviceStateX1BRegister.Value);
             }
         }
         _sendSpecialFunctionCommand.SendSpecialFunction(SpecialFunctionCode.SelectRegisterForReadback,
                                                         (ushort)((ushort)AddressCodesForDataReadback.X1BRegister |
                                                                  (ushort)(((byte)channelAddress & (byte)BasicMasks.SixBits) << 7)));
         var val = _readSPICommand.ReadSPI();
         if (_evalBoard.DeviceState.Precision == DacPrecision.FourteenBit)
         {
             val &= (ushort)BasicMasks.HighFourteenBits;
         }
         _evalBoard.DeviceState.X1BRegisters[channelAddress.ToChannelNumber()] = val;
         return(val);
     }
 }
Exemplo n.º 2
0
        public ushort ReadbackOFS1Register()
        {
            using (_lockFactory.GetLock(LockType.CommandLock))
            {
                if (_evalBoard.DeviceState.UseRegisterCache && _evalBoard.DeviceState.OFS1Register.HasValue)
                {
                    return(_evalBoard.DeviceState.OFS1Register.Value);
                }

                _sendSpecialFunctionCommand.SendSpecialFunction(SpecialFunctionCode.SelectRegisterForReadback,
                                                                (ushort)AddressCodesForDataReadback.OFS1Register);
                var spi = _readSPICommand.ReadSPI();
                var val = (ushort)(spi & (ushort)BasicMasks.FourteenBits);
                _evalBoard.DeviceState.OFS1Register = val;
                return(val);
            }
        }
        public ControlRegisterBits ReadbackControlRegister()
        {
            using (_lockFactory.GetLock(LockType.CommandLock))
            {
                if (_evalBoard.DeviceState.UseRegisterCache && _evalBoard.DeviceState.ControlRegister.HasValue)
                {
                    return((ControlRegisterBits)((ushort)_evalBoard.DeviceState.ControlRegister.Value &
                                                 (ushort)ControlRegisterBits.ReadableBits));
                }

                _sendSpecialFunctionCommand.SendSpecialFunction(SpecialFunctionCode.SelectRegisterForReadback,
                                                                (ushort)AddressCodesForDataReadback.ControlRegister);
                var val = (ControlRegisterBits)(_readSPICommand.ReadSPI() & (ushort)ControlRegisterBits.ReadableBits);
                _evalBoard.DeviceState.ControlRegister = val;
                return(val);
            }
        }
        public ABSelectRegisterBits ReadbackABSelectRegister(int registerNumber)
        {
            if (registerNumber < 0 || registerNumber > 4)
            {
                throw new ArgumentOutOfRangeException(nameof(registerNumber));
            }
            using (_lockFactory.GetLock(LockType.CommandLock))
            {
                var deviceState = _evalBoard.DeviceState;
                if (deviceState.UseRegisterCache && deviceState.ABSelectRegisters[registerNumber].HasValue)
                {
                    return(deviceState.ABSelectRegisters[registerNumber].Value);
                }

                _sendSpecialFunctionCommand.SendSpecialFunction(
                    SpecialFunctionCode.SelectRegisterForReadback,
                    (ushort)AddressCodesForABSelectRegisters[registerNumber]);
                var spi = _readSPICommand.ReadSPI();
                var val = (ABSelectRegisterBits)spi;
                _evalBoard.DeviceState.ABSelectRegisters[registerNumber] = val;
                return(val);
            }
        }