⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 isp-at89.h

📁 at51系列单片机编程源码
💻 H
字号:
#ifndef INCLUDE_ISP_AT89_H#define INCLUDE_ISP_AT89_H/* ---------------------------------------------------------------------------- * isp_at89.h * generel definitions * * Copyright 2003/2004 * * 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. * ----------------------------------------------------------------------------*/#include <termios.h>#ifdef ENABLE_NLS#  include <locale.h>#endif/* Standard gettext macros */#ifdef ENABLE_NLS#  include <libintl.h>#  undef _#  define _(String) dgettext (PACKAGE, String)#  ifdef gettext_noop#    define N_(String) gettext_noop (String)#  else#    define N_(String) (String)#  endif#else#  define textdomain(String) (String)#  define gettext(String) (String)#  define dgettext(Domain,Message) (Message)#  define dcgettext(Domain,Message,Type) (Message)#  define bindtextdomain(Domain,Directory) (Domain)#  define _(String) (String)#  define N_(String) (String)#endif/* usefull global definitions */#define STDBUFLEN	80/* definitions for getopt */#define ARG_ALL			"vhp:cem:d"#define ARG_VERSION		'v'#define ARG_HELP		'h'#define ARG_PPDEV		'p'#define ARG_VERIFY		'c'#define ARG_ERASE		'e'#define ARG_MEMORY		'm'#define ARG_DISASM		'd'/* file status values returned by function getFileStatus()*/#define FST_NOEXIST		1#define FST_CHARDEV		2#define FST_BLKDEV		3#define FST_FILE		4#define FST_NOARG		5#define FST_UNKNOWN		6#define OK			0#define ERROR		-1#define READY		1/* SPI interface on parallel port */#define RESET		0x10	/* board reset */#define	MOSI		0x20	/* SPI data out */#define SCK			0x40	/* SPI clock */#define	MISO_BIT	6		/* SPI data in bitnumber *//* Program modus */enum { CMD_NONE, CMD_READ, CMD_WRITE, CMD_TEST, CMD_DUMP };/* memory type */enum { MEM_INTERN, MEM_EXTERN, MEM_EEPROM };/* AT89S8252 restrictions */#define AT89S8252_MEMSIZE_INTERN	 8192#define AT89S8252_MEMSIZE_EXTERN	65535#define AT89S8252_MEMSIZE_EEPROM	 2048struct ProgrammingFlags {	unsigned int	data:1;			/* read/write eeprom data instead of program memory */	unsigned int	verify:1;		/* verify write operations */	unsigned int	erase:1;		/* erase before write */	unsigned int	disassemble:1;	/* disassemble code instead of  hex dump */	unsigned int	rawterm:1;		/* terminal switched to raw mode */	unsigned int	:0;};struct ProgrammingData {	int command;					/* what to do */	int memory;						/* type of memory to act on */	unsigned short start;			/* start and end address */	unsigned short end;				/* of binary operations */	char ppdevname[STDBUFLEN];		/* path to parport device */	char datafile[STDBUFLEN];		/* name of datafile or empty for stdout */	struct ProgrammingFlags flags;	struct termios oldcfg;			/* store old terminal settings */};/* Each data block contains multiple MemChunks and each MemChunk * is introduced with a MemChunkHeader which contains target * address and block length. The next block follows behind * the end of the previous block. The last block of the list is * an empty block which is identified through a length of '0'. */struct MemChunkHeader {	unsigned short int address;	unsigned short int length;};struct MemChunk {	struct MemChunkHeader header;	unsigned char data[1];			/* block of data is following here */};/* Definitions for dump and disassembler funktions */struct MemoryMap {	int mapsize;	unsigned char flags[1];};/* Label types */#define CODE	0#define DATA	1/* identifier of the MemoryMap and their meaning */#define ADR_FREE	0x80  /* address is not used */#define ADR_CODE	0x40  /* address is code area */#define ADR_OPCODE	0x20  /* address is the first byte of a command */#define ADR_CLABEL	0x10  /* address carries a label for code jumps*/#define ADR_DLABEL	0x08  /* address carries a label for data*/#define ADR_ENTRY	0x04  /* address is possibly a code entry */#define ADR_USED	~(ADR_CLABEL | ADR_DLABEL | ADR_ENTRY)enum { STARTADR, ENDADR,       D0, D1, D2, D3, D4, D5, D6, D7, D8,       D9, D10, D11, D12, D13, D14, D15,       ASCSTR };/* prototypes init.c */int openDataFile (char *name);int evaluateArgs(struct ProgrammingData *pdata, int argc, char *argv[]);void setupProgrammingData(struct ProgrammingData *pdata);int getCommand(char *str);/* prototypes prog.c */void dumpBufferToScreen(struct MemChunk *Buffer, int Type);void disassembleBufferToScreen(struct MemChunk *Buffer, int Type);void writeBufferToFile(struct MemChunk *Buffer, char* FileName, int Type);void writeBufferToMemory(struct ProgrammingData *pdata, struct MemChunk *Buffer);struct MemChunk *readMemoryToBuffer(struct ProgrammingData *pdata);struct MemChunk *readFileToBuffer(char *name, int maxsize);/* prototypes memchunk.c */struct MemChunk *memchunk_Alloc(int size);void memchunk_Free(struct MemChunk *buffer);int memchunk_GetProgramSize(struct MemChunk *Chunk);struct MemoryMap *memchunk_GetMemoryMap(struct MemChunk *Chunk);struct MemChunk *memchunk_FindNext(struct MemChunk *Chunk, int address);struct MemChunk *memchunk_Find(struct MemChunk *Chunk, int address);/* prototypes ppdev.c */int parport_gethandle (char *ppdev);int parport_claim(char *dev);void parport_release (int fd);unsigned char parport_wdata (int fd, unsigned char wdata);/* prototypes atmel.c */void atmel_setReset (int fd, int on);int atmel_checkDevice (int fd);void atmel_initProgMode(int fd);void atmel_eraseChip(int fd);void atmel_writeCodeMemory(int fd, int addr, unsigned char data);unsigned char atmel_readCodeMemory(int fd, int addr);void atmel_writeDataMemory(int fd, int addr, unsigned char data);unsigned char atmel_readDataMemory(int fd, int addr);long atmel_sendCommand (int fd, long cmd);/* prototypes misc.c */int installSighandler();int getFileStatus (char *file);void setTerminal(struct ProgrammingData *pdata, int raw);void printFlags (struct ProgrammingData *pdata);const char *getMemoryName(int type);int getMemorySize(int type);/* prototypes debug.c */void debug_resetbuffer();void debug_adddata(unsigned char data, unsigned char status);void debug_printbuffer(int result);/* prototypes testmode.c */void testmode (char *device);/* prototypes disassembler.c */void disassembler_pass1(struct MemoryMap *MemMap, struct MemChunk *Chunk);void disassembler_pass2(struct MemoryMap *MemMap, struct MemChunk *Chunk);void disassembler_pass3(struct MemoryMap *MemMap, struct MemChunk *Chunk);void addCodeEntryList(struct MemoryMap *MemMap, int *list, int count);/* prototypes hex2bin.c */int hex2bin (struct MemChunk *Buffer);#endif    /* INCLUDE_ISP_AT89_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -