public IOHandler() { RaspberryPi.Initialize(); this.I2C = new I2CBusPi(); this.SPI = new SPIBusPi(0); this.PWMGenHighFreq = new PCA9685(this.I2C, 0x4C, -1, PCA9685.OutputInvert.Inverted, PCA9685.OutputDriverMode.OpenDrain); this.PWMGenLowFreq = new PCA9685(this.I2C, 0x74, -1, PCA9685.OutputInvert.Inverted, PCA9685.OutputDriverMode.OpenDrain); this.PWMGenHighFreq.SetFrequency(333); this.PWMGenLowFreq.SetFrequency(50); this.RailController = new Rail(this.PWMGenHighFreq.Outputs[0], new DigitalInPi(11), this.SPI, new DigitalOutPi(29), this.I2C, null) { TraceLogging = true }; this.DrillController = new Drill(this.PWMGenHighFreq.Outputs[1], this.PWMGenLowFreq.Outputs[0]); this.SampleController = new Sample(this.PWMGenLowFreq.Outputs[1]); this.LEDController = new LEDs(this.PWMGenLowFreq.Outputs, this.PWMGenHighFreq.Outputs); this.AuxSensors = new AuxSensors(this.SPI, this.I2C) { TraceLogging = false }; this.SysSensors = new SysSensors(); this.Music = new MusicPlayer(); this.InitProcedure = new ISubsystem[] { this.RailController, this.DrillController, this.LEDController, this.AuxSensors, this.SysSensors, this.Music }; this.EStopProcedure = new ISubsystem[] { this.Music, this.RailController, this.DrillController, this.LEDController, this.AuxSensors, this.SysSensors }; this.UpdateProcedure = new ISubsystem[] { this.RailController, this.DrillController, this.LEDController /*, this.AuxSensors, this.SysSensors*/ }; if (this.EStopProcedure.Length < this.InitProcedure.Length || this.EStopProcedure.Length < this.UpdateProcedure.Length) { throw new Exception("A system is registered for init or updates, but not for emergency stop. For safety reasons, this is not permitted."); } }
/// <summary> Prepares a TI TLV2544 ADC for use. </summary> /// <remarks> If <c>ConversionClockSource.INTERNAL</c> is used, there must be at least 4us or 8us of delay between SPI transactions for short and long sampling respectively. </remarks> /// <param name="SPIBus"> The SPI bus used to communicate with the device. </param> /// <param name="ChipSelect"> The output used as chip select for the device. </param> /// <param name="ExtRefVoltage"> Set this to the reference voltage only if using an external voltage reference. Expected values are between 0 and 5.5V. Leave as NaN if using internal reference, then select your desired reference via <c>Configure(...)</c>. </param> public TLV2544(ISPIBus SPIBus, IDigitalOut ChipSelect, double ExtRefVoltage = double.NaN) { this.Bus = SPIBus; this.CS = ChipSelect; this.ExtRefVoltage = ExtRefVoltage; this.Inputs = new AnalogueInTLV254x[4]; for (byte i = 0; i < this.Inputs.Length; i++) { this.Inputs[i] = new AnalogueInTLV254x(this, i); } }
/// <summary> WARNING: <c>BME280</c> has not been tested with SPI. </summary> /// <param name="SPIBus"> The SPI bus used to communicate with the device. </param> /// <param name="ChipSelect"> The output to use to signal chip select to the device. </param> public BME280(ISPIBus SPIBus, IDigitalOut ChipSelect) { this.IsSPI = true; this.SPIBus = SPIBus; this.SPICS = ChipSelect; }
/// <summary> Initializes the LS7366R SPI encoder counter chip. </summary> /// <param name="SPIBus"> SPI Bus to communicate with </param> /// <param name="ChipSelect"> Chip Select to use with SPI </param> /// <param name="CountEnable"> Digital Out to enable the counters </param> public LS7366R(ISPIBus SPIBus, IDigitalOut ChipSelect, IDigitalOut CountEnable = null) { this.ChipSelect = ChipSelect; this.CountEnable = CountEnable; this.SPIBus = SPIBus; }
public MAX31855(ISPIBus Bus, IDigitalOut ChipSelect) { this.Bus = Bus; this.ChipSelect = ChipSelect; }
public AuxSensors(ISPIBus SPI, II2CBus I2C) { this.Timer = new Timer(this.UpdateState, null, 0, 250); this.SPI0 = SPI; this.I2C1 = I2C; }