avrftdi: add pgm->power[up|down], fix pgm->enable|disable

avrftdi.c: add pgm->power[up|down] functions and fill
pgm->enable|disable with proper functionality, as suggested by
rliebscher.

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1171 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
hweisbach 2013-05-07 08:50:13 +00:00
parent eee1ae3973
commit 3f3ba207da
2 changed files with 28 additions and 15 deletions

View File

@ -3,6 +3,8 @@
* avrftdi_private.h: Change size of pin_checklist to N_PINS (from N_PINS-1) * avrftdi_private.h: Change size of pin_checklist to N_PINS (from N_PINS-1)
* avrftdi.c: Adapt code to new size of pin_checklist. Remove pins_check() * avrftdi.c: Adapt code to new size of pin_checklist. Remove pins_check()
from set_pin(). from set_pin().
Add pgm->power[up|down] functions as well as fill pgm->enable|disable with
proper content as suggested by Rene Liebscher.
2013-05-05 Rene Liebscher <R.Liebscher@gmx.de> 2013-05-05 Rene Liebscher <R.Liebscher@gmx.de>

View File

@ -239,8 +239,8 @@ static int set_pin(PROGRAMMER * pgm, int pinfunc, int value)
return write_flush(pdata); return write_flush(pdata);
} }
/* these functions are callbacks, which go into the /*
* PROGRAMMER data structure ("optional functions") * Mandatory callbacks which boil down to GPIO.
*/ */
static int set_led_pgm(struct programmer_t * pgm, int value) static int set_led_pgm(struct programmer_t * pgm, int value)
{ {
@ -262,6 +262,26 @@ static int set_led_vfy(struct programmer_t * pgm, int value)
return set_pin(pgm, PIN_LED_VFY, value); return set_pin(pgm, PIN_LED_VFY, value);
} }
static void avrftdi_enable(PROGRAMMER * pgm)
{
set_pin(pgm, PPI_AVR_BUFF, ON);
}
static void avrftdi_disable(PROGRAMMER * pgm)
{
set_pin(pgm, PPI_AVR_BUFF, OFF);
}
static void avrftdi_powerup(PROGRAMMER * pgm)
{
set_pin(pgm, PPI_AVR_VCC, ON);
}
static void avrftdi_powerdown(PROGRAMMER * pgm)
{
set_pin(pgm, PPI_AVR_VCC, OFF);
}
/* Send 'buf_size' bytes from 'cmd' to device and return data from device in /* Send 'buf_size' bytes from 'cmd' to device and return data from device in
* buffer 'data'. * buffer 'data'.
* Write is only performed when mode contains MPSSE_DO_WRITE. * Write is only performed when mode contains MPSSE_DO_WRITE.
@ -657,7 +677,6 @@ static void avrftdi_close(PROGRAMMER * pgm)
avrftdi_t* pdata = to_pdata(pgm); avrftdi_t* pdata = to_pdata(pgm);
if(pdata->ftdic->usb_dev) { if(pdata->ftdic->usb_dev) {
set_pin(pgm, PPI_AVR_BUFF, ON);
set_pin(pgm, PIN_AVR_RESET, ON); set_pin(pgm, PIN_AVR_RESET, ON);
/* Stop driving the pins - except for the LEDs */ /* Stop driving the pins - except for the LEDs */
@ -687,7 +706,6 @@ static int avrftdi_initialize(PROGRAMMER * pgm, AVRPART * p)
else else
{ {
set_pin(pgm, PIN_AVR_RESET, OFF); set_pin(pgm, PIN_AVR_RESET, OFF);
set_pin(pgm, PPI_AVR_BUFF, OFF);
set_pin(pgm, PIN_AVR_SCK, OFF); set_pin(pgm, PIN_AVR_SCK, OFF);
/*use speed optimization with CAUTION*/ /*use speed optimization with CAUTION*/
usleep(20 * 1000); usleep(20 * 1000);
@ -706,18 +724,9 @@ static int avrftdi_initialize(PROGRAMMER * pgm, AVRPART * p)
return pgm->program_enable(pgm, p); return pgm->program_enable(pgm, p);
} }
static void avrftdi_disable(PROGRAMMER * pgm)
{
return;
}
static void avrftdi_enable(PROGRAMMER * pgm)
{
return;
}
static void avrftdi_display(PROGRAMMER * pgm, const char *p) static void avrftdi_display(PROGRAMMER * pgm, const char *p)
{ {
// print the full pin definitiions as in ft245r ?
return; return;
} }
@ -1125,6 +1134,8 @@ void avrftdi_initpgm(PROGRAMMER * pgm)
pgm->display = avrftdi_display; pgm->display = avrftdi_display;
pgm->enable = avrftdi_enable; pgm->enable = avrftdi_enable;
pgm->disable = avrftdi_disable; pgm->disable = avrftdi_disable;
pgm->powerup = avrftdi_powerup;
pgm->powerdown = avrftdi_powerdown;
pgm->program_enable = avrftdi_program_enable; pgm->program_enable = avrftdi_program_enable;
pgm->chip_erase = avrftdi_chip_erase; pgm->chip_erase = avrftdi_chip_erase;
pgm->cmd = avrftdi_cmd; pgm->cmd = avrftdi_cmd;