/// <summary> /// Constructor for generic GPIO /// </summary> /// <param name="spiInterface"> Defines the SP-interface on RasPi board</param> /// <param name="spiAdr">Defines the CS-address combination for addressing the slave</param> /// <param name="givenConstrains">Restriction for using the respective device</param> /// <param name="givenSpecs">Specifications of given GPIO-slave</param> public GenreicGPIOslave(SpiDevice spiInterface, SPIAddressObject spiAdr, SPIHardwareConstrains givenConstrains, GPIOspecificDefinitions givenSpecs) : base(spiInterface, spiAdr, givenConstrains) { GPIOdefines = givenSpecs; PortData = new byte[GPIOdefines.NumOfPorts]; ExecuteConfigRun(eConfigRunMode.DeviceConfigOnly); }
/// <summary> /// Constructor for RasPiMultiSlave /// </summary> /// <param name="spiInterface"> Defines the SP-interface on RasPi board</param> /// <param name="spiAdr">Defines the CS-address combination (optional) to address the slave during transmission of data, /// can be null if no address definition needed</param> /// <param name="givenConstrains">Restriction for the respective device</param> public RaspiMultiSlave(SpiDevice spiInterface, SPIAddressObject spiAdr, SPIHardwareConstrains givenConstrains) { /// check if the SP-interface is defined if (spiInterface != null) { SpiConnectionSettings tempSet = spiInterface.ConnectionSettings; SPIconstrains = givenConstrains; /// Check whether the SPI-configuration meets demanded configuration //@todo Prüfen ob die Abfrage so überhaupt funktioniert if (tempSet.ClockFrequency < SPIconstrains.MinSPIclock) { spiInterface = null; throw new Exception("SPI-Clock doesn't meet the Specification: Clock was set to low"); } if (tempSet.ClockFrequency > SPIconstrains.MaxSPIclock) { spiInterface = null; throw new Exception("SPI-Clock doesn't meet the Specification: Clock was set to high"); } if (tempSet.Mode != SPIconstrains.DemandedSPIMode) { //@todo ggf. hier die Restriktion herausnehmen, wenn SPI on the Fly umkonfiguriert werden kann spiInterface = null; throw new Exception("SPI-Mode doesned meet the Specification"); } if (spiAdr != null) { switch (spiAdr.CSmode) { //@todo Hier prüfen was bei dem Kopieren passiert case SPIAddressObject.eCSadrMode.NoCSPort: case SPIAddressObject.eCSadrMode.SPIdedicated: // no further treatment necessary break; case SPIAddressObject.eCSadrMode.SPIwithGPIO: if (spiAdr.GpioCSpin != null) { throw new Exception("GPIO-Pin for CS use (SPIAddressObject.gpioCSpin) is not defined"); } // Set the CS-Pin high by default spiAdr.GpioCSpin.SetDriveMode(GpioPinDriveMode.Output); this.resetCSsignal(); break; case SPIAddressObject.eCSadrMode.SPIwithCSdemux: if (spiAdr.CSadrPins.Length == 0) { throw new Exception("There are no Address-Pins for CS-Demux specified"); } if (spiAdr.GpioCSpin != null) { spiAdr.GpioCSpin.SetDriveMode(GpioPinDriveMode.Output); } for (int idx = 0; idx < spiAdr.CSadrPins.Length; idx++) { spiAdr.CSadrPins[idx].SetDriveMode(GpioPinDriveMode.Output); } this.resetCSsignal(); break; default: throw new Exception("Some crazy shit just happend. The switch parameter is an enum hence this state should be impossible"); } CSadr = spiAdr; } else { //@todo hier ein Objekt definieren, dass modus ohne CS-Leitung wählt CSadr = new SPIAddressObject(SPIAddressObject.eCSadrMode.NoCSPort, null, null, 0); } /// Memorize SPI-Handle for further usage SPIhandle = spiInterface; } else { throw new Exception("Missing SP-interface-definition"); } }
/// <summary> /// Constructor for LED-driver /// </summary> /// <param name="spiInterface"> Defines the SP-interface on RasPi board</param> /// <param name="spiAdr">Defines the CS-address combination for addressing the slave</param> /// <param name="givenConstrains">Restriction for using the respective device</param> /// <param name="givenSpecs">Specifications of given LED-Slave</param> public GenreicLEDslave(SpiDevice spiInterface, SPIAddressObject spiAdr, SPIHardwareConstrains givenConstrains, LEDdriverSpecificDefinitions givenSpecs) : base(spiInterface, spiAdr, givenConstrains) { LEDSpecifigdefines = givenSpecs; }
/// <summary> /// Constructor for generic ADC /// </summary> /// <param name="spiInterface"> Defines the SP-interface on RasPi board</param> /// <param name="spiAdr">Defines the CS-address combination for addressing the slave</param> /// <param name="givenConstrains">Restriction for using the respective device</param> /// <param name="givenSpecs">Specifications of given ADC-Slave</param> public GenreicADCslave(SpiDevice spiInterface, SPIAddressObject spiAdr, SPIHardwareConstrains givenConstrains, ADCspecificDefinitions givenSpecs) : base(spiInterface, spiAdr, givenConstrains) { ADCdefines = givenSpecs; ADCresults = new Int16[ADCdefines.NumOfADCchannels]; }
/// <summary> /// Constructor for generic DAC /// </summary> /// <param name="spiInterface"> Defines the SP-interface on RasPi board</param> /// <param name="spiAdr">Defines the CS-address combination for addressing the slave</param> /// <param name="givenConstrains">Restriction for using the respective device</param> /// <param name="givenSpecs">Specifications of given DAC-Slave</param> public GenreicDACslave(SpiDevice spiInterface, SPIAddressObject spiAdr, SPIHardwareConstrains givenConstrains, DACspecificDefinitions givenSpecs) : base(spiInterface, spiAdr, givenConstrains) { DACdefines = givenSpecs; DACvalues = new Int16[DACdefines.NumOfDACchannels]; }