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

/* This is a header file for the Phillips Microcontrollers
	P83C270
	P83C370
	P83C570
	P83C770
	P87C770
*/

#ifndef __P8XCX70_H
#define __P8XCX70_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 PWM0	@ 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 P1	@ 0x90;
static		unsigned char STBCON	@ 0x92;
static		unsigned char PWM1	@ 0x96;
static volatile unsigned char IRQ1	@ 0x98;
static volatile unsigned char P2	@ 0xA0;
static		unsigned char PWM2	@ 0xA6;
static		unsigned char IEN0	@ 0xA8;
static volatile unsigned char P3	@ 0xB0;
static		unsigned char PWM3	@ 0xB6;
static		unsigned char SL	@ 0xB7;
static		unsigned char IP0	@ 0xB8;
static		unsigned char PWM4	@ 0xC6;
static volatile unsigned char PSW	@ 0xD0;
static		unsigned char PWM5	@ 0xD6;
static volatile unsigned char CCDATA1	@ 0xD7;
static volatile unsigned char S1CON	@ 0xD8;
static volatile unsigned char S1STA	@ 0xD9;
static volatile unsigned char S1DAT	@ 0xDA;
static volatile unsigned char S1ADR	@ 0xDB;
static volatile unsigned char ACC	@ 0xE0;
static		unsigned char PWM6	@ 0xE6;
static volatile unsigned char CCDATA2	@ 0xE7;
static		unsigned char IEN1	@ 0xE8;
static volatile unsigned char AFCON	@ 0xEA;
static volatile unsigned char BWC	@ 0xEB;
static volatile unsigned char B		@ 0xF0;
static		unsigned char P1SEL	@ 0xF4;
static		unsigned char PWM8	@ 0xF5;
static		unsigned char PWM7	@ 0xF6;
static		unsigned char IP1	@ 0xF8;
static volatile unsigned char WDT	@ 0xFF;

static volatile SFR_BITS P0_BITS		@ 0x80;
static		SFR_BITS PWM0_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 P1_BITS		@ 0x90;
static		SFR_BITS STBCON_BITS		@ 0x92;
static		SFR_BITS PWM1_BITS		@ 0x96;
static volatile SFR_BITS IRQ1_BITS		@ 0x98;
static volatile SFR_BITS P2_BITS		@ 0xA0;
static		SFR_BITS PWM2_BITS		@ 0xA6;
static		SFR_BITS IEN0_BITS		@ 0xA8;
static volatile SFR_BITS P3_BITS		@ 0xB0;
static		SFR_BITS PWM3_BITS		@ 0xB6;
static		SFR_BITS IP0_BITS		@ 0xB8;
static		SFR_BITS PWM4_BITS		@ 0xC6;
static volatile SFR_BITS PSW_BITS		@ 0xD0;
static		SFR_BITS PWM5_BITS		@ 0xD6;
static volatile SFR_BITS S1CON_BITS		@ 0xD8;
static volatile SFR_BITS S1STA_BITS		@ 0xD9;
static volatile SFR_BITS S1ADR_BITS		@ 0xDB;
static volatile SFR_BITS ACC_BITS		@ 0xE0;
static		SFR_BITS PWM6_BITS		@ 0xE6;
static		SFR_BITS IEN1_BITS		@ 0xE8;
static volatile SFR_BITS AFCON_BITS		@ 0xEA;
static volatile SFR_BITS BWC_BITS		@ 0xEB;
static volatile SFR_BITS B_BITS			@ 0xF0;
static		SFR_BITS P1SEL_BITS		@ 0xF4;
static		SFR_BITS PWM8_BITS		@ 0xF5;
static		SFR_BITS PWM7_BITS		@ 0xF6;
static		SFR_BITS IP1_BITS		@ 0xF8;

//Bit Addressable Locations
//Port 0 P0
static volatile bit	A8	@ 0x80;
static volatile bit	A9	@ 0x81;
static volatile bit	A10	@ 0x82;
static volatile bit	A11	@ 0x83;
static volatile bit	A12	@ 0x84;
static volatile bit	A13	@ 0x85;
static volatile bit	A14	@ 0x86;
static volatile bit	A15	@ 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	OE	@ 0x90;
static volatile bit	OTPSEL0	@ 0x91;
static volatile bit	OTPSEL1	@ 0x92;
static volatile bit	OTPSEL2	@ 0x93;
static volatile bit	P14	@ 0x94;
static volatile bit	P15	@ 0x95;
static volatile bit	P16	@ 0x96;
static volatile bit	P17	@ 0x97;

//Interrupt Request Register IRQ1
static volatile bit	RBUSY	@ 0x9D;
static volatile bit	RCC	@ 0x9E;

//Port 2 P2
static volatile bit	A0	@ 0xA0;
static volatile bit	A1	@ 0xA1;
static volatile bit	A2	@ 0xA2;
static volatile bit	A3	@ 0xA3;
static volatile bit	A4	@ 0xA4;
static volatile bit	A5	@ 0xA5;
static volatile bit	A6	@ 0xA6;
static volatile bit	A7	@ 0xA7;

//Interrupt Enable 0 IEN0
static 		bit 	EX0 	@ 0xA8;
static 		bit 	ET0 	@ 0xA9;
static 		bit 	EX1 	@ 0xAA;
static 		bit 	ET1 	@ 0xAB;
static 		bit 	ES1 	@ 0xAD;
static 		bit 	EA	@ 0xAF;

//Port 3 P3
static volatile bit	D0	@ 0xB0;
static volatile bit	D1	@ 0xB1;
static volatile bit	D2	@ 0xB2;
static volatile bit	D3	@ 0xB3;
static volatile bit	D4	@ 0xB4;
static volatile bit	D5	@ 0xB5;
static volatile bit	D6	@ 0xB6;
static volatile bit	D7	@ 0xB7;

//Interrupt Priority 0 IP0
static 		bit 	PX0 	@ 0xB8;
static 		bit 	PT0 	@ 0xB9;
static 		bit 	PX1 	@ 0xBA;
static 		bit 	PT1 	@ 0xBB;
static 		bit 	PS1 	@ 0xBD;

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

//Serial Control 1 S1CON
static 		bit 	CR0 	@ 0xD8;
static 		bit 	CR1 	@ 0xD9;
static volatile bit 	AA	@ 0xDA;
static volatile bit 	SI	@ 0xDB;
static volatile bit 	STO 	@ 0xDC;
static volatile bit 	STA 	@ 0xDD;
static 		bit 	ENS1	@ 0xDE;
static 		bit 	CR2 	@ 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;

//Interrupt Enable 1 IEN1
static 		bit 	EBUSY	@ 0xED;
static 		bit 	ECC	@ 0xEE;

//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 	PBUSY	@ 0xFD;
static 		bit 	PCC	@ 0xFE;


//Interrupt Vectors
#define	RESET	0
#define	EXTINT0	0x03
#define TIMER0	0x0B
#define	EXTINT1	0x13
#define	TIMER1	0x1B
#define	I2CBUS	0x2B
#define	BUSY	0x63
#define	CC	0x6B

#endif
