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

/* header file for Cypress EZ USB Microcontrollers
	AN2121S
	AN2122S
	AN2122T
	AN2125S
	AN2126S
	AN2126T
	AN2131Q
	AN2131S
	AN2135S
	AN2136S
*/

#ifndef	__EZ_USB_H

#define	__EZ_USB_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	SP	@ 0x81;
static volatile	unsigned char	DPL0	@ 0x82;
static volatile	unsigned char	DPH0	@ 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 		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	SPC_FNC	@ 0x8F;
static volatile	unsigned char	EXIF	@ 0x91;
static		unsigned char	MPAGE	@ 0x92;
static volatile	unsigned char	SCON0	@ 0x98;
static volatile	unsigned char	SBUF0	@ 0x99;
static 		unsigned char	IE	@ 0xA8;
static 		unsigned char	IP	@ 0xB8;
static volatile	unsigned char	SCON1	@ 0xC0;
static volatile	unsigned char	SBUF1	@ 0xC1;
static volatile	unsigned char	T2CON	@ 0xC8;
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 volatile	unsigned char	PSW	@ 0xD0;
static volatile	unsigned char	EICON	@ 0xD8;
static volatile	unsigned char	ACC	@ 0xE0;
static 		unsigned char	EIE	@ 0xE8;
static volatile	unsigned char	B	@ 0xF0;
static 		unsigned char	EIP	@ 0xF1;

static 		SFR_BITS	DPS_BITS	@ 0x86;
static 		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	SPC_FNC_BITS	@ 0x8F;
static volatile	SFR_BITS	EXIF_BITS	@ 0x91;
static volatile	SFR_BITS	SCON0_BITS	@ 0x98;
static 		SFR_BITS	IE_BITS		@ 0xA8;
static 		SFR_BITS	IP_BITS		@ 0xB8;
static volatile	SFR_BITS	SCON1_BITS	@ 0xC0;
static volatile	SFR_BITS	T2CON_BITS	@ 0xC8;
static volatile	SFR_BITS	PSW_BITS	@ 0xD0;
static volatile	SFR_BITS	EICON_BITS	@ 0xD8;
static volatile	SFR_BITS	ACC_BITS	@ 0xE0;
static 		SFR_BITS	EIE_BITS	@ 0xE8;
static volatile	SFR_BITS	B_BITS		@ 0xF0;
static 		SFR_BITS	EIP_BITS	@ 0xF1;

//Bit Addressable Locations
//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;

//Serial Control Register 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 		bit	SM0_0	@ 0x9F;

//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	ES2	@ 0xAD;
static 		bit	ES1	@ 0xAE;
static 		bit	EA	@ 0xAF;

//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 Register 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 		bit	SM0_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;

//EICON
static volatile	bit	INT6	@ 0xDB;
static volatile	bit	RESI	@ 0xDC;
static		bit	ERESI	@ 0xDD;
static		bit	SMOD1	@ 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;

//EIE
static 		bit	EUSB	@ 0xE8;
static 		bit	EI2C	@ 0xE9;
static 		bit	EX4	@ 0xEA;
static 		bit	EX5	@ 0xEB;
static 		bit	EWDI	@ 0xEC;

//EIP
static 		bit	PUSB	@ 0xF0;
static 		bit	PI2C	@ 0xF1;
static 		bit	PX4	@ 0xF2;
static 		bit	PX5	@ 0xF3;
static 		bit	PX6	@ 0xF4;

/*	Interrupt vectors */
#define	RESET	0
#define	EXTINT0	0x03
#define	TIMER0	0x0B
#define	EXTINT1	0x13
#define	TIMER1	0x1B
#define	SERIAL	0x23
#define	TIMER2	0x2B
#define	USBWAKE	0x33
#define	S1	0x3B
#define	EXTINT2	0x43
#define	EXTINT3	0x4B
#define	EXTINT4	0x53
#define	EXTINT5	0x5B
#define	EXTINT6	0x63

#endif	
