Join the former "public" header files (avr.h avrpart.h pindefs.h

serial.h fileio.h safemode.h update.h pgm_type.h config.h confwin.h
lists.h) into a single header that can be included by anyone wanting
to link against the library.

Adapt everything to cope with this situation.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1311 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch 2014-05-19 10:01:59 +00:00
parent d8089139d2
commit d09bc2e1fb
71 changed files with 1183 additions and 1274 deletions

View File

@ -1,3 +1,91 @@
2014-05-19 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* libavrdude.h: Join the former "public" header files (avr.h avrpart.h pindefs.h
serial.h fileio.h safemode.h update.h pgm_type.h config.h confwin.h lists.h) into
a single header that can be included by anyone wanting to link against the
library
* avr.h: Remove file.
* avrpart.h: (Dito.)
* pindefs.h: (Dito.)
* serial.h: (Dito.)
* fileio.h: (Dito.)
* safemode.h: (Dito.)
* update.h: (Dito.)
* pgm_type.h: (Dito.)
* config.h: (Dito.)
* confwin.h: (Dito.)
* lists.h: (Dito.)
* Makefile.am: Adapt for new include file constellation; install shared lib
* configure.ac: Bump version date
* arduino.c: #include <libavrdude.h> rather than a bunch of different headers
* avr910.c: (Dito.)
* avr910.h: (Dito.)
* avr.c: (Dito.)
* avrftdi.c: (Dito.)
* avrftdi_tpi.c: (Dito.)
* avrftdi_tpi.h: (Dito.)
* avr.h: (Dito.)
* avrpart.c: (Dito.)
* avrpart.h: (Dito.)
* bitbang.c: (Dito.)
* buspirate.c: (Dito.)
* butterfly.c: (Dito.)
* config.c: (Dito.)
* config_gram.y: (Dito.)
* config.h: (Dito.)
* confwin.c: (Dito.)
* confwin.h: (Dito.)
* dfu.c: (Dito.)
* fileio.c: (Dito.)
* fileio.h: (Dito.)
* flip1.c: (Dito.)
* flip1.h: (Dito.)
* flip2.c: (Dito.)
* flip2.h: (Dito.)
* ft245r.c: (Dito.)
* ft245r.h: (Dito.)
* jtag3.c: (Dito.)
* jtagmkI.c: (Dito.)
* jtagmkII.c: (Dito.)
* lexer.l: (Dito.)
* libavrdude.h: (Dito.)
* linuxgpio.c: (Dito.)
* lists.c: (Dito.)
* lists.h: (Dito.)
* main.c: (Dito.)
* par.c: (Dito.)
* pgm.c: (Dito.)
* pgm_type.c: (Dito.)
* pgm_type.h: (Dito.)
* pickit2.c: (Dito.)
* pickit2.h: (Dito.)
* pindefs.c: (Dito.)
* pindefs.h: (Dito.)
* ppi.c: (Dito.)
* ppiwin.c: (Dito.)
* safemode.c: (Dito.)
* safemode.h: (Dito.)
* ser_avrdoper.c: (Dito.)
* serbb_posix.c: (Dito.)
* serbb_win32.c: (Dito.)
* serial.h: (Dito.)
* ser_posix.c: (Dito.)
* ser_win32.c: (Dito.)
* stk500.c: (Dito.)
* stk500generic.c: (Dito.)
* stk500v2.c: (Dito.)
* stk500v2_private.h: (Dito.)
* term.c: (Dito.)
* term.h: (Dito.)
* update.c: (Dito.)
* update.h: (Dito.)
* usbasp.c: (Dito.)
* usbasp.h: (Dito.)
* usb_libusb.c: (Dito.)
* usbtiny.c: (Dito.)
* usbtiny.h: (Dito.)
* wiring.c: (Dito.)
2014-05-19 Joerg Wunsch <j.gnu@uriah.heep.sax.de> 2014-05-19 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* main.c: Cleanup unused include files. * main.c: Cleanup unused include files.

View File

@ -71,7 +71,7 @@ avrdude_LDADD = $(top_builddir)/$(noinst_LIBRARIES) @LIBUSB_1_0@ @LIBUSB@ @LIBF
bin_PROGRAMS = avrdude bin_PROGRAMS = avrdude
noinst_LIBRARIES = libavrdude.a noinst_LIBRARIES = libavrdude.a
noinst_LTLIBRARIES = libavrdude.la lib_LTLIBRARIES = libavrdude.la
# automake thinks these generated files should be in the distribution, # automake thinks these generated files should be in the distribution,
# but this might cause trouble for some users, so we rather don't want # but this might cause trouble for some users, so we rather don't want
@ -94,7 +94,6 @@ libavrdude_a_SOURCES = \
arduino.h \ arduino.h \
arduino.c \ arduino.c \
avr.c \ avr.c \
avr.h \
avr910.c \ avr910.c \
avr910.h \ avr910.h \
avrdude.h \ avrdude.h \
@ -104,7 +103,6 @@ libavrdude_a_SOURCES = \
avrftdi_tpi.c \ avrftdi_tpi.c \
avrftdi_tpi.h \ avrftdi_tpi.h \
avrpart.c \ avrpart.c \
avrpart.h \
bitbang.c \ bitbang.c \
bitbang.h \ bitbang.h \
buspirate.c \ buspirate.c \
@ -112,15 +110,12 @@ libavrdude_a_SOURCES = \
butterfly.c \ butterfly.c \
butterfly.h \ butterfly.h \
config.c \ config.c \
config.h \
confwin.c \ confwin.c \
confwin.h \
crc16.c \ crc16.c \
crc16.h \ crc16.h \
dfu.c \ dfu.c \
dfu.h \ dfu.h \
fileio.c \ fileio.c \
fileio.h \
flip1.c \ flip1.c \
flip1.h \ flip1.h \
flip2.c \ flip2.c \
@ -137,28 +132,24 @@ libavrdude_a_SOURCES = \
jtag3.c \ jtag3.c \
jtag3.h \ jtag3.h \
jtag3_private.h \ jtag3_private.h \
libavrdude.h \
linuxgpio.c \ linuxgpio.c \
linuxgpio.h \ linuxgpio.h \
linux_ppdev.h \ linux_ppdev.h \
lists.c \ lists.c \
lists.h \
my_ddk_hidsdi.h \ my_ddk_hidsdi.h \
par.c \ par.c \
par.h \ par.h \
pgm.c \ pgm.c \
pgm.h \ pgm.h \
pgm_type.c \ pgm_type.c \
pgm_type.h \
pickit2.c \ pickit2.c \
pickit2.h \ pickit2.h \
pindefs.c \ pindefs.c \
pindefs.h \
ppi.c \ ppi.c \
ppi.h \ ppi.h \
ppiwin.c \ ppiwin.c \
safemode.c \ safemode.c \
safemode.h \
serial.h \
serbb.h \ serbb.h \
serbb_posix.c \ serbb_posix.c \
serbb_win32.c \ serbb_win32.c \
@ -181,13 +172,14 @@ libavrdude_a_SOURCES = \
usb_libusb.c \ usb_libusb.c \
usbtiny.h \ usbtiny.h \
usbtiny.c \ usbtiny.c \
update.h \
update.c \ update.c \
wiring.h \ wiring.h \
wiring.c wiring.c
libavrdude_la_SOURCES = $(libavrdude_a_SOURCES) libavrdude_la_SOURCES = $(libavrdude_a_SOURCES)
libavrdude_la_LDFLAGS = -version-info 1:0 libavrdude_la_LDFLAGS = -version-info 1:0
include_HEADERS = libavrdude.h
avrdude_SOURCES = \ avrdude_SOURCES = \
main.c \ main.c \
term.c \ term.c \

