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

/* This is a header file for the Philips Microcontroller
	PCD6001
*/

#ifndef __PCD6001_H
#define __PCD6001_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 SP	@ 0x81;
static volatile unsigned char DPL	@ 0x82;
static volatile unsigned char DPH	@ 0x83;
// 16 bit definition
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 volatile unsigned char P4	@ 0x98;
static		unsigned char SPCON	@ 0x99;
static		unsigned char CKCON	@ 0x9A;
static volatile unsigned char RTCON	@ 0x9B;
static		unsigned char P4CFG	@ 0x9F;
static volatile unsigned char DTM0	@ 0xA2;
static volatile unsigned char DTM1	@ 0xA3;
static volatile unsigned char DTM2	@ 0xA4;
static volatile unsigned char MTD0	@ 0xA5;
static volatile unsigned char MTD1	@ 0xA6;
static volatile unsigned char MTD2	@ 0xA7;
static		unsigned char IEN0	@ 0xA8;
static		unsigned char MCSC	@ 0xA9;
static volatile unsigned char MCSD	@ 0xAA;
static		unsigned char ALTP	@ 0xAB;
static volatile unsigned char P3	@ 0xB0;
static volatile unsigned char PMTR1	@ 0xB5;
static volatile unsigned char PMTR2	@ 0xB6;
static volatile unsigned char CDTR2	@ 0xB7;
static		unsigned char IP0	@ 0xB8;
static		unsigned char XWUD	@ 0xB9;
static		unsigned char VREFR	@ 0xBA;
static		unsigned char CDVC1	@ 0xBB;
static		unsigned char CDVC2	@ 0xBC;
static volatile unsigned char CDTR1	@ 0xBD;
static volatile unsigned char TCTRL	@ 0xBF;
static volatile unsigned char IRQ1	@ 0xC0;
static volatile unsigned char INTC	@ 0xC1;
static volatile unsigned char GPADR	@ 0xC2;
static volatile unsigned char GPADC	@ 0xC3;
static		unsigned char GPDAR	@ 0xC4;
static		unsigned char SYMOD	@ 0xC5;
static		unsigned char DTCON	@ 0xC7;
static		unsigned char MCON	@ 0xC8;
static volatile unsigned char MBUF	@ 0xC9;
static volatile unsigned char MSTAT	@ 0xCA;
static volatile unsigned char PSW	@ 0xD0;
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 IEN1	@ 0xE8;
static		unsigned char IX1	@ 0xE9;
static volatile unsigned char B		@ 0xF0;
static		unsigned char WDTKEY	@ 0xF7;
static		unsigned char IP1	@ 0xF8;
static volatile unsigned char WDT	@ 0xFF;

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 volatile SFR_BITS	P4_BITS			@ 0x98;
static		SFR_BITS	SPCON_BITS		@ 0x99;
static		SFR_BITS	CKCON_BITS		@ 0x9A;
static volatile SFR_BITS	RTCON_BITS		@ 0x9B;
static		SFR_BITS	P4CFG_BITS		@ 0x9F;
static		SFR_BITS	IEN0_BITS		@ 0xA8;
static		SFR_BITS	MCSC_BITS		@ 0xA9;
static		SFR_BITS	ALTP_BITS		@ 0xAB;
static volatile SFR_BITS	P3_BITS			@ 0xB0;
static volatile SFR_BITS	PMTR1_BITS		@ 0xB5;
static		SFR_BITS	PMTR2_BITS		@ 0xB6;
static		SFR_BITS	CDTR2_BITS		@ 0xB7;
static		SFR_BITS	IP0_BITS		@ 0xB8;
static		SFR_BITS	XWUD_BITS		@ 0xB9;
static		SFR_BITS	VREFR_BITS		@ 0xBA;
static		SFR_BITS	CDVC1_BITS		@ 0xBB;
static		SFR_BITS	CDVC2_BITS		@ 0xBC;
static volatile SFR_BITS	CDTR1_BITS		@ 0xBD;
static volatile SFR_BITS	TCTRL_BITS		@ 0xBF;
static volatile SFR_BITS	IRQ1_BITS		@ 0xC0;
static volatile SFR_BITS	INTC_BITS		@ 0xC1;
static volatile SFR_BITS	GPADC_BITS		@ 0xC3;
static		SFR_BITS	SYMOD_BITS		@ 0xC5;
static		SFR_BITS	DTCON_BITS		@ 0xC7;
static		SFR_BITS	MCON_BITS		@ 0xC8;
static volatile SFR_BITS	MSTAT_BITS		@ 0xCA;
static volatile SFR_BITS	PSW_BITS		@ 0xD0;
static volatile SFR_BITS	S1CON_BITS		@ 0xD8;
static volatile SFR_BITS	S1STA_BITS		@ 0xD9;
static volatile SFR_BITS	S1DAT_BITS		@ 0xDA;
static volatile SFR_BITS	S1ADR_BITS		@ 0xDB;
static volatile SFR_BITS	ACC_BITS		@ 0xE0;
static		SFR_BITS	IEN1_BITS		@ 0xE8;
static		SFR_BITS	IX1_BITS		@ 0xE9;
static volatile SFR_BITS	B_BITS			@ 0xF0;
static		SFR_BITS	IP1_BITS		@ 0xF8;

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

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

