Replace the fallback of avr_read_byte() and avr_write_byte() to

avr_read_byte_default() and avr_write_byte_default (resp.) by directly
calling the latter functions from within all programmers that don't
implement their own read_byte()/write_byte() methods.  In turn, make the
read_byte() and write_byte() methods mandatory, and the cmd() method
(direct ISP command) optional instead (it's effectively mandatory for
any programmer using avr_read_byte_default()/avr_write_byte_default()
though).  Remove all the pointless cmd() method stubs from those programmers
that don't need it.

Eliminate avr_read_byte() as it was now completely identical to
pgm->read_byte().


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@684 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch 2006-11-20 15:04:09 +00:00
parent 23aeb38d13
commit afb13a9936
14 changed files with 141 additions and 114 deletions

View File

@ -1,3 +1,29 @@
2006-11-13 Joerg Wunsch <j@uriah.heep.sax.de>
* avr.c: Replace the fallback of avr_read_byte() and avr_write_byte() to
avr_read_byte_default() and avr_write_byte_default (resp.) by directly
calling the latter functions from within all programmers that don't
implement their own read_byte()/write_byte() methods. In turn, make the
read_byte() and write_byte() methods mandatory, and the cmd() method
(direct ISP command) optional instead (it's effectively mandatory for
any programmer using avr_read_byte_default()/avr_write_byte_default()
though). Remove all the pointless cmd() method stubs from those programmers
that don't need it.
Eliminate avr_read_byte() as it was now completely identical to
pgm->read_byte().
* avr.h: (Ditto.)
* bitbang.c: (Ditto.)
* butterfly.c: (Ditto.)
* jtagmkI.c: (Ditto.)
* jtagmkII.c: (Ditto.)
* par.c: (Ditto.)
* pgm.c: (Ditto.)
* safemode.c: (Ditto.)
* stk500.c: (Ditto.)
* stk500v2.c: (Ditto.)
* term.c: (Ditto.)
* usbasp.c: (Ditto.)
2006-11-13 Joerg Wunsch <j@uriah.heep.sax.de>
* jtagmkI.c: Avoid sending a CMD_RESET when leaving programming

65
avr.c
View File

