avrftdi: apply patch by rliebscher.

Use pin_checklist[] of size N_PINS instead N_PINS - 1, to avoid future
problems. Also remove pins_check from set_pin; instead use mask[0] == 0
to check wether to do something or not.

avrftdi_private.h: Change size of pin_checklist[] to N_PINS.
avrftdi.c: Adapt code to new size of pin_checklist. Remove pins_check
from set_pin.

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1170 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Hannes Weisbach 2013-05-07 08:50:06 +00:00
parent 4fc72c7d58
commit 26ab40f3a5
3 changed files with 23 additions and 23 deletions

View File

@ -1,3 +1,9 @@
2013-05-07 Hannes Weisbach <hannes_weisbach@gmx.net>
* 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().
2013-05-05 Rene Liebscher <R.Liebscher@gmx.de> 2013-05-05 Rene Liebscher <R.Liebscher@gmx.de>
* pindefs.h: use unsigned int if stdint.h is not available and UINT_MAX is 0xffffffff * pindefs.h: use unsigned int if stdint.h is not available and UINT_MAX is 0xffffffff

View File

@ -224,14 +224,9 @@ static int set_pin(PROGRAMMER * pgm, int pinfunc, int value)
avrftdi_t* pdata = to_pdata(pgm); avrftdi_t* pdata = to_pdata(pgm);
struct pindef_t pin = pgm->pin[pinfunc]; struct pindef_t pin = pgm->pin[pinfunc];
if (pins_check(pgm, pdata->pin_checklist, N_PINS - 1)) { if (pin.mask[0] == 0) {
/* this error message is really annoying, maybe use a ratelimit? */ // ignore not defined pins (might be the led or vcc or buff if not needed)
/* return 0;
avrftdi_print(2, "%s info: Pin is zero, value: %d!\n",
progname, value);
*/
return -1;
} }
log_debug("Setting pin %s (%s) as %s: %s (%s active)\n", log_debug("Setting pin %s (%s) as %s: %s (%s active)\n",
@ -476,22 +471,21 @@ static int avrftdi_pin_setup(PROGRAMMER * pgm)
valid_pins_others.inverse[0] = valid_mask ; valid_pins_others.inverse[0] = valid_mask ;
/* build pin checklist */ /* build pin checklist */
for(pin = PPI_AVR_VCC; pin < N_PINS; ++pin) { for(pin = 0; pin < N_PINS; ++pin) {
/* unfortunately, the pin name enum is one-based */ pdata->pin_checklist[pin].pinname = pin;
pdata->pin_checklist[pin - 1].pinname = pin; pdata->pin_checklist[pin].mandatory = 0;
pdata->pin_checklist[pin - 1].mandatory = 0; pdata->pin_checklist[pin].valid_pins = &valid_pins_others;
pdata->pin_checklist[pin - 1].valid_pins = &valid_pins_others;
} }
pdata->pin_checklist[PIN_AVR_SCK - 1].mandatory = 1; pdata->pin_checklist[PIN_AVR_SCK].mandatory = 1;
pdata->pin_checklist[PIN_AVR_SCK - 1].valid_pins = &valid_pins_SCK; pdata->pin_checklist[PIN_AVR_SCK].valid_pins = &valid_pins_SCK;
pdata->pin_checklist[PIN_AVR_MOSI - 1].mandatory = 1; pdata->pin_checklist[PIN_AVR_MOSI].mandatory = 1;
pdata->pin_checklist[PIN_AVR_MOSI - 1].valid_pins = &valid_pins_MOSI; pdata->pin_checklist[PIN_AVR_MOSI].valid_pins = &valid_pins_MOSI;
pdata->pin_checklist[PIN_AVR_MISO - 1].mandatory = 1; pdata->pin_checklist[PIN_AVR_MISO].mandatory = 1;
pdata->pin_checklist[PIN_AVR_MISO - 1].valid_pins = &valid_pins_MISO; pdata->pin_checklist[PIN_AVR_MISO].valid_pins = &valid_pins_MISO;
pdata->pin_checklist[PIN_AVR_RESET].mandatory = 1;
/* everything is an output, except MISO */ /* everything is an output, except MISO */
for(pin = PPI_AVR_VCC; pin < N_PINS; ++pin) { for(pin = 0; pin < N_PINS; ++pin) {
pdata->pin_direction |= pgm->pin[pin].mask[0]; pdata->pin_direction |= pgm->pin[pin].mask[0];
pdata->pin_value = SET_BITS_0(pdata->pin_value, pgm, pin, OFF); pdata->pin_value = SET_BITS_0(pdata->pin_value, pgm, pin, OFF);
} }
@ -502,7 +496,7 @@ static int avrftdi_pin_setup(PROGRAMMER * pgm)
} }
/* assumes all checklists above have same number of entries */ /* assumes all checklists above have same number of entries */
if (pins_check(pgm, pdata->pin_checklist,N_PINS - 1)) { if (pins_check(pgm, pdata->pin_checklist,N_PINS)) {
log_err("Pin configuration for FTDI MPSSE must be:\n"); log_err("Pin configuration for FTDI MPSSE must be:\n");
log_err("%s: 0, %s: 1, %s: 2 (is: %s, %s, %s)\n", avr_pin_name(PIN_AVR_SCK), log_err("%s: 0, %s: 1, %s: 2 (is: %s, %s, %s)\n", avr_pin_name(PIN_AVR_SCK),
avr_pin_name(PIN_AVR_MOSI), avr_pin_name(PIN_AVR_MISO), avr_pin_name(PIN_AVR_MOSI), avr_pin_name(PIN_AVR_MISO),

View File

@ -66,7 +66,7 @@ typedef struct avrftdi_s {
/* internal RX buffer of the device. needed for INOUT transfers */ /* internal RX buffer of the device. needed for INOUT transfers */
int rx_buffer_size; int rx_buffer_size;
/* pin checklist. */ /* pin checklist. */
struct pin_checklist_t pin_checklist[N_PINS - 1]; struct pin_checklist_t pin_checklist[N_PINS];
} avrftdi_t; } avrftdi_t;
void avrftdi_log(int level, const char * func, int line, const char * fmt, ...); void avrftdi_log(int level, const char * func, int line, const char * fmt, ...);