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

/*
 	This is a header file for the Dallas Semiconductor microcontroller
 	DS80C390
 */

#ifndef	__DS80C390_H

#define	__DS80C390_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;

//Special Function Registers
static volatile	unsigned char	P4	@ 0x80;
static volatile	unsigned char	SP	@ 0x81;
static volatile	unsigned char	DPL	@ 0x82;
static volatile	unsigned char	DPH	@ 0x83;
// 16 bit definition
// Alternate definition
static volatile	unsigned char	DPL1	@ 0x84;
static volatile	unsigned char	DPH1	@ 0x85;
// 16 bit definition
static 		unsigned char	DPS	@ 0x86;
static volatile	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 		unsigned char	CKCON	@ 0x8E;
static volatile	unsigned char	P1	@ 0x90;
static volatile	unsigned char	EXIF	@ 0x91;
static 		unsigned char	P4CNT	@ 0x92;
static 		unsigned char	DPX	@ 0x93;
static 		unsigned char	DPX1	@ 0x95;
static 		unsigned char	C0RMS0	@ 0x96;
static 		unsigned char	C0RMS1	@ 0x97;
static volatile	unsigned char	SCON0	@ 0x98;
static volatile	unsigned char	SBUF0	@ 0x99;
static volatile	unsigned char	ESP	@ 0x9B;
static 		unsigned char	AP	@ 0x9C;
static 		unsigned char	ACON	@ 0x9D;
static volatile	unsigned char	C0TMA0	@ 0x9E;
static volatile	unsigned char	C0TMA1	@ 0x9F;
static volatile	unsigned char	P2	@ 0xA0;
static volatile	unsigned char	P5	@ 0xA1;
static volatile	unsigned char	P5CNT	@ 0xA2;
static volatile	unsigned char	C0C	@ 0xA3;
static volatile	unsigned char	C0S	@ 0xA4;
static volatile	unsigned char	C0IR	@ 0xA5;
static volatile	unsigned char	C0TE	@ 0xA6;
static volatile	unsigned char	C0RE	@ 0xA7;
static 		unsigned char	IE	@ 0xA8;
static 		unsigned char	SADDR0  @ 0xA9;
static 		unsigned char	SADDR1	@ 0xAA;
static volatile	unsigned char	C0M1C	@ 0xAB;
static volatile	unsigned char	COM2C	@ 0xAC;
static volatile	unsigned char	COM3C	@ 0xAD;
static volatile	unsigned char	COM4C	@ 0xAE;
static volatile	unsigned char	COM5C	@ 0xAF;
static volatile	unsigned char	P3	@ 0xB0;
static volatile	unsigned char	COM6C	@ 0xB3;
static volatile	unsigned char	COM7C	@ 0xB4;
static volatile	unsigned char	COM8C	@ 0xB5;
static volatile	unsigned char	COM9C	@ 0xB6;
static volatile	unsigned char	COM10C	@ 0xB7;
static 		unsigned char	IP	@ 0xB8;
static 		unsigned char	SADEN0	@ 0xB9;
static 		unsigned char	SADEN1	@ 0xBA;
static volatile	unsigned char	COM11C	@ 0xBB;
static volatile	unsigned char	COM12C	@ 0xBC;
static volatile	unsigned char	COM13C	@ 0xBD;
static volatile	unsigned char	COM14C	@ 0xBE;
static volatile	unsigned char	COM15C	@ 0xBF;
static volatile	unsigned char	SCON1	@ 0xC0;
static volatile	unsigned char	SBUF1	@ 0xC1;
static 		unsigned char	PMR	@ 0xC4;
static volatile	unsigned char	STATUS	@ 0xC5;
static 		unsigned char	MCON	@ 0xC6;
static 		unsigned char	TA	@ 0xC7;
static volatile	unsigned char	T2CON	@ 0xC8;
static 		unsigned char	T2MOD	@ 0xC9;
static volatile	unsigned char	RCAP2L	@ 0xCA;
static volatile	unsigned char	RCAP2H	@ 0xCB;
static volatile	unsigned char	TL2	@ 0xCC;
static volatile	unsigned char	TH2	@ 0xCD;
static 		unsigned char	COR	@ 0xCE;
static volatile	unsigned char	PSW	@ 0xD0;
static volatile	unsigned char	MCNT0	@ 0xD1;
static volatile	unsigned char	MCNT1	@ 0xD2;
static volatile	unsigned char	MA	@ 0xD3;
static volatile	unsigned char	MB	@ 0xD4;
static volatile	unsigned char	MC	@ 0xD5;
static volatile	unsigned char	C1RMS0	@ 0xD6;
static volatile	unsigned char	C1RMS1	@ 0xD7;
static volatile	unsigned char	WDCON	@ 0xD8;
static volatile	unsigned char	C1TMA0	@ 0xDE;
static volatile	unsigned char	C1TMA1	@ 0xDF;
static volatile	unsigned char	ACC	@ 0xE0;
static volatile	unsigned char	C1C	@ 0xE3;
static volatile	unsigned char	C1S	@ 0xE4;
static volatile	unsigned char	C1IR	@ 0xE5;
static volatile	unsigned char	C1TE	@ 0xE6;
static volatile	unsigned char	C1RE	@ 0xE7;
static 		unsigned char	EIE	@ 0xE8;
static 		unsigned char	MXAX	@ 0xEA;
static 		unsigned char	C1M1C	@ 0xEB;
static 		unsigned char	C1M2C	@ 0xEC;
static 		unsigned char	C1M3C	@ 0xED;
static 		unsigned char	C1M4C	@ 0xEE;
static 		unsigned char	C1M5C	@ 0xEF;
static volatile	unsigned char	B	@ 0xF0;
static 		unsigned char	C1M6C	@ 0xF3;
static 		unsigned char	C1M7C	@ 0xF4;
static 		unsigned char	C1M8C	@ 0xF5;
static 		unsigned char	C1M9C	@ 0xF6;
static 		unsigned char	C1M10C	@ 0xF7;
static 		unsigned char	EIP	@ 0xF8;
static 		unsigned char	C1M11C	@ 0xFB;
static 		unsigned char	C1M12C	@ 0xFC;
static 		unsigned char	C1M13C	@ 0xFD;
static 		unsigned char	C1M14C	@ 0xFE;
static 		unsigned char	C1M15C	@ 0xFF;

