2003-03-23 Theodore A. Roth * avr.c: Add avr_read_byte_default(). Have avr_read_byte() call pgm->read_byte() or avr_read_byte_default(). Add avr_write_byte_default(). Have avr_write_byte() call pgm->write_byte or avr_write_byte_default(). * pgm.c: Initialize pgm->write_byte and pgm->read_byte. * pgm.h: Add write_byte and read_byte fields to struct programmer_t. Index: avr.c =================================================================== RCS file: /cvsroot/avrdude/avrdude/avr.c,v retrieving revision 1.53 diff -u -r1.53 avr.c --- avr.c 17 Mar 2003 06:20:01 -0000 1.53 +++ avr.c 23 Mar 2003 23:16:14 -0000 @@ -287,11 +287,8 @@ } -/* - * 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 avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char * value) { unsigned char cmd[4]; unsigned char res[4]; @@ -341,6 +338,21 @@ /* + * 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) +{ + if (pgm->read_byte) { + return pgm->read_byte(pgm, p, mem, addr, value); + } + else { + return avr_read_byte_default(pgm, p, mem, addr, value); + } +} + + +/* * Read the entirety of the specified memory type into the * corresponding buffer of the avrpart pointed to by 'p'. If size = * 0, read the entire contents, otherwise, read 'size' bytes. @@ -465,10 +477,7 @@ } -/* - * write a byte of data at the specified address - */ -int avr_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, +int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, unsigned long addr, unsigned char data) { unsigned char cmd[4]; @@ -650,6 +659,21 @@ pgm->pgm_led(pgm, OFF); return 0; +} + + +/* + * write a byte of data at the specified address + */ +int avr_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char data) +{ + if (pgm->write_byte) { + return pgm->write_byte(pgm, p, mem, addr, data); + } + else { + return avr_write_byte_default(pgm, p, mem, addr, data); + } } Index: pgm.c =================================================================== RCS file: /cvsroot/avrdude/avrdude/pgm.c,v retrieving revision 1.11 diff -u -r1.11 pgm.c --- pgm.c 17 Mar 2003 06:20:01 -0000 1.11 +++ pgm.c 23 Mar 2003 23:16:14 -0000 @@ -89,6 +89,8 @@ */ pgm->paged_write = NULL; pgm->paged_load = NULL; + pgm->write_byte = NULL; + pgm->read_byte = NULL; pgm->read_sig_bytes = NULL; return pgm; Index: pgm.h =================================================================== RCS file: /cvsroot/avrdude/avrdude/pgm.h,v retrieving revision 1.11 diff -u -r1.11 pgm.h --- pgm.h 17 Mar 2003 06:20:02 -0000 1.11 +++ pgm.h 23 Mar 2003 23:16:14 -0000 @@ -66,6 +66,10 @@ int page_size, int n_bytes); int (*paged_load) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m, int page_size, int n_bytes); + 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); int (*read_sig_bytes) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m); char config_file[PATH_MAX]; /* config file where defined */ int lineno; /* config file line number */