コード例 #1
0
        /// <summary>
        /// NOT WORKING YET!
        /// </summary>
        /// <param name="eprom"></param>
        /// <param name="bytes"></param>
        public void WriteEpromFast(Eprom eprom, IList <byte> bytes)
        {
            if (eprom.VppPins.Any(p => eprom.OutputEnable.Any(q => p.Number == q.Number)))
            {
                throw new U2PaException("Fast Programming Algoritm can't by used for this EPROM (yet)");
            }
            var totalNumberOfAdresses = eprom.AddressPins.Length == 0 ? 0 : 1 << eprom.AddressPins.Length;
            var translator            = eprom.GetPinTranslator(ZIFType);

            {
                var zif = new ZIFSocket(ZIFType);
                zif.SetAll(true);
                zif.Disable(eprom.Program, translator.ToZIF);

                WriteZIF(zif, "Apply 1 to all pins");
                SetVccLevel(eprom.VccLevel);
                SetVppLevel(eprom.VppLevel);
                ApplyGnd(translator.ToZIF, eprom.GndPins);
                ApplyVcc(translator.ToZIF, eprom.VccPins);
                ApplyVpp(translator.ToZIF, eprom.VppPins);
            }

            using (var progress = new ProgressBar(Shouter, totalNumberOfAdresses))
            {
                progress.Init();
                foreach (var address in Enumerable.Range(0, totalNumberOfAdresses))
                {
                    var pulse = 1;
                    while (pulse <= 32)
                    {
                        // Writing
                        var writerZif = new ZIFSocket(40);
                        writerZif.SetAll(true);
                        writerZif.Disable(eprom.GndPins, translator.ToZIF);
                        writerZif.Enable(eprom.Constants, translator.ToZIF);
                        writerZif.Disable(eprom.ChipEnable, translator.ToZIF);
                        writerZif.Disable(eprom.OutputEnable, translator.ToZIF);
                        writerZif.Disable(eprom.Program, translator.ToZIF);

                        eprom.SetAddress(writerZif, address);

                        var data = eprom.DataPins.Length > 8
              ? new[] { bytes[2 * address], bytes[2 * address + 1] }
              : new[] { bytes[address] };
                        eprom.SetData(writerZif, data);

                        WriteZIF(writerZif, "Write address & d ata to ZIF");
                        writerZif.Enable(eprom.ChipEnable, translator.ToZIF);
                        writerZif.Enable(eprom.Program, translator.ToZIF);
                        WriteZIF(writerZif, "Start pulse E");
                        writerZif.Disable(eprom.ChipEnable, translator.ToZIF);
                        writerZif.Disable(eprom.Program, translator.ToZIF);
                        BulkDevice.Delay(pulse);
                        WriteZIF(writerZif, "End pulse E");

                        // Reading
                        var addressZif = new ZIFSocket(40);
                        addressZif.SetAll(true);
                        addressZif.Disable(eprom.GndPins, translator.ToZIF);
                        addressZif.Enable(eprom.Constants, translator.ToZIF);
                        addressZif.Enable(eprom.ChipEnable, translator.ToZIF);
                        addressZif.Enable(eprom.OutputEnable, translator.ToZIF);
                        addressZif.Disable(eprom.Program, translator.ToZIF);
                        eprom.SetAddress(addressZif, address);

                        WriteZIF(addressZif, "Write address");
                        var       dataZifs = ReadZIF("Read data");
                        ZIFSocket resultZif;
                        if (Tools.AnalyzeEpromReadSoundness(dataZifs, eprom, address, out resultZif) == ReadSoundness.SeemsToBeAOkay)
                        {
                            if (eprom.GetData(resultZif).SequenceEqual(data))
                            {
                                // Data validates; now we overprogram
                                writerZif.Enable(eprom.ChipEnable, translator.ToZIF);
                                writerZif.Enable(eprom.Program, translator.ToZIF);
                                WriteZIF(writerZif, "Overprogram");
                                BulkDevice.Delay(3 * pulse);
                                writerZif.Disable(eprom.ChipEnable, translator.ToZIF);
                                writerZif.Disable(eprom.Program, translator.ToZIF);
                                WriteZIF(writerZif, "End pulse E");
                                break;
                            }
                            else
                            {
                                Console.WriteLine("Pulse: {0}", pulse);
                                Console.WriteLine("Address: {0}", address.ToString("X4"));
                                Console.WriteLine(eprom.GetData(writerZif).First());
                                Console.WriteLine(eprom.GetData(resultZif).First());
                            }
                        }


                        pulse *= 2;
                    }
                    if (pulse > 32)
                    {
                        progress.Shout("Address {0} doesn't validate! }};-(", address.ToString("X4"));
                    }
                    progress.Progress();
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Writes an EPROM using the Classic Algorithm
        /// </summary>
        /// <param name="eprom">The EPROM type.</param>
        /// <param name="bytes">The bytes to write.</param>
        /// <param name="patch">Not used yet!</param>
        public void WriteEpromClassic(Eprom eprom, IList <byte> bytes, IList <int> patch = null)
        {
            var totalNumberOfAdresses = eprom.AddressPins.Length == 0 ? 0 : 1 << eprom.AddressPins.Length;
            var translator            = eprom.GetPinTranslator(ZIFType);

            SetVccLevel(eprom.VccLevel);
            ApplyGnd(translator.ToZIF, eprom.GndPins);
            ApplyVcc(translator.ToZIF, eprom.VccPins);

            var initZif = new ZIFSocket(ZIFType);

            initZif.SetAll(true);
            initZif.Disable(eprom.GndPins, translator.ToZIF);
            initZif.Enable(eprom.Constants, translator.ToZIF);
            initZif.Disable(eprom.ChipEnable, translator.ToZIF);
            initZif.Disable(eprom.OutputEnable, translator.ToZIF);
            initZif.Disable(eprom.Program, translator.ToZIF);
            WriteZIF(initZif, "Apply 1 to all data and address pins");

            SetVppLevel(eprom.VppLevel);
            ApplyVpp(translator.ToZIF, eprom.VppPins);
            PullUpsEnable(true);

            using (var progress = new ProgressBar(Shouter, totalNumberOfAdresses))
            {
                progress.Init();
                foreach (var address in Enumerable.Range(0, totalNumberOfAdresses))
                {
                    //if(patch != null)
                    //{
                    //  if(!patch.Contains(address))
                    //    continue;
                    //  progress.Shout("Now patching address {0}", address);
                    //}

                    var zif = new ZIFSocket(40);

                    // Pull up all pins
                    zif.SetAll(true);

                    zif.Disable(eprom.GndPins, translator.ToZIF);
                    zif.Enable(eprom.Constants, translator.ToZIF);
                    zif.Disable(eprom.Program, translator.ToZIF);
                    zif.Disable(eprom.ChipEnable, translator.ToZIF);
                    zif.Disable(eprom.OutputEnable, translator.ToZIF);

                    // Set address and data
                    eprom.SetAddress(zif, address);
                    var data = eprom.DataPins.Length > 8
            ? new[] { bytes[2 * address], bytes[2 * address + 1] }
            : new[] { bytes[address] };
                    eprom.SetData(zif, data);

                    // Prepare ZIF without programming in order to let it stabilize
                    // TODO: Do we really need to do this?
                    WriteZIF(zif, "Write address & data to ZIF");

                    // In order to let the boost converter for manual Vcc
                    // spin up to full output voltage.
                    if (address == 0 && eprom.InitialProgDelay != 0)
                    {
                        BulkDevice.Delay(eprom.InitialProgDelay);
                    }

                    // Enter programming mode
                    zif.Enable(eprom.Program, translator.ToZIF);
                    zif.Enable(eprom.ChipEnable, translator.ToZIF);
                    WriteZIF(zif, "Start pulse E");

                    // Exit programming mode after at least <pulse> ms
                    zif.Disable(eprom.Program, translator.ToZIF);
                    zif.Disable(eprom.ChipEnable, translator.ToZIF);
                    BulkDevice.Delay(eprom.ProgPulse);
                    WriteZIF(zif, "End pulse E");

                    progress.Progress();
                }
            }
        }