/* * Turbo Programmer Utilities, turbo-prog-utils, www.bladox.com * * Copyright (C) 2004 BLADOX, s.r.o. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2, or (at your option) any * later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. */ #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <tprog/tproglib.h> #include "../module-src/avrprog.h" void help () { printf ("Print fusion, lock and calibration bytes\n"); printf ("Usage: urdfu [args]\n"); printf ("-a application\tuse application, default is %s\n", APP_AVR_PROG); printf ("-d device\tuse USB device, default is %s\n", USBDEVICE); printf ("-h\t\thelp\n"); printf ("-v\t\tverbose\n"); exit (-1); } int main (int argc, char **argv) { int result; u8 *dev = USBDEVICE; u8 *app_name = APP_AVR_PROG; u8 answer[2048]; u16 answerLen; u16 i; do { result = getopt (argc, argv, "hd:a:v"); switch (result) { case 'a': app_name = optarg; break; case 'd': dev = optarg; break; case 'h': help (); break; case 'v': verbose_inc (); break; } } while (result > 0); open_device (dev); if (select_app (app_name) != NO_ERROR) { close_device (); fprintf (stderr, "Cannot open application %s\n", app_name); exit (-1); } usb_send (ACTION_AVR_PROG_INIT, 0, NULL, &answerLen, answer); printf ("AVR programming mode initialized, %s\n", app_name); printf ("---------------------------------------------------------------------\n"); printf ("Doing Chip ERASE\n"); usb_send (ACTION_AVR_CHIP_ERASE, 0, NULL, &answerLen, answer); printf ("Chip ERASE finished\n Reading Part info, Fuse bytes, Calibration byte and Lock byte\n"); printf ("---------------------------------------------------------------------\n"); printf ("---------------------------------------------------------------------\n"); usb_send (ACTION_AVR_GET_PART_INFO, 0, NULL, &answerLen, answer); for (i = 0; i < answerLen; i++) printf ("Part info byte%d : \t\t0x%02X\n", i, answer[i]); printf ("---------------------------------------------------------------------\n"); printf ("---------------------------------------------------------------------\n"); usb_send (ACTION_AVR_READ_FUSE_LOW_BYTE, 0, NULL, &answerLen, answer); printf ("Fuse low byte : \t\t0x%02X\n", answer[0]); usb_send (ACTION_AVR_READ_FUSE_HIGH_BYTE, 0, NULL, &answerLen, answer); printf ("Fuse high byte : \t\t0x%02X\n", answer[0]); usb_send (ACTION_AVR_READ_FUSE_EXTENDED_BYTE, 0, NULL, &answerLen, answer); printf ("Fuse extended byte : \t\t0x%02X\n", answer[0]); printf ("---------------------------------------------------------------------\n"); printf ("---------------------------------------------------------------------\n"); usb_send (ACTION_AVR_READ_CALIBRATE_BYTE, 0, NULL, &answerLen, answer); printf ("Calibration byte : \t\t0x%02X\n", answer[0]); printf ("---------------------------------------------------------------------\n"); printf ("---------------------------------------------------------------------\n"); usb_send (ACTION_AVR_READ_LOCK_BITS, 0, NULL, &answerLen, answer); printf ("Lock byte : \t\t0x%02X\n", answer[0]); printf ("---------------------------------------------------------------------\n"); printf ("Info end\n"); close_device (); }
Copyright © 2004 BLADOX | Turbo Programmer version 2.0
|