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


/* header file for the TI microcontroller
	TUSB3200
 */

#ifndef	__TUSB3200_H

#define	__TUSB3200_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	P0	@ 0x80;
static volatile unsigned char	SP	@ 0x81;
static volatile unsigned char	DPL	@ 0x82;
static volatile unsigned char	DPH	@ 0x83;
// 16 bit definition
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	SCON	@ 0x98;
static volatile unsigned char	SBUF	@ 0x99;
static volatile unsigned char	P2	@ 0xA0;
static 		unsigned char	IE	@ 0xA8;
static volatile unsigned char	P3	@ 0xB0;
static 		unsigned char	IP	@ 0xB8;
static volatile unsigned char	TL2	@ 0xCC;
static volatile unsigned char	TH2	@ 0xCD;
static volatile unsigned char	PSW	@ 0xD0;
static volatile unsigned char	ACC	@ 0xE0;
static volatile unsigned char	B	@ 0xF0;

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	SCON_BITS	@ 0x98;
static volatile SFR_BITS	P2_BITS		@ 0xA0;
static 		SFR_BITS	IE_BITS		@ 0xA8;
static volatile SFR_BITS	P3_BITS		@ 0xB0;
static 		SFR_BITS	IP_BITS		@ 0xB8;
static volatile SFR_BITS	PSW_BITS	@ 0xD0;
static volatile SFR_BITS	ACC_BITS	@ 0xE0;
static volatile SFR_BITS	B_BITS		@ 0xF0;

