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

/*header file for the TI microcontroller
	TUSB5152
 */

#ifndef	__TUSB5152_H

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

// external USB registers
static volatile xdata unsigned char	FUNADR		@ 0xFFFF;	// address register
static volatile xdata unsigned char	USBSTA		@ 0xFFFE;	// status register
static		xdata unsigned char	USBMSK		@ 0xFFFD;	// interrupt mask register
static volatile xdata unsigned char	USBCTL		@ 0xFFFC;	// control register
static		xdata unsigned char	HUBVIDH		@ 0xFFFB;	// VID high-byte register
static		xdata unsigned char	HUBVIDL		@ 0xFFFA;	// VID low-byte register
static		xdata unsigned char	HUBPIDH		@ 0xFFF9;	// PID high-byte register
static		xdata unsigned char	HUBPIDL		@ 0xFFF8;	// PID low-byte register
static		xdata unsigned char	HUBCNF1		@ 0xFFF7;	// register
static		xdata unsigned char	HUBCNF2		@ 0xFFF6;	// register
static volatile xdata unsigned char	HUBPOTG		@ 0xFFF5;	// power-on to power-good descriptor
static volatile xdata unsigned char	I2CADR		@ 0xFFF3;	// address register
static volatile xdata unsigned char	I2CDATI		@ 0xFFF2;	// data input register
static volatile xdata unsigned char	I2CDATO		@ 0xFFF1;	// data output register
static volatile xdata unsigned char	I2CSTA		@ 0xFFF0;	// status register
static volatile xdata unsigned char	DMACSR5		@ 0xFFE9;	// Control and status register
static volatile xdata unsigned char	DMACDR5		@ 0xFFE8;	// Channel definition register
static volatile xdata unsigned char	DMACSR4		@ 0xFFE7;	// Control and status register
static volatile xdata unsigned char	DMACDR4		@ 0xFFE6;	// Channel definition register
static volatile xdata unsigned char	DMACSR3		@ 0xFFE5;	// Control and status register
static volatile xdata unsigned char	DMACDR3		@ 0xFFE4;	// Channel definition register
static volatile xdata unsigned char	DMACSR2		@ 0xFFE3;	// Control and status register
static volatile xdata unsigned char	DMACDR2		@ 0xFFE2;	// Channel definition register
static volatile xdata unsigned char	DMACSR1		@ 0xFFE1;	// Control and status register
static volatile xdata unsigned char	DMACDR1		@ 0xFFE0;	// Channel definition register
static		xdata unsigned char	MASK2		@ 0xFFBB;	// Interrupt mask register
static volatile xdata unsigned char	XOFF2		@ 0xFFBA;	// Xoff register
static volatile xdata unsigned char	XON2		@ 0xFFB9;	// Xon register
static		xdata unsigned char	DLH2		@ 0xFFB8;	// Divisor high-byte register
static		xdata unsigned char	DLL2		@ 0xFFB7;	// Divisor low-byte register
static volatile xdata unsigned char	MSR2		@ 0xFFB6;	// Modem status register
static volatile xdata unsigned char	LSR2		@ 0xFFB5;	// Line status register
static volatile xdata unsigned char	MCR2		@ 0xFFB4;	// Modem control register
static volatile xdata unsigned char	FCRL2		@ 0xFFB3;	// Flow control register
static volatile xdata unsigned char	LCR2		@ 0xFFB2;	// Line control registers
static volatile xdata unsigned char	TDR2		@ 0xFFB1;	// Transmitter data registers
static volatile xdata unsigned char	RDR2		@ 0xFFB0;	// Receiver data registers
static		xdata unsigned char	MASK1		@ 0xFFAB;	// Interrupt mask register
static volatile xdata unsigned char	XOFF1		@ 0xFFAA;	// Xoff register
static volatile xdata unsigned char	XON1		@ 0xFFA9;	// Xon register
static volatile xdata unsigned char	DLH1		@ 0xFFA8;	// Divisor high-byte register
static volatile xdata unsigned char	DLL1		@ 0xFFA7;	// Divisor low-byte register
static volatile xdata unsigned char	MSR1		@ 0xFFA6;	// Modem status register
static volatile xdata unsigned char	LSR1		@ 0xFFA5;	// Line status register
static volatile xdata unsigned char	MCR1		@ 0xFFA4;	// Modem control register
static volatile xdata unsigned char	FCRL1		@ 0xFFA3;	// Flow control register
static volatile xdata unsigned char	LCR1		@ 0xFFA2;	// Line control registers
static volatile xdata unsigned char	TDR1		@ 0xFFA1;	// Transmitter data registers
static volatile xdata unsigned char	RDR1		@ 0xFFA0;	// Receiver data registers
static volatile xdata unsigned char	PPADR		@ 0xFF9F;	// address register
static volatile xdata unsigned char	PPDAT		@ 0xFF9E;	// data register
static volatile xdata unsigned char	PPCTL		@ 0xFF9D;	// control register
static volatile xdata unsigned char	PPSTA		@ 0xFF9C;	// status register
static		xdata unsigned char	PPIMSK		@ 0xFF9B;	// interrupt mask register
static		xdata unsigned char	PPMCR		@ 0xFF9A;	// mode control register
static volatile xdata unsigned char	PPCNT		@ 0xFF99;	// counter register
static volatile xdata unsigned char	OEPINT		@ 0xFF94;	// endpoint interrupt register
static volatile xdata unsigned char	IEPINT		@ 0xFF93;	// endpoint interrupt register
static volatile xdata unsigned char	VECINT		@ 0xFF92;	// interrupt register
static volatile xdata unsigned char	GLOBCTL		@ 0xFF91;	// control register
static		xdata unsigned char	ROMS		@ 0xFF90;	// shadow configuration register
static volatile xdata unsigned char	OEPBCNT_0	@ 0xFF83;	// endpoint_0: Byte count register
static		xdata unsigned char	OEPCNFG_0	@ 0xFF82;	// endpoint_0: Configuration register
static volatile xdata unsigned char	IEPBCNT_0	@ 0xFF81;	// endpoint_0: Byte count register
static		xdata unsigned char	IEPCNFG_0	@ 0xFF80;	// endpoint_0: Configuration register
static		xdata unsigned char	IEPCNF_7	@ 0xFF78;	// endpoint_7: Configuration
static		xdata unsigned char	IEPCNF_6	@ 0xFF70;	// endpoint_6: Configuration
static		xdata unsigned char	IEPCNF_5	@ 0xFF68;	// endpoint_5: Configuration
static		xdata unsigned char	IEPCNF_4	@ 0xFF60;	// endpoint_4: Configuration
static		xdata unsigned char	IEPCNF_3	@ 0xFF58;	// endpoint_3: Configuration
static		xdata unsigned char	IEPCNF_2	@ 0xFF50;	// endpoint_2: Configuration
static		xdata unsigned char	IEPCNF_1	@ 0xFF48;	// endpoint_1: Configuration
static		xdata unsigned char	OEPCNF_7	@ 0xFF38;	// endpoint_7: Configuration
static		xdata unsigned char	OEPCNF_6	@ 0xFF30;	// endpoint_6: Configuration
static		xdata unsigned char	OEPCNF_5	@ 0xFF28;	// endpoint_5: Configuration
static		xdata unsigned char	OEPCNF_4	@ 0xFF20;	// endpoint_4: Configuration
static		xdata unsigned char	OEPCNF_3	@ 0xFF18;	// endpoint_3: Configuration
static		xdata unsigned char	OEPCNF_2	@ 0xFF10;	// endpoint_2: Configuration
static		xdata unsigned char	OEPCNF_1	@ 0xFF08;	// endpoint_1: Configuration
static volatile xdata unsigned char	INEND07		@ 0xFEFF;	// endpoint_0 buffer 7
static volatile xdata unsigned char	INEND06		@ 0xFEFE;	// endpoint_0 buffer 6
static volatile xdata unsigned char	INEND05		@ 0xFEFD;	// endpoint_0 buffer 5
static volatile xdata unsigned char	INEND04		@ 0xFEFC;	// endpoint_0 buffer 4
static volatile xdata unsigned char	INEND03		@ 0xFEFB;	// endpoint_0 buffer 3
static volatile xdata unsigned char	INEND02		@ 0xFEFA;	// endpoint_0 buffer 2
static volatile xdata unsigned char	INEND01		@ 0xFEF9;	// endpoint_0 buffer 1
static volatile xdata unsigned char	INEND00		@ 0xFEF8;	// endpoint_0 buffer 0
static volatile xdata unsigned char	OUTEND07	@ 0xFEF7;	// endpoint_0 buffer 7
static volatile xdata unsigned char	OUTEND06	@ 0xFEF6;	// endpoint_0 buffer 6
static volatile xdata unsigned char	OUTEND05	@ 0xFEF5;	// endpoint_0 buffer 5
static volatile xdata unsigned char	OUTEND04	@ 0xFEF4;	// endpoint_0 buffer 4
static volatile xdata unsigned char	OUTEND03	@ 0xFEF3;	// endpoint_0 buffer 3
static volatile xdata unsigned char	OUTEND02	@ 0xFEF2;	// endpoint_0 buffer 2
static volatile xdata unsigned char	OUTEND01	@ 0xFEF1;	// endpoint_0 buffer 1
static volatile xdata unsigned char	OUTEND00	@ 0xFEF0;	// endpoint_0 buffer 0

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