예제 #1
0
파일: Kernel.cs 프로젝트: elgendk/u2pa
        /// <summary>
        /// Calculates and writes some statistics about the connected Top Programmer
        /// and the UBS connection.
        /// </summary>
        /// <param name="shouter">The public address instance.</param>
        /// <returns>Exit code. 0 is fine; all other is bad.</returns>
        public static int ProgStat(IShouter shouter)
        {
            using (var td = TopDevice.Create(shouter))
            {
                var writeZif = new ZIFSocket(40);
                writeZif.SetAll(false);
                td.WriteZIF(writeZif, "");
                td.WriteZIF(writeZif, "");
                Stopwatch sw = new Stopwatch();
                sw.Start();
                for (var i = 0; i < 1000; i++)
                {
                    td.WriteZIF(writeZif, "");
                }
                sw.Stop();
                shouter.ShoutLine(0, "Average WriteZif = {0}ms (1000 performed)", (double)sw.ElapsedMilliseconds / 1000);

                sw.Reset();

                sw.Start();
                for (var i = 0; i < 1000; i++)
                {
                    td.ReadZIF("");
                }
                sw.Stop();
                shouter.ShoutLine(0, "Average ReadZif  = {0}ms (1000 performed)", (double)sw.ElapsedMilliseconds / 1000);
            }
            return(0);
        }
예제 #2
0
파일: Kernel.cs 프로젝트: elgendk/u2pa
        /// <summary>
        /// A simple SRAM-test.
        /// </summary>
        /// <param name="shouter">The shouter instance.</param>
        /// <param name="type">The type of SRAM.</param>
        /// <returns>Exit code. 0 is fine; all other is bad.</returns>
        public static int SRamTest(IShouter shouter, string type)
        {
            var sram = SRamXml.Specified[type];
            var totalNumberOfAdresses = sram.AddressPins.Length == 0 ? 0 : 1 << sram.AddressPins.Length;
            List <Tuple <int, string, string> > firstRandomPass, secondRandomPass, firstSimplePass, secondSimplePass;

            using (var progressBar = new ProgressBar(shouter, totalNumberOfAdresses * 8))
            {
                using (var topDevice = TopDevice.Create(shouter))
                {
                    shouter.ShoutLine(1, "Testing SRAM{0}", type);
                    progressBar.Init();
                    firstRandomPass  = topDevice.SRamTestPass(shouter, sram, progressBar, "First random test", totalNumberOfAdresses, new RandomDataGenerator(sram.DataPins.Length, totalNumberOfAdresses));
                    secondRandomPass = topDevice.SRamTestPass(shouter, sram, progressBar, "Second random test", totalNumberOfAdresses, new RandomDataGenerator(sram.DataPins.Length, totalNumberOfAdresses));
                    firstSimplePass  = topDevice.SRamTestPass(shouter, sram, progressBar, "First simple test (01..)", totalNumberOfAdresses, new SimpleDataGenerator(sram.DataPins.Length, false));
                    secondSimplePass = topDevice.SRamTestPass(shouter, sram, progressBar, "Second simple test (10..)", totalNumberOfAdresses, new SimpleDataGenerator(sram.DataPins.Length, true));
                }
            }
            var returnValue       = 0;
            var printingVerbosity = 1;

            returnValue = PrintTestPassResult(shouter, "first random", firstRandomPass, ref printingVerbosity);
            returnValue = PrintTestPassResult(shouter, "second random", secondRandomPass, ref printingVerbosity);
            returnValue = PrintTestPassResult(shouter, "first simple", firstSimplePass, ref printingVerbosity);
            returnValue = PrintTestPassResult(shouter, "second simple", secondSimplePass, ref printingVerbosity);
            if (returnValue == 0)
            {
                shouter.ShoutLine(1, "This piece of SRAM is just a'okay }};-P");
            }

            return(returnValue);
        }
예제 #3
0
파일: Kernel.cs 프로젝트: elgendk/u2pa
 /// <summary>
 /// Programs an EPROM.
 /// </summary>
 /// <param name="shouter">The shouter instance.</param>
 /// <param name="type">The type of the rom the be programmed.</param>
 /// <param name="fileData">The data to be written.</param>
 /// <param name="vppLevel">The Vpp-level; if not present, the one from the EPROM definition is used.
 /// <remarks>Not yet used!</remarks>
 /// </param>
 public static void RomWrite(IShouter shouter, string type, IList <byte> fileData, params string[] vppLevel)
 {
     using (var topDevice = TopDevice.Create(shouter))
     {
         var eprom = EpromXml.Specified[type];
         topDevice.WriteEpromClassic(eprom, fileData);
         //topDevice.WriteEpromFast(eprom, fileData);
     }
 }
