FreeCalypso > hg > freecalypso-hwlab
view lcdtest/main.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 | 4194b6744890 |
line wrap: on
line source
#include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <ftdi.h> char *device_selector = "i:0x0403:0x6010"; struct ftdi_context ftdi; process_cmdline(argc, argv) char **argv; { int c; extern char *optarg; while ((c = getopt(argc, argv, "d:")) != EOF) { switch (c) { case 'd': device_selector = optarg; continue; default: /* error msg already printed */ exit(1); } } } main(argc, argv) char **argv; { char command[512]; process_cmdline(argc, argv); ftdi_init(&ftdi); if (ftdi_usb_open_string(&ftdi, device_selector) < 0) { fprintf(stderr, "FTDI USB open failed: %s\n", ftdi.error_str); exit(1); } if (ftdi_set_bitmode(&ftdi, 0, BITMODE_MCU) < 0) { fprintf(stderr, "unable to enter MCU mode: %s\n", ftdi.error_str); exit(1); } for (;;) { if (isatty(0)) { fputs("lcdtest> ", stdout); fflush(stdout); } if (!fgets(command, sizeof command, stdin)) exit(0); dispatch_cmd(command); } }