Makefile : update dependencies

avr.c : correct status led updates

term.c : update status leds on write, make the address and length
         arguments for dump optional.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@58 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Brian S. Dean 2001-02-08 01:05:05 +00:00
parent aed00dfd26
commit fe0f2dca65
3 changed files with 45 additions and 15 deletions

View File

@ -34,7 +34,7 @@ main.o : avr.h fileio.h ppi.h term.h pindefs.h
avr.o : avr.h ppi.h pindefs.h
fileio.o : fileio.h avr.h
ppi.o : ppi.h
term.o : term.h avr.h
term.o : term.h avr.h pindefs.h ppi.h
clean :
rm -f *~ *.core ${TARGET} *.o

14
avr.c
View File

@ -175,6 +175,7 @@ unsigned char avr_read_byte ( int fd, struct avrpart * p,
static unsigned char cmdbyte[3] = { 0xa0, 0x20, 0x28 };
LED_ON(fd, PIN_LED_PGM);
LED_OFF(fd, PIN_LED_ERR);
offset = 0;
@ -251,6 +252,7 @@ int avr_write_byte ( int fd, struct avrpart * p, AVRMEM memtype,
}
LED_ON(fd, PIN_LED_PGM);
LED_OFF(fd, PIN_LED_ERR);
offset = 0;
@ -294,6 +296,7 @@ int avr_write_byte ( int fd, struct avrpart * p, AVRMEM memtype,
* returning an error code
*/
LED_OFF(fd, PIN_LED_PGM);
LED_ON(fd, PIN_LED_ERR);
return -1;
}
}
@ -319,9 +322,12 @@ int avr_write ( int fd, struct avrpart * p, AVRMEM memtype, int size )
unsigned char * buf;
unsigned short i;
unsigned char data;
int werror;
LED_OFF(fd, PIN_LED_ERR);
werror = 0;
buf = p->mem[memtype];
wsize = p->memsize[memtype];
if (size < wsize) {
@ -344,6 +350,14 @@ int avr_write ( int fd, struct avrpart * p, AVRMEM memtype, int size )
fprintf(stderr, " ***failed; ");
fprintf(stderr, "\n");
LED_ON(fd, PIN_LED_ERR);
werror = 1;
}
if (werror) {
/*
* make sure the error led stay on if there was a previous write
* error, otherwise it gets cleared in avr_write_byte()
*/
LED_ON(fd, PIN_LED_ERR);
}
}

22
term.c
View File

@ -37,6 +37,8 @@
#include <readline/history.h>
#include "avr.h"
#include "pindefs.h"
#include "ppi.h"
extern char * progname;
@ -69,6 +71,7 @@ int cmd_quit (int fd, struct avrpart * p, int argc, char *argv[]);
struct command cmd[] = {
{ "dump", cmd_dump, "dump memory : %s [eeprom|flash] <addr> <N-Bytes>" },
{ "read", cmd_dump, "alias for dump" },
{ "write", cmd_write, "write memory : %s [eeprom|flash] <addr> <b1> <b2> ... <bN>" },
{ "erase", cmd_erase, "perform a chip erase" },
{ "sig", cmd_sig, "display device signature bytes" },
@ -209,8 +212,8 @@ int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] )
addr += len;
}
else {
if (argc != 4) {
fprintf(stderr, "Usage: dump flash|eeprom <addr> <len>\n");
if (!((argc == 2) || (argc == 4))) {
fprintf(stderr, "Usage: dump flash|eeprom [<addr> <len>]\n");
return -1;
}
@ -227,6 +230,7 @@ int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] )
return -1;
}
if (argc == 4) {
addr = strtoul(argv[2], &e, 0);
if (*e || (e == argv[2])) {
fprintf(stderr, "%s (dump): can't parse address \"%s\"\n",
@ -241,9 +245,15 @@ int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] )
return -1;
}
}
}
maxsize = p->memsize[memtype];
if (argc == 2) {
addr = 0;
len = maxsize;
}
if (addr > maxsize) {
fprintf(stderr,
"%s (dump): address 0x%04x is out of range for %s memory\n",
@ -282,6 +292,7 @@ int cmd_write ( int fd, struct avrpart * p, int argc, char * argv[] )
unsigned short addr;
char * buf;
int rc;
int werror;
if (argc < 4) {
fprintf(stderr,
@ -344,11 +355,16 @@ int cmd_write ( int fd, struct avrpart * p, int argc, char * argv[] )
}
}
for (i=0; i<len; i++) {
LED_OFF(fd, PIN_LED_ERR);
for (werror=0, i=0; i<len; i++) {
rc = avr_write_byte(fd, p, memtype, addr+i, buf[i]);
if (rc) {
fprintf(stderr, "%s (write): error writing 0x%02x at 0x%04x\n",
progname, buf[i], addr+i);
werror = 1;
}
if (werror) {
LED_ON(fd, PIN_LED_ERR);
}
}