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


 /* header file for the Goal microcontrollers
	VERSA1B
 */

#ifndef	__VERSA1B_H

#define	__VERSA1B_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 DPL0	@ 0x82;
static volatile unsigned char DPH0	@ 0x83;
// 16 bit definition
// Alternate 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 CKCON	@ 0x8E;
static volatile unsigned char SPC_FNC	@ 0x8F;
static volatile unsigned char EXIF	@ 0x91;
static		unsigned char MPAGE	@ 0x92;
static volatile unsigned char SCON0	@ 0x98;
static volatile unsigned char SBUF0	@ 0x99;
static          unsigned char IE	@ 0xA8;
static		unsigned char SPICTRL	@ 0xB4;
static volatile unsigned char SPIRX	@ 0xB5;
static		unsigned char SPITX	@ 0xB6;
static		unsigned char SPIIE	@ 0xB7;
static          unsigned char IP	@ 0xB8;
static		unsigned char IOCTRL	@ 0xBA;
static volatile unsigned char IOREAD	@ 0xBB;
static volatile unsigned char SPIINTSTAT	@ 0xBC;
static		unsigned char SPIRXOVC	@ 0xBD;
static volatile unsigned char SCON1	@ 0xC0;
static volatile unsigned char SBUF1	@ 0xC1;
static volatile unsigned char MACACC0	@ 0xC4;
static volatile unsigned char MACACC1	@ 0xC5;
static volatile unsigned char MACACC2	@ 0xC6;
static volatile unsigned char MACACC3	@ 0xC7;
static volatile unsigned char T2CON	@ 0xC8;
static volatile unsigned char RCAP2L	@ 0xCA;
static volatile unsigned char RCAP2H	@ 0xCB;
static volatile unsigned char TL2	@ 0xCC;
static volatile unsigned char TH2	@ 0xCD;
static volatile unsigned char PSW	@ 0xD0;
static volatile unsigned char J17CTRL	@ 0xD7;
static volatile unsigned char EICON	@ 0xD8;
static		unsigned char J17PRIREG	@ 0xD9;
static		unsigned char J17IDLE	@ 0xDA;
static		unsigned char J17BDLO	@ 0xDB;
static		unsigned char J17BDHI	@ 0xDC;
static volatile unsigned char J17DATA	@ 0xDD;
static		unsigned char J17IE	@ 0xDE;
static volatile unsigned char J17INTSTAT	@ 0xDF;
static volatile unsigned char ACC	@ 0xE0;
static volatile unsigned char INTSRC	@ 0xE4;
static		unsigned char CLKDIV	@ 0xE5;
static volatile unsigned char MACA0	@ 0xE6;
static volatile unsigned char MACA1	@ 0xE7;
static          unsigned char EIE	@ 0xE8;
static volatile unsigned char MACRES0	@ 0xEA;
static volatile unsigned char MACRES1	@ 0xEB;
static volatile unsigned char MACRES2	@ 0xEC;
static volatile unsigned char MACRES3	@ 0xED;
static volatile unsigned char MACB0	@ 0xEE;
static volatile unsigned char MACB1	@ 0xEF;
static volatile unsigned char B		@ 0xF0;
static          unsigned char EIP	@ 0xF8;

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	 CKCON_BITS	@ 0x8E;
static volatile SFR_BITS	 SPC_FNC_BITS	@ 0x8F;
static volatile SFR_BITS	 EXIF_BITS	@ 0x91;
static volatile SFR_BITS	 SCON0_BITS	@ 0x98;
static          SFR_BITS	 IE_BITS	@ 0xA8;
static		SFR_BITS	 SPICTRL_BITS	@ 0xB4;
static		SFR_BITS	 SPIIE_BITS	@ 0xB7;
static          SFR_BITS	 IP_BITS	@ 0xB8;
static		SFR_BITS	 IOCTRL_BITS	@ 0xBA;
static volatile SFR_BITS	 IOREAD_BITS	@ 0xBB;
static volatile SFR_BITS	 SPIINTSTAT_BITS	@ 0xBC;
static volatile SFR_BITS	 SCON1_BITS	@ 0xC0;
static volatile SFR_BITS	 T2CON_BITS	@ 0xC8;
static volatile SFR_BITS	 PSW_BITS	@ 0xD0;
static volatile SFR_BITS	 J17CTRL_BITS	@ 0xD7;
static volatile SFR_BITS	 EICON_BITS	@ 0xD8;
static		SFR_BITS	 J17IE_BITS	@ 0xDE;
static volatile SFR_BITS	 J17INTSTAT_BITS	@ 0xDF;
static volatile SFR_BITS	 ACC_BITS	@ 0xE0;
static volatile SFR_BITS	 INTSRC_BITS	@ 0xE4;
static		SFR_BITS	 CLKDIV_BITS	@ 0xE5;
static          SFR_BITS	 EIE_BITS	@ 0xE8;
static volatile SFR_BITS	 B_BITS		@ 0xF0;
static          SFR_BITS	 EIP_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;

//Serial Control Register 0 SCON0
static volatile bit	RI_0	@ 0x98;
static volatile bit	TI_0	@ 0x99;
static volatile bit	RB8_0	@ 0x9A;
static 		bit	TB8_0	@ 0x9B;
static 		bit	REN_0	@ 0x9C;
static 		bit	SM2_0	@ 0x9D;
static 		bit	SM1_0	@ 0x9E;
static 		bit	SM0_0	@ 0x9F;

//Interrupt Enable IE
static		bit	EX0	@ 0xA8;
static		bit	ET0	@ 0xA9;
static		bit	EX1	@ 0xAA;
static		bit	ET1	@ 0xAB;
static 		bit	ES0	@ 0xAC;
static 		bit	ET2	@ 0xAD;
static 		bit	ES1	@ 0xAE;
static 		bit	EA	@ 0xAF;

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

//Serial Control 1 SCON1
static volatile	bit	RI_1	@ 0xC0;
static volatile	bit	TI_1	@ 0xC1;
static volatile	bit	RB8_1	@ 0xC2;
static 		bit	TB8_1	@ 0xC3;
static 		bit	REN_1	@ 0xC4;
static 		bit	SM2_1	@ 0xC5;
static 		bit	SM1_1	@ 0xC6;
static		bit	SM0_1	@ 0xC7;

//Timer 2 Control T2CON
static 		bit	RL2	@ 0xC8;
static 		bit	T2	@ 0xC9;
static 		bit	TR2	@ 0xCA;
static		bit	TCLK0	@ 0xCC;
static		bit	RCLK0	@ 0xCD;
static volatile	bit	FIRQT2	@ 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;

// Extended Interrupt Control EICON
static volatile bit	INT2	@ 0xDB;
static volatile bit	PFI	@ 0xDC;
static volatile bit	EPFI	@ 0xDD;
static		bit	SMOD1	@ 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;

//Extended Interrupt Enable EIE
static		bit	EX2	@ 0xE8;
static		bit	EX3	@ 0xE9;
static		bit	EIE2	@ 0xEC;

//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	PEX2	@ 0xF8;
static		bit	PEX3	@ 0xF9;
static		bit	PEI2	@ 0xFC;


//Interrupt Vectors
#define	RESET	0
#define	SPIJ17	0x03
#define TIMER0	0x0B
#define	EXTINT1	0x13
#define	TIMER1	0x1B
#define	SERIAL	0x23
#define	TIMER2	0x2B
#define	S1	0x3B
#define	EXTINT0	0x4B
#define	EXTINT2	0x63

#endif
