home *** CD-ROM | disk | FTP | other *** search
- /* DL.C -- Download DSP56001 programs to the DSP CARD 3
- *
- * Copyright (C) by Alef Null 1990, 1991
- * Author(s): Jarkko Vuori, OH2LNS
- * Modification(s):
- */
-
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <memory.h>
- #include <conio.h>
- #include "dspio.h"
- #include "sylk.h"
-
-
- int cdecl main(int argc, char *argv[]) {
- FILE *fd;
- static struct {
- unsigned debug:1;
- unsigned log:1;
- unsigned dump:1;
- unsigned port:1;
- unsigned ssi:1;
- } flags = { 0 };
- int y = 1;
- char option, *filename = NULL;
-
- printf("DSP CARD 3 program downloader (%s)\n", __DATE__);
-
- /* parse arguments */
- argc--; argv++;
- while(argc > 0) {
- switch(**argv) {
- case '-':
- switch(option = *(++(*argv))) {
- /* flag for dl to enter special debug mode */
- case 'd':
- case 'D':
- flags.debug = -1;
- break;
-
- /* flag for dl to enter special data logger mode */
- case 'l':
- case 'L':
- flags.log = -1;
- break;
-
- /* flag for dl to enter memory dump check mode */
- case 'c':
- case 'C':
- flags.dump = -1;
- break;
-
- /* flag for dl to force printer port selection */
- case 'p':
- case 'P':
- flags.port = atoi(++(*argv));
- break;
-
- /* flag for dl to force SSI source selection */
- case 's':
- case 'S':
- flags.ssi = atoi(++(*argv));
- break;
-
- default:
- fprintf(stderr, "unknown option '%c', type 'dl ?' to get the allowed options\n", option);
- break;
- }
- break;
-
- case '?':
- fprintf(stderr, "usage: dl [-d | -l | -c | -p<portno> | -s<ssisource>] [<filename>]\n");
- fprintf(stderr, "\t-d reads data from DSP CARD 3 and displays it\n");
- fprintf(stderr, "\t-l reads data from DSP CARD 3 and stores it to the file LOG.DAT\n");
- fprintf(stderr, "\t-c reads memory image from DSP CARD 3 and verifies it\n");
- fprintf(stderr, "\t-p<portno> uses the specified printer port (1 LPT1, 2 LPT2)\n");
- fprintf(stderr, "\t (otherwise dl searches it automatically)\n");
- fprintf(stderr, "\t-s<ssisource> selects the specified ssi source\n");
- fprintf(stderr, "\t (1 external, 0 internal (default))\n");
- return (0);
- break;
-
- default:
- filename = *argv;
- break;
- }
-
- argc--; argv++;
- }
-
- if(!filename && !flags.debug) {
- fprintf(stderr, "no file specified\n");
- return (-1);
- }
-
- fd = stdout;
- if (OpenCardIo(flags.port) ||
- (filename ? OpenLodFile(filename) : 0) ||
- (flags.log ? !(fd = fopen("LOG.DAT", "w")) : 0))
- return (-1);
- setvbuf(fd, NULL, _IOFBF, 4096);
-
- /* select ssi source, and download the software */
- SelectSSI(!flags.ssi);
- if (filename)
- DownLoad(-1);
-
- /* if debug (or log) mode, read data from DSP */
- if (flags.debug || flags.log)
- while (!kbhit())
- if (ReadByte(ISR) & 0x01) {
- fprintf(fd, "%8ld ", ReadHostWord()); if (!(y++ % 8)) fprintf(fd, "\n");
- }
-
- /* if dump check mode, read memory dumps from the DSP and check them */
- if (flags.dump)
- CheckMemDump();
-
- CloseCardIo(); CloseLodFile();
- return (0);
- }
-