diff lcdtest/busops.c @ 13:238a77db4134

lcdtest: read operations implemented, but don't work
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 06 Apr 2018 06:43:02 +0000
parents 5eaf832d57d0
children 5a602e512b12
line wrap: on
line diff
--- a/lcdtest/busops.c	Fri Apr 06 06:15:11 2018 +0000
+++ b/lcdtest/busops.c	Fri Apr 06 06:43:02 2018 +0000
@@ -72,3 +72,27 @@
 	cmd[8] = val16;
 	do_ftdi_write(cmd, 9);
 }
+
+bus_read(rs)
+{
+	u_char cmd[8], resp[2];
+
+	/* set RS */
+	cmd[0] = 0x82;
+	cmd[1] = rs ? 0x03 : 0x02;
+	cmd[2] = 0x03;
+	/* read upper byte */
+	cmd[3] = 0x90;
+	cmd[4] = 0;	/* dummy addr */
+	/* read lower byte */
+	cmd[5] = 0x90;
+	cmd[6] = 0;	/* dummy addr */
+	/* send immediate */
+	cmd[7] = 0x87;
+	do_ftdi_write(cmd, 8);
+	if (ftdi_read_data(&ftdi, resp, 2) != 2) {
+		fprintf(stderr, "FTDI read error: %s\n", ftdi.error_str);
+		exit(1);
+	}
+	return (resp[0] << 8) | resp[1];
+}