View File

@ -32,10 +32,9 @@
#include <unistd.h> #include <unistd.h>
#include "avrdude.h" #include "avrdude.h"
#include "pgm.h" #include "libavrdude.h"
#include "stk500_private.h" #include "stk500_private.h"
#include "stk500.h" #include "stk500.h"
#include "serial.h"
#include "arduino.h" #include "arduino.h"
/* read signature bytes - arduino version */ /* read signature bytes - arduino version */

7
avr.c
View File

@ -29,13 +29,8 @@
#include <time.h> #include <time.h>
#include "avrdude.h" #include "avrdude.h"
#include "libavrdude.h"
#include "avr.h"
#include "lists.h"
#include "pindefs.h"
#include "ppi.h"
#include "safemode.h"
#include "update.h"
#include "tpi.h" #include "tpi.h"
FP_UpdateProgress update_progress; FP_UpdateProgress update_progress;

77
avr.h
View File

@ -1,77 +0,0 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
*
* 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.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* $Id$ */
#ifndef __avr_h__
#define __avr_h__
#include <stdio.h>
#include "avrpart.h"
#include "pgm.h"
typedef void (*FP_UpdateProgress)(int percent, double etime, char *hdr);
extern struct avrpart parts[];
extern FP_UpdateProgress update_progress;
#ifdef __cplusplus
extern "C" {
#endif
int avr_tpi_poll_nvmbsy(PROGRAMMER *pgm);
int avr_tpi_chip_erase(PROGRAMMER * pgm, AVRPART * p);
int avr_tpi_program_enable(PROGRAMMER * pgm, AVRPART * p, unsigned char guard_time);
int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
unsigned long addr, unsigned char * value);
int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype, AVRPART * v);
int avr_write_page(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
unsigned long addr);
int avr_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
unsigned long addr, unsigned char data);
int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
unsigned long addr, unsigned char data);
int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
int auto_erase);
int avr_signature(PROGRAMMER * pgm, AVRPART * p);
int avr_verify(AVRPART * p, AVRPART * v, char * memtype, int size);
int avr_get_cycle_count(PROGRAMMER * pgm, AVRPART * p, int * cycles);
int avr_put_cycle_count(PROGRAMMER * pgm, AVRPART * p, int cycles);
int avr_mem_hiaddr(AVRMEM * mem);
int avr_chip_erase(PROGRAMMER * pgm, AVRPART * p);
void report_progress (int completed, int total, char *hdr);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -36,11 +36,9 @@
#include <unistd.h> #include <unistd.h>
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "config.h"
#include "pgm.h"
#include "avr910.h" #include "avr910.h"
#include "serial.h"
/* /*
* Private data for this programmer. * Private data for this programmer.

View File

@ -21,8 +21,6 @@
#ifndef avr910_h #ifndef avr910_h
#define avr910_h #define avr910_h
#include "avrpart.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -34,11 +34,9 @@
#include <stdarg.h> #include <stdarg.h>
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "pgm.h"
#include "pindefs.h"
#include "avrftdi.h" #include "avrftdi.h"
#include "avrpart.h"
#include "avrftdi_tpi.h" #include "avrftdi_tpi.h"
#include "avrftdi_private.h" #include "avrftdi_private.h"
#include "usbdevs.h" #include "usbdevs.h"

View File

@ -5,11 +5,9 @@
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include "avr.h" #include "avrdude.h"
#include "pgm.h" #include "libavrdude.h"
#include "avrpart.h"
#include "pindefs.h"
#include "tpi.h"
#include "usbasp.h" #include "usbasp.h"
#include "avrftdi_tpi.h" #include "avrftdi_tpi.h"

View File

@ -1,8 +1,5 @@
#pragma once #pragma once
#include "pgm.h"
#include "avrpart.h"
//int avrftdi_tpi_write_byte(PROGRAMMER * pgm, unsigned char byte); //int avrftdi_tpi_write_byte(PROGRAMMER * pgm, unsigned char byte);
//int avrftdi_tpi_read_byte(PROGRAMMER * pgm, unsigned char * byte); //int avrftdi_tpi_read_byte(PROGRAMMER * pgm, unsigned char * byte);
int avrftdi_cmd_tpi(PROGRAMMER * pgm, const unsigned char *cmd, int cmd_len, int avrftdi_cmd_tpi(PROGRAMMER * pgm, const unsigned char *cmd, int cmd_len,

View File

@ -24,8 +24,7 @@
#include <string.h> #include <string.h>
#include "avrdude.h" #include "avrdude.h"
#include "avrpart.h" #include "libavrdude.h"
#include "pindefs.h"
/*** /***
*** Elementary functions dealing with OPCODE structures *** Elementary functions dealing with OPCODE structures

236
avrpart.h
View File

@ -1,236 +0,0 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2003-2004 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2006 Joerg Wunsch <j@uriah.heep.sax.de>
*
* 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.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* $Id$ */
#ifndef avrpart_h
#define avrpart_h
#include <limits.h>
#include "lists.h"
/*
* AVR serial programming instructions
*/
enum {
AVR_OP_READ,
AVR_OP_WRITE,
AVR_OP_READ_LO,
AVR_OP_READ_HI,
AVR_OP_WRITE_LO,
AVR_OP_WRITE_HI,
AVR_OP_LOADPAGE_LO,
AVR_OP_LOADPAGE_HI,
AVR_OP_LOAD_EXT_ADDR,
AVR_OP_WRITEPAGE,
AVR_OP_CHIP_ERASE,
AVR_OP_PGM_ENABLE,
AVR_OP_MAX
};
enum {
AVR_CMDBIT_IGNORE, /* bit is ignored on input and output */
AVR_CMDBIT_VALUE, /* bit is set to 0 or 1 for input or output */
AVR_CMDBIT_ADDRESS, /* this bit represents an input address bit */
AVR_CMDBIT_INPUT, /* this bit is an input bit */
AVR_CMDBIT_OUTPUT /* this bit is an output bit */
};
enum { /* these are assigned to reset_disposition of AVRPART */
RESET_DEDICATED, /* reset pin is dedicated */
RESET_IO /* reset pin might be configured as an I/O pin */
};
enum ctl_stack_t {
CTL_STACK_NONE, /* no control stack defined */
CTL_STACK_PP, /* parallel programming control stack */
CTL_STACK_HVSP /* high voltage serial programming control stack */
};
/*
* serial programming instruction bit specifications
*/
typedef struct cmdbit {
int type; /* AVR_CMDBIT_* */
int bitno; /* which input bit to use for this command bit */
int value; /* bit value if type == AVR_CMDBIT_VALUD */
} CMDBIT;
typedef struct opcode {
CMDBIT bit[32]; /* opcode bit specs */
} OPCODE;
#define AVRPART_SERIALOK 0x0001 /* part supports serial programming */
#define AVRPART_PARALLELOK 0x0002 /* part supports parallel programming */
#define AVRPART_PSEUDOPARALLEL 0x0004 /* part has pseudo parallel support */
#define AVRPART_HAS_JTAG 0x0008 /* part has a JTAG i/f */
#define AVRPART_ALLOWFULLPAGEBITSTREAM 0x0010 /* JTAG ICE mkII param. */
#define AVRPART_ENABLEPAGEPROGRAMMING 0x0020 /* JTAG ICE mkII param. */
#define AVRPART_HAS_DW 0x0040 /* part has a debugWire i/f */
#define AVRPART_HAS_PDI 0x0080 /* part has PDI i/f rather than ISP (ATxmega) */
#define AVRPART_AVR32 0x0100 /* part is in AVR32 family */
#define AVRPART_INIT_SMC 0x0200 /* part will undergo chip erase */
#define AVRPART_WRITE 0x0400 /* at least one write operation specified */
#define AVRPART_HAS_TPI 0x0800 /* part has TPI i/f rather than ISP (ATtiny4/5/9/10) */
#define AVRPART_IS_AT90S1200 0x1000 /* part is an AT90S1200 (needs special treatment) */
#define AVR_DESCLEN 64
#define AVR_IDLEN 32
#define CTL_STACK_SIZE 32
#define FLASH_INSTR_SIZE 3
#define EEPROM_INSTR_SIZE 20
#define TAG_ALLOCATED 1 /* memory byte is allocated */
typedef struct avrpart {
char desc[AVR_DESCLEN]; /* long part name */
char id[AVR_IDLEN]; /* short part name */
int stk500_devcode; /* stk500 device code */
int avr910_devcode; /* avr910 device code */
int chip_erase_delay; /* microseconds */
unsigned char pagel; /* for parallel programming */
unsigned char bs2; /* for parallel programming */
unsigned char signature[3]; /* expected value of signature bytes */
unsigned short usbpid; /* USB DFU product ID (0 = none) */
int reset_disposition; /* see RESET_ enums */
int retry_pulse; /* retry program enable by pulsing
this pin (PIN_AVR_*) */
unsigned flags; /* see AVRPART_ masks */
int timeout; /* stk500 v2 xml file parameter */
int stabdelay; /* stk500 v2 xml file parameter */
int cmdexedelay; /* stk500 v2 xml file parameter */
int synchloops; /* stk500 v2 xml file parameter */
int bytedelay; /* stk500 v2 xml file parameter */
int pollindex; /* stk500 v2 xml file parameter */
unsigned char pollvalue; /* stk500 v2 xml file parameter */
int predelay; /* stk500 v2 xml file parameter */
int postdelay; /* stk500 v2 xml file parameter */
int pollmethod; /* stk500 v2 xml file parameter */
enum ctl_stack_t ctl_stack_type; /* what to use the ctl stack for */
unsigned char controlstack[CTL_STACK_SIZE]; /* stk500v2 PP/HVSP ctl stack */
unsigned char flash_instr[FLASH_INSTR_SIZE]; /* flash instructions (debugWire, JTAG) */
unsigned char eeprom_instr[EEPROM_INSTR_SIZE]; /* EEPROM instructions (debugWire, JTAG) */
int hventerstabdelay; /* stk500 v2 hv mode parameter */
int progmodedelay; /* stk500 v2 hv mode parameter */
int latchcycles; /* stk500 v2 hv mode parameter */
int togglevtg; /* stk500 v2 hv mode parameter */
int poweroffdelay; /* stk500 v2 hv mode parameter */
int resetdelayms; /* stk500 v2 hv mode parameter */
int resetdelayus; /* stk500 v2 hv mode parameter */
int hvleavestabdelay; /* stk500 v2 hv mode parameter */
int resetdelay; /* stk500 v2 hv mode parameter */
int chiperasepulsewidth; /* stk500 v2 hv mode parameter */
int chiperasepolltimeout; /* stk500 v2 hv mode parameter */
int chiperasetime; /* stk500 v2 hv mode parameter */
int programfusepulsewidth; /* stk500 v2 hv mode parameter */
int programfusepolltimeout; /* stk500 v2 hv mode parameter */
int programlockpulsewidth; /* stk500 v2 hv mode parameter */
int programlockpolltimeout; /* stk500 v2 hv mode parameter */
int synchcycles; /* stk500 v2 hv mode parameter */
int hvspcmdexedelay; /* stk500 v2 xml file parameter */
unsigned char idr; /* JTAG ICE mkII XML file parameter */
unsigned char rampz; /* JTAG ICE mkII XML file parameter */
unsigned char spmcr; /* JTAG ICE mkII XML file parameter */
unsigned short eecr; /* JTAC ICE mkII XML file parameter */
unsigned int mcu_base; /* Base address of MCU control block in ATxmega devices */
unsigned int nvm_base; /* Base address of NVM controller in ATxmega devices */
int ocdrev; /* OCD revision (JTAGICE3 parameter, from AS6 XML files) */
OPCODE * op[AVR_OP_MAX]; /* opcodes */
LISTID mem; /* avr memory definitions */
char config_file[PATH_MAX]; /* config file where defined */
int lineno; /* config file line number */
} AVRPART;
#define AVR_MEMDESCLEN 64
typedef struct avrmem {
char desc[AVR_MEMDESCLEN]; /* memory description ("flash", "eeprom", etc) */
int paged; /* page addressed (e.g. ATmega flash) */
int size; /* total memory size in bytes */
int page_size; /* size of memory page (if page addressed) */
int num_pages; /* number of pages (if page addressed) */
unsigned int offset; /* offset in IO memory (ATxmega) */
int min_write_delay; /* microseconds */
int max_write_delay; /* microseconds */
int pwroff_after_write; /* after this memory type is written to,
the device must be powered off and
back on, see errata
http://www.atmel.com/dyn/resources/prod_documents/doc1280.pdf */
unsigned char readback[2]; /* polled read-back values */
int mode; /* stk500 v2 xml file parameter */
int delay; /* stk500 v2 xml file parameter */
int blocksize; /* stk500 v2 xml file parameter */
int readsize; /* stk500 v2 xml file parameter */
int pollindex; /* stk500 v2 xml file parameter */
unsigned char * buf; /* pointer to memory buffer */
unsigned char * tags; /* allocation tags */
OPCODE * op[AVR_OP_MAX]; /* opcodes */
} AVRMEM;
#ifdef __cplusplus
extern "C" {
#endif
/* Functions for OPCODE structures */
OPCODE * avr_new_opcode(void);
void avr_free_opcode(OPCODE * op);
int avr_set_bits(OPCODE * op, unsigned char * cmd);
int avr_set_addr(OPCODE * op, unsigned char * cmd, unsigned long addr);
int avr_set_input(OPCODE * op, unsigned char * cmd, unsigned char data);
int avr_get_output(OPCODE * op, unsigned char * res, unsigned char * data);
int avr_get_output_index(OPCODE * op);
/* Functions for AVRMEM structures */
AVRMEM * avr_new_memtype(void);
int avr_initmem(AVRPART * p);
AVRMEM * avr_dup_mem(AVRMEM * m);
void avr_free_mem(AVRMEM * m);
AVRMEM * avr_locate_mem(AVRPART * p, char * desc);
void avr_mem_display(const char * prefix, FILE * f, AVRMEM * m, int type,
int verbose);
/* Functions for AVRPART structures */
AVRPART * avr_new_part(void);
AVRPART * avr_dup_part(AVRPART * d);
void avr_free_part(AVRPART * d);
AVRPART * locate_part(LISTID parts, char * partdesc);
AVRPART * locate_part_by_avr910_devcode(LISTID parts, int devcode);
void avr_display(FILE * f, AVRPART * p, const char * prefix, int verbose);
typedef void (*walk_avrparts_cb)(const char *name, const char *desc,
const char *cfgname, int cfglineno,
void *cookie);
void walk_avrparts(LISTID avrparts, walk_avrparts_cb cb, void *cookie);
void sort_avrparts(LISTID avrparts);
#ifdef __cplusplus
}
#endif
#endif /* avrpart_h */

