File: s51dude.h

package info (click to toggle)
s51dude 0.2.0-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 220 kB
  • ctags: 243
  • sloc: ansic: 879; makefile: 97
file content (146 lines) | stat: -rw-r--r-- 3,558 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
 * 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"

#define _(String) gettext(String)
#define gettext_noop(String) (String)
#define N_(String) gettext_noop(String)

/*--------------------
* 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.2.0"

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