static int arduino_open(PROGRAMMER * pgm, char * port) { strcpy(pgm->port, port); if (serial_open(port, pgm->baudrate? pgm->baudrate: 115200, &pgm->fd)==-1) { return -1; } /* Clear DTR and RTS to unload the RESET capacitor * (for example in Arduino) */ serial_set_dtr_rts(&pgm->fd, 0); usleep(50*1000); /* Set DTR and RTS back to high */ serial_set_dtr_rts(&pgm->fd, 1); usleep(50*1000); /* * drain any extraneous input */ stk500_drain(pgm, 0); if (stk500_getsync(pgm) < 0) return -1; return 0; }
static int arduino_open(PROGRAMMER * pgm, char * port) { union pinfo pinfo; strcpy(pgm->port, port); pinfo.baud = pgm->baudrate? pgm->baudrate: 115200; if (serial_open(port, pinfo, &pgm->fd)==-1) { return -1; } #ifdef CUSTOMER_REST_PIN gpio_export(pgm->reset_pin); gpio_set_dir(pgm->reset_pin, OUT); gpio_set_value(pgm->reset_pin,LOW); usleep(250*1000); gpio_set_value(pgm->reset_pin,HIGH); usleep(50*1000); #else /* Clear DTR and RTS to unload the RESET capacitor * (for example in Arduino) */ serial_set_dtr_rts(&pgm->fd, 0); usleep(250*1000); /* Set DTR and RTS back to high */ serial_set_dtr_rts(&pgm->fd, 1); usleep(50*1000); #endif /* * drain any extraneous input */ stk500_drain(pgm, 0); if (stk500_getsync(pgm) < 0) return -1; return 0; }