Hi all, I have this:
namespace TwoADC{ public class Program { public static SPI.Configuration LPMConfig = new SPI.Configuration(Pins.GPIO_PIN_D10, false, 0, 0, false, false, 1000, SPI_Devices.SPI1); public static SPI.Configuration ScatteringConfig = new SPI.Configuration(Pins.GPIO_PIN_D7, false, 0, 0, false, false, 1000, SPI_Devices.SPI1); public static AD7714 LaserADC = new AD7714(LPMConfig, Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D8); public static AD7714 ScatteringADC = new AD7714(ScatteringConfig, Pins.GPIO_PIN_D6, Pins.GPIO_PIN_D5);
And the AD7714 class I'm trying to adjust:
namespace TwoADC{ public class AD7714 { public AD7714(SPI.Configuration gooby, Cpu.Pin DataReadyPin, Cpu.Pin ResetPin) { ADC_drdy = new InputPort(DataReadyPin, false, Port.ResistorMode.PullUp); ADC_reset = new OutputPort(ResetPin, true); ADCBus = new SPI(gooby); } private static InputPort ADC_drdy { get; set; } private static OutputPort ADC_reset { get; set; } private static SPI ADCBus { get; set; }
What I would like to do is declare each ADC separately, so that I can then call
int Scattering = ScatteringADC.ReadChannel(1, 1, false, 40);int LPM = LaserADC.ReadChannel(1, 1, false, 40);
And have each call address a different SPI device. The SPI devices are identical.
What happens is when I try to initialize the second SPI object, the program throws a System.InvalidOperationException. I have no idea why, but I assume it's in trying to declare two different objects on the same bus. When I comment out either of the AD7714 objects, the code compiles and runs. I'm using different Chip Select pins each time in the constructors, so I don't know where the complaint is.
Help!