
#ifndef	_HTC_H_
#warning Header file s80c517a.h included directly. Use #include <htc.h> instead.
#endif

/*header file for the SIEMENS microcontrollers
	SAB80C517A
	SAB83C517A_5
 */

#ifndef __S80C517A_H

#define __S80C517A_H
	
typedef struct {
	unsigned B7:1;	/* this is the most significant bit */
	unsigned B6:1;
	unsigned B5:1;
	unsigned B4:1;
	unsigned B3:1;
	unsigned B2:1;
	unsigned B1:1;
	unsigned B0:1;
}	SFR_BITS;

static volatile unsigned char		P0	@ 0x80;
static volatile unsigned char		SP	@ 0x81;
static volatile unsigned char		DPL	@ 0x82;
static volatile unsigned char		DPH	@ 0x83;
// 16 bit definition
static volatile	unsigned char		WDTL	@ 0x84;
static volatile	unsigned char		WDTH	@ 0x85;
static 		unsigned char		WDTREL	@ 0x86;
static 		unsigned char		PCON	@ 0x87;
static volatile	unsigned char		TCON	@ 0x88;
static 		unsigned char		TMOD	@ 0x89;
static volatile unsigned char		TL0	@ 0x8A;
static volatile unsigned char		TL1	@ 0x8B;
static volatile unsigned char		TH0	@ 0x8C;
static volatile unsigned char		TH1	@ 0x8D;
static volatile unsigned char		P1	@ 0x90;
static		unsigned char		XPAGE	@ 0x91;
static		unsigned char		DPSEL	@ 0x92;
static volatile	unsigned char		S0CON	@ 0x98;
static volatile unsigned char		S0BUF	@ 0x99;
static		unsigned char		IEN2	@ 0x9A;
static volatile unsigned char		S1CON	@ 0x9B;
static volatile unsigned char		S1BUF	@ 0x9C;
static		unsigned char		S1RELL	@ 0x9D;
static volatile unsigned char		P2	@ 0xA0;
static		unsigned char		COMSETL	@ 0xA1;
static		unsigned char		COMSETH	@ 0xA2;
static		unsigned char		COMCLRL	@ 0xA3;
static		unsigned char		COMCLRH	@ 0xA4;
static		unsigned char		SETMSK	@ 0xA5;
static		unsigned char		CLRMSK	@ 0xA6;
static 		unsigned char		IEN0	@ 0xA8;
static 		unsigned char		IP0	@ 0xA9;
static		unsigned char		S0RELL	@ 0xAA;
static volatile unsigned char		P3	@ 0xB0;
static volatile unsigned char		SYSCON	@ 0xB1;
static		unsigned char		IEN1	@ 0xB8;
static 		unsigned char		IP1	@ 0xB9;
static		unsigned char		S0RELH	@ 0xBA;
static		unsigned char		S1RELH	@ 0xBB;
static volatile unsigned char		IRCON0	@ 0xC0;
static		unsigned char		CCEN	@ 0xC1;
static volatile unsigned char		CCL1	@ 0xC2;
static volatile unsigned char		CCH1	@ 0xC3;
static volatile unsigned char		CCL2	@ 0xC4;
static volatile unsigned char		CCH2	@ 0xC5;
static volatile unsigned char		CCL3	@ 0xC6;
static volatile unsigned char		CCH3	@ 0xC7;
static volatile	unsigned char		T2CON	@ 0xC8;
static		unsigned char		CC4EN	@ 0xC9;
static volatile unsigned char		CRCL	@ 0xCA;
static volatile unsigned char		CRCH	@ 0xCB;
static volatile unsigned char		TL2	@ 0xCC;
static volatile unsigned char		TH2	@ 0xCD;
static volatile unsigned char		CCL4	@ 0xCE;
static volatile unsigned char		CCH4	@ 0xCF;
static volatile unsigned char		PSW	@ 0xD0;
static volatile unsigned char		IRCON1	@ 0xD1;
static volatile unsigned char		CML0	@ 0xD2;
static volatile unsigned char		CMH0	@ 0xD3;
static volatile unsigned char		CML1	@ 0xD4;
static volatile unsigned char		CMH1	@ 0xD5;
static volatile unsigned char		CML2	@ 0xD6;
static volatile unsigned char		CMH2	@ 0xD7;
static volatile unsigned char		ADCON0	@ 0xD8;
static volatile unsigned char		ADDATH	@ 0xD9;
static volatile unsigned char		ADDATL	@ 0xDA;
static volatile unsigned char		P7	@ 0xDB;
static		unsigned char		ADCON1	@ 0xDC;
static volatile unsigned char		P8	@ 0xDD;
static		unsigned char		CTRELL	@ 0xDE;
static		unsigned char		CTRELH	@ 0xDF;
static volatile unsigned char		ACC	@ 0xE0;
static volatile unsigned char		CTCON	@ 0xE1;
static volatile unsigned char		CML3	@ 0xE2;
static volatile unsigned char		CMH3	@ 0xE3;
static volatile unsigned char		CML4	@ 0xE4;
static volatile unsigned char		CMH4	@ 0xE5;
static volatile unsigned char		CML5	@ 0xE6;
static volatile unsigned char		CMH5	@ 0xE7;
static volatile unsigned char		P4	@ 0xE8;
static volatile unsigned char		MD0	@ 0xE9;
static volatile unsigned char		MD1	@ 0xEA;
static volatile unsigned char		MD2	@ 0xEB;
static volatile unsigned char		MD3	@ 0xEC;
static volatile unsigned char		MD4	@ 0xED;
static volatile unsigned char		MD5	@ 0xEE;
static volatile unsigned char		ARCON	@ 0xEF;
static volatile unsigned char		B	@ 0xF0;
static volatile unsigned char		CML6	@ 0xF2;
static volatile unsigned char		CMH6	@ 0xF3;
static volatile unsigned char		CML7	@ 0xF4;
static volatile unsigned char		CMH7	@ 0xF5;
static		unsigned char		CMEN	@ 0xF6;
static		unsigned char		CMSEL	@ 0xF7;
static volatile unsigned char		P5	@ 0xF8;
static volatile unsigned char		P6	@ 0xFA;
static volatile unsigned char		IS0	@ 0xFD;
static volatile unsigned char		IS1	@ 0xFE;