// Registers mapped into the external data space */
static volatile xdata unsigned char	USBFADR		@ 0xFFFF;	// function address register
static volatile xdata unsigned char	USBSTA		@ 0xFFFE;	// status register
static		xdata unsigned char	USBIMSK		@ 0xFFFD;	// interrupt mask register
static volatile xdata unsigned char	USBCTL		@ 0xFFFC;	// control register
static volatile xdata unsigned char	USBFNL		@ 0xFFFB;	// frame number register (low byte)
static volatile xdata unsigned char	USBFNH		@ 0xFFFA;	// frame number register (high byte)
static volatile xdata unsigned char	DMATSL3		@ 0xFFF9;	// channel 3 time slot assignment register (low byte)
static volatile xdata unsigned char	DMATSH3		@ 0xFFF8;	// channel 3 time slot assignment register (high byte)
static volatile xdata unsigned char	DMACTL3		@ 0xFFF7;	// channel 3 control register
static volatile xdata unsigned char	DMATSL2		@ 0xFFF6;	// channel 2 time slot assignment register (low byte)
static volatile xdata unsigned char	DMATSH2		@ 0xFFF5;	// channel 2 time slot assignment register (high byte)
static volatile xdata unsigned char	DMACTL2		@ 0xFFF4;	// channel 2 control register
static volatile xdata unsigned char	DMATSL1		@ 0xFFF0;	// channel 1 time slot assignment register (low byte)
static volatile xdata unsigned char	DMATSH1		@ 0xFFEF;	// channel 1 time slot assignment register (high byte)
static volatile xdata unsigned char	DMACTL1		@ 0xFFEE;	// channel 1 control register
static volatile xdata unsigned char	DMATSL0		@ 0xFFEA;	// channel 0 time slot assignment register (low byte)
static volatile xdata unsigned char	DMATSH0		@ 0xFFE9;	// Channel 0 time slot assignment register (high byte)
static volatile xdata unsigned char	DMACTL0		@ 0xFFE8;	// channel 0 control register
static		xdata unsigned char	ACGFRQ0		@ 0xFFE7;	// clock generator frequency register (byte 0)
static		xdata unsigned char	ACGFRQ1		@ 0xFFE6;	// clock generator frequency register (byte 1)
static		xdata unsigned char	ACGFRQ2		@ 0xFFE5;	// clock generator frequency register (byte 2)
static volatile xdata unsigned char	ACGCAPL		@ 0xFFE4;	// clock generator mclk capture register (low byte)
static volatile xdata unsigned char	ACGCAPH		@ 0xFFE3;	// clock generator mclk capture register (high byte)
static		xdata unsigned char	ACGDCTL		@ 0xFFE2;	// clock generator divider control register
static volatile xdata unsigned char	ACGCTL		@ 0xFFE1;	// clock generator control register
static		xdata unsigned char	CPTCNF1		@ 0xFFE0;	// port interface configuration register 1
static		xdata unsigned char	CPTCNF2		@ 0xFFDF;	// port interface configuration register 2
static		xdata unsigned char	CPTCNF3		@ 0xFFDE;	// port interface configuration register 3
static		xdata unsigned char	CPTCNF4		@ 0xFFDD;	// port interface configuration register 4
static volatile xdata unsigned char	CPTCTL		@ 0xFFDC;	// port interface control and status register
static volatile xdata unsigned char	CPTADR		@ 0xFFDB;	// port interface address register
static volatile xdata unsigned char	CPTDATL		@ 0xFFDA;	// port interface data register (low byte)
static volatile xdata unsigned char	CPTDATH		@ 0xFFD9;	// port interface data register (high byte)
static volatile xdata unsigned char	CPTVSLL		@ 0xFFD8;	// port interface valid slots register (low byte)
static volatile xdata unsigned char	CPTVSLH		@ 0xFFD7;	// port interface valid slots register (high byte)
static volatile xdata unsigned char	I2CADR		@ 0xFFC3;	// interface address register
static volatile xdata unsigned char	I2CDATI		@ 0xFFC2;	// interface receive data register
static volatile xdata unsigned char	I2CDATO		@ 0xFFC1;	// Interface Transmit Data Register
static volatile xdata unsigned char	I2CCTL		@ 0xFFC0;	// interface control and status register
static		xdata unsigned char	PWMFRQ		@ 0xFFBF;	// frequency register
static		xdata unsigned char	PWMPWL		@ 0xFFBE;	// pulse width register (low byte)
static		xdata unsigned char	PWMPWH		@ 0xFFBD;	// pulse width register (high byte)
static volatile xdata unsigned char	OEPINT		@ 0xFFB4;	// out endpoint interrupt register
static volatile xdata unsigned char	IEPINT		@ 0xFFB3;	// in endpoint interrupt register
static volatile xdata unsigned char	VECINT		@ 0xFFB2;	// vector register
static volatile xdata unsigned char	GLOBCTL		@ 0xFFB1;	// control register
static		xdata unsigned char	MEMCFG		@ 0xFFB0;	// configuration register
static volatile xdata unsigned char	OEPDCNTY0	@ 0xFFAF;	// endpoint 0 - Y buffer data count byte
static volatile xdata unsigned char	OEPBBAY0	@ 0xFFAD;	// endpoint 0 - Y buffer base address byte
static volatile xdata unsigned char	OEPDCNTX0	@ 0xFFAB;	// endpoint 0 - X buffer data count byte
static volatile xdata unsigned char	OEPBSIZ0	@ 0xFFAA;	// endpoint 0 - X and Y buffer size byte
static volatile xdata unsigned char	OEPBBAX0	@ 0xFFA9;	// endpoint 0 - X buffer base address byte
static		xdata unsigned char	OEPCNF0		@ 0xFFA8;	// endpoint 0 - configuration byte
static volatile xdata unsigned char	OEPDCNTY1	@ 0xFFA7;	// endpoint 1 - Y buffer data count byte
static volatile xdata unsigned char	OEPBBAY1	@ 0xFFA5;	// endpoint 1 - Y buffer base address byte
static volatile xdata unsigned char	OEPDCNTX1	@ 0xFFA3;	// endpoint 1 - X buffer data count byte
static volatile xdata unsigned char	OEPBSIZ1	@ 0xFFA2;	// endpoint 1 - X and Y buffer size byte
static volatile xdata unsigned char	OEPBBAX1	@ 0xFFA1;	// endpoint 1 - X buffer base address byte
static		xdata unsigned char	OEPCNF1		@ 0xFFA0;	// endpoint 1 - configuration byte
static volatile xdata unsigned char	OEPDCNTY2	@ 0xFF9F;	// endpoint 2 - Y buffer data count byte
static volatile xdata unsigned char	OEPBBAY2	@ 0xFF9D;	// endpoint 2 - Y buffer base address byte
static volatile xdata unsigned char	OEPDCNTX2	@ 0xFF9B;	// endpoint 2 - X buffer data count byte
static volatile xdata unsigned char	OEPBSIZ2	@ 0xFF9A;	// endpoint 2 - X and Y buffer size byte
static volatile xdata unsigned char	OEPBBAX2	@ 0xFF99;	// endpoint 2 - X buffer base address byte
static		xdata unsigned char	OEPCNF2		@ 0xFF98;	// endpoint 2 - configuration byte
static volatile xdata unsigned char	OEPDCNTY3	@ 0xFF97;	// endpoint 3 - Y buffer data count byte
static volatile xdata unsigned char	OEPBBAY3	@ 0xFF95;	// endpoint 3 - Y buffer base address byte
static volatile xdata unsigned char	OEPDCNTX3	@ 0xFF93;	// endpoint 3 - X buffer data count byte
static volatile xdata unsigned char	OEPBSIZ3	@ 0xFF92;	// endpoint 3 - X and Y buffer size byte
static volatile xdata unsigned char	OEPBBAX3	@ 0xFF91;	// endpoint 3 - X buffer base address byte
static		xdata unsigned char	OEPCNF3		@ 0xFF90;	// endpoint 3 - configuration byte
static volatile xdata unsigned char	OEPDCNTY4	@ 0xFF8F;	// endpoint 4 - Y buffer data count byte
static volatile xdata unsigned char	OEPBBAY4	@ 0xFF8D;	// endpoint 4 - Y buffer base address byte
static volatile xdata unsigned char	OEPDCNTX4	@ 0xFF8B;	// endpoint 4 - X buffer data count byte
static volatile xdata unsigned char	OEPBSIZ4	@ 0xFF8A;	// endpoint 4 - X and Y buffer size byte
static volatile xdata unsigned char	OEPBBAX4	@ 0xFF89;	// endpoint 4 - X buffer base address byte
static		xdata unsigned char	OEPCNF4		@ 0xFF88;	// endpoint 4 - configuration byte
static volatile xdata unsigned char	OEPDCNTY5	@ 0xFF87;	// endpoint 5 - Y buffer data count byte
static volatile xdata unsigned char	OEPBBAY5	@ 0xFF85;	// endpoint 5 - Y buffer base address byte
static volatile xdata unsigned char	OEPDCNTX5	@ 0xFF83;	// endpoint 5 - X buffer data count byte
static volatile xdata unsigned char	OEPBSIZ5	@ 0xFF82;	// endpoint 5 - X and Y buffer size byte
static volatile xdata unsigned char	OEPBBAX5	@ 0xFF81;	// endpoint 5 - X Buffer Base Address Byte
static		xdata unsigned char	OEPCNF5		@ 0xFF80;	// endpoint 5 - configuration byte
static volatile xdata unsigned char	OEPDCNTY6	@ 0xFF7F;	// endpoint 6 - Y buffer data count byte
static volatile xdata unsigned char	OEPBBAY6	@ 0xFF7D;	// endpoint 6 - Y buffer base address byte
static volatile xdata unsigned char	OEPDCNTX6	@ 0xFF7B;	// endpoint 6 - X buffer data count byte
static volatile xdata unsigned char	OEPBSIZ6	@ 0xFF7A;	// endpoint 6 - X and Y buffer size byte
static volatile xdata unsigned char	OEPBBAX6	@ 0xFF79;	// endpoint 6 - X buffer base address byte
static		xdata unsigned char	OEPCNF6		@ 0xFF78;	// endpoint 6 - configuration byte
static volatile xdata unsigned char	OEPDCNTY7	@ 0xFF77;	// endpoint 7 - Y buffer data count byte
static volatile xdata unsigned char	OEPBBAY7	@ 0xFF75;	// endpoint 7 - Y buffer base address byte
static volatile xdata unsigned char	OEPDCNTX7	@ 0xFF73;	// endpoint 7 - X buffer data count byte
static volatile xdata unsigned char	OEPBSIZ7	@ 0xFF72;	// endpoint 7 - X and Y buffer size byte
static volatile xdata unsigned char	OEPBBAX7	@ 0xFF71;	// endpoint 7 - X buffer base address byte
static		xdata unsigned char	OEPCNF7		@ 0xFF70;	// endpoint 7 - configuration byte
static volatile xdata unsigned char	IEPDCNTY0	@ 0xFF6F;	// endpoint 0 - Y buffer data count byte
static volatile xdata unsigned char	IEPBBAY0	@ 0xFF6D;	// endpoint 0 - Y buffer base address byte
static volatile xdata unsigned char	IEPDCNTX0	@ 0xFF6B;	// endpoint 0 - X buffer data count byte
static volatile xdata unsigned char	IEPBSIZ0	@ 0xFF6A;	// endpoint 0 - X and Y buffer size byte
static volatile xdata unsigned char	IEPBBAX0	@ 0xFF69;	// endpoint 0 - X buffer base address byte
static		xdata unsigned char	IEPCNF0		@ 0xFF68;	// endpoint 0 - configuration byte
static volatile xdata unsigned char	IEPDCNTY1	@ 0xFF67;	// endpoint 1 - Y buffer data count byte
static volatile xdata unsigned char	IEPBBAY1	@ 0xFF65;	// endpoint 1 - Y buffer base address byte
static volatile xdata unsigned char	IEPDCNTX1	@ 0xFF63;	// endpoint 1 - X buffer data count byte
static volatile xdata unsigned char	IEPBSIZ1	@ 0xFF62;	// endpoint 1 - X and Y buffer size byte
static volatile xdata unsigned char	IEPBBAX1	@ 0xFF61;	// endpoint 1 - X buffer base address byte
static		xdata unsigned char	IEPCNF1		@ 0xFF60;	// endpoint 1 - configuration byte
static volatile xdata unsigned char	IEPDCNTY2	@ 0xFF5F;	// endpoint 2 - Y buffer data count byte
static volatile xdata unsigned char	IEPBBAY2	@ 0xFF5D;	// endpoint 2 - Y buffer base address byte
static volatile xdata unsigned char	IEPDCNTX2	@ 0xFF5B;	// endpoint 2 - X buffer data count byte
static volatile xdata unsigned char	IEPBSIZ2	@ 0xFF5A;	// endpoint 2 - X and Y buffer size byte
static volatile xdata unsigned char	IEPBBAX2	@ 0xFF59;	// endpoint 2 - X buffer base address byte
static		xdata unsigned char	IEPCNF2		@ 0xFF58;	// endpoint 2 - configuration byte
static volatile xdata unsigned char	IEPDCNTY3	@ 0xFF57;	// endpoint 3 - Y buffer data count byte
static volatile xdata unsigned char	IEPBBAY3	@ 0xFF55;	// endpoint 3 - Y buffer base address byte
static volatile xdata unsigned char	IEPDCNTX3	@ 0xFF53;	// endpoint 3 - X buffer data count byte
static volatile xdata unsigned char	IEPBSIZ3	@ 0xFF52;	// endpoint 3 - X and Y buffer size byte
static volatile xdata unsigned char	IEPBBAX3	@ 0xFF51;	// endpoint 3 - X buffer base address byte
static		xdata unsigned char	IEPCNF3		@ 0xFF50;	// endpoint 3 - configuration byte
static volatile xdata unsigned char	IEPDCNTY4	@ 0xFF4F;	// endpoint 4 - Y buffer data count byte
static volatile xdata unsigned char	IEPBBAY4	@ 0xFF4D;	// endpoint 4 - Y buffer base address byte
static volatile xdata unsigned char	IEPDCNTX4	@ 0xFF4B;	// endpoint 4 - X buffer data count byte
static volatile xdata unsigned char	IEPBSIZ4	@ 0xFF4A;	// endpoint 4 - X and Y buffer size byte
static volatile xdata unsigned char	IEPBBAX4	@ 0xFF49;	// endpoint 4 - X buffer base address byte
static		xdata unsigned char	IEPCNF4		@ 0xFF48;	// endpoint 4 - configuration byte
static volatile xdata unsigned char	IEPDCNTY5	@ 0xFF47;	// endpoint 5 - Y buffer data count byte
static volatile xdata unsigned char	IEPBBAY5	@ 0xFF45;	// endpoint 5 - Y buffer base address byte
static volatile xdata unsigned char	IEPDCNTX5	@ 0xFF43;	// endpoint 5 - X buffer data count byte
static volatile xdata unsigned char	IEPBSIZ5	@ 0xFF42;	// endpoint 5 - X and Y buffer size byte
static volatile xdata unsigned char	IEPBBAX5	@ 0xFF41;	// endpoint 5 - X buffer base address byte
static		xdata unsigned char	IEPCNF5		@ 0xFF40;	// endpoint 5 - configuration byte
static volatile xdata unsigned char	IEPDCNTY6	@ 0xFF3F;	// endpoint 6 - Y buffer data count byte
static volatile xdata unsigned char	IEPBBAY6	@ 0xFF3D;	// endpoint 6 - Y buffer base address byte
static volatile xdata unsigned char	IEPDCNTX6	@ 0xFF3B;	// endpoint 6 - X buffer data count byte
static volatile xdata unsigned char	IEPBSIZ6	@ 0xFF3A;	// endpoint 6 - X and Y buffer size byte
static volatile xdata unsigned char	IEPBBAX6	@ 0xFF39;	// endpoint 6 - X buffer base address byte
static		xdata unsigned char	IEPCNF6		@ 0xFF38;	// endpoint 6 - configuration byte
static volatile xdata unsigned char	IEPDCNTY7	@ 0xFF37;	// endpoint 7 - Y buffer data count byte
static volatile xdata unsigned char	IEPBBAY7	@ 0xFF35;	// endpoint 7 - Y buffer base address byte
static volatile xdata unsigned char	IEPDCNTX7	@ 0xFF33;	// endpoint 7 - X buffer data count byte
static volatile xdata unsigned char	IEPBSIZ7	@ 0xFF32;	// endpoint 7 - X and Y buffer size byte
static volatile xdata unsigned char	IEPBBAX7	@ 0xFF31;	// endpoint 7 - X buffer base address byte
static		xdata unsigned char	IEPCNF7		@ 0xFF30;	// endpoint 7 - configuration byte

/* 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;
// Alternate Functions
static volatile bit	AD0	@ 0x80;
static volatile bit	AD1	@ 0x81;
static volatile bit	AD2	@ 0x82;
static volatile bit	AD3	@ 0x83;
static volatile bit	AD4	@ 0x84;
static volatile bit	AD5	@ 0x85;
static volatile bit	AD6	@ 0x86;
static volatile bit	AD7	@ 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;

//Serial Control SCON
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		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;
// 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	ES	@ 0xAC;
static 		bit	EA	@ 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;
// Alternate Functions
static volatile bit	RXD	@ 0xB0;
static volatile bit	TXD	@ 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;

//Interrupt Priority
static 		bit	PX0	@ 0xB8;
static 		bit	PT0	@ 0xB9;
static 		bit	PX1	@ 0xBA;
static 		bit	PT1	@ 0xBB;
static 		bit	PS	@ 0xBC;


//Program Status Word PSW
static volatile bit	P	@ 0xD0;
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;

//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;

//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;


/*	Interrupt vectors */
#define	RESET	0
#define	EXTINT0	0x03
#define TIMER0	0x0B
#define	EXTINT1	0x13
#define	TIMER1	0x1B
#define	SERIAL	0x23

#endif	
