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); } }
public static void Main() { List <string> msgs = new List <string>(); USB_24FC256 usb = new USB_24FC256(); if (!usb.connect(msgs)) { return; } usb.Address = 0; //usb.PageWrite(0, new byte[]{161,162,163,164,165}); byte ss = usb.RandomRead(0); ss = usb.RandomRead(1); ss = usb.CurrentAddressRead(); byte[] b = usb.SequentialRead(0, 512); }