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


 /* header file for the microcontrollers
	W925E240
	W925C240
	W925E625
	W925C625
 */

#ifndef	__W925X240_H

#define	__W925X240_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 volatile unsigned char DPL1	@ 0x84;
static volatile unsigned char DPH1	@ 0x85;
// 16-Bit definition
static          unsigned char DPS	@ 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		unsigned char CKCON1	@ 0x8E;
static		unsigned char CKCON2	@ 0x8F;
static volatile unsigned char P1	@ 0x90;
static volatile unsigned char EXIF	@ 0x91;
#if defined(_W925C240) || defined(_W925E240)
static		unsigned char RPAGE	@ 0x92;
#endif
static volatile unsigned char P1SR	@ 0x93;
static		unsigned char P0IO	@ 0x94;
static		unsigned char P1IO	@ 0x95;
static		unsigned char P2IO	@ 0x96;
static		unsigned char P3IO	@ 0x97;
static volatile unsigned char P1EF	@ 0x9B;
static		unsigned char P1H	@ 0x9D;
static		unsigned char P2H	@ 0x9E;
static		unsigned char P3H	@ 0x9F;
static volatile unsigned char P2	@ 0xA0;
static volatile unsigned char HB	@ 0xA1;
static		unsigned char P4H	@ 0xA2;
static volatile unsigned char P4	@ 0xA6;
static          unsigned char IE	@ 0xA8;
static		unsigned char P4IO	@ 0xAE;
static volatile unsigned char P3	@ 0xB0;
static volatile unsigned char CIDR	@ 0xB1;
static volatile unsigned char CIDFG	@ 0xB2;
static		unsigned char CIDPCR	@ 0xB3;
static volatile unsigned char FSKDR	@ 0xB4;
static volatile unsigned char DTMFDR	@ 0xB5;
static volatile unsigned char DTMFPT	@ 0xB6;
static volatile unsigned char DTMFAT	@ 0xB7;
static          unsigned char IP	@ 0xB8;
static		unsigned char DTMFG	@ 0xBA;
static volatile unsigned char COMPR	@ 0xBB;
static volatile unsigned char IRC1	@ 0xBC;
static volatile unsigned char IRC2	@ 0xBD;
static volatile unsigned char CASPT	@ 0xBE;
static volatile unsigned char CASAT	@ 0xBF;
static volatile unsigned char SCON1	@ 0xC0;
static volatile unsigned char SBUF1	@ 0xC1;
static		unsigned char REGVC	@ 0xC2;
static          unsigned char PMR	@ 0xC4;
static volatile unsigned char STATUS	@ 0xC5;
static volatile unsigned char FSKTC	@ 0xC6;
static volatile unsigned char FSKTB	@ 0xC7;
static		unsigned char DIVC	@ 0xC8;
static volatile unsigned char PSW	@ 0xD0;
static volatile unsigned char WDCON	@ 0xD8;
static volatile unsigned char ACC	@ 0xE0;
static          unsigned char EIE	@ 0xE8;
static volatile unsigned char B		@ 0xF0;
static          unsigned char EIP	@ 0xF8;
static		unsigned char CIDGD	@ 0xF9;
static volatile unsigned char CIDGA	@ 0xFA;