static volatile SFR_BITS	P0_BITS		@ 0x80;
static 		SFR_BITS	PCON_BITS	@ 0x87;
static volatile	SFR_BITS	TCON_BITS	@ 0x88;
static 		SFR_BITS	TMOD_BITS	@ 0x89;
static volatile SFR_BITS	P1_BITS		@ 0x90;
static		SFR_BITS	DPSEL_BITS	@ 0x92;
static volatile	SFR_BITS	S0CON_BITS	@ 0x98;
static		SFR_BITS	IEN2_BITS	@ 0x9A;
static volatile SFR_BITS	S1CON_BITS	@ 0x9B;
static volatile SFR_BITS	P2_BITS		@ 0xA0;
static		SFR_BITS	SETMSK_BITS	@ 0xA5;
static		SFR_BITS	CLRMSK_BITS	@ 0xA6;
static 		SFR_BITS	IEN0_BITS	@ 0xA8;
static 		SFR_BITS	IP0_BITS	@ 0xA9;
static volatile SFR_BITS	P3_BITS		@ 0xB0;
static volatile SFR_BITS	SYSCON_BITS	@ 0xB1;
static		SFR_BITS	IEN1_BITS	@ 0xB8;
static 		SFR_BITS	IP1_BITS	@ 0xB9;
static volatile SFR_BITS	IRCON0_BITS	@ 0xC0;
static		SFR_BITS	CCEN_BITS	@ 0xC1;
static volatile	SFR_BITS	T2CON_BITS	@ 0xC8;
static		SFR_BITS	CC4EN_BITS	@ 0xC9;
static volatile SFR_BITS	PSW_BITS	@ 0xD0;
static volatile SFR_BITS	IRCON1_BITS	@ 0xD1;
static volatile SFR_BITS	ADCON0_BITS	@ 0xD8;
static volatile SFR_BITS	P7_BITS		@ 0xDB;
static		SFR_BITS	ADCON1_BITS	@ 0xDC;
static volatile SFR_BITS	P8_BITS		@ 0xDD;
static volatile SFR_BITS	ACC_BITS	@ 0xE0;
static volatile SFR_BITS	CTCON_BITS	@ 0xE1;
static volatile SFR_BITS	P4_BITS		@ 0xE8;
static volatile SFR_BITS	ARCON_BITS	@ 0xEF;
static volatile SFR_BITS	B_BITS		@ 0xF0;
static		SFR_BITS	CMEN_BITS	@ 0xF6;
static		SFR_BITS	CMSEL_BITS	@ 0xF7;
static volatile SFR_BITS	P5_BITS		@ 0xF8;
static volatile SFR_BITS	P6_BITS		@ 0xFA;
static volatile SFR_BITS	IS0_BITS	@ 0xFD;
static volatile SFR_BITS	IS1_BITS	@ 0xFE;