@ -53,6 +53,14 @@ int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
unsigned char data;
OPCODE * readop, * lext;
if (pgm->cmd == NULL) {
fprintf(stderr,
"%s: Error: %s programmer uses avr_read_byte_default() but does not\n"
"provide a cmd() method.\n",
progname, pgm->type);
return -1;
}
pgm->pgm_led(pgm, ON);
pgm->err_led(pgm, OFF);
@ -107,26 +115,6 @@ int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
}
/*
* read a byte of data from the indicated memory region
*/
int avr_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
unsigned long addr, unsigned char * value)
{
int rc;
if (pgm->read_byte) {
rc = pgm->read_byte(pgm, p, mem, addr, value);
if (rc == 0) {
return rc;
}
/* read_byte() method failed, try again with default. */
}
return avr_read_byte_default(pgm, p, mem, addr, value);
}
/*
* Return the number of "interesting" bytes in a memory buffer,
* "interesting" being defined as up to the last non-0xff data
@ -218,7 +206,7 @@ int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
}
for (i=0; i<size; i++) {
rc = avr_read_byte(pgm, p, mem, i, &rbyte);
rc = pgm->read_byte(pgm, p, mem, i, &rbyte);
if (rc != 0) {
fprintf(stderr, "avr_read(): error reading address 0x%04lx\n", i);
if (rc == -1)
@ -248,6 +236,14 @@ int avr_write_page(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
unsigned char res[4];
OPCODE * wp, * lext;
if (pgm->cmd == NULL) {
fprintf(stderr,
"%s: Error: %s programmer uses avr_write_page() but does not\n"
"provide a cmd() method.\n",
progname, pgm->type);
return -1;
}
wp = mem->op[AVR_OP_WRITEPAGE];
if (wp == NULL) {
fprintf(stderr,
@ -312,13 +308,21 @@ int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
int readok=0;
struct timeval tv;
if (pgm->cmd == NULL) {
fprintf(stderr,
"%s: Error: %s programmer uses avr_write_byte_default() but does not\n"
"provide a cmd() method.\n",
progname, pgm->type);
return -1;
}
if (!mem->paged) {
/*
* check to see if the write is necessary by reading the existing
* value and only write if we are changing the value; we can't
* use this optimization for paged addressing.
*/
rc = avr_read_byte(pgm, p, mem, addr, &b);
rc = pgm->read_byte(pgm, p, mem, addr, &b);
if (rc != 0) {
if (rc != -1) {
return -2;
@ -410,7 +414,7 @@ int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
* specified for the chip.
*/
usleep(mem->max_write_delay);
rc = avr_read_byte(pgm, p, mem, addr, &r);
rc = pgm->read_byte(pgm, p, mem, addr, &r);
if (rc != 0) {
pgm->pgm_led(pgm, OFF);
pgm->err_led(pgm, OFF);
@ -424,7 +428,7 @@ int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
/*
* Do polling, but timeout after max_write_delay.
*/
rc = avr_read_byte(pgm, p, mem, addr, &r);
rc = pgm->read_byte(pgm, p, mem, addr, &r);
if (rc != 0) {
pgm->pgm_led(pgm, OFF);
pgm->err_led(pgm, ON);
@ -509,7 +513,6 @@ int avr_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
unsigned char safemode_hfuse;
unsigned char safemode_efuse;
unsigned char safemode_fuse;
int rc;
/* If we write the fuses, then we need to tell safemode that they *should* change */
safemode_memfuses(0, &safemode_lfuse, &safemode_hfuse, &safemode_efuse, &safemode_fuse);
@ -529,15 +532,7 @@ int avr_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
safemode_memfuses(1, &safemode_lfuse, &safemode_hfuse, &safemode_efuse, &safemode_fuse);
if (pgm->write_byte) {
rc = pgm->write_byte(pgm, p, mem, addr, data);
if (rc == 0) {
return rc;
}
/* write_byte() method failed, try again with default. */
}
return avr_write_byte_default(pgm, p, mem, addr, data);
return pgm->write_byte(pgm, p, mem, addr, data);
}
@ -741,7 +736,7 @@ int avr_get_cycle_count(PROGRAMMER * pgm, AVRPART * p, int * cycles)
}
for (i=4; i>0; i--) {
rc = avr_read_byte(pgm, p, a, a->size-i, &v1);
rc = pgm->read_byte(pgm, p, a, a->size-i, &v1);
if (rc < 0) {
fprintf(stderr, "%s: WARNING: can't read memory for cycle count, rc=%d\n",
progname, rc);

5
avr.h
View File

@ -32,7 +32,7 @@
extern struct avrpart parts[];
int avr_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
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, int size,
@ -44,6 +44,9 @@ int avr_write_page(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
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 verbose);

View File

@ -355,4 +355,10 @@ void bitbang_check_prerequisites(PROGRAMMER *pgm)
verify_pin_assigned(pgm, PIN_AVR_SCK, "AVR SCK");
verify_pin_assigned(pgm, PIN_AVR_MISO, "AVR MISO");
verify_pin_assigned(pgm, PIN_AVR_MOSI, "AVR MOSI");
if (pgm->cmd == NULL) {
fprintf(stderr, "%s: error: no cmd() method defined for bitbang programmer\n",
progname);
exit(1);
}
}

View File

@ -661,17 +661,15 @@ void butterfly_initpgm(PROGRAMMER * pgm)
pgm->powerdown = butterfly_powerdown;
pgm->program_enable = butterfly_program_enable;
pgm->chip_erase = butterfly_chip_erase;
/* pgm->cmd not supported, use default error message */
pgm->open = butterfly_open;
pgm->close = butterfly_close;
pgm->read_byte = butterfly_read_byte;
pgm->write_byte = butterfly_write_byte;
/*
* optional functions
*/
pgm->write_byte = butterfly_write_byte;
pgm->read_byte = butterfly_read_byte;
pgm->paged_write = butterfly_paged_write;
pgm->paged_load = butterfly_paged_load;

View File

@ -334,16 +334,6 @@ static int jtagmkI_getsync(PROGRAMMER * pgm)
return 0;
}
static int jtagmkI_cmd(PROGRAMMER * pgm, unsigned char cmd[4],
unsigned char res[4])
{
fprintf(stderr, "%s: jtagmkI_command(): no direct SPI supported for JTAG\n",
progname);
return -1;
}
/*
* issue the 'chip erase' command to the AVR device
*/
@ -1354,17 +1344,16 @@ void jtagmkI_initpgm(PROGRAMMER * pgm)
pgm->disable = jtagmkI_disable;
pgm->program_enable = jtagmkI_program_enable_dummy;
pgm->chip_erase = jtagmkI_chip_erase;
pgm->cmd = jtagmkI_cmd;
pgm->open = jtagmkI_open;
pgm->close = jtagmkI_close;
pgm->read_byte = jtagmkI_read_byte;
pgm->write_byte = jtagmkI_write_byte;
/*
* optional functions
*/
pgm->paged_write = jtagmkI_paged_write;
pgm->paged_load = jtagmkI_paged_load;
pgm->read_byte = jtagmkI_read_byte;
pgm->write_byte = jtagmkI_write_byte;
pgm->print_parms = jtagmkI_print_parms;
pgm->set_sck_period = jtagmkI_set_sck_period;
pgm->page_size = 256;

View File

@ -757,16 +757,6 @@ int jtagmkII_getsync(PROGRAMMER * pgm, int mode) {
return 0;
}
static int jtagmkII_cmd(PROGRAMMER * pgm, unsigned char cmd[4],
unsigned char res[4])
{
fprintf(stderr, "%s: jtagmkII_command(): no direct SPI supported for JTAG\n",
progname);
return -1;
}
/*
* issue the 'chip erase' command to the AVR device
*/
@ -1951,17 +1941,16 @@ void jtagmkII_initpgm(PROGRAMMER * pgm)
pgm->disable = jtagmkII_disable;
pgm->program_enable = jtagmkII_program_enable_dummy;
pgm->chip_erase = jtagmkII_chip_erase;
pgm->cmd = jtagmkII_cmd;
pgm->open = jtagmkII_open;
pgm->close = jtagmkII_close;
pgm->read_byte = jtagmkII_read_byte;
pgm->write_byte = jtagmkII_write_byte;
/*
* optional functions
*/
pgm->paged_write = jtagmkII_paged_write;
pgm->paged_load = jtagmkII_paged_load;
pgm->read_byte = jtagmkII_read_byte;
pgm->write_byte = jtagmkII_write_byte;
pgm->print_parms = jtagmkII_print_parms;
pgm->set_sck_period = jtagmkII_set_sck_period;
pgm->page_size = 256;
@ -1981,17 +1970,16 @@ void jtagmkII_dragon_initpgm(PROGRAMMER * pgm)
pgm->disable = jtagmkII_disable;
pgm->program_enable = jtagmkII_program_enable_dummy;
pgm->chip_erase = jtagmkII_chip_erase;
pgm->cmd = jtagmkII_cmd;
pgm->open = jtagmkII_dragon_open;
pgm->close = jtagmkII_close;
pgm->read_byte = jtagmkII_read_byte;
pgm->write_byte = jtagmkII_write_byte;
/*
* optional functions
*/
pgm->paged_write = jtagmkII_paged_write;
pgm->paged_load = jtagmkII_paged_load;
pgm->read_byte = jtagmkII_read_byte;
pgm->write_byte = jtagmkII_write_byte;
pgm->print_parms = jtagmkII_print_parms;
pgm->set_sck_period = jtagmkII_set_sck_period;
pgm->page_size = 256;

2
par.c
View File

@ -425,6 +425,8 @@ void par_initpgm(PROGRAMMER * pgm)
pgm->getpin = par_getpin;
pgm->highpulsepin = par_highpulsepin;
pgm->parseexitspecs = par_parseexitspecs;
pgm->read_byte = avr_read_byte_default;
pgm->write_byte = avr_write_byte_default;
}
#else /* !HAVE_PARPORT */

23
pgm.c
View File

@ -30,9 +30,11 @@
extern char * progname;
static int pgm_default_2 (struct programmer_t *, AVRPART *);
static int pgm_default_3 (struct programmer_t * pgm, AVRPART * p, AVRMEM * mem,
unsigned long addr, unsigned char * value);
static void pgm_default_4 (struct programmer_t *);
static int pgm_default_5 (struct programmer_t *, unsigned char cmd[4],
unsigned char res[4]);
static int pgm_default_5 (struct programmer_t * pgm, AVRPART * p, AVRMEM * mem,
unsigned long addr, unsigned char data);
static void pgm_default_6 (struct programmer_t *, char *);
@ -96,9 +98,10 @@ PROGRAMMER * pgm_new(void)
pgm->powerdown = pgm_default_powerup_powerdown;
pgm->program_enable = pgm_default_2;
pgm->chip_erase = pgm_default_2;
pgm->cmd = pgm_default_5;
pgm->open = pgm_default_open;
pgm->close = pgm_default_4;
pgm->read_byte = pgm_default_3;
pgm->write_byte = pgm_default_5;
/*
* predefined functions - these functions have a valid default
@ -114,11 +117,10 @@ PROGRAMMER * pgm_new(void)
* optional functions - these are checked to make sure they are
* assigned before they are called
*/
pgm->cmd = NULL;
pgm->paged_write = NULL;
pgm->paged_load = NULL;
pgm->write_setup = NULL;
pgm->write_byte = NULL;
pgm->read_byte = NULL;
pgm->read_sig_bytes = NULL;
pgm->set_vtarget = NULL;
pgm->set_varef = NULL;
@ -141,13 +143,20 @@ static int pgm_default_2 (struct programmer_t * pgm, AVRPART * p)
return -1;
}
static int pgm_default_3 (struct programmer_t * pgm, AVRPART * p, AVRMEM * mem,
unsigned long addr, unsigned char * value)
{
pgm_default();
return -1;
}
static void pgm_default_4 (struct programmer_t * pgm)
{
pgm_default();
}
static int pgm_default_5 (struct programmer_t * pgm, unsigned char cmd[4],
unsigned char res[4])
static int pgm_default_5 (struct programmer_t * pgm, AVRPART * p, AVRMEM * mem,
unsigned long addr, unsigned char data)
{
pgm_default();
return -1;

View File

@ -50,7 +50,7 @@ int safemode_writefuse (unsigned char fuse, char * fusename, PROGRAMMER * pgm,
/* Keep trying to write then read back the fuse values */
while (tries > 0) {
avr_write_byte(pgm, p, m, 0, fuse);
avr_read_byte(pgm, p, m, 0, &fuseread);
pgm->read_byte(pgm, p, m, 0, &fuseread);
/* Report information to user if needed */
if (verbose > 0) {
@ -99,10 +99,10 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
m = avr_locate_mem(p, "fuse");
if (m != NULL) {
fusegood = 0; /* By default fuse is a failure */
avr_read_byte(pgm, p, m, 0, &safemode_fuse);
avr_read_byte(pgm, p, m, 0, &value);
pgm->read_byte(pgm, p, m, 0, &safemode_fuse);
pgm->read_byte(pgm, p, m, 0, &value);
if (value == safemode_fuse) {
avr_read_byte(pgm, p, m, 0, &value);
pgm->read_byte(pgm, p, m, 0, &value);
if (value == safemode_fuse){
fusegood = 1; /* Fuse read OK three times */
}
@ -126,10 +126,10 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
m = avr_locate_mem(p, "lfuse");
if (m != NULL) {
fusegood = 0; /* By default fuse is a failure */
avr_read_byte(pgm, p, m, 0, &safemode_lfuse);
avr_read_byte(pgm, p, m, 0, &value);
pgm->read_byte(pgm, p, m, 0, &safemode_lfuse);
pgm->read_byte(pgm, p, m, 0, &value);
if (value == safemode_lfuse) {
avr_read_byte(pgm, p, m, 0, &value);
pgm->read_byte(pgm, p, m, 0, &value);
if (value == safemode_lfuse){
fusegood = 1; /* Fuse read OK three times */
}
@ -152,10 +152,10 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
m = avr_locate_mem(p, "hfuse");
if (m != NULL) {
fusegood = 0; /* By default fuse is a failure */
avr_read_byte(pgm, p, m, 0, &safemode_hfuse);
avr_read_byte(pgm, p, m, 0, &value);
pgm->read_byte(pgm, p, m, 0, &safemode_hfuse);
pgm->read_byte(pgm, p, m, 0, &value);
if (value == safemode_hfuse) {
avr_read_byte(pgm, p, m, 0, &value);
pgm->read_byte(pgm, p, m, 0, &value);
if (value == safemode_hfuse){
fusegood = 1; /* Fuse read OK three times */
}
@ -178,10 +178,10 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
m = avr_locate_mem(p, "efuse");
if (m != NULL) {
fusegood = 0; /* By default fuse is a failure */
avr_read_byte(pgm, p, m, 0, &safemode_efuse);
avr_read_byte(pgm, p, m, 0, &value);
pgm->read_byte(pgm, p, m, 0, &safemode_efuse);
pgm->read_byte(pgm, p, m, 0, &value);
if (value == safemode_efuse) {
avr_read_byte(pgm, p, m, 0, &value);
pgm->read_byte(pgm, p, m, 0, &value);
if (value == safemode_efuse){
fusegood = 1; /* Fuse read OK three times */
}

View File

@ -176,6 +176,14 @@ static int stk500_chip_erase(PROGRAMMER * pgm, AVRPART * p)
unsigned char cmd[4];
unsigned char res[4];
if (pgm->cmd == NULL) {
fprintf(stderr,
"%s: Error: %s programmer uses stk500_chip_erase() but does not\n"
"provide a cmd() method.\n",
progname, pgm->type);
return -1;
}
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
fprintf(stderr, "chip erase instruction not defined for part \"%s\"\n",
p->desc);
@ -1236,6 +1244,8 @@ void stk500_initpgm(PROGRAMMER * pgm)
pgm->cmd = stk500_cmd;
pgm->open = stk500_open;
pgm->close = stk500_close;
pgm->read_byte = avr_read_byte_default;
pgm->write_byte = avr_write_byte_default;
/*
* optional functions

View File

@ -643,16 +643,6 @@ static int stk500v2_cmd(PROGRAMMER * pgm, unsigned char cmd[4],
}
static int stk500hv_cmd(PROGRAMMER * pgm, unsigned char cmd[4],
unsigned char res[4])
{
fprintf(stderr, "%s: stk500hv_command(): no direct SPI supported for PP mode\n",
progname);
return -1;
}
/*
* issue the 'chip erase' command to the AVR device
*/
@ -2375,6 +2365,8 @@ void stk500v2_initpgm(PROGRAMMER * pgm)
pgm->cmd = stk500v2_cmd;
pgm->open = stk500v2_open;
pgm->close = stk500v2_close;
pgm->read_byte = avr_read_byte_default;
pgm->write_byte = avr_write_byte_default;
/*
* optional functions
@ -2403,15 +2395,14 @@ void stk500pp_initpgm(PROGRAMMER * pgm)
pgm->disable = stk500pp_disable;
pgm->program_enable = stk500pp_program_enable;
pgm->chip_erase = stk500pp_chip_erase;
pgm->cmd = stk500hv_cmd;
pgm->open = stk500v2_open;
pgm->close = stk500v2_close;
pgm->read_byte = stk500pp_read_byte;
pgm->write_byte = stk500pp_write_byte;
/*
* optional functions
*/
pgm->read_byte = stk500pp_read_byte;
pgm->write_byte = stk500pp_write_byte;
pgm->paged_write = stk500pp_paged_write;
pgm->paged_load = stk500pp_paged_load;
pgm->print_parms = stk500v2_print_parms;
@ -2435,15 +2426,14 @@ void stk500hvsp_initpgm(PROGRAMMER * pgm)
pgm->disable = stk500hvsp_disable;
pgm->program_enable = stk500hvsp_program_enable;
pgm->chip_erase = stk500hvsp_chip_erase;
pgm->cmd = stk500hv_cmd;
pgm->open = stk500v2_open;
pgm->close = stk500v2_close;
pgm->read_byte = stk500hvsp_read_byte;
pgm->write_byte = stk500hvsp_write_byte;
/*
* optional functions
*/
pgm->read_byte = stk500hvsp_read_byte;
pgm->write_byte = stk500hvsp_write_byte;
pgm->paged_write = stk500hvsp_paged_write;
pgm->paged_load = stk500hvsp_paged_load;
pgm->print_parms = stk500v2_print_parms;
@ -2470,6 +2460,8 @@ void stk500v2_jtagmkII_initpgm(PROGRAMMER * pgm)
pgm->cmd = stk500v2_cmd;
pgm->open = stk500v2_jtagmkII_open;
pgm->close = jtagmkII_close;
pgm->read_byte = avr_read_byte_default;
pgm->write_byte = avr_write_byte_default;
/*
* optional functions
@ -2498,6 +2490,8 @@ void stk500v2_dragon_isp_initpgm(PROGRAMMER * pgm)
pgm->cmd = stk500v2_cmd;
pgm->open = stk500v2_dragon_isp_open;
pgm->close = jtagmkII_close;
pgm->read_byte = avr_read_byte_default;
pgm->write_byte = avr_write_byte_default;
/*
* optional functions
@ -2522,15 +2516,14 @@ void stk500v2_dragon_pp_initpgm(PROGRAMMER * pgm)
pgm->disable = stk500pp_disable;
pgm->program_enable = stk500pp_program_enable;
pgm->chip_erase = stk500pp_chip_erase;
pgm->cmd = stk500hv_cmd;
pgm->open = stk500v2_dragon_hv_open;
pgm->close = jtagmkII_close;
pgm->read_byte = stk500pp_read_byte;
pgm->write_byte = stk500pp_write_byte;
/*
* optional functions
*/
pgm->read_byte = stk500pp_read_byte;
pgm->write_byte = stk500pp_write_byte;
pgm->paged_write = stk500pp_paged_write;
pgm->paged_load = stk500pp_paged_load;
pgm->print_parms = stk500v2_print_parms;
@ -2554,15 +2547,14 @@ void stk500v2_dragon_hvsp_initpgm(PROGRAMMER * pgm)
pgm->disable = stk500hvsp_disable;
pgm->program_enable = stk500hvsp_program_enable;
pgm->chip_erase = stk500hvsp_chip_erase;
pgm->cmd = stk500hv_cmd;
pgm->open = stk500v2_dragon_hv_open;
pgm->close = jtagmkII_close;
pgm->read_byte = stk500hvsp_read_byte;
pgm->write_byte = stk500hvsp_write_byte;
/*
* optional functions
*/
pgm->read_byte = stk500hvsp_read_byte;
pgm->write_byte = stk500hvsp_write_byte;
pgm->paged_write = stk500hvsp_paged_write;
pgm->paged_load = stk500hvsp_paged_load;
pgm->print_parms = stk500v2_print_parms;

11
term.c
View File

@ -292,7 +292,7 @@ int cmd_dump(PROGRAMMER * pgm, struct avrpart * p, int argc, char * argv[])
}
for (i=0; i<len; i++) {
rc = avr_read_byte(pgm, p, mem, addr+i, &buf[i]);
rc = pgm->read_byte(pgm, p, mem, addr+i, &buf[i]);
if (rc != 0) {
fprintf(stderr, "error reading %s address 0x%05lx of part %s\n",
mem->desc, addr+i, p->desc);
@ -399,7 +399,7 @@ int cmd_write(PROGRAMMER * pgm, struct avrpart * p, int argc, char * argv[])
werror = 1;
}
rc = avr_read_byte(pgm, p, mem, addr+i, &b);
rc = pgm->read_byte(pgm, p, mem, addr+i, &b);
if (b != buf[i]) {
fprintf(stderr,
"%s (write): error writing 0x%02x at 0x%05lx cell=0x%02x\n",
@ -427,6 +427,13 @@ int cmd_send(PROGRAMMER * pgm, struct avrpart * p, int argc, char * argv[])
int i;
int len;
if (pgm->cmd == NULL) {
fprintf(stderr,
"The %s programmer does not support direct ISP commands.\n",
pgm->type);
return -1;
}
if (argc != 5) {
fprintf(stderr, "Usage: send <byte1> <byte2> <byte3> <byte4>\n");
return -1;

View File

@ -411,6 +411,8 @@ void usbasp_initpgm(PROGRAMMER * pgm)
pgm->cmd = usbasp_cmd;
pgm->open = usbasp_open;
pgm->close = usbasp_close;
pgm->read_byte = avr_read_byte_default;
pgm->write_byte = avr_write_byte_default;
/*
* optional functions