static volatile	SFR_BITS	P4_BITS		@ 0x80;
static 		SFR_BITS	DPS_BITS	@ 0x86;
static volatile	SFR_BITS	PCON_BITS	@ 0x87;
static volatile	SFR_BITS	TCON_BITS	@ 0x88;
static 		SFR_BITS	TMOD_BITS	@ 0x89;
static 		SFR_BITS	CKCON_BITS	@ 0x8E;
static volatile	SFR_BITS	P1_BITS		@ 0x90;
static volatile	SFR_BITS	EXIF_BITS	@ 0x91;
static 		SFR_BITS	P4CNT_BITS	@ 0x92;
static volatile	SFR_BITS	SCON0_BITS	@ 0x98;
static volatile	SFR_BITS	ESP_BITS	@ 0x9B;
static volatile	SFR_BITS	ACON_BITS	@ 0x9D;
static volatile	SFR_BITS	P2_BITS		@ 0xA0;
static volatile	SFR_BITS	P5_BITS		@ 0xA1;
static volatile	SFR_BITS	P5CNT_BITS	@ 0xA2;
static volatile	SFR_BITS	C0C_BITS	@ 0xA3;
static volatile	SFR_BITS	C0S_BITS	@ 0xA4;
static volatile	SFR_BITS	C0IR_BITS	@ 0xA5;
static volatile	SFR_BITS	C0TE_BITS	@ 0xA6;
static volatile	SFR_BITS	C0RE_BITS	@ 0xA7;
static 		SFR_BITS	IE_BITS		@ 0xA8;
static volatile	SFR_BITS	C0M1C_BITS	@ 0xAB;
static volatile	SFR_BITS	C0M2C_BITS	@ 0xAC;
static volatile	SFR_BITS	C0M3C_BITS	@ 0xAD;
static volatile	SFR_BITS	C0M4C_BITS	@ 0xAE;
static volatile	SFR_BITS	C0M5C_BITS	@ 0xAF;
static volatile	SFR_BITS	P3_BITS		@ 0xB0;
static volatile	SFR_BITS	C0M6C_BITS	@ 0xB3;
static volatile	SFR_BITS	C0M7C_BITS	@ 0xB4;
static volatile	SFR_BITS	C0M8C_BITS	@ 0xB5;
static volatile	SFR_BITS	C0M9C_BITS	@ 0xB6;
static volatile	SFR_BITS	C0M10C_BITS	@ 0xB7;
static 		SFR_BITS	IP_BITS		@ 0xB8;
static volatile	SFR_BITS	C0M11C_BITS	@ 0xBB;
static volatile	SFR_BITS	C0M12C_BITS	@ 0xBC;
static volatile	SFR_BITS	C0M13C_BITS	@ 0xBD;
static volatile	SFR_BITS	C0M14C_BITS	@ 0xBE;
static volatile	SFR_BITS	C0M15C_BITS	@ 0xBF;
static volatile	SFR_BITS	SCON1_BITS	@ 0xC0;
static 		SFR_BITS	PMR_BITS	@ 0xC4;
static volatile	SFR_BITS	STATUS_BITS	@ 0xC5;
static 		SFR_BITS	MCON_BITS	@ 0xC6;
static volatile	SFR_BITS	T2CON_BITS	@ 0xC8;
static 		SFR_BITS	T2MOD_BITS	@ 0xC9;
static 		SFR_BITS	COR_BITS	@ 0xCE;
static volatile	SFR_BITS	PSW_BITS	@ 0xD0;
static volatile	SFR_BITS	MCNT0_BITS	@ 0xD1;
static volatile	SFR_BITS	MCNT1_BITS	@ 0xD2;
static volatile	SFR_BITS	WDCON_BITS	@ 0xD8;
static volatile	SFR_BITS	C1C_BITS	@ 0xE3;
static volatile	SFR_BITS	C1S_BITS	@ 0xE4;
static volatile	SFR_BITS	C1IR_BITS	@ 0xE5;
static 		SFR_BITS	EIE_BITS	@ 0xE8;
static 		SFR_BITS	C1M1C_BITS	@ 0xEB;
static 		SFR_BITS	C1M2C_BITS	@ 0xEC;
static 		SFR_BITS	C1M3C_BITS	@ 0xED;
static 		SFR_BITS	C1M4C_BITS	@ 0xEE;
static 		SFR_BITS	C1M5C_BITS	@ 0xEF;
static volatile SFR_BITS	B_BITS		@ 0xF0;
static 		SFR_BITS	C1M6C_BITS	@ 0xF3;
static 		SFR_BITS	C1M7C_BITS	@ 0xF4;
static 		SFR_BITS	C1M8C_BITS	@ 0xF5;
static 		SFR_BITS	C1M9C_BITS	@ 0xF6;
static 		SFR_BITS	C1M10C_BITS	@ 0xF7;
static 		SFR_BITS	EIP_BITS	@ 0xF8;
static 		SFR_BITS	C1M11C_BITS	@ 0xFB;
static 		SFR_BITS	C1M12C_BITS	@ 0xFC;
static 		SFR_BITS	C1M13C_BITS	@ 0xFD;
static 		SFR_BITS	C1M14C_BITS	@ 0xFE;
static 		SFR_BITS	C1M15C_BITS	@ 0xFF;

