示例#1
0
        private void buttonI2Cread_Click(object sender, EventArgs e)
        {
            listBoxProgramMessages.Items.Clear();

            USB_I2C_Flash i2cflash = null;

            switch (comboBoxI2CFlashType.Text)
            {
            case "Microchip 24FC256":
                i2cflash = new USB_24FC256();
                break;
            }
            if (i2cflash == null)
            {
                postMessage("No flash type selected");
                return;
            }

            List <string> msgs      = new List <string>();
            bool          connected = i2cflash.connect(msgs);

            postMessages(msgs);

            if (!connected)
            {
                postMessage("Programmer: connection failed");
                return;
            }
            postMessage("Programmer: connected");

            int flashsiz = i2cflash.FlashSize();

            postMessage("FlashInfo: " + flashsiz.ToString() + " bytes flash");

            postMessage("Reading device at address 0 number of bytes " + flashsiz.ToString());
            long tick2 = System.DateTime.Now.Ticks;

            byte[] flashprogrammemory = i2cflash.SequentialRead(0, flashsiz);
            double tock2 = (System.DateTime.Now.Ticks - tick2) / 10000000.0;

            postMessage("Reading took " + tock2.ToString() + "s");

            SaveFileDialog fd = new SaveFileDialog();

            fd.AddExtension = true;
            fd.Filter       = "Raw Binary File (*.bin)|*.bin";
            DialogResult res = fd.ShowDialog();

            if (res == DialogResult.OK)
            {
                RawBinaryfile rbf = new RawBinaryfile(flashprogrammemory);
                rbf.SaveFile(fd.FileName);
            }
        }
示例#2
0
        private void buttonProgramRead_Click(object sender, EventArgs e)
        {
            listBoxProgramMessages.Items.Clear();

            USB_ATTinyTPI usb       = createInterface();
            List <string> msgs      = new List <string>();
            bool          connected = usb.connect(msgs);

            postMessages(msgs);

            if (!connected)
            {
                postMessage("Target: connection failed");
                return;
            }
            postMessage("Target: connected");

            USB_ATTinyTPI.Processor proc = usb.CPU_identify();
            listBoxProgramMessages.Items.Add("CPU = " + proc.ToString());

            usb.NVM_command(USB_ATTinyTPI.NVMCommand.NO_OPERATION);
            usb.NVM_waitbusy();

            postMessage("Reading device at address " + usb.CPU_flashaddress() + " number of bytes " + usb.CPU_flashsize());
            long tick2 = System.DateTime.Now.Ticks;

            byte[] flashprogrammemory = usb.CPU_readbytes(usb.CPU_flashaddress(), usb.CPU_flashsize());
            double tock2     = (System.DateTime.Now.Ticks - tick2) / 10000000.0;
            bool   flashedok = true;

            postMessage("Reading took " + tock2.ToString() + "s");

            SaveFileDialog fd = new SaveFileDialog();

            fd.AddExtension = true;
            fd.Filter       = "Raw Binary File (*.bin)|*.bin";
            DialogResult res = fd.ShowDialog();

            if (res == DialogResult.OK)
            {
                RawBinaryfile rbf = new RawBinaryfile(flashprogrammemory);
                rbf.SaveFile(fd.FileName);
            }
        }