Logo Search packages:      
Sourcecode: s51dude version File versions

s51dude.h

/*
 * s51dude - A Downloader/Uploader for 8051 device programmers
 * Copyright (C) 2008 Lucas Chiesa.
 *
 * 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 of the License, 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 Library General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
 */
 
#ifndef _s51dude_h_
#define _s51dude_h_

#include "ihex.h"

/*--------------------
* COMMAND LINE OPTIONS
* ------------------*/

#define         LC_DEV            'p'
#define                 LC_UPLOAD         'u'
#define                 LC_ERASE          'e'
#define                 LC_READ                 'r'
#define                 LC_HELP                 'h'
#define                 LC_VERSION        'V'

#define         LC_LONG_DEV   "part"
#define                 LC_LONG_UPLOAD    "upload"
#define                 LC_LONG_ERASE     "erase"
#define                 LC_LONG_VERSION   "version"
#define                 LC_LONG_VERIFY    "no-verify"
#define                 LC_LONG_DEBUG     "debug"
#define                 LC_LONG_VERBOSE   "verbose"
#define                 LC_LONG_DRY_RUN   "dry-run"
#define                 LC_LONG_READ      "read"
#define                 LC_LONG_HELP      "help"

#define                 ALLOWED_SHORT_ARGUMENTS "r:u:p:he"

#define                 APPNAME                 "s51dude"
#define                 VERSION_STRING    "0.1.3"

typedef enum dest {
      NAP,                    // NotAPart
      AT89S8253,
      AT89S8252,
      AT89S52,
      AT89S53,
} dest;

typedef enum {
      NAA,                    // NotAnAction
      UPLOAD,                       // Erase target and then upload to the target.
      READ,                   // Only read the target memory.
      ERASE,                        // Only erase the target.
} actions;

typedef struct global_options {
      dest                    micro;
      unsigned int            mem_micro;
      unsigned int            val;
      unsigned int            ind_r_eeprom;
      unsigned int            ind_w_eeprom;
      unsigned int            ind_r_flash;
      unsigned int            ind_w_flash;
      unsigned char           enable_programing[4];
      unsigned char           erase[4];
      unsigned int            delay;
      char*                   text_micro;
      actions                       operation;
      char                    *path;
      FILE*                   file;
} global_options;

extern global_options   options;
extern int verify_flag;
extern int verbose_flag;
extern int dry_run_flag;
extern int debug_flag;
extern int  sck_period;

// Prototipos
void get_params (int argc, char *argv[]);

void load_dev (char *dest);

void load_action (actions modo, char* archivo);

void open_file (void);

uint16_t upload(void);

uint16_t read_hex_file(void);

void read_mem(unsigned int size_mem);

void print_params(void);

void check_open_file(void);

inline void print_error(char *msg);

int usbtiny_open (void);

void usbtiny_configure(int ind);

int usb_control (unsigned int requestid, unsigned int val, unsigned int index );

void usbtiny_powerup(void);

void usbtiny_powerdown(void);

int usbtiny_trasnparent_spi(unsigned char cmd[4], unsigned char res[4]);

void enable_programing();

int verify(uint16_t size);

int usb_out (unsigned int requestid, unsigned int val, unsigned int index,
                unsigned char* buffer, int buflen, int bitclk );

int usb_in (unsigned int requestid, unsigned int val, unsigned int index,
               unsigned char* buffer, int buflen, int bitclk );

void exit_nice (void);

void free_mem (void);

void print_help (void);

void print_version (void);

#endif

Generated by  Doxygen 1.6.0   Back to index