View File

@ -34,9 +34,8 @@
#endif #endif
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "pindefs.h"
#include "pgm.h"
#include "par.h" #include "par.h"
#include "serbb.h" #include "serbb.h"
#include "tpi.h" #include "tpi.h"

View File

@ -46,9 +46,8 @@
#endif #endif
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "pgm.h"
#include "serial.h"
#include "bitbang.h" #include "bitbang.h"
#include "buspirate.h" #include "buspirate.h"

View File

@ -45,10 +45,9 @@
#include <unistd.h> #include <unistd.h>
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "pgm.h"
#include "butterfly.h" #include "butterfly.h"
#include "serial.h"
/* /*
* Private data for this programmer. * Private data for this programmer.

View File

@ -27,8 +27,8 @@
#include <string.h> #include <string.h>
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "config.h"
#include "config_gram.h" #include "config_gram.h"
char default_programmer[MAX_STR_CONST]; char default_programmer[MAX_STR_CONST];

117
config.h
View File

@ -1,117 +0,0 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
*
* 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.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* $Id$ */
#ifndef config_h
#define config_h
#include "lists.h"
#include "pindefs.h"
#include "avr.h"
#define MAX_STR_CONST 1024
enum { V_NONE, V_NUM, V_NUM_REAL, V_STR };
typedef struct value_t {
int type;
/*union { TODO: use an anonymous union here ? */
int number;
double number_real;
char * string;
/*};*/
} VALUE;
typedef struct token_t {
int primary;
VALUE value;
} TOKEN;
typedef struct token_t *token_p;
extern FILE * yyin;
extern PROGRAMMER * current_prog;
extern AVRPART * current_part;
extern AVRMEM * current_mem;
extern int lineno;
extern const char * infile;
extern LISTID string_list;
extern LISTID number_list;
extern LISTID part_list;
extern LISTID programmers;
extern char default_programmer[];
extern char default_parallel[];
extern char default_serial[];
extern double default_bitclock;
extern int default_safemode;
/* This name is fixed, it's only here for symmetry with
* default_parallel and default_serial. */
#define DEFAULT_USB "usb"
#if !defined(HAS_YYSTYPE)
#define YYSTYPE token_p
#endif
extern YYSTYPE yylval;
extern char string_buf[MAX_STR_CONST];
extern char *string_buf_ptr;
#ifdef __cplusplus
extern "C" {
#endif
int yyparse(void);
int init_config(void);
void cleanup_config(void);
TOKEN * new_token(int primary);
void free_token(TOKEN * tkn);
void free_tokens(int n, ...);
TOKEN * number(char * text);
TOKEN * number_real(char * text);
TOKEN * hexnumber(char * text);
TOKEN * string(char * text);
TOKEN * keyword(int primary);
void print_token(TOKEN * tkn);
void pyytext(void);
char * dup_string(const char * str);
int read_config(const char * file);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -27,16 +27,11 @@
#include <math.h> #include <math.h>
#include "avrdude.h" #include "avrdude.h"
#include "libavrdude.h"
#include "config.h"
#include "lists.h"
#include "par.h" #include "par.h"
#include "serbb.h" #include "serbb.h"
#include "pindefs.h"
#include "ppi.h" #include "ppi.h"
#include "pgm.h"
#include "pgm_type.h"
#include "avr.h"
#if defined(WIN32NATIVE) #if defined(WIN32NATIVE)
#define strtok_r( _s, _sep, _lasts ) \ #define strtok_r( _s, _sep, _lasts ) \

View File

@ -23,7 +23,7 @@
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
AC_PREREQ(2.60) AC_PREREQ(2.60)
AC_INIT(avrdude, 6.1-20140516, avrdude-dev@nongnu.org) AC_INIT(avrdude, 6.1-20140519, avrdude-dev@nongnu.org)
AC_CANONICAL_BUILD AC_CANONICAL_BUILD
AC_CANONICAL_HOST AC_CANONICAL_HOST

View File

@ -18,6 +18,7 @@
#include "avrdude.h" #include "avrdude.h"
#include "libavrdude.h"
#if defined(WIN32NATIVE) #if defined(WIN32NATIVE)

View File

@ -1,39 +0,0 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2003-2004 Eric B. Weddington <eric@ecentral.com>
*
* 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.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if defined(WIN32NATIVE)
#ifndef confwin_h
#define confwin_h
#ifdef __cplusplus
extern "C" {
#endif
void win_sys_config_set(char sys_config[PATH_MAX]);
void win_usr_config_set(char usr_config[PATH_MAX]);
#ifdef __cplusplus
}
#endif
#endif
#endif

8
dfu.c
View File

@ -19,9 +19,6 @@
/* $Id$ */ /* $Id$ */
#include "ac_cfg.h" #include "ac_cfg.h"
#include "dfu.h"
#include "avrdude.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -30,6 +27,11 @@
#include <limits.h> #include <limits.h>
#include <unistd.h> #include <unistd.h>
#include "avrdude.h"
#include "libavrdude.h"
#include "dfu.h"
#include "usbdevs.h" /* for USB_VENDOR_ATMEL */ #include "usbdevs.h" /* for USB_VENDOR_ATMEL */
/* If we don't have LibUSB, define dummy functions that report an error. */ /* If we don't have LibUSB, define dummy functions that report an error. */

View File

@ -38,8 +38,7 @@
#endif #endif
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "fileio.h"
#define IHEX_MAXDATA 256 #define IHEX_MAXDATA 256

View File

@ -1,64 +0,0 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
*
* 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.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* $Id$ */
#ifndef fileio_h
#define fileio_h
typedef enum {
FMT_AUTO,
FMT_SREC,
FMT_IHEX,
FMT_RBIN,
FMT_IMM,
FMT_HEX,
FMT_DEC,
FMT_OCT,
FMT_BIN,
FMT_ELF
} FILEFMT;
struct fioparms {
int op;
char * mode;
char * iodesc;
char * dir;
char * rw;
unsigned int fileoffset;
};
enum {
FIO_READ,
FIO_WRITE
};
#ifdef __cplusplus
extern "C" {
#endif
char * fmtstr(FILEFMT format);
int fileio(int op, char * filename, FILEFMT format,
struct avrpart * p, char * memtype, int size);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -36,13 +36,12 @@
#include <inttypes.h> #include <inttypes.h>
#endif #endif
#include "flip1.h"
#include "dfu.h"
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "pgm.h"
#include "flip1.h"
#include "dfu.h"
#include "usbdevs.h" /* for USB_VENDOR_ATMEL */ #include "usbdevs.h" /* for USB_VENDOR_ATMEL */
/* There are three versions of the FLIP protocol: /* There are three versions of the FLIP protocol:

View File

@ -21,8 +21,6 @@
#ifndef flip1_h #ifndef flip1_h
#define flip1_h #define flip1_h
#include "pgm.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -33,13 +33,11 @@
#include <inttypes.h> #include <inttypes.h>
#endif #endif
#include "avrdude.h"
#include "libavrdude.h"
#include "flip2.h" #include "flip2.h"
#include "dfu.h" #include "dfu.h"
#include "avrdude.h"
#include "avr.h"
#include "pgm.h"
#include "usbdevs.h" /* for USB_VENDOR_ATMEL */ #include "usbdevs.h" /* for USB_VENDOR_ATMEL */
/* There are three versions of the FLIP protocol: /* There are three versions of the FLIP protocol:

View File

@ -21,8 +21,6 @@
#ifndef flip2_h #ifndef flip2_h
#define flip2_h #define flip2_h
#include "pgm.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -61,11 +61,8 @@
#include <stdint.h> #include <stdint.h>
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "avrpart.h"
#include "pindefs.h"
#include "pgm.h"
#include "config.h"
#include "bitbang.h" #include "bitbang.h"
#include "ft245r.h" #include "ft245r.h"
#include "usbdevs.h" #include "usbdevs.h"

View File

@ -1,8 +1,6 @@
#ifndef ft245r_h #ifndef ft245r_h
#define ft245r_h #define ft245r_h
#include "pgm.h"
extern const char ft245r_desc[]; extern const char ft245r_desc[];
void ft245r_initpgm (PROGRAMMER * pgm); void ft245r_initpgm (PROGRAMMER * pgm);

View File

@ -36,12 +36,11 @@
#include <time.h> #include <time.h>
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "crc16.h" #include "crc16.h"
#include "pgm.h"
#include "jtag3.h" #include "jtag3.h"
#include "jtag3_private.h" #include "jtag3_private.h"
#include "serial.h"
#include "usbdevs.h" #include "usbdevs.h"
/* /*

View File

@ -33,12 +33,11 @@
#include <time.h> #include <time.h>
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "crc16.h" #include "crc16.h"
#include "pgm.h"
#include "jtagmkI.h" #include "jtagmkI.h"
#include "jtagmkI_private.h" #include "jtagmkI_private.h"
#include "serial.h"
/* /*
* Private data for this programmer. * Private data for this programmer.

View File

@ -43,12 +43,11 @@
#include <time.h> #include <time.h>
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "crc16.h" #include "crc16.h"
#include "pgm.h"
#include "jtagmkII.h" #include "jtagmkII.h"
#include "jtagmkII_private.h" #include "jtagmkII_private.h"
#include "serial.h"
#include "usbdevs.h" #include "usbdevs.h"
/* /*

View File

@ -29,10 +29,9 @@
#include <sys/stat.h> #include <sys/stat.h>
#include "avrdude.h" #include "avrdude.h"
#include "libavrdude.h"
#include "config.h"
#include "config_gram.h" #include "config_gram.h"
#include "lists.h"
#ifndef YYERRCODE #ifndef YYERRCODE
#define YYERRCODE 256 #define YYERRCODE 256

1003
libavrdude.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -29,9 +29,8 @@
#include <errno.h> #include <errno.h>
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "pindefs.h"
#include "pgm.h"
#include "bitbang.h" #include "bitbang.h"
#if HAVE_LINUXGPIO #if HAVE_LINUXGPIO

View File

@ -40,7 +40,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "lists.h" #include "libavrdude.h"
#define MAGIC 0xb05b05b0 #define MAGIC 0xb05b05b0

116
lists.h
View File

@ -1,116 +0,0 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 1990-2004 Brian S. Dean <bsd@bsdhome.com>
*
* 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.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* $Id$ */
/*----------------------------------------------------------------------
Id: lists.h,v 1.2 2001/08/19 23:13:17 bsd Exp $
----------------------------------------------------------------------*/
/*----------------------------------------------------------------------
General purpose linked list routines - header file declarations.
Author : Brian Dean
Date : 10 January, 1990
----------------------------------------------------------------------*/
#ifndef lists_h
#define lists_h
#include <stdio.h>
typedef void * LISTID;
typedef void * LNODEID;
/*----------------------------------------------------------------------
several defines to access the LIST structure as as stack or a queue
--- use for program readability
----------------------------------------------------------------------*/
#define STACKID LISTID
#define SNODEID LNODEID
#define QUEUEID LISTID
#define QNODEID LNODEID
#define PUSH(s,d) lins_n(s,d,1) /* push 'd' onto the stack */
#define POP(s) lrmv_n(s,1) /* pop the stack */
#define LOOKSTACK(s) lget_n(s,1) /* look at the top of the stack,
but don't pop */
#define ENQUEUE(q,d) lins_n(q,d,1) /* put 'd' on the end of the queue */
#define DEQUEUE(q) lrmv(q) /* remove next item from the front of
the queue */
#define REQUEUE(q,d) ladd(q,d) /* re-insert (push) item back on the
front of the queue */
#define LOOKQUEUE(q) lget(q) /* return next item on the queue,
but don't dequeue */
#define QUEUELEN(q) lsize(q) /* length of the queue */
#define LISTADD(l,d) ladd(l,d) /* add to end of the list */
#define LISTRMV(l,d) lrmv_d(l,d) /* remove from end of the list */
#ifdef __cplusplus
extern "C" {
#endif
/* .................... Function Prototypes .................... */
LISTID lcreat ( void * liststruct, int poolsize );
void ldestroy ( LISTID lid );
void ldestroy_cb ( LISTID lid, void (*ucleanup)(void * data_ptr) );
LNODEID lfirst ( LISTID ); /* head of the list */
LNODEID llast ( LISTID ); /* tail of the list */
LNODEID lnext ( LNODEID ); /* next item in the list */
LNODEID lprev ( LNODEID ); /* previous item in the list */
void * ldata ( LNODEID ); /* data at the current position */
int lsize ( LISTID ); /* number of elements in the list */
int ladd ( LISTID lid, void * p );
int laddo ( LISTID lid, void *p,
int (*compare)(const void *p1,const void *p2),
LNODEID * firstdup );
int laddu ( LISTID lid, void * p,
int (*compare)(const void *p1,const void *p2));
int lins_n ( LISTID lid, void * d, unsigned int n );
int lins_ln ( LISTID lid, LNODEID lnid, void * data_ptr );
void * lget ( LISTID lid );
void * lget_n ( LISTID lid, unsigned int n );
LNODEID lget_ln ( LISTID lid, unsigned int n );
void * lrmv ( LISTID lid );
void * lrmv_n ( LISTID lid, unsigned int n );
void * lrmv_ln ( LISTID lid, LNODEID lnid );
void * lrmv_d ( LISTID lid, void * data_ptr );
LISTID lcat ( LISTID lid1, LISTID lid2 );
void lsort ( LISTID lid, int (*compare)(void * p1, void * p2));
void * lsrch ( LISTID lid, void * p, int (*compare)(void *p1,void *p2));
int lprint ( FILE * f, LISTID lid );
#ifdef __cplusplus
}
#endif
#endif

11
main.c
View File

@ -45,15 +45,10 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/time.h> #include <sys/time.h>
#include "avr.h" #include "avrdude.h"
#include "config.h" #include "libavrdude.h"
#include "confwin.h"
#include "fileio.h"
#include "lists.h"
#include "term.h" #include "term.h"
#include "safemode.h"
#include "update.h"
#include "pgm_type.h"
/* Get VERSION from ac_cfg.h */ /* Get VERSION from ac_cfg.h */

5
par.c
View File

@ -36,9 +36,8 @@
#endif #endif
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "pindefs.h"
#include "pgm.h"
#include "ppi.h" #include "ppi.h"
#include "bitbang.h" #include "bitbang.h"
#include "par.h" #include "par.h"

2
pgm.c
View File

@ -26,7 +26,7 @@
#include <string.h> #include <string.h>
#include "avrdude.h" #include "avrdude.h"
#include "pgm.h" #include "libavrdude.h"
static int pgm_default_2 (struct programmer_t *, AVRPART *); static int pgm_default_2 (struct programmer_t *, AVRPART *);
static int pgm_default_3 (struct programmer_t * pgm, AVRPART * p, AVRMEM * mem, static int pgm_default_3 (struct programmer_t * pgm, AVRPART * p, AVRMEM * mem,

View File

@ -26,10 +26,9 @@
#include <string.h> #include <string.h>
#include "avrdude.h" #include "avrdude.h"
#include "pgm_type.h" #include "libavrdude.h"
#include "arduino.h" #include "arduino.h"
#include "avr.h"
#include "avr910.h" #include "avr910.h"
#include "avrftdi.h" #include "avrftdi.h"
#include "buspirate.h" #include "buspirate.h"

View File

@ -1,50 +0,0 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2002-2004 Brian S. Dean <bsd@bsdhome.com>
* Copyright 2007 Joerg Wunsch <j@uriah.heep.sax.de>
*
* 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.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* $Id: pgm.h 1007 2011-09-14 21:49:42Z joerg_wunsch $ */
#ifndef pgm_type_h
#define pgm_type_h
#include "lists.h"
#include "pgm.h"
/*LISTID programmer_types;*/
typedef struct programmer_type_t {
const char * const id;
void (*initpgm)(struct programmer_t * pgm);
const char * const desc;
} PROGRAMMER_TYPE;
#ifdef __cplusplus
extern "C" {
#endif
const PROGRAMMER_TYPE * locate_programmer_type(/*LISTID programmer_types, */const char * id);
typedef void (*walk_programmer_types_cb)(const char *id, const char *desc,
void *cookie);
void walk_programmer_types(/*LISTID programmer_types,*/ walk_programmer_types_cb cb, void *cookie);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -52,8 +52,7 @@
#include <unistd.h> #include <unistd.h>
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "pgm.h"
#if defined(HAVE_LIBUSB) || (defined(WIN32NATIVE) && defined(HAVE_LIBHID)) #if defined(HAVE_LIBUSB) || (defined(WIN32NATIVE) && defined(HAVE_LIBHID))

View File

@ -21,8 +21,6 @@
#ifndef pickit2_h #ifndef pickit2_h
#define pickit2_h #define pickit2_h
#include "avrpart.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -21,9 +21,9 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "avrdude.h" #include "avrdude.h"
#include "pindefs.h" #include "libavrdude.h"
#include "pgm.h"
/** /**
* Adds a pin in the pin definition as normal or inverse pin. * Adds a pin in the pin definition as normal or inverse pin.

202
pindefs.h
View File

@ -1,202 +0,0 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
*
* 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.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* $Id$ */
#ifndef __pindefs_h__
#define __pindefs_h__
#include <limits.h>
#include "ac_cfg.h"
/* lets try to select at least 32 bits */
#ifdef HAVE_STDINT_H
#include <stdint.h>
typedef uint32_t pinmask_t;
#else
#if UINT_MAX >= 0xFFFFFFFF
typedef unsigned int pinmask_t;
#else
typedef unsigned long pinmask_t;
#endif
#endif
#include <stdbool.h>
enum {
PPI_AVR_VCC = 1,
PPI_AVR_BUFF,
PIN_AVR_RESET,
PIN_AVR_SCK,
PIN_AVR_MOSI,
PIN_AVR_MISO,
PIN_LED_ERR,
PIN_LED_RDY,
PIN_LED_PGM,
PIN_LED_VFY,
N_PINS
};
#define PIN_MASK (UINT_MAX>>1)
#define PIN_INVERSE (~(PIN_MASK)) /* flag for inverted pin in serbb */
#define PIN_MIN 0 /* smallest allowed pin number */
#define PIN_MAX 31 /* largest allowed pin number */
#ifdef HAVE_LINUXGPIO
/* Embedded systems might have a lot more gpio than only 0-31 */
#undef PIN_MAX
#define PIN_MAX 255 /* largest allowed pin number */
#endif
/** Number of pins in each element of the bitfield */
#define PIN_FIELD_ELEMENT_SIZE (sizeof(pinmask_t) * 8)
/** Numer of elements to store the complete bitfield of all pins */
#define PIN_FIELD_SIZE ((PIN_MAX + PIN_FIELD_ELEMENT_SIZE)/PIN_FIELD_ELEMENT_SIZE)
/**
* This sets the corresponding bits to 1 or 0, the inverse mask is used to invert the value in necessary.
* It uses only the lowest element (index=0) of the bitfield, which should be enough for most
* programmers.
*
* @param[in] x input value
* @param[in] pgm the programmer whose pin definitions to use
* @param[in] pinname the logical name of the pin (PIN_AVR_*, ...)
* @param[in] level the logical level (level != 0 => 1, level == 0 => 0),
* if the pin is defined as inverted the resulting bit is also inverted
* @returns the input value with the relevant bits modified
*/
#define SET_BITS_0(x,pgm,pinname,level) (((x) & ~(pgm)->pin[pinname].mask[0]) \
| (\
(pgm)->pin[pinname].mask[0] & ( \
(level) \
?~((pgm)->pin[pinname].inverse[0]) \
: ((pgm)->pin[pinname].inverse[0]) \
) \
) \
)
/**
* Check if the corresponding bit is set (returns != 0) or cleared.
* The inverse mask is used, to invert the relevant bits.
* If the pin definition contains multiple pins, then a single set pin leads to return value != 0.
* Then you have to check the relevant bits of the returned value, if you need more information.
* It uses only the lowest element (index=0) of the bitfield, which should be enough for most
* programmers.
*
* @param[in] x input value
* @param[in] pgm the programmer whose pin definitions to use
* @param[in] pinname the logical name of the pin (PIN_AVR_*, ...)
* @returns the input value with only the relevant bits (which are already inverted,
* so you get always the logical level)
*/
#define GET_BITS_0(x,pgm,pinname) (((x) ^ (pgm)->pin[pinname].inverse[0]) & (pgm)->pin[pinname].mask[0])
/**
* Data structure to hold used pins by logical function (PIN_AVR_*, ...)
*/
struct pindef_t {
pinmask_t mask[PIN_FIELD_SIZE]; ///< bitfield of used pins
pinmask_t inverse[PIN_FIELD_SIZE]; ///< bitfield of inverse/normal usage of used pins
};
/**
* Data structure to define a checklist of valid pins for each function.
*/
struct pin_checklist_t {
int pinname; ///< logical pinname eg. PIN_AVR_SCK
int mandatory; ///< is this a mandatory pin
const struct pindef_t* valid_pins; ///< mask defines allowed pins, inverse define is they might be used inverted
};
/**
* Adds a pin in the pin definition as normal or inverse pin.
*
* @param[out] pindef pin definition to update
* @param[in] pin number of pin [0..PIN_MAX]
* @param[in] inverse inverse (true) or normal (false) pin
*/
void pin_set_value(struct pindef_t * const pindef, const int pin, const bool inverse);
/**
* Clear all defined pins in pindef.
*
* @param[out] pindef pin definition to clear
*/
void pin_clear_all(struct pindef_t * const pindef);
struct programmer_t; /* forward declaration */
/**
* Convert for given programmer new pin definitions to old pin definitions.
*
* @param[inout] pgm programmer whose pins shall be converted.
*/
int pgm_fill_old_pins(struct programmer_t * const pgm);
/**
* This function checks all pin of pgm against the constraints given in the checklist.
* It checks if
* @li any invalid pins are used
* @li valid pins are used inverted when not allowed
* @li any pins are used by more than one function
* @li any mandatory pin is not set all.
*
* In case of any error it report the wrong function and the pin numbers.
* For verbose >= 2 it also reports the possible correct values.
* For verbose >=3 it shows also which pins were ok.
*
* @param[in] pgm the programmer to check
* @param[in] checklist the constraint for the pins
* @param[in] size the number of entries in checklist
* @param[in] output false suppresses error messages to the user
* @returns 0 if all pin definitions are valid, -1 otherwise
*/
int pins_check(const struct programmer_t * const pgm, const struct pin_checklist_t * const checklist, const int size, const bool output);
/**
* Returns the name of the pin as string.
*
* @param pinname the pinname which we want as string.
* @returns a string with the pinname, or <unknown> if pinname is invalid.
*/
const char * avr_pin_name(int pinname);
/**
* This function returns a string representation of defined pins eg. ~1,2,~4,~5,7
* Another execution of this function will overwrite the previous result in the static buffer.
*
* @param[in] pindef the pin definition for which we want the string representation
* @returns pointer to a static string.
*/
const char * pins_to_str(const struct pindef_t * const pindef);
/**
* This function returns a string representation of pins in the mask eg. 1,3,5-7,9,12
* Another execution of this function will overwrite the previous result in the static buffer.
* Consecutive pin number are representated as start-end.
*
* @param[in] pinmask the pin mask for which we want the string representation
* @returns pointer to a static string.
*/
const char * pinmask_to_str(const pinmask_t * const pinmask);
#endif

5
ppi.c
View File

@ -41,9 +41,8 @@
#endif #endif
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "pindefs.h"
#include "pgm.h"
#include "ppi.h" #include "ppi.h"
enum { enum {

View File

@ -31,7 +31,6 @@ reg = register as defined in an enum in ppi.h. This must be converted
#include "ac_cfg.h" #include "ac_cfg.h"
#include "avrdude.h"
#if defined (WIN32NATIVE) #if defined (WIN32NATIVE)
@ -45,7 +44,9 @@ reg = register as defined in an enum in ppi.h. This must be converted
#include <sys/time.h> #include <sys/time.h>
#include <windows.h> #include <windows.h>
#include "serial.h" #include "avrdude.h"
#include "libavrdude.h"
#include "ppi.h" #include "ppi.h"
#define DEVICE_LPT1 "lpt1" #define DEVICE_LPT1 "lpt1"

View File

@ -22,10 +22,9 @@
#include <stdio.h> #include <stdio.h>
#include "ac_cfg.h" #include "ac_cfg.h"
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "pgm.h"
#include "safemode.h"
/* This value from ac_cfg.h */ /* This value from ac_cfg.h */
/* /*

View File

@ -1,46 +0,0 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* avrdude is Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This file: Copyright (C) 2005 Colin O'Flynn <coflynn@newae.com>
*
* 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.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef safemode_h
#define safemode_h
#ifdef __cplusplus
extern "C" {
#endif
/* Writes the specified fuse in fusename (can be "lfuse", "hfuse", or "efuse") and verifies it. Will try up to tries
amount of times before giving up */
int safemode_writefuse (unsigned char fuse, char * fusename, PROGRAMMER * pgm, AVRPART * p, int tries, int verbose);
/* Reads the fuses three times, checking that all readings are the same. This will ensure that the before values aren't in error! */
int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse, unsigned char * efuse, unsigned char * fuse, PROGRAMMER * pgm, AVRPART * p, int verbose);
/* This routine will store the current values pointed to by lfuse, hfuse, and efuse into an internal buffer in this routine
when save is set to 1. When save is 0 (or not 1 really) it will copy the values from the internal buffer into the locations
pointed to be lfuse, hfuse, and efuse. This allows you to change the fuse bits if needed from another routine (ie: have it so
if user requests fuse bits are changed, the requested value is now verified */
int safemode_memfuses (int save, unsigned char * lfuse, unsigned char * hfuse, unsigned char * efuse, unsigned char * fuse);
#ifdef __cplusplus
}
#endif
#endif /* safemode_h */

View File

@ -33,7 +33,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "avrdude.h" #include "avrdude.h"
#include "serial.h" #include "libavrdude.h"
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */

View File

@ -43,7 +43,7 @@
#include <unistd.h> #include <unistd.h>
#include "avrdude.h" #include "avrdude.h"
#include "serial.h" #include "libavrdude.h"
long serial_recv_timeout = 5000; /* ms */ long serial_recv_timeout = 5000; /* ms */

View File

@ -23,15 +23,14 @@
* Native Win32 serial interface for avrdude. * Native Win32 serial interface for avrdude.
*/ */
#include "avrdude.h"
#if defined(WIN32NATIVE) #if defined(WIN32NATIVE)
#include <windows.h> #include <windows.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h> /* for isprint */ #include <ctype.h> /* for isprint */
#include "serial.h" #include "avrdude.h"
#include "libavrdude.h"
long serial_recv_timeout = 5000; /* ms */ long serial_recv_timeout = 5000; /* ms */

View File

@ -37,9 +37,8 @@
#include <termios.h> #include <termios.h>
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "pindefs.h"
#include "pgm.h"
#include "bitbang.h" #include "bitbang.h"
#include "serbb.h" #include "serbb.h"

View File

@ -33,9 +33,9 @@
#include <windows.h> #include <windows.h>
#include <stdio.h> #include <stdio.h>
#include "avr.h" #include "avrdude.h"
#include "pindefs.h" #include "libavrdude.h"
#include "pgm.h"
#include "bitbang.h" #include "bitbang.h"
#include "serbb.h" #include "serbb.h"

View File

@ -1,94 +0,0 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2003-2004 Theodore A. Roth <troth@openavr.org>
*
* 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.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* $Id$ */
/* This is the API for the generic serial interface. The implementations are
actually provided by the target dependant files:
ser_posix.c : posix serial interface.
ser_win32.c : native win32 serial interface.
The target file will be selected at configure time. */
#ifndef serial_h
#define serial_h
extern long serial_recv_timeout;
union filedescriptor
{
int ifd;
void *pfd;
struct
{
void *handle;
int rep; /* bulk read endpoint */
int wep; /* bulk write endpoint */
int eep; /* event read endpoint */
int max_xfer; /* max transfer size */
int use_interrupt_xfer; /* device uses interrupt transfers */
} usb;
};
union pinfo
{
long baud;
struct
{
unsigned short vid;
unsigned short pid;
unsigned short flags;
#define PINFO_FL_USEHID 0x0001
#define PINFO_FL_SILENT 0x0002 /* don't complain if not found */
} usbinfo;
};
struct serial_device
{
// open should return -1 on error, other values on success
int (*open)(char * port, union pinfo pinfo, union filedescriptor *fd);
int (*setspeed)(union filedescriptor *fd, long baud);
void (*close)(union filedescriptor *fd);
int (*send)(union filedescriptor *fd, unsigned char * buf, size_t buflen);
int (*recv)(union filedescriptor *fd, unsigned char * buf, size_t buflen);
int (*drain)(union filedescriptor *fd, int display);
int (*set_dtr_rts)(union filedescriptor *fd, int is_on);
int flags;
#define SERDEV_FL_NONE 0x0000 /* no flags */
#define SERDEV_FL_CANSETSPEED 0x0001 /* device can change speed */
};
extern struct serial_device *serdev;
extern struct serial_device serial_serdev;
extern struct serial_device usb_serdev;
extern struct serial_device usb_serdev_frame;
extern struct serial_device avrdoper_serdev;
#define serial_open (serdev->open)
#define serial_setspeed (serdev->setspeed)
#define serial_close (serdev->close)
#define serial_send (serdev->send)
#define serial_recv (serdev->recv)
#define serial_drain (serdev->drain)
#define serial_set_dtr_rts (serdev->set_dtr_rts)
#endif /* serial_h */

View File

@ -37,11 +37,10 @@
#include <unistd.h> #include <unistd.h>
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "pgm.h"
#include "stk500.h" #include "stk500.h"
#include "stk500_private.h" #include "stk500_private.h"
#include "serial.h"
#define STK500_XTAL 7372800U #define STK500_XTAL 7372800U
#define MAX_SYNC_ATTEMPTS 10 #define MAX_SYNC_ATTEMPTS 10

View File

@ -32,7 +32,8 @@
#include <string.h> #include <string.h>
#include "avrdude.h" #include "avrdude.h"
#include "pgm.h" #include "libavrdude.h"
#include "stk500generic.h" #include "stk500generic.h"
#include "stk500.h" #include "stk500.h"
#include "stk500v2.h" #include "stk500v2.h"

View File

@ -48,12 +48,11 @@
#include <time.h> #include <time.h>
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "pgm.h"
#include "stk500_private.h" // temp until all code converted #include "stk500_private.h" // temp until all code converted
#include "stk500v2.h" #include "stk500v2.h"
#include "stk500v2_private.h" #include "stk500v2_private.h"
#include "serial.h"
#include "usbdevs.h" #include "usbdevs.h"
/* /*

View File

@ -9,8 +9,6 @@
//* //*
//************************************************************************** //**************************************************************************
#include "pgm.h"
// *****************[ STK message constants ]*************************** // *****************[ STK message constants ]***************************
#define MESSAGE_START 0x1B //= ESC = 27 decimal #define MESSAGE_START 0x1B //= ESC = 27 decimal

7
term.c
View File

@ -34,12 +34,7 @@
#endif #endif
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "term.h"
#include "config.h"
#include "lists.h"
#include "pgm.h"
#include "pindefs.h"
#include "ppi.h"
struct command { struct command {
char * name; char * name;

3
term.h
View File

@ -21,8 +21,7 @@
#ifndef term_h #ifndef term_h
#define term_h #define term_h
#include "avr.h" #include "libavrdude.h"
#include "pgm.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -26,11 +26,7 @@
#include <time.h> #include <time.h>
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "config.h"
#include "confwin.h"
#include "fileio.h"
#include "update.h"
UPDATE * parse_op(char * s) UPDATE * parse_op(char * s)
{ {

View File

@ -1,61 +0,0 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000-2005 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2007 Joerg Wunsch
*
* 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.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* $Id$ */
#ifndef update_h
#define update_h
enum {
DEVICE_READ,
DEVICE_WRITE,
DEVICE_VERIFY
};
enum updateflags {
UF_NONE = 0,
UF_NOWRITE = 1,
UF_AUTO_ERASE = 2,
};
typedef struct update_t {
char * memtype;
int op;
char * filename;
int format;
} UPDATE;
#ifdef __cplusplus
extern "C" {
#endif
extern UPDATE * parse_op(char * s);
extern UPDATE * dup_update(UPDATE * upd);
extern UPDATE * new_update(int op, char * memtype, int filefmt,
char * filename);
extern void free_update(UPDATE * upd);
extern int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd,
enum updateflags flags);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -44,7 +44,8 @@
#endif #endif
#include "avrdude.h" #include "avrdude.h"
#include "serial.h" #include "libavrdude.h"
#include "usbdevs.h" #include "usbdevs.h"
#if defined(WIN32NATIVE) #if defined(WIN32NATIVE)

View File

@ -35,8 +35,8 @@
#include <unistd.h> #include <unistd.h>
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "pgm.h"
#include "usbasp.h" #include "usbasp.h"
#include "usbdevs.h" #include "usbdevs.h"

View File

@ -21,8 +21,6 @@
#ifndef usbasp_h #ifndef usbasp_h
#define usbasp_h #define usbasp_h
#include "avrpart.h"
/* USB function call identifiers */ /* USB function call identifiers */
#define USBASP_FUNC_CONNECT 1 #define USBASP_FUNC_CONNECT 1
#define USBASP_FUNC_DISCONNECT 2 #define USBASP_FUNC_DISCONNECT 2

View File

@ -33,9 +33,8 @@
#include <unistd.h> #include <unistd.h>
#include "avrdude.h" #include "avrdude.h"
#include "avr.h" #include "libavrdude.h"
#include "pgm.h"
#include "config.h"
#include "usbtiny.h" #include "usbtiny.h"
#include "usbdevs.h" #include "usbdevs.h"

View File

@ -20,9 +20,6 @@
#ifndef usbtiny_h #ifndef usbtiny_h
#define usbtiny_h #define usbtiny_h
#include "avrpart.h"
// Generic requests to the USBtiny // Generic requests to the USBtiny
#define USBTINY_ECHO 0 // echo test #define USBTINY_ECHO 0 // echo test
#define USBTINY_READ 1 // read byte (wIndex:address) #define USBTINY_READ 1 // read byte (wIndex:address)

View File

@ -46,10 +46,10 @@
#include <unistd.h> #include <unistd.h>
#include "avrdude.h" #include "avrdude.h"
#include "pgm.h" #include "libavrdude.h"
#include "stk500v2_private.h" #include "stk500v2_private.h"
#include "stk500v2.h" #include "stk500v2.h"
#include "serial.h"
#include "wiring.h" #include "wiring.h"
/* /*