Ticket #22867: patch-arduino.c.diff
File patch-arduino.c.diff, 1.6 KB (added by ranauei@…, 15 years ago) |
---|
-
arduino.c
old new 17 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 18 */ 19 19 20 /* $Id: arduino.c 8 08 2009-02-25 09:39:04Z joerg_wunsch$ */20 /* $Id: arduino.c 874 2009-11-02 23:52:52Z mludvig $ */ 21 21 22 22 /* 23 23 * avrdude interface for Arduino programmer … … 30 30 31 31 #include <stdio.h> 32 32 #include <string.h> 33 #include <unistd.h> 33 34 34 35 #include "avrdude.h" 35 36 #include "pgm.h" … … 82 83 return 3; 83 84 } 84 85 86 static int arduino_open(PROGRAMMER * pgm, char * port) 87 { 88 strcpy(pgm->port, port); 89 serial_open(port, pgm->baudrate? pgm->baudrate: 115200, &pgm->fd); 90 91 /* Clear DTR and RTS to unload the RESET capacitor 92 * (for example in Arduino) */ 93 serial_set_dtr_rts(&pgm->fd, 0); 94 usleep(50*1000); 95 /* Set DTR and RTS back to high */ 96 serial_set_dtr_rts(&pgm->fd, 1); 97 usleep(50*1000); 98 99 /* 100 * drain any extraneous input 101 */ 102 stk500_drain(pgm, 0); 103 104 if (stk500_getsync(pgm) < 0) 105 return -1; 106 107 return 0; 108 } 109 110 static void arduino_close(PROGRAMMER * pgm) 111 { 112 serial_set_dtr_rts(&pgm->fd, 0); 113 serial_close(&pgm->fd); 114 pgm->fd.ifd = -1; 115 } 116 85 117 void arduino_initpgm(PROGRAMMER * pgm) 86 118 { 87 119 /* This is mostly a STK500; just the signature is read 88 differently than on real STK500v1 */ 120 differently than on real STK500v1 121 and the DTR signal is set when opening the serial port 122 for the Auto-Reset feature */ 89 123 stk500_initpgm(pgm); 90 124 91 125 strcpy(pgm->type, "Arduino"); 92 126 pgm->read_sig_bytes = arduino_read_sig_bytes; 93 127 pgm->open = arduino_open; 128 pgm->close = arduino_close; 94 129 }