FreeCalypso > hg > freecalypso-hwlab
changeset 26:225556110fa6
lcdtest: beginning of reorg for adding lcdphone program
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 27 May 2018 21:36:07 +0000 |
parents | 0a44549a64c8 |
children | 4b7cac119fb5 |
files | lcdtest/Makefile lcdtest/main.c lcdtest/testmain.c |
diffstat | 3 files changed, 74 insertions(+), 73 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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 <sys/types.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <ftdi.h> - -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); - } -}
--- /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 <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <ftdi.h> + +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); + } +}