Set pin number or pin list rather than adding them

Pin definitions in config_gram.y fail to clear existing pin
definitions when setting them for the second time, eg, through
inheritance, For example,

programmer parent "ft2232h"
    id                     = "tigard";
    reset                  = 5; # BD5 (GPIOL1)
;

would add pin 5 to the existing pin 3 for reset from the partent
programmer rather than overwriting the reset pin.

This commit clears any pre-existing pin definition first before
assigning the new pin number or pin list (for vcc or buff).
This commit is contained in:
Stefan Rueger 2023-01-02 23:57:53 +00:00
parent c44d0e9c73
commit 5eddc33864
No known key found for this signature in database
GPG Key ID: B0B4F1FD86B1EC55
1 changed files with 22 additions and 10 deletions

View File

@ -44,6 +44,7 @@ int yylex(void);
int yyerror(char * errmsg, ...); int yyerror(char * errmsg, ...);
int yywarning(char * errmsg, ...); int yywarning(char * errmsg, ...);
static int clear_pin(int pinfunc);
static int assign_pin(int pinfunc, TOKEN *v, int invert); static int assign_pin(int pinfunc, TOKEN *v, int invert);
static int assign_pin_list(int invert); static int assign_pin_list(int invert);
static int which_opcode(TOKEN * opcode); static int which_opcode(TOKEN * opcode);
@ -650,16 +651,16 @@ pin_list:
; ;
prog_parm_pins: prog_parm_pins:
K_VCC TKN_EQUAL {pin_name = PPI_AVR_VCC; } pin_list | K_VCC TKN_EQUAL {pin_name = PPI_AVR_VCC; clear_pin(pin_name); } pin_list |
K_BUFF TKN_EQUAL {pin_name = PPI_AVR_BUFF; } pin_list | K_BUFF TKN_EQUAL {pin_name = PPI_AVR_BUFF; clear_pin(pin_name); } pin_list |
K_RESET TKN_EQUAL {pin_name = PIN_AVR_RESET;} pin_number { free_token($1); } | K_RESET TKN_EQUAL {pin_name = PIN_AVR_RESET; clear_pin(pin_name);} pin_number { free_token($1); } |
K_SCK TKN_EQUAL {pin_name = PIN_AVR_SCK; } pin_number { free_token($1); } | K_SCK TKN_EQUAL {pin_name = PIN_AVR_SCK; clear_pin(pin_name); } pin_number { free_token($1); } |
K_SDO TKN_EQUAL {pin_name = PIN_AVR_SDO; } pin_number | K_SDO TKN_EQUAL {pin_name = PIN_AVR_SDO; clear_pin(pin_name); } pin_number |
K_SDI TKN_EQUAL {pin_name = PIN_AVR_SDI; } pin_number | K_SDI TKN_EQUAL {pin_name = PIN_AVR_SDI; clear_pin(pin_name); } pin_number |
K_ERRLED TKN_EQUAL {pin_name = PIN_LED_ERR; } pin_number | K_ERRLED TKN_EQUAL {pin_name = PIN_LED_ERR; clear_pin(pin_name); } pin_number |
K_RDYLED TKN_EQUAL {pin_name = PIN_LED_RDY; } pin_number | K_RDYLED TKN_EQUAL {pin_name = PIN_LED_RDY; clear_pin(pin_name); } pin_number |
K_PGMLED TKN_EQUAL {pin_name = PIN_LED_PGM; } pin_number | K_PGMLED TKN_EQUAL {pin_name = PIN_LED_PGM; clear_pin(pin_name); } pin_number |
K_VFYLED TKN_EQUAL {pin_name = PIN_LED_VFY; } pin_number K_VFYLED TKN_EQUAL {pin_name = PIN_LED_VFY; clear_pin(pin_name); } pin_number
; ;
opcode : opcode :
@ -1545,6 +1546,17 @@ static char * vtypestr(int type)
#endif #endif
static int clear_pin(int pinfunc) {
if(pinfunc < 0 || pinfunc >= N_PINS) {
yyerror("pin function must be in the range [0, %d]", N_PINS-1);
return -1;
}
pin_clear_all(&(current_prog->pin[pinfunc]));
return 0;
}
static int assign_pin(int pinfunc, TOKEN *v, int invert) { static int assign_pin(int pinfunc, TOKEN *v, int invert) {
if(pinfunc < 0 || pinfunc >= N_PINS) { if(pinfunc < 0 || pinfunc >= N_PINS) {
yyerror("pin function must be in the range [0, %d]", N_PINS-1); yyerror("pin function must be in the range [0, %d]", N_PINS-1);