From 3f3ba207dae534745bcd671c074855f47f19af82 Mon Sep 17 00:00:00 2001 From: hweisbach Date: Tue, 7 May 2013 08:50:13 +0000 Subject: [PATCH] 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 --- ChangeLog | 2 ++ avrftdi.c | 41 ++++++++++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2a42403b..0b9db848 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ * 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() 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 diff --git a/avrftdi.c b/avrftdi.c index 5f5ac131..ddb7b11e 100644 --- a/avrftdi.c +++ b/avrftdi.c @@ -239,8 +239,8 @@ static int set_pin(PROGRAMMER * pgm, int pinfunc, int value) 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) { @@ -262,6 +262,26 @@ static int set_led_vfy(struct programmer_t * pgm, int 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 * buffer 'data'. * Write is only performed when mode contains MPSSE_DO_WRITE. @@ -638,7 +658,7 @@ static int avrftdi_open(PROGRAMMER * pgm, char *port) pdata->rx_buffer_size = pdata->ftdic->max_packet_size; break; } - + if(avrftdi_pin_setup(pgm)) return -1; @@ -657,7 +677,6 @@ static void avrftdi_close(PROGRAMMER * pgm) avrftdi_t* pdata = to_pdata(pgm); if(pdata->ftdic->usb_dev) { - set_pin(pgm, PPI_AVR_BUFF, ON); set_pin(pgm, PIN_AVR_RESET, ON); /* Stop driving the pins - except for the LEDs */ @@ -687,7 +706,6 @@ static int avrftdi_initialize(PROGRAMMER * pgm, AVRPART * p) else { set_pin(pgm, PIN_AVR_RESET, OFF); - set_pin(pgm, PPI_AVR_BUFF, OFF); set_pin(pgm, PIN_AVR_SCK, OFF); /*use speed optimization with CAUTION*/ usleep(20 * 1000); @@ -706,18 +724,9 @@ static int avrftdi_initialize(PROGRAMMER * pgm, AVRPART * 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) { + // print the full pin definitiions as in ft245r ? return; } @@ -1125,6 +1134,8 @@ void avrftdi_initpgm(PROGRAMMER * pgm) pgm->display = avrftdi_display; pgm->enable = avrftdi_enable; pgm->disable = avrftdi_disable; + pgm->powerup = avrftdi_powerup; + pgm->powerdown = avrftdi_powerdown; pgm->program_enable = avrftdi_program_enable; pgm->chip_erase = avrftdi_chip_erase; pgm->cmd = avrftdi_cmd;