/*bit addressable locations*/
//Port 0 P0
static volatile bit P00		@ 0x80;
static volatile bit P01		@ 0x81;
static volatile bit P02		@ 0x82;
static volatile bit P03		@ 0x83;
static volatile bit P04		@ 0x84;
static volatile bit P05		@ 0x85;
static volatile bit P06		@ 0x86;
static volatile bit P07		@ 0x87;

//Timer Control TCON
static 		bit	IT0	@ 0x88;
static volatile bit	IE0	@ 0x89;
static 		bit	IT1	@ 0x8A;
static volatile bit	IE1	@ 0x8B;
static 		bit	TR0	@ 0x8C;
static volatile bit	TF0	@ 0x8D;
static 		bit	TR1	@ 0x8E;
static volatile bit	TF1	@ 0x8F;

//Port 1 P1
static volatile bit P10		@ 0x90;
static volatile bit P11		@ 0x91;
static volatile bit P12		@ 0x92;
static volatile bit P13		@ 0x93;
static volatile bit P14		@ 0x94;
static volatile bit P15		@ 0x95;
static volatile bit P16		@ 0x96;
static volatile bit P17		@ 0x97;
// Alternate Functions
static volatile bit INT3	@ 0x90;
static volatile bit INT4	@ 0x91;
static volatile bit INT5	@ 0x92;
static volatile bit INT6	@ 0x93;
static volatile bit INT2	@ 0x94;
static volatile bit T2EX	@ 0x95;
static volatile bit CLKOUT	@ 0x96;
static volatile bit T2		@ 0x97;

//Serial Control 0 S0CON
static volatile bit	RI	@ 0x98;
static volatile bit	TI	@ 0x99;
static volatile bit	RB8	@ 0x9A;
static		bit	TB8	@ 0x9B;
static 		bit	REN	@ 0x9C;
static		bit	SM2	@ 0x9D;
static		bit	SM1	@ 0x9E;
static volatile bit	SM0	@ 0x9F;

//Port 2 P2
static volatile bit P20		@ 0xA0;
static volatile bit P21		@ 0xA1;
static volatile bit P22		@ 0xA2;
static volatile bit P23		@ 0xA3;
static volatile bit P24		@ 0xA4;
static volatile bit P25		@ 0xA5;
static volatile bit P26		@ 0xA6;
static volatile bit P27		@ 0xA7;

//Interrupt Enable IEN0
static		bit IEN00	@ 0xA8;
static		bit IEN01	@ 0xA9;
static		bit IEN02	@ 0xAA;
static		bit IEN03	@ 0xAB;
static 		bit IEN04	@ 0xAC;
static 		bit IEN05	@ 0xAD;
static 		bit IEN06	@ 0xAE;
static 		bit IEN07	@ 0xAF;

//Port 3 P3
static volatile bit P30		@ 0xB0;
static volatile bit P31		@ 0xB1;
static volatile bit P32		@ 0xB2;
static volatile bit P33		@ 0xB3;
static volatile bit P34		@ 0xB4;
static volatile bit P35		@ 0xB5;
static volatile bit P36		@ 0xB6;
static volatile bit P37		@ 0xB7;

//Interrupt Enable 1 IEN1
static 		bit IEN10	@ 0xB8;
static 		bit IEN11	@ 0xB9;
static 		bit IEN12	@ 0xBA;
static 		bit IEN13	@ 0xBB;
static 		bit IEN14	@ 0xBC;
static 		bit IEN15	@ 0xBD;
static 		bit IEN16	@ 0xBE;
static 		bit IEN17	@ 0xBF;

