diff lcdtest/busops.c @ 12:5eaf832d57d0

lcdtest program started, skeleton compiles
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 06 Apr 2018 06:15:11 +0000
parents
children 238a77db4134
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lcdtest/busops.c	Fri Apr 06 06:15:11 2018 +0000
@@ -0,0 +1,74 @@
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <ftdi.h>
+
+extern struct ftdi_context ftdi;
+
+do_ftdi_write(cmd, cmdlen)
+	u_char *cmd;
+{
+	if (ftdi_write_data(&ftdi, cmd, cmdlen) != cmdlen) {
+		fprintf(stderr, "FTDI write error: %s\n", ftdi.error_str);
+		exit(1);
+	}
+}
+
+set_gpio_pins(rs, reset)
+{
+	u_char cmd[3];
+
+	cmd[0] = 0x82;
+	cmd[1] = (rs ? 1 : 0) | (reset ? 2 : 0);
+	cmd[2] = 0x03;
+	do_ftdi_write(cmd, 3);
+}
+
+reset_pulse()
+{
+	set_gpio_pins(0, 0);
+	usleep(50000);
+	set_gpio_pins(0, 1);
+	return(0);
+}
+
+write_ir(val16)
+	unsigned val16;
+{
+	u_char cmd[9];
+
+	/* set RS low */
+	cmd[0] = 0x82;
+	cmd[1] = 0x02;
+	cmd[2] = 0x03;
+	/* write upper byte */
+	cmd[3] = 0x92;
+	cmd[4] = 0;	/* dummy addr */
+	cmd[5] = val16 >> 8;
+	/* write lower byte */
+	cmd[6] = 0x92;
+	cmd[7] = 0;	/* dummy addr */
+	cmd[8] = val16;
+	do_ftdi_write(cmd, 9);
+}
+
+write_dr(val16)
+	unsigned val16;
+{
+	u_char cmd[9];
+
+	/* set RS high */
+	cmd[0] = 0x82;
+	cmd[1] = 0x03;
+	cmd[2] = 0x03;
+	/* write upper byte */
+	cmd[3] = 0x92;
+	cmd[4] = 0;	/* dummy addr */
+	cmd[5] = val16 >> 8;
+	/* write lower byte */
+	cmd[6] = 0x92;
+	cmd[7] = 0;	/* dummy addr */
+	cmd[8] = val16;
+	do_ftdi_write(cmd, 9);
+}