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



 /* header file for the Infineon microcontrollers
	C868_1R
	C868_1S
 */

#ifndef	__C868_H

#define	__C868_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          unsigned char DPSEL	@ 0x84;
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 PMCON0	@ 0x8E;
static		unsigned char CMCON	@ 0x8F;
static volatile unsigned char P1	@ 0x90;
static		unsigned char EXICON	@ 0x91;
static volatile unsigned char IRCON0	@ 0x92;
static volatile unsigned char IRCON1	@ 0x93;
static volatile unsigned char SCON	@ 0x98;
static volatile unsigned char SBUF	@ 0x99;
static		unsigned char WDTCON	@ 0xA2;
static          unsigned char WDTREL	@ 0xA3;
static volatile unsigned char PSLRL	@ 0xA6;
static          unsigned char IEN0	@ 0xA8;
static          unsigned char IEN1	@ 0xA9;
static		unsigned char IEN2	@ 0xAA;
static          unsigned char IP1	@ 0xAC;
static		unsigned char SYSCON0	@ 0xAD;
static volatile unsigned char SYSCON1	@ 0xAF;
static volatile unsigned char P3	@ 0xB0;
static		unsigned char P3ALT	@ 0xB1;
static volatile unsigned char WDTL	@ 0xB2;
static volatile unsigned char WDTH	@ 0xB3;
static		unsigned char P1ALT	@ 0xB4;
static volatile unsigned char CC63SRL	@ 0xB6;
static volatile unsigned char CC63SRH	@ 0xB7;
static          unsigned char IP0	@ 0xB8;
static volatile unsigned char ISSL	@ 0xBC;
static volatile unsigned char ISSH	@ 0xBD;
static		unsigned char IENL	@ 0xBE;
static		unsigned char IENH	@ 0xBF;
static volatile unsigned char SCUWDT	@ 0xC0;
static volatile unsigned char CC60RL	@ 0xC2;
static volatile unsigned char CC60RH	@ 0xC3;
static volatile unsigned char CC61RL	@ 0xC4;
static volatile unsigned char CC61RH	@ 0xC5;
static volatile unsigned char CC62RL	@ 0xC6;
static volatile unsigned char CC62RH	@ 0xC7;
static volatile unsigned char T2CON	@ 0xC8;
static          unsigned char T2MOD	@ 0xC9;
static volatile unsigned char RC2L	@ 0xCA;
static volatile unsigned char RC2H	@ 0xCB;
static volatile unsigned char TL2	@ 0xCC;
static volatile unsigned char TH2	@ 0xCD;
static		unsigned char TRPCTRL	@ 0xCE;
static		unsigned char TRPCTRH	@ 0xCF;
static volatile unsigned char PSW	@ 0xD0;
static		unsigned char T13PRL	@ 0xD2;
static		unsigned char T13PRH	@ 0xD3;
static volatile unsigned char CC63RL	@ 0xD4;
static volatile unsigned char CC63RH	@ 0xD5;
static		unsigned char MCMCTRLL	@ 0xD6;
static volatile unsigned char ADCON0	@ 0xD8;
static volatile unsigned char ADCON1	@ 0xD9;
static volatile unsigned char ADDATH	@ 0xDB;
static volatile unsigned char MCMOUTL	@ 0xDC;
static volatile unsigned char MCMOUTH	@ 0xDD;
static		unsigned char T12PRL	@ 0xDE;
static		unsigned char T12PRH	@ 0xDF;
static volatile unsigned char ACC	@ 0xE0;
static volatile unsigned char TCTR0L	@ 0xE2;
static volatile unsigned char TCTR0H	@ 0xE3;
static volatile unsigned char ISL	@ 0xE4;
static volatile unsigned char ISH	@ 0xE5;
static		unsigned char T12DTCL	@ 0xE6;
static volatile unsigned char T12DTCH	@ 0xE7;
static		unsigned char PMCON1	@ 0xE8;
static		unsigned char CMPMODIFL	@ 0xEA;
static		unsigned char CMPMODIFH	@ 0xEB;
static volatile unsigned char T12L	@ 0xEC;
static volatile unsigned char T12H	@ 0xED;
static volatile unsigned char T13L	@ 0xEE;
static volatile unsigned char T13H	@ 0xEF;
static volatile unsigned char B		@ 0xF0;
static volatile unsigned char TCTR4L	@ 0xF2;
static volatile unsigned char TCTR4H	@ 0xF3;
static volatile unsigned char CMPSTATL	@ 0xF4;
static volatile unsigned char CMPSTATH	@ 0xF5;
static		unsigned char T12MSELL	@ 0xF6;
static		unsigned char T12MSELH	@ 0xF7;
static		unsigned char PMCON2	@ 0xF8;
static		unsigned char VERSION	@ 0xF9;

