# HG changeset patch # User Mychaela Falconia # Date 1522996982 0 # Node ID 238a77db41340bd7aead7a9153d4cf315dd58e93 # Parent 5eaf832d57d0400edbc88cf2adb1c4e07563d1c3 lcdtest: read operations implemented, but don't work diff -r 5eaf832d57d0 -r 238a77db4134 lcdtest/busops.c --- 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]; +} diff -r 5eaf832d57d0 -r 238a77db4134 lcdtest/commands.c --- 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 #include +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; { diff -r 5eaf832d57d0 -r 238a77db4134 lcdtest/dispatch.c --- 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 #include +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},