/*
 * Velleman K8048 Programmer for FreeBSD and others.
 *
 * Copyright (c) 2005-2007 Darron Broad
 * All rights reserved.
 *
 * Licensed under the terms of the BSD license, see file LICENSE
 * for details.
 *
 * $Id: k8048.h,v 1.45 2008/09/19 04:42:20 darron Exp $
 */

#ifndef _K8048_H
#define _K8048_H

/*
 * system includes
 */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <search.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/ioctl.h>
#include <errno.h> 
#include <libgen.h>

/*
 * operating mode defined in cli args
 */
#define PROGRAM (1)
#define VERIFY  (2)

/* 
 * operation success return codes (nb: to update counters)
 */
#define PASS (0)            /* pass: add none to fault count */
#define FAIL (1)            /* fail: add one  to fault count */

/*
 * generic c string
 */
#define STRLEN (1024)
#define STRMAX (STRLEN-1)

/*
 * default dump size
 */
#define DEFAULT_SIZE (128)

/*
 * device parameters
 */
#define ARCH12BIT   (0x0fff)
#define ARCH14BIT   (0x3fff)
#define ARCH16BIT   (0xffff)

struct k8048
{
    char dotfile[STRLEN];   /* dotfile */
    char device[STRLEN];    /* tty device name */
    unsigned char flags;    /* I/O flip bits */
    int fd;                 /* I/O handle */
    unsigned short arch;    /* architecture mask: 12, 14 or 16 bit */
    char devicename[STRLEN];/* overridden device name */
    int sleep_short;        /* default 1uS */
    int sleep_long;         /* default 1uS */
    int debug_level;	    /* default 0=debugging off */
};

/*
 * readline
 */
#include <readline/readline.h>
#include <readline/history.h>

/*
 * debug
 */
#ifdef DMALLOC
#include "dmalloc.h"
#endif

/*
 * local
 */
#include "util.h"
#include "dotconf.h"
#include "inhx32.h"
#include "serial_posix.h"
#include "io.h"
#include "pic16f.h"
#include "pic18f.h"
#include "pic.h"

/*
 * prototypes
 */
void usage(struct k8048 *, char *, char *);
int main(int, char **);

#endif /* !_K8048_H */
