/* * 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 ("Set uwrfl\n"); printf ("Usage: uwrfl [args] val_in_hex\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; u8 val; 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); if (argc - optind != 1) help (); sscanf (argv[optind], "%x", &val); 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"); answer[0] = val; printf ("Writing new FUSE LOW byte : \t\t0x%02X\n", answer[0]); usb_send (ACTION_AVR_WRITE_FUSE_LOW_BYTE, 1, answer, &answerLen, answer); printf ("---------------------------------------------------------------------\n"); printf ("---------------------------------------------------------------------\n"); usb_send (ACTION_AVR_READ_FUSE_LOW_BYTE, 0, NULL, &answerLen, answer); printf ("New FUSE LOW byte : \t\t0x%02X\n", answer[0]); printf ("---------------------------------------------------------------------\n"); close_device (); if (answer[0] != val) { fprintf (stderr, "ERROR! FUSE LOW not set\n"); exit (-1); } }
Copyright © 2004 BLADOX | Turbo Programmer version 2.0
|