//Bit Addressable Locations
//Port 4
static volatile bit	P40	@ 0x80;
static volatile bit	P41	@ 0x81;
static volatile bit	P42	@ 0x82;
static volatile bit	P43	@ 0x83;
static volatile bit	P44	@ 0x84;
static volatile bit	P45	@ 0x85;
static volatile bit	P46	@ 0x86;
static volatile bit	P47	@ 0x87;
// Alternate Functions
static volatile bit	CE0	@ 0x80;
static volatile bit	CE1	@ 0x81;
static volatile bit	CE2	@ 0x82;
static volatile bit	CE3	@ 0x83;
static volatile bit	A16	@ 0x84;
static volatile bit	A17	@ 0x85;
static volatile bit	A18	@ 0x86;
static volatile bit	A19	@ 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
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 T2		@ 0x90;
static volatile bit T2EX	@ 0x91;
static volatile bit RXD1	@ 0x92;
static volatile bit TXD1	@ 0x93;
static volatile bit INT2	@ 0x94;
static volatile bit INT3	@ 0x95;
static volatile bit INT4	@ 0x96;
static volatile bit INT5	@ 0x97;

//Serial Control 0 SCON0
static volatile	bit RI_0	@ 0x98;
static volatile	bit TI_0	@ 0x99;
static volatile	bit RB8_0	@ 0x9A;
static 		bit TB8_0	@ 0x9B;
static 		bit REN_0	@ 0x9C;
static 		bit SM2_0	@ 0x9D;
static 		bit SM1_0	@ 0x9E;
static volatile	bit SM0_0	@ 0x9F;
// Alternate Function
static volatile	bit FE_0	@ 0x9F;