static          SFR_BITS	 DPSEL_BITS	@ 0x84;
static volatile SFR_BITS	 PCON_BITS	@ 0x87;
static volatile SFR_BITS	 TCON_BITS	@ 0x88;
static          SFR_BITS	 TMOD_BITS	@ 0x89;
static volatile SFR_BITS	 PMCON0_BITS	@ 0x8E;
static		SFR_BITS	 CMCON_BITS	@ 0x8F;
static volatile SFR_BITS	 P1_BITS	@ 0x90;
static		SFR_BITS	 EXICON_BITS	@ 0x91;
static volatile SFR_BITS	 IRCON0_BITS	@ 0x92;
static volatile SFR_BITS	 IRCON1_BITS	@ 0x93;
static volatile SFR_BITS	 SCON_BITS	@ 0x98;
static		SFR_BITS	 WDTCON_BITS	@ 0xA2;
static volatile SFR_BITS	 PSLRL_BITS	@ 0xA6;
static          SFR_BITS	 IEN0_BITS	@ 0xA8;
static          SFR_BITS	 IEN1_BITS	@ 0xA9;
static		SFR_BITS	 IEN2_BITS	@ 0xAA;
static          SFR_BITS	 IP1_BITS	@ 0xAC;
static		SFR_BITS	 SYSCON0_BITS	@ 0xAD;
static volatile SFR_BITS	 SYSCON1_BITS	@ 0xAF;
static volatile SFR_BITS	 P3_BITS	@ 0xB0;
static		SFR_BITS	 P3ALT_BITS	@ 0xB1;
static volatile SFR_BITS	 WDTL_BITS	@ 0xB2;
static volatile SFR_BITS	 WDTH_BITS	@ 0xB3;
static		SFR_BITS	 P1ALT_BITS	@ 0xB4;
static          SFR_BITS	 IP0_BITS	@ 0xB8;
static volatile SFR_BITS	 ISSL_BITS	@ 0xBC;
static volatile SFR_BITS	 ISSH_BITS	@ 0xBD;
static		SFR_BITS	 IENL_BITS	@ 0xBE;
static		SFR_BITS	 IENH_BITS	@ 0xBF;
static volatile SFR_BITS	 SCUWDT_BITS	@ 0xC0;
static volatile SFR_BITS	 T2CON_BITS	@ 0xC8;
static          SFR_BITS	 T2MOD_BITS	@ 0xC9;
static		SFR_BITS	 TRPCTRL_BITS	@ 0xCE;
static		SFR_BITS	 TRPCTRH_BITS	@ 0xCF;
static volatile SFR_BITS	 PSW_BITS	@ 0xD0;
static		SFR_BITS	 MCMCTRLL_BITS	@ 0xD6;
static volatile SFR_BITS	 ADCON0_BITS	@ 0xD8;
static volatile SFR_BITS	 ADCON1_BITS	@ 0xD9;
static volatile SFR_BITS	 MCMOUTH_BITS	@ 0xDD;
static		SFR_BITS	 T12PRL_BITS	@ 0xDE;
static		SFR_BITS	 T12PRH_BITS	@ 0xDF;
static volatile SFR_BITS	 ACC_BITS	@ 0xE0;
static volatile SFR_BITS	 TCTR0L_BITS	@ 0xE2;
static volatile SFR_BITS	 TCTR0H_BITS	@ 0xE3;
static volatile SFR_BITS	 ISL_BITS	@ 0xE4;
static volatile SFR_BITS	 ISH_BITS	@ 0xE5;
static volatile SFR_BITS	 T12DTCH_BITS	@ 0xE7;
static		SFR_BITS	 PMCON1_BITS	@ 0xE8;
static		SFR_BITS	 CMPMODIFL_BITS	@ 0xEA;
static		SFR_BITS	 CMPMODIFH_BITS	@ 0xEB;
static volatile SFR_BITS	 B_BITS		@ 0xF0;
static volatile SFR_BITS	 TCTR4L_BITS	@ 0xF2;
static volatile SFR_BITS	 TCTR4H_BITS	@ 0xF3;
static volatile SFR_BITS	 CMPSTATL_BITS	@ 0xF4;
static volatile SFR_BITS	 CMPSTATH_BITS	@ 0xF5;
static		SFR_BITS	 T12MSELL_BITS	@ 0xF6;
static		SFR_BITS	 T12MSELH_BITS	@ 0xF7;
static volatile SFR_BITS	 PMCON2_BITS	@ 0xF8;

