# HG changeset patch # User Mychaela Falconia # Date 1527456967 0 # Node ID 225556110fa6b6b93d959008dc3dab8e19d38589 # Parent 0a44549a64c8677160ba598c007acdcf2723dc04 lcdtest: beginning of reorg for adding lcdphone program diff -r 0a44549a64c8 -r 225556110fa6 lcdtest/Makefile --- a/lcdtest/Makefile Fri May 25 02:41:30 2018 +0000 +++ b/lcdtest/Makefile Sun May 27 21:36:07 2018 +0000 @@ -1,13 +1,14 @@ CC= gcc CFLAGS= -O2 -PROG= lcdtest -OBJS= busops.o commands.o dispatch.o haoran.o main.o readops.o showppm.o \ - startek.o +PROGS= lcdtest + +LCDTEST_OBJS= busops.o commands.o dispatch.o haoran.o readops.o showppm.o \ + startek.o testmain.o -all: ${PROG} +all: ${PROGS} -${PROG}: ${OBJS} - ${CC} -o $@ ${OBJS} -lftdi +lcdtest: ${LCDTEST_OBJS} + ${CC} -o $@ ${LCDTEST_OBJS} -lftdi clean: - rm -f ${PROG} *.o *errs *.out + rm -f ${PROGS} *.o *errs *.out diff -r 0a44549a64c8 -r 225556110fa6 lcdtest/main.c --- a/lcdtest/main.c Fri May 25 02:41:30 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -#include -#include -#include -#include -#include - -char *device_serial; -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_serial = optarg; - continue; - default: - /* error msg already printed */ - exit(1); - } - } - switch (argc - optind) { - case 0: - break; - case 1: - if (chdir(argv[optind]) < 0) { - perror(argv[optind]); - exit(1); - } - break; - default: - fprintf(stderr, "usage: %s [options] [chdir]\n", argv[0]); - exit(1); - } -} - -main(argc, argv) - char **argv; -{ - char command[512]; - - process_cmdline(argc, argv); - ftdi_init(&ftdi); - if (ftdi_usb_open_desc(&ftdi, 0x0403, 0x7157, 0, device_serial) < 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); - } -} diff -r 0a44549a64c8 -r 225556110fa6 lcdtest/testmain.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lcdtest/testmain.c Sun May 27 21:36:07 2018 +0000 @@ -0,0 +1,66 @@ +#include +#include +#include +#include +#include + +char *device_serial; +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_serial = optarg; + continue; + default: + /* error msg already printed */ + exit(1); + } + } + switch (argc - optind) { + case 0: + break; + case 1: + if (chdir(argv[optind]) < 0) { + perror(argv[optind]); + exit(1); + } + break; + default: + fprintf(stderr, "usage: %s [options] [chdir]\n", argv[0]); + exit(1); + } +} + +main(argc, argv) + char **argv; +{ + char command[512]; + + process_cmdline(argc, argv); + ftdi_init(&ftdi); + if (ftdi_usb_open_desc(&ftdi, 0x0403, 0x7157, 0, device_serial) < 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); + } +}