//Port 4
static volatile bit	P40	@ 0x98;
static volatile bit	P41	@ 0x99;
static volatile bit	P42	@ 0x9A;
static volatile bit	P43	@ 0x9B;
static volatile bit	P44	@ 0x9C;
static volatile bit	P45	@ 0x9D;
static volatile bit	P46	@ 0x9E;
static volatile bit	P47	@ 0x9F;
// alternate functions
static volatile bit	LE	@ 0x98;
static volatile bit	FSK	@ 0x99;
static volatile bit	FS0	@ 0x9A;
static volatile bit	FSI	@ 0x9C;
static volatile bit	GPG	@ 0x9D;

//Interrupt Enable 0 IEN0
static 		bit 	EX0 	@ 0xA8;
static 		bit 	ET0 	@ 0xA9;
static 		bit 	EX1 	@ 0xAA;
static 		bit 	ET1 	@ 0xAB;
static 		bit 	EMSK 	@ 0xAC;
static 		bit 	ETIME 	@ 0xAD;
static 		bit 	EFS 	@ 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	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 0 IP0
static 		bit 	PX0 	@ 0xB8;
static 		bit 	PT0 	@ 0xB9;
static 		bit 	PX1 	@ 0xBA;
static 		bit 	PT1 	@ 0xBB;
static 		bit 	PMSK 	@ 0xBC;
static 		bit 	PTIME 	@ 0xBD;
static 		bit 	PFS 	@ 0xBE;

//Interrupt Request Register IRQ1
static volatile bit	X2F	@ 0xC0;
static volatile bit	X3F	@ 0xC1;
static volatile bit	X4F	@ 0xC2;
static volatile bit	X5F	@ 0xC3;
static volatile bit	X6F	@ 0xC4;
static volatile bit	TIMEF	@ 0xC5;
static volatile bit	DSPF	@ 0xC6;
static volatile bit	RTCF	@ 0xC7;

// Modem Control Register MCON
static 		bit 	MREN 	@ 0xC8;
static 		bit 	MTEN 	@ 0xC9;
static 		bit 	MB0 	@ 0xCA;
static 		bit 	MB1 	@ 0xCB;
static 		bit 	MPR0	@ 0xCC;
static 		bit 	MPR1 	@ 0xCD;
static 		bit 	MPR2 	@ 0xCE;
static 		bit 	MPR3 	@ 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;

//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 	EX2	@ 0xE8;
static 		bit 	EX3	@ 0xE9;
static 		bit 	EX4	@ 0xEA;
static 		bit 	EX5	@ 0xEB;
static 		bit 	EX6	@ 0xEC;
static 		bit 	EI2C	@ 0xED;
static 		bit 	EDSP	@ 0xEE;
static 		bit 	ERTC	@ 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	PX2	@ 0xF8;
static 		bit	PX3	@ 0xF9;
static 		bit 	PX4	@ 0xFA;
static 		bit 	PX5	@ 0xFB;
static 		bit 	PX6	@ 0xFC;
static 		bit 	PI2C	@ 0xFD;
static 		bit 	PDSP	@ 0xFE;
static 		bit 	PRTC	@ 0xFF;


//Interrupt Vectors
#define	RESET	0
#define	EXTINT0	0x03
#define TIMER0	0x0B
#define	EXTINT1	0x13
#define	TIMER1	0x1B
#define	MSKINT	0x23
#define	TIMEINT	0x2B
#define	FSINT	0x33
#define	EXTINT2	0x3B
#define	EXTINT3	0x43
#define	EXTINT4	0x4B
#define	EXTINT5	0x53
#define	EXTINT6	0x5B
#define	I2CINT	0x63
#define	DSPINT	0x6B
#define	RTCINT	0x73

#endif
