1 package com.atmel.fpslic;
6 * Exposes the raw pin-level configuration interface to the FPSLIC
8 public class FpslicPinsUsb implements FpslicPins {
10 private FtdiUart ftdiuart;
12 public FpslicPinsUsb(FtdiUart ftdiuart) {
13 this.ftdiuart = ftdiuart;
16 public void avrrstPin(boolean on) throws IOException { setDBusLine(7, on); }
17 public void cclkPin(boolean on) throws IOException { setDBusLine(6, on); }
18 public void configDataPin(boolean on) throws IOException { setDBusLine(5, on); }
19 public boolean initPin() throws IOException { flush(); return (ftdiuart.readPins() & (1<<4))!=0; }
21 // tricky: RESET has a weak pull-up, and is wired to a CBUS line. So,
22 // we can pull it down (assert reset) from uart-mode, or we can
23 // let it float upward from either mode.
24 public void resetPin(boolean on) throws IOException {
25 ftdiuart.uart_and_cbus_mode(1<<1, on ? (1<<1) : 0);
28 ftdiuart.dbus_mode(dmask);
33 public void flush() throws IOException { ftdiuart.getOutputStream().flush(); }
35 private int dbits = 0;
36 public void setDBusLine() throws IOException {
37 ftdiuart.getOutputStream().write((byte)dbits);
39 public void clearDBusLines() throws IOException {
43 public void setDBusLine(int bit, boolean val) throws IOException {
44 dbits = val ? (dbits | (1 << bit)) : (dbits & (~(1 << bit)));
48 public void releaseConPin() throws IOException {
50 ftdiuart.dbus_mode(dmask);
54 public void conPin(boolean on) throws IOException {
56 ftdiuart.dbus_mode(dmask);
61 public void close() throws IOException {
62 // switching to uart mode will implicitly release AVRRST
65 ftdiuart.uart_and_cbus_mode(1<<1, 1<<1);
78 public InputStream getUartInputStream() throws IOException { return ftdiuart.getInputStream(); }
79 public OutputStream getUartOutputStream() throws IOException { return ftdiuart.getOutputStream(); }