From ae3f4e852f0140aac084a276177ace8a9c8842c5 Mon Sep 17 00:00:00 2001 From: troth Date: Sun, 16 Mar 2003 18:19:37 +0000 Subject: [PATCH] * avrdude.conf.in: Add avr910 and pavr programmers. * config_gram.y: Add parsing of avr910 programmer. * lexer.l: Add avr910 token. * avr910.c: [this is still work in progress] Add some debug output. Add probe for programmer presense. * main.c: Set port to default_serial if programmer type is avr910. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@292 81a1dc3b-b13d-400b-aceb-764788c761c2 --- ChangeLog | 10 +++++ avr910.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++- avrdude.conf.in | 14 ++++++- config_gram.y | 8 ++++ lexer.l | 1 + main.c | 3 +- 6 files changed, 134 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 61f10a5a..ae6dc7a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2003-03-16 Theodore A. Roth + + * avrdude.conf.in: Add avr910 and pavr programmers. + * config_gram.y: Add parsing of avr910 programmer. + * lexer.l: Add avr910 token. + * avr910.c: [this is still work in progress] + Add some debug output. + Add probe for programmer presense. + * main.c: Set port to default_serial if programmer type is avr910. + 2003-03-13 Theodore A. Roth * ser_posix.c, ser_win32.c, serial.h: diff --git a/avr910.c b/avr910.c index 72de6b22..02c85327 100644 --- a/avr910.c +++ b/avr910.c @@ -39,45 +39,73 @@ extern char * progname; extern int do_cycles; +#define show_func_info() \ + fprintf(stderr, "%s: %d: called %s()\n", __FILE__, __LINE__, __FUNCTION__) + + static int avr910_send(PROGRAMMER * pgm, char * buf, size_t len) { + show_func_info(); + return serial_send(pgm->fd, buf, len); } static int avr910_recv(PROGRAMMER * pgm, char * buf, size_t len) { + show_func_info(); + return serial_recv(pgm->fd, buf, len); } static int avr910_drain(PROGRAMMER * pgm, int display) { + show_func_info(); + + /* Do nothing. */ + return serial_drain(pgm->fd, display); } static int avr910_rdy_led(PROGRAMMER * pgm, int value) { + show_func_info(); + + /* Do nothing. */ + return 0; } static int avr910_err_led(PROGRAMMER * pgm, int value) { + show_func_info(); + + /* Do nothing. */ + return 0; } static int avr910_pgm_led(PROGRAMMER * pgm, int value) { + show_func_info(); + + /* Do nothing. */ + return 0; } static int avr910_vfy_led(PROGRAMMER * pgm, int value) { + show_func_info(); + + /* Do nothing. */ + return 0; } @@ -87,6 +115,8 @@ static int avr910_vfy_led(PROGRAMMER * pgm, int value) */ static int avr910_chip_erase(PROGRAMMER * pgm, AVRPART * p) { + show_func_info(); + return 0; } @@ -95,6 +125,8 @@ static int avr910_chip_erase(PROGRAMMER * pgm, AVRPART * p) */ static int avr910_program_enable(PROGRAMMER * pgm, AVRPART * p) { + show_func_info(); + return -1; } @@ -104,6 +136,10 @@ static int avr910_program_enable(PROGRAMMER * pgm, AVRPART * p) */ static void avr910_powerup(PROGRAMMER * pgm) { + show_func_info(); + + /* Do nothing. */ + return; } @@ -113,6 +149,10 @@ static void avr910_powerup(PROGRAMMER * pgm) */ static void avr910_powerdown(PROGRAMMER * pgm) { + show_func_info(); + + /* Do nothing. */ + return; } @@ -122,30 +162,79 @@ static void avr910_powerdown(PROGRAMMER * pgm) */ static int avr910_initialize(PROGRAMMER * pgm, AVRPART * p) { + char pn[8]; + char sw[2]; + char hw[2]; + unsigned char c; + + show_func_info(); + + /* Programmer returns exactly 7 chars _without_ the null.*/ + + avr910_send(pgm, "S", 1); + memset (pn, 0, sizeof(pn)); + avr910_recv(pgm, pn, sizeof(pn)-1); + + /* Get the HW and SW versions to see if the programmer is present. */ + + avr910_send(pgm, "V", 1); + avr910_recv(pgm, sw, sizeof(sw)); + + avr910_send(pgm, "v", 1); + avr910_recv(pgm, hw, sizeof(hw)); + + fprintf(stderr, "Found programmer: %s\n", pn); + fprintf(stderr, " Software Version = %c.%c; " + "Hardware Version = %c.%c\n", sw[0], sw[1], hw[0], hw[1]); + + /* Get list of devices that the programmer supports. */ + + avr910_send(pgm, "t", 1); + while (1) { + avr910_recv(pgm, &c, 1); + if (c == 0) + break; + fprintf(stderr, "Device code: 0x%02x\n", c); + }; + return 0; } static int avr910_save(PROGRAMMER * pgm) { + show_func_info(); + + /* Do nothing. */ + return 0; } static void avr910_restore(PROGRAMMER * pgm) { + show_func_info(); + + /* Do nothing. */ + return; } static void avr910_disable(PROGRAMMER * pgm) { + show_func_info(); + return; } static void avr910_enable(PROGRAMMER * pgm) { + show_func_info(); + + /* Do nothing. */ + return; } @@ -157,12 +246,16 @@ static void avr910_enable(PROGRAMMER * pgm) static int avr910_cmd(PROGRAMMER * pgm, unsigned char cmd[4], unsigned char res[4]) { - return 0; + show_func_info(); + + return 0; } static void avr910_open(PROGRAMMER * pgm, char * port) { + show_func_info(); + strcpy(pgm->port, port); pgm->fd = serial_open(port, 19200); @@ -174,6 +267,8 @@ static void avr910_open(PROGRAMMER * pgm, char * port) static void avr910_close(PROGRAMMER * pgm) { + show_func_info(); + serial_close(pgm->fd); pgm->fd = -1; } @@ -181,12 +276,16 @@ static void avr910_close(PROGRAMMER * pgm) static void avr910_display(PROGRAMMER * pgm, char * p) { + show_func_info(); + return; } void avr910_initpgm(PROGRAMMER * pgm) { + show_func_info(); + strcpy(pgm->type, "avr910"); /* diff --git a/avrdude.conf.in b/avrdude.conf.in index 1206588b..dad2337f 100644 --- a/avrdude.conf.in +++ b/avrdude.conf.in @@ -15,7 +15,7 @@ # programmer # id = [, [, ] ...] ; # are quoted strings # desc = ; # quoted string -# type = par | stk500 ; # programmer type +# type = par | stk500 | avr910; # programmer type # vcc = [, ... ] ; # pin number(s) # reset = ; # pin number # sck = ; # pin number @@ -203,6 +203,18 @@ programmer type = stk500; ; +programmer + id = "avr910"; + desc = "Atmel Low Cost Serial Programmer"; + type = avr910; +; + +programmer + id = "pavr"; + desc = "Jason Kyle's pAVR Serial Programmer"; + type = avr910; +; + programmer id = "stk200"; desc = "STK200"; diff --git a/config_gram.y b/config_gram.y index 70bc8fca..a1213509 100644 --- a/config_gram.y +++ b/config_gram.y @@ -33,6 +33,7 @@ #include "ppi.h" #include "pgm.h" #include "stk500.h" +#include "avr910.h" #include "avr.h" extern char * progname; @@ -101,6 +102,7 @@ static int parse_cmdbits(OPCODE * op); %token K_SCK %token K_SIZE %token K_STK500 +%token K_AVR910 %token K_TYPE %token K_VCC %token K_VFYLED @@ -284,6 +286,12 @@ prog_parm : } } | + K_TYPE TKN_EQUAL K_AVR910 { + { + avr910_initpgm(current_prog); + } + } | + K_DESC TKN_EQUAL TKN_STRING { strncpy(current_prog->desc, $3->value.string, PGM_DESCLEN); current_prog->desc[PGM_DESCLEN-1] = 0; diff --git a/lexer.l b/lexer.l index a09cd234..64df0a95 100644 --- a/lexer.l +++ b/lexer.l @@ -152,6 +152,7 @@ retry_pulse { yylval=NULL; return K_RETRY_PULSE; } serial { yylval=NULL; return K_SERIAL; } size { yylval=NULL; return K_SIZE; } stk500 { yylval=NULL; return K_STK500; } +avr910 { yylval=NULL; return K_AVR910; } type { yylval=NULL; return K_TYPE; } vcc { yylval=NULL; return K_VCC; } vfyled { yylval=NULL; return K_VFYLED; } diff --git a/main.c b/main.c index 6fb8c135..30926df8 100644 --- a/main.c +++ b/main.c @@ -610,7 +610,8 @@ int main(int argc, char * argv []) exit(1); } - if (strcmp(pgm->type, "STK500") == 0) { + if ((strcmp(pgm->type, "STK500") == 0) + || (strcmp(pgm->type, "avr910") == 0)){ if (port == default_parallel) { port = default_serial; }