* 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.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@296 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Theodore A. Roth
2003-03-23 23:22:50 +00:00
parent 0c1039d8b3
commit 4165644dd9
4 changed files with 48 additions and 9 deletions

42
avr.c
View File

@@ -287,11 +287,8 @@ int avr_get_output(OPCODE * op, unsigned char * res, unsigned char * data)
}
/*
* 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];
@@ -340,6 +337,21 @@ int avr_read_byte(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)
{
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 =
@@ -465,10 +477,7 @@ int avr_write_page(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
}
/*
* 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];
@@ -653,6 +662,21 @@ int avr_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
}
/*
* 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);
}
}
/*
* Write the whole memory region of the specified memory from the
* corresponding buffer of the avrpart pointed to by 'p'. Write up to