Move the bitbang prerequisite checks out from

main() into their own bitbang_check_prerequisites().


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@626 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch 2006-08-23 21:06:28 +00:00
parent 432b1fbc5e
commit 840af6b242
7 changed files with 38 additions and 19 deletions

View File

@ -1,3 +1,13 @@
2006-08-22 Joerg Wunsch <j@uriah.heep.sax.de>
* bitbang.c: Move the bitbang prerequisite checks out from
main() into their own bitbang_check_prerequisites().
* bitbang.h: (Ditto.)
* main.c: (Ditto.)
* par.c: (Ditto.)
* serbb_posix.c: (Ditto.)
* serbb_win32.c: (Ditto.)
2006-08-22 Joerg Wunsch <j@uriah.heep.sax.de>
* avrdude.conf.in: Add page mode parameters for all "eeprom"

View File

@ -335,4 +335,24 @@ int bitbang_initialize(PROGRAMMER * pgm, AVRPART * p)
return 0;
}
static void verify_pin_assigned(PROGRAMMER * pgm, int pin, char * desc)
{
if (pgm->pinno[pin] == 0) {
fprintf(stderr, "%s: error: no pin has been assigned for %s\n",
progname, desc);
exit(1);
}
}
/*
* Verify all prerequisites for a bit-bang programmer are present.
*/
void bitbang_check_prerequisites(PROGRAMMER *pgm)
{
verify_pin_assigned(pgm, PIN_AVR_RESET, "AVR RESET");
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");
}

View File

@ -27,6 +27,8 @@ int bitbang_getpin(int fd, int pin);
int bitbang_highpulsepin(int fd, int pin);
void bitbang_delay(unsigned int us);
void bitbang_check_prerequisites(PROGRAMMER *pgm);
int bitbang_rdy_led (PROGRAMMER * pgm, int value);
int bitbang_err_led (PROGRAMMER * pgm, int value);
int bitbang_pgm_led (PROGRAMMER * pgm, int value);

19
main.c
View File

@ -165,17 +165,6 @@ void programmer_display(char * p)
void verify_pin_assigned(int pin, char * desc)
{
if (pgm->pinno[pin] == 0) {
fprintf(stderr, "%s: error: no pin has been assigned for %s\n",
progname, desc);
exit(1);
}
}
PROGRAMMER * locate_programmer(LISTID programmers, char * configid)
{
LNODEID ln1, ln2;
@ -1097,7 +1086,6 @@ int main(int argc, char * argv [])
}
}
/*
* set up seperate instances of the avr part, one for use in
* programming, one for use in verifying. These are separate
@ -1106,13 +1094,6 @@ int main(int argc, char * argv [])
p = avr_dup_part(p);
v = avr_dup_part(p);
if (strcmp(pgm->type, "PPI") == 0) {
verify_pin_assigned(PIN_AVR_RESET, "AVR RESET");
verify_pin_assigned(PIN_AVR_SCK, "AVR SCK");
verify_pin_assigned(PIN_AVR_MISO, "AVR MISO");
verify_pin_assigned(PIN_AVR_MOSI, "AVR MOSI");
}
/*
* open the programmer
*/

2
par.c
View File

@ -254,6 +254,8 @@ static int par_open(PROGRAMMER * pgm, char * port)
{
int rc;
bitbang_check_prerequisites(pgm);
pgm->fd = ppi_open(port);
if (pgm->fd < 0) {
fprintf(stderr, "%s: failed to open parallel port \"%s\"\n\n",

View File

@ -200,6 +200,8 @@ static int serbb_open(PROGRAMMER *pgm, char *port)
struct termios mode;
int flags;
bitbang_check_prerequisites(pgm);
/* adapted from uisp code */
pgm->fd = open(port, O_RDWR | O_NOCTTY | O_NONBLOCK);

View File

@ -272,6 +272,8 @@ static int serbb_open(PROGRAMMER *pgm, char *port)
LPVOID lpMsgBuf;
HANDLE hComPort = INVALID_HANDLE_VALUE;
bitbang_check_prerequisites(pgm);
hComPort = CreateFile(port, GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);