private const int LatencyTimer = 255; // Hz static void Main(string[] args) { var adcSpiConfig = new FtChannelConfig { ClockRate = ConnectionSpeed, LatencyTimer = LatencyTimer, configOptions = FtConfigOptions.Mode0 | FtConfigOptions.CsDbus3 | FtConfigOptions.CsActivelow }; var adcConfig = new Maxim186Configuration { Channel = Maxim186.Channel.Channel0, ConversionType = Maxim186.ConversionType.SingleEnded, Polarity = Maxim186.Polarity.Unipolar, PowerMode = Maxim186.PowerMode.InternalClockMode }; var adc = new Maxim186(adcConfig, adcSpiConfig); do { Console.WriteLine(adc.GetConvertedSample()); } while (true); //*/ }
public int Begin(int address) { if (_i2cDevice == null) { var adci2cConfig = new FtChannelConfig { ClockRate = ConnectionSpeed, LatencyTimer = LatencyTimer }; if (_i2cDevice == null) { _i2cDevice = new I2CDevice(adci2cConfig, address); var b = _i2cDevice.Read(1); if (b == null) { Debugger.Break(); } _shadow = Convert.ToInt32(b[0]); _initialised = true; } } return 1; }
private void InitLibAndHandle() { FtResult result; if (_handle != IntPtr.Zero) return; LibMpsse.Init(); result = LibMpsseSpi.SPI_OpenChannel(_spiConfig.ChannelIndex, out _handle); CheckResult(result); if (_handle == IntPtr.Zero) throw new SpiChannelNotConnectedException(FtResult.InvalidHandle); result = LibMpsseSpi.SPI_InitChannel(_handle, ref _cfg); CheckResult(result); _currentGlobalConfig = _cfg; }
public extern static FtResult SPI_InitChannel(IntPtr handle, ref FtChannelConfig config);
public static extern FtResult I2C_InitChannel(System.IntPtr handle, ref FtChannelConfig config);
public Maxim186(Maxim186Configuration adcConfig, FtChannelConfig config, SpiConfiguration spiConfig) : base(config, spiConfig) { _adcConfig = adcConfig; }
public Maxim186(Maxim186Configuration adcConfig, FtChannelConfig config) : this(adcConfig, config, null) { }
protected SpiDevice(FtChannelConfig config, SpiConfiguration spiConfig) { _spiConfig = spiConfig ?? SpiConfiguration.ChannelZeroConfiguration; _cfg = config; InitLibAndHandle(); }
protected SpiDevice(FtChannelConfig config) : this(config, null) { }
private void EnforceRightConfiguration() { if (_currentGlobalConfig.configOptions != _cfg.configOptions) { LibMpsseSpi.SPI_ChangeCS(_handle, _cfg.configOptions); _currentGlobalConfig = _cfg; } }