/* SFRs from the mapped area. Accessable if SYSCON0.4 (RMAP) = 1 */
static		unsigned char P1DIR	@ 0x90;
static		unsigned char P3DIR	@ 0xB0;
static volatile unsigned char ISRL	@ 0xBC;
static volatile unsigned char ISRH	@ 0xBD;
static		unsigned char INPL	@ 0xBE;
static		unsigned char INPH	@ 0xBF;
static		unsigned char MODCTRL	@ 0xD6;
static		unsigned char MODCTRH	@ 0xD7;
static volatile unsigned char MCMOUTSL	@ 0xDC;
static volatile unsigned char MCMOUTSH	@ 0xDD;
static volatile unsigned char TCTR2L	@ 0xF2;
static		SFR_BITS	 P1DIR_BITS	@ 0x90;
static		SFR_BITS	 P3DIR_BITS	@ 0xB0;
static volatile SFR_BITS	 ISRL_BITS	@ 0xBC;
static volatile SFR_BITS	 ISRH_BITS	@ 0xBD;
static		SFR_BITS	 INPL_BITS	@ 0xBE;
static		SFR_BITS	 INPH_BITS	@ 0xBF;
static		SFR_BITS	 MODCTRL_BITS	@ 0xD6;
static		SFR_BITS	 MODCTRH_BITS	@ 0xD7;
static volatile SFR_BITS	 MCMOUTSL_BITS	@ 0xDC;
static volatile SFR_BITS	 MCMOUTSH_BITS	@ 0xDD;
static volatile SFR_BITS	 TCTR2L_BITS	@ 0xF2;


// 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;
// Alternate Funcxtions
static volatile bit	TXD	@ 0x90;
static volatile bit	EXIF2	@ 0x91;	// renamed to avoid conflict with EXF2 in T2CON
static volatile bit	INT3	@ 0x93;
static volatile bit	RXD	@ 0x94;
// Port 1 Direction register P1DIR
static volatile bit	P1DIR0	@ 0x90;
static volatile bit	P1DIR1	@ 0x91;
static volatile bit	P1DIR2	@ 0x92;
static volatile bit	P1DIR3	@ 0x93;
static volatile bit	P1DIR4	@ 0x94;

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

//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 	ET2 	@ 0xAD;
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	COUT63	@ 0xB0;
static volatile bit	CTRAP	@ 0xB1;
static volatile bit	COUT62	@ 0xB2;
static volatile bit	CC62	@ 0xB3;
static volatile bit	COUT61	@ 0xB4;
static volatile bit	CC61	@ 0xB5;
static volatile bit	COUT60	@ 0xB6;
static volatile bit	CC60	@ 0xB7;
// PORT 3 Direction register P3DIR
static volatile bit	P3DIR0	@ 0xB0;
static volatile bit	P3DIR1	@ 0xB1;
static volatile bit	P3DIR2	@ 0xB2;
static volatile bit	P3DIR3	@ 0xB3;
static volatile bit	P3DIR4	@ 0xB4;
static volatile bit	P3DIR5	@ 0xB5;
static volatile bit	P3DIR6	@ 0xB6;
static volatile bit	P3DIR7	@ 0xB7;

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

// Register SCUWDT
static		bit	WDTRE	@ 0xC0;
static volatile bit	WDTRS	@ 0xC1;
static		bit	WDTDIS	@ 0xC2;
static volatile bit	WDTREOI	@ 0xC3;
static volatile bit	WDTR	@ 0xC4;
static volatile bit	PLLR	@ 0xC6;

//Timer 2 Control T2CON
static 		bit	CPRL2	@ 0xC8;
static 		bit	CT2	@ 0xC9;
static 		bit	TR2	@ 0xCA;
static 		bit	EXEN2	@ 0xCB;
static		bit	TCLK	@ 0xCC;
static		bit	RCLK	@ 0xCD;
static volatile	bit	EXF2	@ 0xCE;
static volatile	bit	TF2	@ 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;

// A2D Control Register 0 ADCON0
static		bit	ADCH0	@ 0xD8;
static		bit	ADCH1	@ 0xD9;
static		bit	ADCH2	@ 0xDA;
static		bit	ADM0	@ 0xDC;
static		bit	ADM1	@ 0xDD;
static volatile bit	ADBSY	@ 0xDE;
static volatile bit	ADST	@ 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;

// Register PMCON1
static		bit	ADCDIS	@ 0xE8;
static		bit	T2DIS	@ 0xE9;
static		bit	CCUDIS	@ 0xEA;

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

// Register PMCON2
static volatile bit	ADCST	@ 0xF8;
static volatile bit	T2ST	@ 0xF9;
static volatile bit	CCUST	@ 0xFA;


//Interrupt Vectors
#define	RESET	0
#define	EXTINT0	0x03
#define TIMER0	0x0B
#define	EXTINT1	0x13
#define	TIMER1	0x1B
#define	SERIAL	0x23
#define	TIMER2	0x2B
#define	A2D	0x33
#define	EXTINT2	0x3B
#define	EXTINT3	0x43
#define	EX9	0x4B
#define	EX10	0x53
#define	EX11	0x5B
#define	EX12	0x63
#define	EX13	0x6B
#define	WAKE	0x7B
#define	CCU6IN0	0x83
#define	CCU6IN1	0x8B
#define	CCU6IN2	0x93
#define	CCU6IN3	0x9B
#define	EX18	0xA3
#define	EX19	0xAB
#define	EX20	0xD3
#define	EX21	0xDB
#define	EX22	0xE3

#endif