예제 #4
0
파일: Kernel.cs 프로젝트: elgendk/u2pa
        public static int DevGndPins(Shouter shouter)
        {
            var  onScreen = "n/f = increase pinnumber by 1/10; p/b = decrease pinnumber by 1/10; q = quit!";
            byte p        = 0;
            var  quit     = false;

            while (!quit)
            {
                var tr  = new PinTranslator(40, 40, 0);
                var zif = new ZIFSocket(40);
                zif.SetAll(true);
                using (var td = TopDevice.Create(shouter))
                {
                    td.SetVccLevel(0x2D);
                    td.ApplyGnd(tr.ToZIF, new Pin {
                        Number = 40
                    });
                    td.ApplyVcc(tr.ToZIF, new Pin {
                        Number = 20
                    });
                    td.PullUpsEnable(true);
                    td.WriteZIF(zif, "");
                    Console.WriteLine(onScreen);
                    switch (Console.ReadKey().Key)
                    {
                    case ConsoleKey.N:
                        p++;
                        break;

                    case ConsoleKey.F:
                        p += 10;
                        break;

                    case ConsoleKey.P:
                        p--;
                        break;

                    case ConsoleKey.B:
                        p -= 10;
                        break;

                    case ConsoleKey.Q:
                        quit = true;
                        break;

                    default:
                        Console.WriteLine(onScreen);
                        break;
                    }
                }
            }
            return(0);
        }
예제 #5
0
파일: Kernel.cs 프로젝트: elgendk/u2pa
        /// <summary>
        /// For dev.
        /// </summary>
        /// <param name="shouter">The shouter instance.</param>
        /// <returns>Exit code. 0 is fine; all other is bad.</returns>
        public static int Dev(IShouter shouter)
        {
            //var fpgaFile = new FPGAProgram(@"C:\Top\Topwin6\Blib2\ictest.bit");
            //Console.WriteLine(fpgaFile);
            {
                var tr  = new PinTranslator(40, 40, 0);
                var zif = new ZIFSocket(40);
                zif.SetAll(true);
                using (var td = TopDevice.Create(shouter))
                {
                    td.SetVccLevel(5.0);
                    td.SetVppLevel(13.0);
                    td.ApplyGnd(tr.ToZIF, new Pin {
                        Number = 10
                    });
                    td.ApplyVcc(tr.ToZIF, new Pin {
                        Number = 40
                    });
                    td.PullUpsEnable(true);
                    td.WriteZIF(zif, "");
                    Console.ReadLine();
                }
            }

            {
                var tr  = new PinTranslator(40, 40, 0);
                var zif = new ZIFSocket(40);
                zif.SetAll(false);
                using (var td = TopDevice.Create(shouter))
                {
                    td.SetVccLevel(5.0);
                    td.SetVppLevel(21.0);
                    td.ApplyGnd(tr.ToZIF, new Pin {
                        Number = 10
                    });
                    td.ApplyVcc(tr.ToZIF, new Pin {
                        Number = 40
                    });
                    td.PullUpsEnable(true);
                    td.WriteZIF(zif, "");
                    Console.ReadLine();
                }
            }
            //Console.WriteLine("Testing {0} for Erasure }};-P", args[1]);
            //var fileData = Tools.ReadBinaryFile(args[1]).ToArray();

            //if(fileData.Any(b => b != 0xff))
            //  throw new U2PaException("No good }};-(");
            //else Console.WriteLine("File {0} filled with all nice little 0xFF's }};-P", args[1]);

            return(0);
        }
예제 #6
0
파일: Kernel.cs 프로젝트: elgendk/u2pa
        /// <summary>
        /// A simple vector test.
        /// </summary>
        /// <param name="shouter">The shouter instance.</param>
        /// <param name="type">The type of test.</param>
        /// <returns>The results of the test.</returns>
        public static int VectorTest(IShouter shouter, string type)
        {
            IList <byte>        bytes      = new List <byte>();
            var                 vectorTest = VectorTestXml.Specified[type];
            List <VectorResult> results;

            using (var progressBar = new ProgressBar(shouter, vectorTest.Vectors.Count))
            {
                using (var topDevice = TopDevice.Create(shouter))
                {
                    results = topDevice.VectorTest(vectorTest, progressBar);
                }
            }
            return(0);
        }
예제 #7
0
파일: Kernel.cs 프로젝트: elgendk/u2pa
        /// <summary>
        /// The main method for reading a rom that is defined in the Eproms.xml file.
        /// </summary>
        /// <param name="shouter">The shouter instance.</param>
        /// <param name="type">The type of the rom the be read.</param>
        /// <returns>Exit code. 0 is fine; all other is bad.</returns>
        public static IList <byte> RomRead(IShouter shouter, string type)
        {
            IList <byte> bytes = new List <byte>();
            var          eprom = EpromXml.Specified[type];
            var          totalNumberOfAdresses = eprom.AddressPins.Length == 0 ? 0 : 1 << eprom.AddressPins.Length;
            var          startAddress          = 0;

            using (var progressBar = new ProgressBar(shouter, totalNumberOfAdresses))
            {
                while (startAddress < totalNumberOfAdresses)
                {
                    using (var topDevice = TopDevice.Create(shouter))
                    {
                        startAddress = topDevice.ReadEprom(eprom, progressBar, bytes, startAddress, totalNumberOfAdresses);
                    }
                    if (startAddress < totalNumberOfAdresses)
                    {
                        progressBar.Shout("Disposing Top USB interface and inits a new");
                    }
                }
            }
            return(bytes);
        }