static volatile SFR_BITS	 P0_BITS	@ 0x80;
static          SFR_BITS	 DPS_BITS	@ 0x86;
static volatile SFR_BITS	 PCON_BITS	@ 0x87;
static volatile SFR_BITS	 TCON_BITS	@ 0x88;
static          SFR_BITS	 TMOD_BITS	@ 0x89;
static		SFR_BITS	 CKCON1_BITS	@ 0x8E;
static		SFR_BITS	 CKCON2_BITS	@ 0x8F;
static volatile SFR_BITS	 P1_BITS	@ 0x90;
static volatile SFR_BITS	 EXIF_BITS	@ 0x91;
#if defined(_W925C240) || defined(_W925E240)
static		SFR_BITS	 RPAGE_BITS	@ 0x92;
#endif
static volatile SFR_BITS	 P1SR_BITS	@ 0x93;
static		SFR_BITS	 P0IO_BITS	@ 0x94;
static		SFR_BITS	 P1IO_BITS	@ 0x95;
static		SFR_BITS	 P2IO_BITS	@ 0x96;
static		SFR_BITS	 P3IO_BITS	@ 0x97;
static volatile SFR_BITS	 P1EF_BITS	@ 0x9B;
static		SFR_BITS	 P1H_BITS	@ 0x9D;
static		SFR_BITS	 P2H_BITS	@ 0x9E;
static		SFR_BITS	 P3H_BITS	@ 0x9F;
static volatile SFR_BITS	 P2_BITS	@ 0xA0;
static		SFR_BITS	 P4H_BITS	@ 0xA2;
static volatile SFR_BITS	 P4_BITS	@ 0xA6;
static          SFR_BITS	 IE_BITS	@ 0xA8;
static		SFR_BITS	 P4IO_BITS	@ 0xAE;
static volatile SFR_BITS	 P3_BITS	@ 0xB0;
static volatile SFR_BITS	 CIDR_BITS	@ 0xB1;
static volatile SFR_BITS	 CIDFG_BITS	@ 0xB2;
static		SFR_BITS	 CIDPCR_BITS	@ 0xB3;
static volatile SFR_BITS	 DTMFDR_BITS	@ 0xB5;
static          SFR_BITS	 IP_BITS	@ 0xB8;
static		SFR_BITS	 DTMFG_BITS	@ 0xBA;
static volatile SFR_BITS	 COMPR_BITS	@ 0xBB;
static volatile SFR_BITS	 IRC1_BITS	@ 0xBC;
static volatile SFR_BITS	 IRC2_BITS	@ 0xBD;
static volatile SFR_BITS	 SCON1_BITS	@ 0xC0;
static		SFR_BITS	 REGVC_BITS	@ 0xC2;
static          SFR_BITS	 PMR_BITS	@ 0xC4;
static volatile SFR_BITS	 STATUS_BITS	@ 0xC5;
static volatile SFR_BITS	 FSKTC_BITS	@ 0xC6;
static volatile SFR_BITS	 FSKTB_BITS	@ 0xC7;
static		SFR_BITS	 DIVC_BITS	@ 0xC8;
static volatile SFR_BITS	 PSW_BITS	@ 0xD0;
static volatile SFR_BITS	 WDCON_BITS	@ 0xD8;
static volatile SFR_BITS	 ACC_BITS	@ 0xE0;
static          SFR_BITS	 EIE_BITS	@ 0xE8;
static volatile SFR_BITS	 B_BITS		@ 0xF0;
static          SFR_BITS	 EIP_BITS	@ 0xF8;
static volatile SFR_BITS	 CIDGA_BITS	@ 0xFA;


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

// 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	INT20	@ 0x90;
static volatile bit	INT21	@ 0x91;
static volatile bit	INT22	@ 0x92;
static volatile bit	INT23	@ 0x93;
static volatile bit	INT30	@ 0x94;
static volatile bit	INT31	@ 0x95;
static volatile bit	INT32	@ 0x96;
static volatile bit	INT33	@ 0x97;

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

// Interrupt Enable IE
static		bit	EX0	@ 0xA8;
static		bit	ET0	@ 0xA9;
static		bit	EX1	@ 0xAA;
static		bit	ET1	@ 0xAB;
static 		bit	ES1	@ 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	INT0	@ 0xB2;
static volatile bit	INT1	@ 0xB3;
static volatile bit	T0	@ 0xB4;
static volatile bit	T1	@ 0xB5;

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

// Serial Control 1 SCON1
static		bit	SIO	@ 0xC0;
static		bit	CLKIO	@ 0xC1;
static		bit	SEDG	@ 0xC2;
static 		bit	SFQ	@ 0xC3;
static volatile bit	REN1	@ 0xC4;
static 		bit	REGON	@ 0xC5;
#if defined(_W925C625) || defined(_W925E625)
static 		bit	LCDON	@ 0xC6;
#endif
static volatile	bit	SF1	@ 0xC7;

// definitions for register DIVC
static		bit	DIVA	@ 0xC8;

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

// Watchdog Control WDCON
static volatile bit	RWT	@ 0xD8;
static		bit	EWT	@ 0xD9;
static volatile bit	WTRF	@ 0xDA;
static volatile bit	WDIF	@ 0xDB;
static		bit	WFS	@ 0xDC;
static volatile bit	POR	@ 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;

// Extended Interrupt Enable EIE
static		bit	EX2	@ 0xE8;
static		bit	EX3	@ 0xE9;
static		bit	ECID	@ 0xEA;
static		bit	EDIV	@ 0xEB;
static		bit	ECOMP	@ 0xEC;
static		bit	EWDI	@ 0xED;

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

// Extended Interrupt Priority EIP
static		bit	PX2	@ 0xF8;
static		bit	PX3	@ 0xF9;
static		bit	PCID	@ 0xFA;
static		bit	PDIV	@ 0xFB;
static		bit	PCOMP	@ 0xFC;
static		bit	PWDI	@ 0xFD;


// Interrupt Vectors
#define	RESET	0
#define	EXTINT0	0x03
#define TIMER0	0x0B
#define	EXTINT1	0x13
#define	TIMER1	0x1B
#define	SERIAL	0x3B
#define	EXTINT2	0x43
#define	EXTINT3	0x4B
#define CIDINT	0x53
#define	DIVOVR	0x5B
#define	COMPDIF	0x63
#define	WDTINT	0x6B

#endif
