From c09c84eb5843cbdbce7ae6c8f3d2ec669ad1e351 Mon Sep 17 00:00:00 2001 From: Olaf Rempel Date: Sun, 21 May 2006 19:43:19 +0200 Subject: [PATCH] unknown version --- isp_down.c | 251 +++++++++++++++++++++++------------------------------ 1 file changed, 108 insertions(+), 143 deletions(-) diff --git a/isp_down.c b/isp_down.c index e6715ec..7795401 100644 --- a/isp_down.c +++ b/isp_down.c @@ -3,143 +3,110 @@ #include #include -//#define BAUDRATE B115200 -//#define BAUDRATE B57600 -#define BAUDRATE B38400 +#define BAUDRATE B115200 -unsigned char sign[6][3]= -{0x00,0x90,0x1E, /* AT90S1200 tested 05.04.2001 */ - 0x01,0x91,0x1E, /* AT90S2313 tested 21.02.2001 */ - 0x02,0x91,0x1E, /* AT90S2323 */ - 0x03,0x91,0x1E, /* AT90S2343 */ - 0x01,0x92,0x1E, /* AT90S4414 */ - 0x01,0x93,0x1E}; /* AT90S8515 tested 12.11.2001 */ +struct chip_ { + char shortname[8]; + char longname[16]; + char signatur[3]; + int flash_size; + int eeprom_size; +}; -unsigned int mem_size[6][2]= -{0x1FF,0x3F, /* AT90S1200 tested 05.04.2001 */ - 0x3FF,0x7F, /* AT90S2313 tested 21.02.2001 */ - 0x3FF,0x7F, /* AT90S2323 */ - 0x3FF,0x7F, /* AT90S2343 */ - 0x7FF,0xFF, /* AT90S4414 */ - 0xFFF,0x1FF}; /* AT90S8515 tested 12.11.2001*/ +typedef struct chip_ CHIP; -struct termios oldtio, newtio; -int ser; +CHIP chips[] = { + { "1200", "AT90S1200", { 0x00, 0x90, 0x1E }, 0x200, 0x40 }, + { "2313", "AT90S2313", { 0x01, 0x91, 0x1E }, 0x400, 0x80 }, + { "8515", "AT90S8515", { 0x01, 0x93, 0x1E }, 0x1000, 0x200 }, + { "\0", "\0", {0, 0, 0}, 0, 0 } +}; -void end_prg(char level); void show_usage(); -main(int argc,char *argv[]) +int main(int argc, char *argv[]) { - int avr_device=5, verify=0, flash=0, eeprom=0, reset=0; - char arg, ser_device[64]="/dev/ttyS0", flash_file[64]="", eeprom_file[64]=""; + char arg; - unsigned char inbuf[8], outbuf[8], databuf[8]; - int fdat, eedat; - unsigned int t; - - printf("\n***************************************\n"); - printf("* In-System-Programmer for Atmel AVRs *\n"); - printf("***************************************\n\n"); - if (argc <= 1) - { - show_usage(); - end_prg(0); - } - for (arg=1; arg ", ser_device); ser = open(ser_device, O_RDWR | O_NOCTTY ); if (ser <0) @@ -452,23 +419,21 @@ void end_prg(char level) exit (0); } -void show_usage() -{ - printf("USAGE:\n"); - printf(" isp_down [OPTIONS] \n\n"); - printf("OPTIONS:\n"); - printf(" -avr selects AVR-device\n"); - printf(" 1200 -> AT90S1200 1kB FLASH / 64 bytes EEPROM\n"); - printf(" 2313 -> AT90S2313 2kB FLASH / 128 bytes EEPROM\n"); - printf(" 2323 -> AT90S2323 2kB FLASH / 128 bytes EEPROM\n"); - printf(" 2343 -> AT90S2343 2kB FLASH / 128 bytes EEPROM\n"); - printf(" 4414 -> AT90S4414 4kB FLASH / 256 bytes EEPROM\n"); - printf(" 8515 -> AT90S8515 8kB FLASH / 512 bytes EEPROM (default)\n\n"); - printf(" -dev selects RS232-device (default: /dev/ttyS0)\n"); - printf(" -flash Write (1st) file to FLASH\n"); - printf(" -eeprom Write (2nd) file to EEPROM\n"); - printf(" -verify Verify writing\n"); - printf(" -reset Only resets AVR\n"); - end_prg(0); +void show_usage() { + printf("USAGE:\n"); + printf(" isp_down [OPTIONS] \n\n"); + printf("OPTIONS:\n"); + printf(" -avr selects AVR-device\n"); + printf(" 1200 -> AT90S1200 1kB FLASH / 64 bytes EEPROM\n"); + printf(" 2313 -> AT90S2313 2kB FLASH / 128 bytes EEPROM\n"); + printf(" 2323 -> AT90S2323 2kB FLASH / 128 bytes EEPROM\n"); + printf(" 2343 -> AT90S2343 2kB FLASH / 128 bytes EEPROM\n"); + printf(" 4414 -> AT90S4414 4kB FLASH / 256 bytes EEPROM\n"); + printf(" 8515 -> AT90S8515 8kB FLASH / 512 bytes EEPROM (default)\n\n"); + printf(" -dev selects RS232-device (default: /dev/ttyS0)\n"); + printf(" -flash Write (1st) file to FLASH\n"); + printf(" -eeprom Write (2nd) file to EEPROM\n"); + printf(" -verify Verify writing\n"); + printf(" -reset Only resets AVR\n"); }