Merge pull request #933 from MCUdude/linuxspi-default-port-fix

Fix linuxspi default port
This commit is contained in:
Stefan Rueger 2022-07-18 14:25:52 +01:00 committed by GitHub
commit 1d3a7591ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 3 deletions

View File

@ -22,7 +22,7 @@
# desc = <description> ; # quoted string # desc = <description> ; # quoted string
# type = <type>; # programmer type, quoted string # type = <type>; # programmer type, quoted string
# # supported programmer types can be listed by "-c ?type" # # supported programmer types can be listed by "-c ?type"
# connection_type = parallel | serial | usb # connection_type = parallel | serial | usb | spi
# baudrate = <num> ; # baudrate for avr910-programmer # baudrate = <num> ; # baudrate for avr910-programmer
# vcc = <num1> [, <num2> ... ] ; # pin number(s) # vcc = <num1> [, <num2> ... ] ; # pin number(s)
# buff = <num1> [, <num2> ... ] ; # pin number(s) # buff = <num1> [, <num2> ... ] ; # pin number(s)
@ -337,6 +337,7 @@
# #
default_parallel = "@DEFAULT_PAR_PORT@"; default_parallel = "@DEFAULT_PAR_PORT@";
default_serial = "@DEFAULT_SER_PORT@"; default_serial = "@DEFAULT_SER_PORT@";
default_spi = "@DEFAULT_SPI_PORT@";
# default_bitclock = 2.5; # default_bitclock = 2.5;
# #
@ -1642,6 +1643,7 @@ programmer
id = "linuxspi"; id = "linuxspi";
desc = "Use Linux SPI device in /dev/spidev*"; desc = "Use Linux SPI device in /dev/spidev*";
type = "linuxspi"; type = "linuxspi";
connection_type = spi;
reset = 25; # Pi GPIO number - this is J8:22 reset = 25; # Pi GPIO number - this is J8:22
; ;
@HAVE_LINUXSPI_END@ @HAVE_LINUXSPI_END@

View File

@ -35,6 +35,7 @@
char default_programmer[MAX_STR_CONST]; char default_programmer[MAX_STR_CONST];
char default_parallel[PATH_MAX]; char default_parallel[PATH_MAX];
char default_serial[PATH_MAX]; char default_serial[PATH_MAX];
char default_spi[PATH_MAX];
double default_bitclock; double default_bitclock;
char string_buf[MAX_STR_CONST]; char string_buf[MAX_STR_CONST];

View File

