- public FtdiUart(int vendor, int product, int baud) {
- example.ftdi_init(context);
- example.ftdi_usb_open(context, vendor, product);
- example.ftdi_usb_reset(context);
- example.ftdi_set_baudrate(context, baud);
- example.ftdi_set_line_property(context, 8, 0, 0);
- purge();
+ /**
+ * Switch to uart mode, with read/write access to four CBUS lines.
+ * This function is used to write to the CBUS lines (re-invoke it to change their state).
+ * I think readPins() is used to read from them, but I'm not sure.
+ *
+ * @param cbus_mask a four-bit mask; set bit=1 to write to a CBUS line, bit=0 to read from it
+ * @param cbus_bits a four-bit mask; the bits to assert on the write-enabled CBUS lines
+ */
+ public synchronized void uart_and_cbus_mode(int cbus_mask, int cbus_bits) throws IOException {
+ FtdiUartNative.ftdi_set_bitmode(context, (short)((cbus_mask << 4) | cbus_bits), (short)0x20);
+ FtdiUartNative.ftdi_setflowctrl(context, (1<<8));