changeset 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
files lcdtest/busops.c lcdtest/commands.c lcdtest/dispatch.c
diffstat 3 files changed, 40 insertions(+), 0 deletions(-) [+]
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];
+}
--- a/lcdtest/commands.c	Fri Apr 06 06:15:11 2018 +0000
+++ b/lcdtest/commands.c	Fri Apr 06 06:43:02 2018 +0000
@@ -1,6 +1,18 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+cmd_ri()
+{
+	printf("%04X\n", bus_read(0));
+	return(0);
+}
+
+cmd_rd()
+{
+	printf("%04X\n", bus_read(1));
+	return(0);
+}
+
 cmd_wi(argc, argv)
 	char **argv;
 {
--- a/lcdtest/dispatch.c	Fri Apr 06 06:15:11 2018 +0000
+++ b/lcdtest/dispatch.c	Fri Apr 06 06:43:02 2018 +0000
@@ -4,6 +4,8 @@
 #include <strings.h>
 #include <stdlib.h>
 
+extern int cmd_rd();
+extern int cmd_ri();
 extern int cmd_wd();
 extern int cmd_wi();
 extern int cmd_wr();
@@ -23,7 +25,9 @@
 } cmdtab[] = {
 	{"exit", 0, 0, cmd_exit},
 	{"quit", 0, 0, cmd_exit},
+	{"rd", 0, 0, cmd_rd},
 	{"reset", 0, 0, reset_pulse},
+	{"ri", 0, 0, cmd_ri},
 	{"wd", 1, 1, cmd_wd},
 	{"wi", 1, 1, cmd_wi},
 	{"wr", 2, 2, cmd_wr},