//Interrupt Request Control Register 0 IRCON0
static volatile	bit IRCON00	@ 0xC0;
static volatile	bit IRCON01	@ 0xC1;
static volatile	bit IRCON02	@ 0xC2;
static volatile	bit IRCON03	@ 0xC3;
static volatile	bit IRCON04	@ 0xC4;
static volatile	bit IRCON05	@ 0xC5;
static volatile	bit IRCON06	@ 0xC6;
static volatile	bit IRCON07	@ 0xC7;

//Timer 2 Control T2CON
static volatile	bit T2I0	@ 0xC8;
static volatile	bit T2I1	@ 0xC9;
static volatile	bit T2C		@ 0xCA;
static volatile	bit T2R0	@ 0xCB;
static volatile	bit T2R1	@ 0xCC;
static volatile	bit T2FR	@ 0xCD;
static volatile	bit T3FR	@ 0xCE;
static volatile	bit T2PS	@ 0xCF;

//Program Status Word PSW
static volatile bit P		@ 0xD0;
static volatile bit F1		@ 0xD1;
static volatile bit OV		@ 0xD2;
static 		bit RS0		@ 0xD3;
static 		bit RS1		@ 0xD4;
static volatile bit F0		@ 0xD5;
static volatile bit AC		@ 0xD6;
static volatile bit CY		@ 0xD7;

//AD Control 0 ADCON0
static 		bit MX0		@ 0xD8;
static 		bit MX1		@ 0xD9;
static 		bit MX2		@ 0xDA;
static volatile bit ADM		@ 0xDB;
static volatile bit BSY		@ 0xDC;
static volatile bit ADEX	@ 0xDD;
static		bit CLK		@ 0xDE;
static		bit BD		@ 0xDF;

//Accumulator ACC
static volatile bit ACC0	@ 0xE0;
static volatile bit ACC1	@ 0xE1;
static volatile bit ACC2	@ 0xE2;
static volatile bit ACC3	@ 0xE3;
static volatile bit ACC4	@ 0xE4;
static volatile bit ACC5	@ 0xE5;
static volatile bit ACC6	@ 0xE6;
static volatile bit ACC7	@ 0xE7;

//Port 4 P4
static volatile bit CM0		@ 0xE8;
static volatile bit CM1		@ 0xE9;
static volatile bit CM2		@ 0xEA;
static volatile bit CM3		@ 0xEB;
static volatile bit CM4		@ 0xEC;
static volatile bit CM5		@ 0xED;
static volatile bit CM6		@ 0xEE;
static volatile bit CM7		@ 0xEF;

//B register
static volatile bit B0		@ 0xF0;
static volatile bit B1		@ 0xF1;
static volatile bit B2		@ 0xF2;
static volatile bit B3		@ 0xF3;
static volatile bit B4		@ 0xF4;
static volatile bit B5		@ 0xF5;
static volatile bit B6		@ 0xF6;
static volatile bit B7		@ 0xF7;

//Port 5
static volatile bit CCM0	@ 0xF8;
static volatile bit CCM1	@ 0xF9;
static volatile bit CCM2	@ 0xFA;
static volatile bit CCM3	@ 0xFB;
static volatile bit CCM4	@ 0xFC;
static volatile bit CCM5	@ 0xFD;
static volatile bit CCM6	@ 0xFE;
static volatile bit CCM7	@ 0xFF;

/*	Interrupt vectors */
#define	RESET	0
#define	EXTINT0	0x03
#define TIMER0	0x0B
#define	EXTINT1	0x13
#define	TIMER1	0x1B
#define	SERIAL	0x23
#define	TIMER2	0x2B
#define	ADC	0x43
#define	EXTINT2	0x4B
#define	EXTINT3	0x53
#define	EXTINT4	0x5B
#define	EXTINT5	0x63
#define	EXTINT6	0x6B
#define	S1	0x83
#define	CMT2	0x93
#define	CMTO	0x9B
#define	CCOMSET	0xA3
#define	CCOMCLR	0xAB

#endif
