return exampleJNI.ftdi_setflowctrl(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), flowctrl);
}
+ public static int ftdi_usb_reset(SWIGTYPE_p_ftdi_context ftdi) {
+ return exampleJNI.ftdi_usb_reset(SWIGTYPE_p_ftdi_context.getCPtr(ftdi));
+ }
+
public static void ftdi_deinit(SWIGTYPE_p_ftdi_context ftdi) {
exampleJNI.ftdi_deinit(SWIGTYPE_p_ftdi_context.getCPtr(ftdi));
}
return exampleJNI.ftdi_usb_close(SWIGTYPE_p_ftdi_context.getCPtr(ftdi));
}
- public static int ftdi_usb_reset(SWIGTYPE_p_ftdi_context ftdi) {
- return exampleJNI.ftdi_usb_reset(SWIGTYPE_p_ftdi_context.getCPtr(ftdi));
- }
-
public static int ftdi_usb_purge_buffers(SWIGTYPE_p_ftdi_context ftdi) {
return exampleJNI.ftdi_usb_purge_buffers(SWIGTYPE_p_ftdi_context.getCPtr(ftdi));
}
public final static native int ftdi_set_bitmode(long jarg1, short jarg2, short jarg3);
public final static native int ftdi_read_pins(long jarg1, byte[] jarg2);
public final static native int ftdi_setflowctrl(long jarg1, int jarg2);
+ public final static native int ftdi_usb_reset(long jarg1);
public final static native void ftdi_deinit(long jarg1);
public final static native void ftdi_set_usbdev(long jarg1, long jarg2);
public final static native int ftdi_usb_find_all(long jarg1, long jarg2, int jarg3, int jarg4);
public final static native int ftdi_usb_open_desc(long jarg1, int jarg2, int jarg3, String jarg4, String jarg5);
public final static native int ftdi_usb_open_dev(long jarg1, long jarg2);
public final static native int ftdi_usb_close(long jarg1);
- public final static native int ftdi_usb_reset(long jarg1);
public final static native int ftdi_usb_purge_buffers(long jarg1);
public final static native int ftdi_read_data_set_chunksize(long jarg1, long jarg2);
public final static native int ftdi_read_data_get_chunksize(long jarg1, long jarg2);
private void init() throws IOException {
Log.debug(this, "waiting for device to identify itself");
+ /*
if (in.readByte() != (byte)'O') throw new RuntimeException("didn't get the proper signature");
if (in.readByte() != (byte)'B') throw new RuntimeException("didn't get the proper signature");
if (in.readByte() != (byte)'I') throw new RuntimeException("didn't get the proper signature");
if (in.readByte() != (byte)'T') throw new RuntimeException("didn't get the proper signature");
if (in.readByte() != (byte)'S') throw new RuntimeException("didn't get the proper signature");
if (in.readByte() != (byte)'\n') throw new RuntimeException("didn't get the proper signature");
+ */
+ out.write(0);
+ byte[] bytes = new byte[6];
+ for(int i=0; i<6; i++) {
+ bytes[i] = in.readByte();
+ System.out.println("got " + (i+1) + " header bytes: " + (bytes[i] & 0xff) + " '" + ((char)bytes[i]) + "'");
+ // FIXME
+ }
Log.info(this, "device correctly identified itself; ready for operation");
}
public class ChipImpl extends FtdiChip implements Chip {
- protected int dmask =
+ private int dmask =
//(1<<0) |
(1<<1) |
(1<<2) |
}
public void doReset() {
+ /*
+dmask =
+ (1<<0) |
+ (1<<1) |
+ (1<<2) |
+ //(1<<3) |
+ //(1<<4) |
+ (1<<5) |
+ (1<<6) |
+ (1<<7);
+ */
flush();
+ //purge();
dbangmode(dmask);
flush();
data(false);
con(false);
flush();
+ //try { Thread.sleep(500); } catch (Exception e) { }
reset(false);
flush();
reset(true);
flush();
try { Thread.sleep(500); } catch (Exception e) { }
-
+
dbangmode(dmask);
flush();
}
public void boot(Reader r) throws Exception {
boolean pin;
Chip d = chip;
- /*
- d.buffered(false);
+
+ //d.buffered(false);
+ for(int i=0; i<1000; i++) {
d.doReset();
d.config(0,10);
- d.con();
d.flush();
+ d.con();
+ //d.flush();
d.config(Integer.parseInt("10110111", 2), 8);
d.config(0,1);
d.flush();
+ try { Thread.sleep(100); } catch (Exception e) { }
pin = d.initErr();
System.out.println("good preamble => " + pin + " " + (pin ? green("good") : red("BAD")));
d.doReset();
+ try { Thread.sleep(100); } catch (Exception e) { }
d.config(0,9);
- d.con();
d.flush();
+ d.con();
+ //d.flush();
d.config(Integer.parseInt("10110111", 2), 8);
d.config(0, 2);
d.flush();
+ try { Thread.sleep(100); } catch (Exception e) { }
pin = d.initErr();
System.out.println("bad preamble #2 => " + pin + " " + (pin ? red("BAD") : green("good")));
d.doReset();
+ try { Thread.sleep(100); } catch (Exception e) { }
d.config(0,10);
- d.con();
d.flush();
+ d.con();
+ //d.flush();
d.config(Integer.parseInt("11110111", 2), 8);
d.config(0, 1);
d.flush();
+ try { Thread.sleep(100); } catch (Exception e) { }
pin = d.initErr();
System.out.println("bad preamble #1 => " + pin + " " + (pin ? red("BAD") : green("good")));
- */
+ }
d.doReset();
d.config(0,10);
//((ChipImpl)d).avr();
//System.out.println("avr reset => true");
- chip.uart();
chip.purge();
+ chip.uart();
//d.avrrst(true);
//try { Thread.sleep(500); } catch (Exception e) { }
example.ftdi_init(context);
example.ftdi_usb_open(context, 0x6666, 0x3133);
example.ftdi_usb_reset(context);
- example.ftdi_set_baudrate(context, 750 * 1000);
+ //example.ftdi_set_baudrate(context, 750 * 1000);
+ example.ftdi_set_baudrate(context, 1500 * 1000);
+ //example.ftdi_set_baudrate(context, 750 * 1000 * 4);
example.ftdi_set_line_property(context, 8, 0, 0);
purge();
}
}
public synchronized void uart() {
example.ftdi_set_bitmode(context, (short)((mask << 4) | bits), (short)0x20);
- example.ftdi_setflowctrl(context, (1 << 8));
+ //example.ftdi_setflowctrl(context, (1 << 8));
}
public synchronized void dbangmode(int dmask) {
example.ftdi_set_bitmode(context, (short)dmask, (short)0x01);