2002-11-30 14:09:12 +00:00
|
|
|
/*
|
2003-02-08 04:17:25 +00:00
|
|
|
* avrdude - A Downloader/Uploader for AVR device programmers
|
2004-12-22 01:52:45 +00:00
|
|
|
* Copyright (C) 2002-2004 Brian S. Dean <bsd@bsdhome.com>
|
main.c, pgm.c, pgm.h: Add setup and teardown hooks to the programmer
definition. If present, call the setup hook immediately after finding
the respective programmer object, and schedule the teardown hook to be
called upon exit. This allows the programmer implementation to
dynamically allocate private programmer data.
avr910.c, butterfly.c, jtagmkI.c, jtagmkII.c, stk500v2.c, usbasp.c,
usbtiny.c: Convert static programmer data into dynamically allocated
data.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@764 81a1dc3b-b13d-400b-aceb-764788c761c2
2007-11-07 20:36:12 +00:00
|
|
|
* Copyright 2007 Joerg Wunsch <j@uriah.heep.sax.de>
|
2002-11-30 14:09:12 +00:00
|
|
|
*
|
2003-02-06 19:08:33 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2002-11-30 14:09:12 +00:00
|
|
|
*
|
2003-02-06 19:08:33 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2002-11-30 14:09:12 +00:00
|
|
|
*
|
2003-02-06 19:08:33 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2002-11-30 14:09:12 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
2007-01-24 22:43:46 +00:00
|
|
|
#ifndef pgm_h
|
|
|
|
#define pgm_h
|
2002-11-30 14:09:12 +00:00
|
|
|
|
2002-12-01 04:30:01 +00:00
|
|
|
#include <limits.h>
|
|
|
|
|
2002-11-30 14:09:12 +00:00
|
|
|
#include "avrpart.h"
|
|
|
|
#include "lists.h"
|
|
|
|
#include "pindefs.h"
|
2006-12-11 12:47:35 +00:00
|
|
|
#include "serial.h"
|
2002-11-30 14:09:12 +00:00
|
|
|
|
|
|
|
#define ON 1
|
|
|
|
#define OFF 0
|
|
|
|
|
|
|
|
#define PGM_DESCLEN 80
|
2002-12-01 04:30:01 +00:00
|
|
|
#define PGM_PORTLEN PATH_MAX
|
2002-11-30 14:09:12 +00:00
|
|
|
#define PGM_TYPELEN 32
|
2011-08-25 16:12:30 +00:00
|
|
|
#define PGM_USBSTRINGLEN 256
|
2004-07-05 15:04:19 +00:00
|
|
|
|
2006-08-29 23:12:15 +00:00
|
|
|
typedef enum {
|
|
|
|
EXIT_VCC_UNSPEC,
|
|
|
|
EXIT_VCC_ENABLED,
|
|
|
|
EXIT_VCC_DISABLED
|
|
|
|
} exit_vcc_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
EXIT_RESET_UNSPEC,
|
|
|
|
EXIT_RESET_ENABLED,
|
|
|
|
EXIT_RESET_DISABLED
|
|
|
|
} exit_reset_t;
|
|
|
|
|
2011-08-26 12:35:08 +00:00
|
|
|
typedef enum {
|
|
|
|
EXIT_DATAHIGH_UNSPEC,
|
|
|
|
EXIT_DATAHIGH_ENABLED,
|
|
|
|
EXIT_DATAHIGH_DISABLED
|
|
|
|
} exit_datahigh_t;
|
|
|
|
|
2002-11-30 14:09:12 +00:00
|
|
|
typedef struct programmer_t {
|
|
|
|
LISTID id;
|
|
|
|
char desc[PGM_DESCLEN];
|
|
|
|
char type[PGM_TYPELEN];
|
2002-12-01 04:30:01 +00:00
|
|
|
char port[PGM_PORTLEN];
|
2002-11-30 14:09:12 +00:00
|
|
|
unsigned int pinno[N_PINS];
|
2006-08-29 23:12:15 +00:00
|
|
|
exit_vcc_t exit_vcc;
|
|
|
|
exit_reset_t exit_reset;
|
2011-08-26 12:35:08 +00:00
|
|
|
exit_datahigh_t exit_datahigh;
|
2002-11-30 14:09:12 +00:00
|
|
|
int ppidata;
|
2004-01-28 20:01:44 +00:00
|
|
|
int ppictrl;
|
2004-01-03 18:36:44 +00:00
|
|
|
int baudrate;
|
2011-08-25 16:12:30 +00:00
|
|
|
int usbvid, usbpid;
|
|
|
|
char usbdev[PGM_USBSTRINGLEN], usbsn[PGM_USBSTRINGLEN];
|
|
|
|
char usbvendor[PGM_USBSTRINGLEN], usbproduct[PGM_USBSTRINGLEN];
|
Mega-commit to bring in both, the STK500v2 support from Erik
Walthinsen, as well as JTAG ICE mkII support (by me).
Erik's submission has been cleaned up a little bit, mostly to add his
name and the current year to the copyright of the new file, remove
trailing white space before importing the files, and fix the minor
syntax errors in his avrdude.conf.in additions (missing semicolons).
The JTAG ICE mkII support should be considered alpha to beta quality
at this point. Few things are still to be done, like defering the
hfuse (OCDEN) tweaks until they are really required. Also, for
reasons not yet known, the target MCU doesn't start to run after
signing off from the ICE, it needs a power-cycle first (at least on my
STK500).
Note that for the JTAG ICE, I did change a few things in the internal
API. Notably I made the serial receive timeout configurable by the
backends via an exported variable (done in both the Posix and the
Win32 implementation), and I made the serial_recv() function return a
-1 instead of bailing out with exit(1) upon encountering a receive
timeout (currently only done in the Posix implementation). Both
measures together allow me to receive a datastreem from the ICE at 115
kbps on a somewhat lossy PCI multi-UART card that occasionally drops a
character. The JTAG ICE mkII protocol has enough of safety layers to
allow recovering from these events, but the previous code wasn't
prepared for any kind of recovery. The Win32 change for this still
has to be done, and the traditional drivers need to be converted to
exit(1) upon encountering a timeout (as they're now getting a -1
returned they didn't see before in that case).
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@451 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 19:17:12 +00:00
|
|
|
double bitclock; /* JTAG ICE clock period in microseconds */
|
2006-08-17 15:06:20 +00:00
|
|
|
int ispdelay; /* ISP clock delay */
|
2006-12-11 12:47:35 +00:00
|
|
|
union filedescriptor fd;
|
2002-12-01 15:05:56 +00:00
|
|
|
int page_size; /* page size if the programmer supports paged write/load */
|
2002-11-30 14:09:12 +00:00
|
|
|
int (*rdy_led) (struct programmer_t * pgm, int value);
|
|
|
|
int (*err_led) (struct programmer_t * pgm, int value);
|
|
|
|
int (*pgm_led) (struct programmer_t * pgm, int value);
|
|
|
|
int (*vfy_led) (struct programmer_t * pgm, int value);
|
|
|
|
int (*initialize) (struct programmer_t * pgm, AVRPART * p);
|
2007-01-30 13:41:54 +00:00
|
|
|
void (*display) (struct programmer_t * pgm, const char * p);
|
2002-11-30 14:09:12 +00:00
|
|
|
void (*enable) (struct programmer_t * pgm);
|
|
|
|
void (*disable) (struct programmer_t * pgm);
|
|
|
|
void (*powerup) (struct programmer_t * pgm);
|
|
|
|
void (*powerdown) (struct programmer_t * pgm);
|
|
|
|
int (*program_enable) (struct programmer_t * pgm, AVRPART * p);
|
|
|
|
int (*chip_erase) (struct programmer_t * pgm, AVRPART * p);
|
|
|
|
int (*cmd) (struct programmer_t * pgm, unsigned char cmd[4],
|
|
|
|
unsigned char res[4]);
|
2011-08-23 21:03:36 +00:00
|
|
|
int (*cmd_tpi) (struct programmer_t * pgm, unsigned char cmd[],
|
|
|
|
int cmd_len, unsigned char res[], int res_len);
|
2009-02-17 15:31:27 +00:00
|
|
|
int (*spi) (struct programmer_t * pgm, unsigned char cmd[],
|
|
|
|
unsigned char res[], int count);
|
2004-01-28 20:01:44 +00:00
|
|
|
int (*open) (struct programmer_t * pgm, char * port);
|
2002-11-30 14:09:12 +00:00
|
|
|
void (*close) (struct programmer_t * pgm);
|
2002-12-01 06:35:18 +00:00
|
|
|
int (*paged_write) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m,
|
2002-12-01 15:05:56 +00:00
|
|
|
int page_size, int n_bytes);
|
2002-12-01 06:35:18 +00:00
|
|
|
int (*paged_load) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m,
|
2002-12-01 15:05:56 +00:00
|
|
|
int page_size, int n_bytes);
|
2003-03-24 07:09:16 +00:00
|
|
|
void (*write_setup) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m);
|
2003-03-23 23:22:50 +00:00
|
|
|
int (*write_byte) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m,
|
|
|
|
unsigned long addr, unsigned char value);
|
|
|
|
int (*read_byte) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m,
|
|
|
|
unsigned long addr, unsigned char * value);
|
2003-03-17 06:20:02 +00:00
|
|
|
int (*read_sig_bytes) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m);
|
2003-07-24 21:26:28 +00:00
|
|
|
void (*print_parms) (struct programmer_t * pgm);
|
|
|
|
int (*set_vtarget) (struct programmer_t * pgm, double v);
|
2008-03-14 13:00:08 +00:00
|
|
|
int (*set_varef) (struct programmer_t * pgm, unsigned int chan, double v);
|
2003-07-24 21:26:28 +00:00
|
|
|
int (*set_fosc) (struct programmer_t * pgm, double v);
|
2004-07-07 08:59:07 +00:00
|
|
|
int (*set_sck_period) (struct programmer_t * pgm, double v);
|
2005-11-01 23:02:06 +00:00
|
|
|
int (*setpin) (struct programmer_t * pgm, int pin, int value);
|
|
|
|
int (*getpin) (struct programmer_t * pgm, int pin);
|
|
|
|
int (*highpulsepin) (struct programmer_t * pgm, int pin);
|
2006-08-29 23:12:15 +00:00
|
|
|
int (*parseexitspecs) (struct programmer_t * pgm, char *s);
|
2006-10-09 14:34:24 +00:00
|
|
|
int (*perform_osccal) (struct programmer_t * pgm);
|
2007-11-06 19:42:16 +00:00
|
|
|
int (*parseextparams) (struct programmer_t * pgm, LISTID xparams);
|
main.c, pgm.c, pgm.h: Add setup and teardown hooks to the programmer
definition. If present, call the setup hook immediately after finding
the respective programmer object, and schedule the teardown hook to be
called upon exit. This allows the programmer implementation to
dynamically allocate private programmer data.
avr910.c, butterfly.c, jtagmkI.c, jtagmkII.c, stk500v2.c, usbasp.c,
usbtiny.c: Convert static programmer data into dynamically allocated
data.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@764 81a1dc3b-b13d-400b-aceb-764788c761c2
2007-11-07 20:36:12 +00:00
|
|
|
void (*setup) (struct programmer_t * pgm);
|
|
|
|
void (*teardown) (struct programmer_t * pgm);
|
2003-02-22 16:45:13 +00:00
|
|
|
char config_file[PATH_MAX]; /* config file where defined */
|
|
|
|
int lineno; /* config file line number */
|
main.c, pgm.c, pgm.h: Add setup and teardown hooks to the programmer
definition. If present, call the setup hook immediately after finding
the respective programmer object, and schedule the teardown hook to be
called upon exit. This allows the programmer implementation to
dynamically allocate private programmer data.
avr910.c, butterfly.c, jtagmkI.c, jtagmkII.c, stk500v2.c, usbasp.c,
usbtiny.c: Convert static programmer data into dynamically allocated
data.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@764 81a1dc3b-b13d-400b-aceb-764788c761c2
2007-11-07 20:36:12 +00:00
|
|
|
void *cookie; /* for private use by the programmer */
|
2005-09-18 20:12:23 +00:00
|
|
|
char flag; /* for private use of the programmer */
|
2002-11-30 14:09:12 +00:00
|
|
|
} PROGRAMMER;
|
|
|
|
|
2007-01-24 22:43:46 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2002-11-30 14:09:12 +00:00
|
|
|
|
|
|
|
PROGRAMMER * pgm_new(void);
|
|
|
|
|
2007-01-30 13:41:54 +00:00
|
|
|
void programmer_display(PROGRAMMER * pgm, const char * p);
|
|
|
|
PROGRAMMER * locate_programmer(LISTID programmers, const char * configid);
|
2007-01-29 20:41:47 +00:00
|
|
|
|
|
|
|
typedef void (*walk_programmers_cb)(const char *name, const char *desc,
|
|
|
|
const char *cfgname, int cfglineno,
|
|
|
|
void *cookie);
|
|
|
|
void walk_programmers(LISTID programmers, walk_programmers_cb cb, void *cookie);
|
2004-06-24 11:05:07 +00:00
|
|
|
|
2007-01-24 22:43:46 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2004-06-24 11:05:07 +00:00
|
|
|
|
2002-11-30 14:09:12 +00:00
|
|
|
#endif
|