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


 /* header file for the Philips microcontrollers
	P89LPC933
	P89LPC934
	P89LPC935
 */

#ifndef	__P89LPC933_H

#define	__P89LPC933_H

typedef struct {
	unsigned B7:1; //This is the most signifigant 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 P0M1	@ 0x84;
static		unsigned char P0M2	@ 0x85;
static		unsigned char KBMASK	@ 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 volatile unsigned char ADCON0	@ 0x8E;
static		unsigned char TAMOD	@ 0x8F;
static volatile unsigned char P1	@ 0x90;
static		unsigned char P1M1	@ 0x91;
static		unsigned char P1M2	@ 0x92;
static		unsigned char KBPATN	@ 0x93;
static volatile unsigned char KBCON	@ 0x94;
static		unsigned char DIVM	@ 0x95;
static		unsigned char TRIM	@ 0x96;
static volatile unsigned char ADCON1	@ 0x97;
static volatile unsigned char SCON	@ 0x98;
static volatile unsigned char SBUF	@ 0x99;
static volatile unsigned char P2	@ 0xA0;
static		unsigned char ADMODB	@ 0xA1;
static		unsigned char AUXR1	@ 0xA2;
static		unsigned char ADINS	@ 0xA3;
static		unsigned char P2M1	@ 0xA4;
static		unsigned char P2M2	@ 0xA5;
static		unsigned char AD0BL	@ 0xA6;
static volatile unsigned char WDCON	@ 0xA7;
static          unsigned char IEN0	@ 0xA8;
static          unsigned char SADDR	@ 0xA9;
static volatile unsigned char CMP1	@ 0xAC;
static volatile unsigned char CMP2	@ 0xAD;
static volatile unsigned char P3	@ 0xB0;
static		unsigned char P3M1	@ 0xB1;
static		unsigned char P3M2	@ 0xB2;
static volatile unsigned char PCONA	@ 0xB5;
static		unsigned char IP0H	@ 0xB7;
static          unsigned char IP0	@ 0xB8;
static          unsigned char SADEN	@ 0xB9;
static volatile unsigned char SSTAT	@ 0xBA;
static		unsigned char AD0BH	@ 0xBB;
static		unsigned char AD1BL	@ 0xBC;
static volatile unsigned char BRGCON	@ 0xBD;
static		unsigned char BRGR0	@ 0xBE;
static		unsigned char BRGR1	@ 0xBF;
static		unsigned char ADMODA	@ 0xC0;
static          unsigned char WDL	@ 0xC1;
static volatile unsigned char WFEED1	@ 0xC2;
static volatile unsigned char WFEED2	@ 0xC3;
static		unsigned char AD1BH	@ 0xC4;
static volatile unsigned char AD0DAT0	@ 0xC5;
static volatile unsigned char AD0DAT1	@ 0xC6;
static volatile unsigned char AD0DAT2	@ 0xC7;
static volatile unsigned char PSW	@ 0xD0;
static volatile unsigned char RTCCON	@ 0xD1;
static volatile unsigned char RTCH	@ 0xD2;
static volatile unsigned char RTCL	@ 0xD3;
static volatile unsigned char AD1DAT0	@ 0xD5;
static volatile unsigned char AD1DAT1	@ 0xD6;
static volatile unsigned char AD1DAT2	@ 0xD7;
static volatile unsigned char I2CON	@ 0xD8;
static volatile unsigned char I2STAT	@ 0xD9;
static volatile unsigned char I2DAT	@ 0xDA;
static		unsigned char I2ADR	@ 0xDB;
static		unsigned char I2SCLL	@ 0xDC;
static		unsigned char I2SCLH	@ 0xDD;
static volatile unsigned char RSTSRC	@ 0xDF;
static volatile unsigned char ACC	@ 0xE0;
static volatile unsigned char SPSTAT	@ 0xE1;
static volatile unsigned char SPCTL	@ 0xE2;
static volatile unsigned char SPDAT	@ 0xE3;
static volatile unsigned char FMCON	@ 0xE4;
static volatile unsigned char FMDATA	@ 0xE5;
static volatile unsigned char FMADRL	@ 0xE6;
static volatile unsigned char FMADRH	@ 0xE7;
static          unsigned char IEN1	@ 0xE8;
static volatile unsigned char B		@ 0xF0;
static volatile unsigned char AD0DAT3	@ 0xF4;
static volatile unsigned char AD1DAT3	@ 0xF5;
static		unsigned char PT0AD	@ 0xF6;
static		unsigned char IP1H	@ 0xF7;
static          unsigned char IP1	@ 0xF8;

static volatile SFR_BITS	 P0_BITS	@ 0x80;
static		SFR_BITS	 P0M1_BITS	@ 0x84;
static		SFR_BITS	 P0M2_BITS	@ 0x85;
static		SFR_BITS	 KBMASK_BITS	@ 0x86;
static volatile SFR_BITS	 PCON_BITS	@ 0x87;
static volatile SFR_BITS	 TCON_BITS	@ 0x88;
static          SFR_BITS	 TMOD_BITS	@ 0x89;
static volatile SFR_BITS	 ADCON0_BITS	@ 0x8E;
static		SFR_BITS	 TAMOD_BITS	@ 0x8F;
static volatile SFR_BITS	 P1_BITS	@ 0x90;
static		SFR_BITS	 P1M1_BITS	@ 0x91;
static		SFR_BITS	 P1M2_BITS	@ 0x92;
static volatile SFR_BITS	 KBCON_BITS	@ 0x94;
static		SFR_BITS	 TRIM_BITS	@ 0x96;
static volatile SFR_BITS	 ADCON1_BITS	@ 0x97;
static volatile SFR_BITS	 SCON_BITS	@ 0x98;
static volatile SFR_BITS	 P2_BITS	@ 0xA0;
static		SFR_BITS	 ADMODB_BITS	@ 0xA1;
static		SFR_BITS	 AUXR1_BITS	@ 0xA2;
static		SFR_BITS	 ADINS_BITS	@ 0xA3;
static		SFR_BITS	 P2M1_BITS	@ 0xA4;
static		SFR_BITS	 P2M2_BITS	@ 0xA5;
static volatile SFR_BITS	 WDCON_BITS	@ 0xA7;
static          SFR_BITS	 IEN0_BITS	@ 0xA8;
static          SFR_BITS	 SADDR_BITS	@ 0xA9;
static volatile SFR_BITS	 CMP1_BITS	@ 0xAC;
static volatile SFR_BITS	 CMP2_BITS	@ 0xAD;
static volatile SFR_BITS	 P3_BITS	@ 0xB0;
static		SFR_BITS	 P3M1_BITS	@ 0xB1;
static		SFR_BITS	 P3M2_BITS	@ 0xB2;
static volatile SFR_BITS	 PCONA_BITS	@ 0xB5;
static		SFR_BITS	 IP0H_BITS	@ 0xB7;
static          SFR_BITS	 IP0_BITS	@ 0xB8;
static          SFR_BITS	 SADEN_BITS	@ 0xB9;
static volatile SFR_BITS	 SSTAT_BITS	@ 0xBA;
static volatile SFR_BITS	 BRGCON_BITS	@ 0xBD;
static		SFR_BITS	 ADMODA_BITS	@ 0xC0;
static          SFR_BITS	 WDL_BITS	@ 0xC1;
static volatile SFR_BITS	 WFEED1_BITS	@ 0xC2;
static volatile SFR_BITS	 WFEED2_BITS	@ 0xC3;
static volatile SFR_BITS	 PSW_BITS	@ 0xD0;
static volatile SFR_BITS	 RTCCON_BITS	@ 0xD1;
static volatile SFR_BITS	 I2CON_BITS	@ 0xD8;
static volatile SFR_BITS	 I2STAT_BITS	@ 0xD9;
static volatile SFR_BITS	 I2DAT_BITS	@ 0xDA;
static		SFR_BITS	 I2SCLL_BITS	@ 0xDC;
static		SFR_BITS	 I2SCLH_BITS	@ 0xDD;
static volatile SFR_BITS	 RSTSRC_BITS	@ 0xDF;
static volatile SFR_BITS	 ACC_BITS	@ 0xE0;
static volatile SFR_BITS	 SPSTAT_BITS	@ 0xE1;
static volatile SFR_BITS	 SPCTL_BITS	@ 0xE2;
static volatile SFR_BITS	 SPDAT_BITS	@ 0xE3;
static volatile SFR_BITS	 FMCON_BITS	@ 0xE4;
static          SFR_BITS	 IEN1_BITS	@ 0xE8;
static volatile SFR_BITS	 B_BITS		@ 0xF0;
static		SFR_BITS	 PT0AD_BITS	@ 0xF6;
static		SFR_BITS	 IP1H_BITS	@ 0xF7;
static          SFR_BITS	 IP1_BITS	@ 0xF8;


// 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	CP2	@ 0x80;
static volatile bit	CIN2B	@ 0x81;
static volatile bit	CIN2A	@ 0x82;
static volatile bit	CIN1B	@ 0x83;
static volatile bit	CIN1A	@ 0x84;
static volatile bit	CMPREF	@ 0x85;
static volatile bit	CP1	@ 0x86;
static volatile bit	T1	@ 0x87;
// Alternate Functions
static volatile bit	KB0	@ 0x80;
static volatile bit	KB1	@ 0x81;
static volatile bit	KB2	@ 0x82;
static volatile bit	KB3	@ 0x83;
static volatile bit	KB4	@ 0x84;
static volatile bit	KB5	@ 0x85;
static volatile bit	KB6	@ 0x86;
static volatile bit	KB7	@ 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	TXD	@ 0x90;
static volatile bit	RXD	@ 0x91;
static volatile bit	SCL	@ 0x92;
static volatile bit	INT0	@ 0x93;
static volatile bit	INT1	@ 0x94;
static volatile bit	RST	@ 0x95;
static volatile bit	OCB	@ 0x96;
static volatile bit	OCC	@ 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 volatile bit	SM0	@ 0x9F;
// Alternate Functions
static volatile bit	FE	@ 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	ICB	@ 0xA0;
static volatile bit	OCD	@ 0xA1;
static volatile bit	MOSI	@ 0xA2;
static volatile bit	MISO	@ 0xA3;
static volatile bit	SS	@ 0xA4;
static volatile bit	SPICLK	@ 0xA5;
static volatile bit	OCA	@ 0xA6;
static volatile bit	ICA	@ 0xA7;

// Interrupt Enable 0 IEN0
static 		bit 	EX0 	@ 0xA8;
static 		bit 	ET0 	@ 0xA9;
static 		bit 	EX1 	@ 0xAA;
static 		bit 	ET1 	@ 0xAB;
static 		bit 	ES 	@ 0xAC;
static 		bit 	EBO 	@ 0xAD;
static 		bit 	EWDRT 	@ 0xAE;
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	XTAL2	@ 0xB0;
static volatile bit	XTAL1	@ 0xB1;

// Interrupt Priority 0 IP0
static 		bit 	PX0 	@ 0xB8;
static 		bit 	PTO 	@ 0xB9;
static 		bit 	PX1 	@ 0xBA;
static 		bit 	PT1 	@ 0xBB;
static 		bit 	PS 	@ 0xBC;
static 		bit 	PBO 	@ 0xBD;
static 		bit 	PWDRT 	@ 0xBE;

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

// I2C Control Register I2CON
static volatile	bit CRSEL 	@ 0xD8;
static volatile bit AA	 	@ 0xDA;
static volatile bit SI	 	@ 0xDB;
static volatile bit STO 	@ 0xDC;
static volatile bit STA 	@ 0xDD;
static volatile	bit I2EN	@ 0xDE;

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

// Interrupt Enable 1 IEN1
static 		bit 	EI2C	@ 0xE8;
static 		bit 	EKBI	@ 0xE9;
static 		bit 	EC	@ 0xEA;
static 		bit 	ESPI	@ 0xEB;
static 		bit 	ECCU	@ 0xEC;
static 		bit 	EST	@ 0xEE;
static 		bit 	EAD	@ 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;

// Interrupt Priority 1 IP1
static 		bit 	PI2C	@ 0xF8;
static 		bit 	PKBI	@ 0xF9;
static 		bit 	PC	@ 0xFA;
static 		bit 	PSPI	@ 0xFB;
static 		bit 	PCCU	@ 0xFC;
static 		bit 	PST	@ 0xFE;
static 		bit 	PAD	@ 0xFF;


// Interrupt Vectors
#define	RESET	0
#define	EXTINT0	0x03
#define TIMER0	0x0B
#define	EXTINT1	0x13
#define	TIMER1	0x1B
#define	SERIAL	0x23
#define	TIMER2	0x2B

#endif
