FreeCalypso > hg > freecalypso-hwlab
view lcdtest/readops.c @ 142:74c5dc7408e9
uicc/Makefile: add install
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 04 Feb 2021 05:06:28 +0000 |
parents | 5a602e512b12 |
children |
line wrap: on
line source
#include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <ftdi.h> extern struct ftdi_context ftdi; read_command(rs) { u_char cmd[8]; /* 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); } cmd_ri() { read_command(0); return(0); } cmd_rd() { read_command(1); return(0); } cmd_fr(argc, argv) char **argv; { unsigned reqlen = strtoul(argv[1], 0, 0); u_char rdbuf[256]; int rc, i; if (reqlen < 1 || reqlen > sizeof rdbuf) { printf("error: bad read request length\n"); return(-1); } rc = ftdi_read_data(&ftdi, rdbuf, reqlen); printf("FTDI read returned %d\n", rc); for (i = 0; i < rc; i++) printf("read byte: %02X\n", rdbuf[i]); return(0); }