1 package edu.berkeley.obits.device.atmel;
5 public class ChipImpl extends FtdiChip implements Chip {
22 public void doReset() {
45 //try { Thread.sleep(500); } catch (Exception e) { }
49 try { Thread.sleep(500); } catch (Exception e) { }
50 if (initErr()) throw new RuntimeException("INIT was still high after pulling RESET low");
51 //System.out.println("0 con() = " + con());
55 try { Thread.sleep(500); } catch (Exception e) { }
56 if (!initErr()) throw new RuntimeException("INIT was still low after releasing RESET");
57 //System.out.println("1 con() = " + con());
62 public void porte(int pin, boolean b) {
63 porte = (~(1<<pin)) | (b ? (1<<pin) : 0);
70 public void config(boolean bit) { config(bit?1:0, 1); }
71 public void config(int dat) { config(dat, 8); }
72 public void config(int dat, int numbits) {
73 for(int i=(numbits-1); i>=0; i--) {
74 boolean bit = (dat & (1<<i)) != 0;
81 // tricky: RESET has a weak pull-up, and is wired to a CBUS line. So,
82 // we can pull it down (assert reset) from uart-mode, or we can
83 // let it float upward from either mode.
84 public void reset(boolean on) {
85 bits = on ? (1<<1) : 0;
98 public void avrrst(boolean on) { dbang(7, on); }
99 public void clk(boolean on) { dbang(6, on); }
100 public void data(boolean on) { dbang(5, on); }
102 public boolean initErr() { flush(); return (readPins() & (1<<4))!=0; }
104 public boolean con() {
108 return (readPins() & (1<<0)) != 0;
110 public void con(boolean on) {