FreeCalypso > hg > freecalypso-hwlab
view lcdtest/main.c @ 19:f3671d3ad953
lcdtest: added cd command to avoid typing long pathnames for show
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 10 Apr 2018 23:37:19 +0000 |
parents | 4194b6744890 |
children | e9df47110181 |
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:0x7157"; 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); } }