private void DeactivateLED(int index) { switch (index) { case 0: FX3.SetPin(new FX3Api.FX3PinObject(13), 1); break; case 1: FX3.SetPin(new FX3Api.BitBangSpiConfig(true).CS, 1); break; case 2: FX3.SetPin(FX3.DIO4, 1); break; case 3: FX3.SetPin(FX3.DIO3, 1); break; case 4: FX3.SetPin(FX3.DIO2, 1); break; case 5: FX3.SetPin(FX3.DIO1, 1); break; case 6: case 7: FX3.DutSupplyMode = DutVoltage.Off; break; } }
public void USBTimingTest() { Console.WriteLine("Starting USB command execution timing test..."); const int NUM_TRIALS = 5000; /* Timer for measuring elapsed time */ Stopwatch timer = new Stopwatch(); //Set pin timer.Restart(); for (int trial = 0; trial < NUM_TRIALS; trial++) { FX3.SetPin(FX3.DIO1, 0); } timer.Stop(); Console.WriteLine("Average SetPin execution time: " + ((timer.ElapsedMilliseconds * 1000) / NUM_TRIALS).ToString() + "us"); timer.Restart(); for (int trial = 0; trial < NUM_TRIALS; trial++) { FX3.ReadPin(FX3.DIO1); } timer.Stop(); Console.WriteLine("Average ReadPin execution time: " + ((timer.ElapsedMilliseconds * 1000) / NUM_TRIALS).ToString() + "us"); timer.Restart(); for (int trial = 0; trial < NUM_TRIALS; trial++) { FX3.StallTime = 10; } timer.Stop(); Console.WriteLine("Average SPI parameter configuration time: " + ((timer.ElapsedMilliseconds * 1000) / NUM_TRIALS).ToString() + "us"); }
public void PinFunctionTimeoutTest() { Console.WriteLine("Starting pin functions timeout functionality test..."); /* Timer for measuring elapsed time */ Stopwatch timer = new Stopwatch(); for (uint timeout = 100; timeout <= 800; timeout += 100) { Console.WriteLine("Testing timeout of " + timeout.ToString() + "ms..."); FX3.SetPin(FX3.DIO4, 1); /* Pulse wait */ timer.Restart(); FX3.PulseWait(FX3.DIO3, 0, 0, timeout); timer.Stop(); Console.WriteLine("Pulse wait time: " + timer.ElapsedMilliseconds.ToString() + "ms"); Assert.GreaterOrEqual(timer.ElapsedMilliseconds, timeout, "ERROR: Function returned in less than timeout period"); Assert.LessOrEqual(timer.ElapsedMilliseconds, timeout + 100, "ERROR: Function returned in over 100ms more than timeout period"); CheckFirmwareResponsiveness(); /* Measure pin freq */ timer.Restart(); Assert.AreEqual(double.PositiveInfinity, FX3.MeasurePinFreq(FX3.DIO4, 0, timeout, 1), "ERROR: Invalid pin freq. Expected timeout"); timer.Stop(); Console.WriteLine("Measure pin freq time: " + timer.ElapsedMilliseconds.ToString() + "ms"); Assert.GreaterOrEqual(timer.ElapsedMilliseconds, timeout, "ERROR: Function returned in less than timeout period"); Assert.LessOrEqual(timer.ElapsedMilliseconds, timeout + 100, "ERROR: Function returned in over 100ms more than timeout period"); CheckFirmwareResponsiveness(); /* Measure pin delay */ timer.Restart(); FX3.MeasurePinDelay(FX3.DIO4, 0, FX3.DIO1, timeout); timer.Stop(); Console.WriteLine("Measure pin delay time: " + timer.ElapsedMilliseconds.ToString() + "ms"); Assert.GreaterOrEqual(timer.ElapsedMilliseconds, timeout, "ERROR: Function returned in less than timeout period"); Assert.LessOrEqual(timer.ElapsedMilliseconds, timeout + 100, "ERROR: Function returned in over 100ms more than timeout period"); CheckFirmwareResponsiveness(); /* Measure busy pulse */ timer.Restart(); Assert.AreEqual(double.PositiveInfinity, FX3.MeasureBusyPulse(FX3.DIO4, 1, 1, FX3.DIO1, 0, timeout), "ERROR: Expected measure busy pulse to return timeout"); timer.Stop(); Console.WriteLine("Measure busy pulse time: " + timer.ElapsedMilliseconds.ToString() + "ms"); Assert.GreaterOrEqual(timer.ElapsedMilliseconds, timeout, "ERROR: Function returned in less than timeout period"); Assert.LessOrEqual(timer.ElapsedMilliseconds, timeout + 100, "ERROR: Function returned in over 100ms more than timeout period"); CheckFirmwareResponsiveness(); } }
public void SetReadPinTest() { Console.WriteLine("Starting pin read/write test..."); const int NUM_TRIALS = 100; Console.WriteLine("Testing " + NUM_TRIALS.ToString() + " pin set/read trials"); for (int trial = 0; trial < NUM_TRIALS; trial++) { Console.WriteLine("Starting trial " + trial.ToString()); FX3.SetPin(FX3.DIO3, 1); Assert.AreEqual(1, FX3.ReadPin(FX3.DIO4), "ERROR: Invalid pin value read on DIO4"); FX3.SetPin(FX3.DIO3, 0); Assert.AreEqual(0, FX3.ReadPin(FX3.DIO4), "ERROR: Invalid pin value read on DIO4"); FX3.SetPin(FX3.DIO4, 1); Assert.AreEqual(1, FX3.ReadPin(FX3.DIO3), "ERROR: Invalid pin value read on DIO3"); FX3.SetPin(FX3.DIO4, 0); Assert.AreEqual(0, FX3.ReadPin(FX3.DIO3), "ERROR: Invalid pin value read on DIO3"); } }
private void ActivateLED(int index) { switch (index) { case 0: FX3.SetPin(new FX3Api.FX3PinObject(13), 0); break; case 1: FX3.SetPin(new FX3Api.BitBangSpiConfig(true).CS, 0); break; case 2: FX3.SetPin(FX3.DIO4, 0); break; case 3: FX3.SetPin(FX3.DIO3, 0); break; case 4: FX3.SetPin(FX3.DIO2, 0); break; case 5: FX3.SetPin(FX3.DIO1, 0); break; case 6: FX3.DutSupplyMode = DutVoltage.On5_0Volts; break; case 7: FX3.DutSupplyMode = DutVoltage.On3_3Volts; break; } }