From: adam Date: Wed, 20 Sep 2006 07:22:23 +0000 (+0100) Subject: checkpoint X-Git-Tag: mpar_demo_release~85 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=32c32a0f04453f5675f5ebf5adfd8ca33e7cf821;p=slipway.git checkpoint --- diff --git a/src/com/ftdi/usb/example.java b/src/com/ftdi/usb/example.java index d2f165b..0296c95 100644 --- a/src/com/ftdi/usb/example.java +++ b/src/com/ftdi/usb/example.java @@ -55,6 +55,10 @@ public class example { 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)); } @@ -83,10 +87,6 @@ public class example { 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)); } diff --git a/src/com/ftdi/usb/exampleJNI.java b/src/com/ftdi/usb/exampleJNI.java index 2f8ea3a..8ed3e98 100644 --- a/src/com/ftdi/usb/exampleJNI.java +++ b/src/com/ftdi/usb/exampleJNI.java @@ -20,6 +20,7 @@ class exampleJNI { 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); @@ -27,7 +28,6 @@ class exampleJNI { 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); diff --git a/src/edu/berkeley/obits/device/atmel/AvrDrone.java b/src/edu/berkeley/obits/device/atmel/AvrDrone.java index 6e1a37c..23cf27d 100644 --- a/src/edu/berkeley/obits/device/atmel/AvrDrone.java +++ b/src/edu/berkeley/obits/device/atmel/AvrDrone.java @@ -24,12 +24,21 @@ public class AvrDrone extends AtmelDevice { 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"); } diff --git a/src/edu/berkeley/obits/device/atmel/ChipImpl.java b/src/edu/berkeley/obits/device/atmel/ChipImpl.java index ec48f7b..12fcaec 100644 --- a/src/edu/berkeley/obits/device/atmel/ChipImpl.java +++ b/src/edu/berkeley/obits/device/atmel/ChipImpl.java @@ -4,7 +4,7 @@ import java.io.*; public class ChipImpl extends FtdiChip implements Chip { - protected int dmask = + private int dmask = //(1<<0) | (1<<1) | (1<<2) | @@ -20,8 +20,20 @@ public class ChipImpl extends FtdiChip implements Chip { } 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(); @@ -30,6 +42,7 @@ public class ChipImpl extends FtdiChip implements Chip { data(false); con(false); flush(); + //try { Thread.sleep(500); } catch (Exception e) { } reset(false); flush(); @@ -38,7 +51,7 @@ public class ChipImpl extends FtdiChip implements Chip { reset(true); flush(); try { Thread.sleep(500); } catch (Exception e) { } - + dbangmode(dmask); flush(); } diff --git a/src/edu/berkeley/obits/device/atmel/FtdiBoard.java b/src/edu/berkeley/obits/device/atmel/FtdiBoard.java index e90aaca..63771d1 100644 --- a/src/edu/berkeley/obits/device/atmel/FtdiBoard.java +++ b/src/edu/berkeley/obits/device/atmel/FtdiBoard.java @@ -35,38 +35,47 @@ public class FtdiBoard extends Board { 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); @@ -120,8 +129,8 @@ public class FtdiBoard extends Board { //((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) { } diff --git a/src/edu/berkeley/obits/device/atmel/FtdiChip.java b/src/edu/berkeley/obits/device/atmel/FtdiChip.java index 60d84f6..aeea77e 100644 --- a/src/edu/berkeley/obits/device/atmel/FtdiChip.java +++ b/src/edu/berkeley/obits/device/atmel/FtdiChip.java @@ -14,7 +14,9 @@ public class FtdiChip { 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(); } @@ -44,7 +46,7 @@ public class FtdiChip { } 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);