@ -79,6 +79,7 @@ static int pin_name;
%token K_DEFAULT_PARALLEL %token K_DEFAULT_PARALLEL
%token K_DEFAULT_PROGRAMMER %token K_DEFAULT_PROGRAMMER
%token K_DEFAULT_SERIAL %token K_DEFAULT_SERIAL
%token K_DEFAULT_SPI
%token K_DESC %token K_DESC
%token K_FAMILY_ID %token K_FAMILY_ID
%token K_DEVICECODE %token K_DEVICECODE
@ -115,6 +116,7 @@ static int pin_name;
%token K_RESET %token K_RESET
%token K_RETRY_PULSE %token K_RETRY_PULSE
%token K_SERIAL %token K_SERIAL
%token K_SPI
%token K_SCK %token K_SCK
%token K_SIGNATURE %token K_SIGNATURE
%token K_SIZE %token K_SIZE
@ -254,6 +256,12 @@ def :
free_token($3); free_token($3);
} | } |
K_DEFAULT_SPI TKN_EQUAL TKN_STRING TKN_SEMI {
strncpy(default_spi, $3->value.string, PATH_MAX);
default_spi[PATH_MAX-1] = 0;
free_token($3);
} |
K_DEFAULT_BITCLOCK TKN_EQUAL number_real TKN_SEMI { K_DEFAULT_BITCLOCK TKN_EQUAL number_real TKN_SEMI {
default_bitclock = $3->value.number_real; default_bitclock = $3->value.number_real;
free_token($3); free_token($3);
@ -507,7 +515,8 @@ prog_parm_conntype:
prog_parm_conntype_id: prog_parm_conntype_id:
K_PARALLEL { current_prog->conntype = CONNTYPE_PARALLEL; } | K_PARALLEL { current_prog->conntype = CONNTYPE_PARALLEL; } |
K_SERIAL { current_prog->conntype = CONNTYPE_SERIAL; } | K_SERIAL { current_prog->conntype = CONNTYPE_SERIAL; } |
K_USB { current_prog->conntype = CONNTYPE_USB; } K_USB { current_prog->conntype = CONNTYPE_USB; } |
K_SPI { current_prog->conntype = CONNTYPE_SPI; }
; ;
prog_parm_usb: prog_parm_usb:

View File

@ -139,6 +139,7 @@ default_bitclock { yylval=NULL; return K_DEFAULT_BITCLOCK; }
default_parallel { yylval=NULL; return K_DEFAULT_PARALLEL; } default_parallel { yylval=NULL; return K_DEFAULT_PARALLEL; }
default_programmer { yylval=NULL; return K_DEFAULT_PROGRAMMER; } default_programmer { yylval=NULL; return K_DEFAULT_PROGRAMMER; }
default_serial { yylval=NULL; return K_DEFAULT_SERIAL; } default_serial { yylval=NULL; return K_DEFAULT_SERIAL; }
default_spi { yylval=NULL; return K_DEFAULT_SPI; }
delay { yylval=NULL; return K_DELAY; } delay { yylval=NULL; return K_DELAY; }
desc { yylval=NULL; return K_DESC; } desc { yylval=NULL; return K_DESC; }
family_id { yylval=NULL; return K_FAMILY_ID; } family_id { yylval=NULL; return K_FAMILY_ID; }
@ -222,6 +223,7 @@ sck { yylval=new_token(K_SCK); return K_SCK; }
serial { yylval=NULL; return K_SERIAL; } serial { yylval=NULL; return K_SERIAL; }
signature { yylval=NULL; return K_SIGNATURE; } signature { yylval=NULL; return K_SIGNATURE; }
size { yylval=NULL; return K_SIZE; } size { yylval=NULL; return K_SIZE; }
spi { yylval=NULL; return K_SPI; }
spmcr { yylval=NULL; return K_SPMCR; } spmcr { yylval=NULL; return K_SPMCR; }
stabdelay { yylval=NULL; return K_STABDELAY; } stabdelay { yylval=NULL; return K_STABDELAY; }
stk500_devcode { yylval=NULL; return K_STK500_DEVCODE; } stk500_devcode { yylval=NULL; return K_STK500_DEVCODE; }

View File

@ -645,7 +645,8 @@ typedef enum {
typedef enum { typedef enum {
CONNTYPE_PARALLEL, CONNTYPE_PARALLEL,
CONNTYPE_SERIAL, CONNTYPE_SERIAL,
CONNTYPE_USB CONNTYPE_USB,
CONNTYPE_SPI
} conntype_t; } conntype_t;
typedef struct programmer_t { typedef struct programmer_t {
@ -924,6 +925,7 @@ extern LISTID programmers;
extern char default_programmer[]; extern char default_programmer[];
extern char default_parallel[]; extern char default_parallel[];
extern char default_serial[]; extern char default_serial[];
extern char default_spi[];
extern double default_bitclock; extern double default_bitclock;
/* This name is fixed, it's only here for symmetry with /* This name is fixed, it's only here for symmetry with

View File

@ -383,6 +383,7 @@ int main(int argc, char * argv [])
default_parallel[0] = 0; default_parallel[0] = 0;
default_serial[0] = 0; default_serial[0] = 0;
default_spi[0] = 0;
default_bitclock = 0.0; default_bitclock = 0.0;
init_config(); init_config();
@ -926,6 +927,12 @@ int main(int argc, char * argv [])
case CONNTYPE_USB: case CONNTYPE_USB:
port = DEFAULT_USB; port = DEFAULT_USB;
break; break;
#ifdef HAVE_LINUXSPI
case CONNTYPE_SPI:
port = *default_spi ? default_spi : "unknown";
break;
#endif
} }
} }