//Port 2
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;
// Alternate Functions
static volatile bit A8		@ 0xA0;
static volatile bit A9		@ 0xA1;
static volatile bit A10		@ 0xA2;
static volatile bit A11		@ 0xA3;
static volatile bit A12		@ 0xA4;
static volatile bit A13		@ 0xA5;
static volatile bit A14		@ 0xA6;
static volatile bit A15		@ 0xA7;

//Interrupt Enable IE
static 		bit EX0		@ 0xA8;
static 		bit ET0		@ 0xA9;
static 		bit EX1		@ 0xAA;	
static 		bit ET1		@ 0xAB;
static 		bit ES0		@ 0xAC;
static 		bit ET2		@ 0xAD;
static 		bit ES1		@ 0xAE;
static 		bit EA		@ 0xAF;

//Port 3
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;
// Alternate Functions
static volatile bit RXD0	@ 0xB0;
static volatile bit TXD0	@ 0xB1;
static volatile bit INT0	@ 0xB2;
static volatile bit INT1	@ 0xB3;
static volatile bit T0		@ 0xB4;
static volatile bit T1		@ 0xB5;
static volatile bit WR		@ 0xB6;
static volatile bit RD		@ 0xB7;
static volatile bit XCLKT1	@ 0xB5;

//Interrupt Priority IP
static 		bit PX0		@ 0xB8;
static 		bit PT0		@ 0xB9;
static 		bit PX1		@ 0xBA;
static 		bit PT1		@ 0xBB;
static 		bit PS0		@ 0xBC;
static 		bit PT2		@ 0xBD;
static 		bit PS1		@ 0xBE;

//Serial Control 1 SCON1
static volatile	bit RI_1	@ 0xC0;
static volatile	bit TI_1	@ 0xC1;
static volatile	bit RB8_1	@ 0xC2;
static 		bit TB8_1	@ 0xC3;
static 		bit REN_1	@ 0xC4;
static 		bit SM2_1	@ 0xC5;
static 		bit SM1_1	@ 0xC6;
static volatile	bit SM0_1	@ 0xC7;
// Alternate Function
static volatile	bit FE_1	@ 0xC7;

//Timer 2 Control T2CON
static 		bit	CPRL2	@ 0xC8;
static 		bit	CT2	@ 0xC9;
static 		bit	TR2	@ 0xCA;
static 		bit	EXEN2	@ 0xCB;
static volatile	bit	TCLK	@ 0xCC;
static volatile	bit	RCLK	@ 0xCD;
static volatile	bit	EXF2	@ 0xCE;
static volatile	bit	TF2	@ 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;

//Watchdog Control WDCON
static volatile bit	RWT	@ 0xD8;
static		bit	EWT	@ 0xD9;
static volatile bit	WTRF	@ 0xDA;
static volatile bit	WDIF	@ 0xDB;
static volatile bit	PFI	@ 0xDC;
static		bit	EPFI	@ 0xDD;
static volatile bit	POR	@ 0xDE;
static volatile bit	SMOD_1	@ 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;

//Extended Interrupt Enable EIE
static		bit	EX2	@ 0xE8;
static		bit	EX3	@ 0xE9;
static		bit	EX4	@ 0xEA;
static		bit	EX5	@ 0xEB;
static		bit	EWDI	@ 0xEC;
static		bit	C1IE	@ 0xED;
static		bit	C0IE	@ 0xEE;
static		bit	CANBIE	@ 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;

//Extended Interrupt Priority EIP
static		bit	PX2	@ 0xF8;
static		bit	PX3	@ 0xF9;
static		bit	PX4	@ 0xFA;
static		bit	PX5	@ 0xFB;
static		bit	PWDI	@ 0xFC;
static		bit	C1IP	@ 0xFD;
static		bit	C0IP	@ 0xFE;
static		bit	CANBIP	@ 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	PF	0x33
#define	S1	0x3B
#define	EXTINT2	0x43
#define	EXTINT3	0x4B
#define	EXTINT4	0x53
#define	EXTINT5	0x5B
#define	CAN0	0x6B
#define	CAN1	0x73
#define	WDTI	0x63
#define	CANBUS	0x7B

#endif	
