* avr.c (avr_read_byte): If pgm->read_byte method fails, retry with

avr_read_byte_default.
* avr.c (avr_write_byte): If pgm->write_byte method fails, retry with
avr_write_byte_default.
* avr910.c (avr910_cmd): Implement using universal command.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@364 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
troth 2003-09-05 16:40:55 +00:00
parent 10a26677f8
commit 3827320f15
3 changed files with 43 additions and 12 deletions

View File

@ -1,3 +1,12 @@
2003-09-05 Theodore A. Roth <troth@openavr.org>
[Contributed by Jan-Hinnerk Reichert <jan-hinnerk_reichert@hamburg.de>]
* avr.c (avr_read_byte): If pgm->read_byte method fails, retry with
avr_read_byte_default.
* avr.c (avr_write_byte): If pgm->write_byte method fails, retry with
avr_write_byte_default.
* avr910.c (avr910_cmd): Implement using universal command.
2003-09-04 Theodore A. Roth <troth@openavr.org> 2003-09-04 Theodore A. Roth <troth@openavr.org>
* Makefile.am: Change AM_CPPFLAGS to avrdude_CPPFLAGS. * Makefile.am: Change AM_CPPFLAGS to avrdude_CPPFLAGS.

22
avr.c
View File

@ -343,13 +343,18 @@ int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
int avr_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, int avr_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
unsigned long addr, unsigned char * value) unsigned long addr, unsigned char * value)
{ {
int rc;
if (pgm->read_byte) { if (pgm->read_byte) {
return pgm->read_byte(pgm, p, mem, addr, value); rc = pgm->read_byte(pgm, p, mem, addr, value);
if (rc == 0) {
return rc;
} }
else { /* read_byte() method failed, try again with default. */
}
return avr_read_byte_default(pgm, p, mem, addr, value); return avr_read_byte_default(pgm, p, mem, addr, value);
} }
}
/* /*
@ -699,13 +704,18 @@ int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
int avr_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, int avr_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
unsigned long addr, unsigned char data) unsigned long addr, unsigned char data)
{ {
int rc;
if (pgm->write_byte) { if (pgm->write_byte) {
return pgm->write_byte(pgm, p, mem, addr, data); rc = pgm->write_byte(pgm, p, mem, addr, data);
if (rc == 0) {
return rc;
} }
else { /* write_byte() method failed, try again with default. */
}
return avr_write_byte_default(pgm, p, mem, addr, data); return avr_write_byte_default(pgm, p, mem, addr, data);
} }
}
/* /*

View File

@ -324,13 +324,25 @@ static void avr910_enable(PROGRAMMER * pgm)
static int avr910_cmd(PROGRAMMER * pgm, unsigned char cmd[4], static int avr910_cmd(PROGRAMMER * pgm, unsigned char cmd[4],
unsigned char res[4]) unsigned char res[4])
{ {
int i; unsigned char buf[5];
no_show_func_info(); no_show_func_info();
for (i=0; i<4; i++) { /* FIXME: Insert version check here */
fprintf(stderr, "cmd[%d] = 0x%02x\n", i, cmd[i]);
} buf[0] = '.'; /* New Universal Command */
buf[1] = cmd[0];
buf[2] = cmd[1];
buf[3] = cmd[2];
buf[4] = cmd[3];
avr910_send (pgm, buf, 5);
avr910_recv (pgm, buf, 2);
res[0] = 0x00; /* Dummy value */
res[1] = cmd[0];
res[2] = cmd[1];
res[3] = buf[0];
return 0; return 0;
} }