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


 /* header file for the Sharp microcontrollers
	LZ87010
 */

#ifndef	__LZ87010_H

#define	__LZ87010_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
// 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 volatile unsigned char PORT1	@ 0x90;
static volatile unsigned char PORT5	@ 0x91;
static volatile unsigned char PORT8	@ 0x93;
static volatile unsigned char CLKCFG	@ 0x94;
static		unsigned char ALTFEN1	@ 0x95;
static volatile unsigned char FLASHCFG	@ 0x96;
static		unsigned char FLASHTB	@ 0x97;
static volatile unsigned char SCON	@ 0x98;
static volatile unsigned char SBUF	@ 0x99;
static volatile unsigned char PORT2	@ 0xA0;
static volatile unsigned char T5CON	@ 0xA1;
static volatile unsigned char T5STA	@ 0xA2;
static volatile unsigned char T5CMP	@ 0xA3;
static          unsigned char T5CMP0L	@ 0xA4;
static          unsigned char T5CMP0H	@ 0xA5;
static          unsigned char T5CMP1L	@ 0xA6;
static          unsigned char T5CMP1H	@ 0xA7;
static          unsigned char IE	@ 0xA8;
static volatile unsigned char PORT9	@ 0xA9;
static volatile unsigned char WDTCTL	@ 0xAC;
static volatile unsigned char WDTCNT	@ 0xAD;
static volatile unsigned char T5CNTL	@ 0xAE;
static volatile unsigned char T5CNTH	@ 0xAF;
static volatile unsigned char PORT3	@ 0xB0;
static volatile unsigned char TCMPOE	@ 0xB3;
static volatile unsigned char ICCON	@ 0xB4;
static		unsigned char ICSAR	@ 0xB5;
static		unsigned char ICUSAR	@ 0xB6;
static volatile unsigned char ICDATA	@ 0xB7;
static          unsigned char IP	@ 0xB8;
static          unsigned char IPH	@ 0xB9;
static		unsigned char ICHCNT	@ 0xBC;
static		unsigned char ICLCNT	@ 0xBD;
static volatile unsigned char ICDBUG	@ 0xBE;
static volatile unsigned char ICSTAT	@ 0xBF;
static volatile unsigned char PORT6	@ 0xC0;
static volatile unsigned char ADCDL	@ 0xC1;
static volatile unsigned char ADCDH	@ 0xC2;
static volatile unsigned char ADCC	@ 0xC3;
static		unsigned char DACC	@ 0xC4;
static		unsigned char XMCFG	@ 0xC5;
static          unsigned char BRGCNTL	@ 0xC6;
static          unsigned char BRGCNTH	@ 0xC7;
static volatile unsigned char SCON1	@ 0xC8;
static volatile unsigned char SBUF1	@ 0xC9;
static volatile unsigned char WGCTL0	@ 0xCA;
static volatile unsigned char WGCTL1	@ 0xCB;
static volatile unsigned char WGCFG0	@ 0xCC;
static volatile unsigned char WGCFG1	@ 0xCD;
static volatile unsigned char WGINX0	@ 0xCE;
static volatile unsigned char WGINX1	@ 0xCF;
static volatile unsigned char PSW	@ 0xD0;
static volatile unsigned char T2CON	@ 0xD1;
static volatile unsigned char T2STA	@ 0xD2;
static volatile unsigned char T2CMP	@ 0xD3;
static          unsigned char T2CMP0L	@ 0xD4;
static          unsigned char T2CMP0H	@ 0xD5;
static          unsigned char T2CMP1L	@ 0xD6;
static          unsigned char T2CMP1H	@ 0xD7;
static volatile unsigned char PORT7	@ 0xD8;
static volatile unsigned char T2CAP	@ 0xD9;
static volatile unsigned char T2CAP0L	@ 0xDA;
static volatile unsigned char T2CAP0H	@ 0xDB;
static volatile unsigned char T2CAP1L	@ 0xDC;
static volatile unsigned char T2CAP1H	@ 0xDD;
static volatile unsigned char T2CNTL	@ 0xDE;
static volatile unsigned char T2CNTH	@ 0xDF;
static volatile unsigned char ACC	@ 0xE0;
static volatile unsigned char T3CON	@ 0xE1;
static volatile unsigned char T3STA	@ 0xE2;
static volatile unsigned char T3CMP	@ 0xE3;
static          unsigned char T3CMP0L	@ 0xE4;
static          unsigned char T3CMP0H	@ 0xE5;
static          unsigned char T3CMP1L	@ 0xE6;
static          unsigned char T3CMP1H	@ 0xE7;
static          unsigned char IE1	@ 0xE8;
static volatile unsigned char T3CAP	@ 0xE9;
static volatile unsigned char T3CAP0L	@ 0xEA;
static volatile unsigned char T3CAP0H	@ 0xEB;
static volatile unsigned char T3CAP1L	@ 0xEC;
static volatile unsigned char T3CAP1H	@ 0xED;
static volatile unsigned char T3CNTL	@ 0xEE;
static volatile unsigned char T3CNTH	@ 0xEF;
static volatile unsigned char B		@ 0xF0;
static volatile unsigned char T4CON	@ 0xF1;
static volatile unsigned char T4STA	@ 0xF2;
static volatile unsigned char T4CMP	@ 0xF3;
static          unsigned char T4CMP0L	@ 0xF4;
static          unsigned char T4CMP0H	@ 0xF5;
static          unsigned char T4CMP1L	@ 0xF6;
static          unsigned char T4CMP1H	@ 0xF7;
static          unsigned char IP1	@ 0xF8;
static          unsigned char IPH1	@ 0xF9;
static volatile unsigned char WGMA0	@ 0xFA;
static volatile unsigned char WGMD0	@ 0xFB;
static volatile unsigned char WGMA1	@ 0xFC;
static volatile unsigned char WGMD1	@ 0xFD;
static volatile unsigned char T4CNTL	@ 0xFE;
static volatile unsigned char T4CNTH	@ 0xFF;
// alternate definitions
static volatile unsigned char P1	@ 0x90;
static volatile unsigned char P5	@ 0x91;
static volatile unsigned char P8	@ 0x93;
static volatile unsigned char P2	@ 0xA0;
static volatile unsigned char P9	@ 0xA9;
static volatile unsigned char P3	@ 0xB0;
static volatile unsigned char P6	@ 0xC0;
static volatile unsigned char P7	@ 0xD8;

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 volatile SFR_BITS	 PORT1_BITS	@ 0x90;
static volatile SFR_BITS	 PORT5_BITS	@ 0x91;
static volatile SFR_BITS	 PORT8_BITS	@ 0x93;
static volatile SFR_BITS	 CLKCFG_BITS	@ 0x94;
static volatile SFR_BITS	 FLASHCFG_BITS	@ 0x96;
static volatile SFR_BITS	 SCON_BITS	@ 0x98;
static volatile SFR_BITS	 PORT2_BITS	@ 0xA0;
static volatile SFR_BITS	 T5CON_BITS	@ 0xA1;
static volatile SFR_BITS	 T5STA_BITS	@ 0xA2;
static volatile SFR_BITS	 T5CMP_BITS	@ 0xA3;
static          SFR_BITS	 IE_BITS	@ 0xA8;
static volatile SFR_BITS	 PORT9_BITS	@ 0xA9;
static volatile SFR_BITS	 WDTCTL_BITS	@ 0xAC;
static volatile SFR_BITS	 PORT3_BITS	@ 0xB0;
static volatile SFR_BITS	 TCMPOE_BITS	@ 0xB3;
static volatile SFR_BITS	 ICCON_BITS	@ 0xB4;
static          SFR_BITS	 IP_BITS	@ 0xB8;
static          SFR_BITS	 IPH_BITS	@ 0xB9;
static volatile SFR_BITS	 ICDBUG_BITS	@ 0xBE;
static volatile SFR_BITS	 ICSTAT_BITS	@ 0xBF;
static volatile SFR_BITS	 PORT6_BITS	@ 0xC0;
static volatile SFR_BITS	 ADCC_BITS	@ 0xC3;
static		SFR_BITS	 DACC_BITS	@ 0xC4;
static		SFR_BITS	 XMCFG_BITS	@ 0xC5;
static volatile SFR_BITS	 SCON1_BITS	@ 0xC8;
static volatile SFR_BITS	 WGCTL0_BITS	@ 0xCA;
static volatile SFR_BITS	 WGCTL1_BITS	@ 0xCB;
static volatile SFR_BITS	 WGCFG0_BITS	@ 0xCC;
static volatile SFR_BITS	 WGCFG1_BITS	@ 0xCD;
static volatile SFR_BITS	 WGINX0_BITS	@ 0xCE;
static volatile SFR_BITS	 WGINX1_BITS	@ 0xCF;
static volatile SFR_BITS	 PSW_BITS	@ 0xD0;
static volatile SFR_BITS	 T2CON_BITS	@ 0xD1;
static volatile SFR_BITS	 T2STA_BITS	@ 0xD2;
static volatile SFR_BITS	 T2CMP_BITS	@ 0xD3;
static volatile SFR_BITS	 PORT7_BITS	@ 0xD8;
static volatile SFR_BITS	 T2CAP_BITS	@ 0xD9;
static volatile SFR_BITS	 ACC_BITS	@ 0xE0;
static volatile SFR_BITS	 T3CON_BITS	@ 0xE1;
static volatile SFR_BITS	 T3STA_BITS	@ 0xE2;
static volatile SFR_BITS	 T3CMP_BITS	@ 0xE3;
static          SFR_BITS	 IE1_BITS	@ 0xE8;
static volatile SFR_BITS	 T3CAP_BITS	@ 0xE9;
static volatile SFR_BITS	 B_BITS		@ 0xF0;
static volatile SFR_BITS	 T4CON_BITS	@ 0xF1;
static volatile SFR_BITS	 T4STA_BITS	@ 0xF2;
static volatile SFR_BITS	 T4CMP_BITS	@ 0xF3;
static          SFR_BITS	 IP1_BITS	@ 0xF8;
static          SFR_BITS	 IPH1_BITS	@ 0xF9;
static volatile SFR_BITS	 WGMA0_BITS	@ 0xFA;
static volatile SFR_BITS	 WGMD0_BITS	@ 0xFB;
static volatile SFR_BITS	 WGMA1_BITS	@ 0xFC;
static volatile SFR_BITS	 WGMD1_BITS	@ 0xFD;
// alternate definitions
static volatile SFR_BITS	 P1_BITS	@ 0x90;
static volatile SFR_BITS	 P5_BITS	@ 0x91;
static volatile SFR_BITS	 P8_BITS	@ 0x93;
static volatile SFR_BITS	 P2_BITS	@ 0xA0;
static volatile SFR_BITS	 P9_BITS	@ 0xA9;
static volatile SFR_BITS	 P3_BITS	@ 0xB0;
static volatile SFR_BITS	 P6_BITS	@ 0xC0;
static volatile SFR_BITS	 P7_BITS	@ 0xD8;


// 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	IEX0	@ 0x89;	// renamed for consistency with IEX1
// alternate definition
static volatile bit	IE0	@ 0x89;
static 		bit	IT1	@ 0x8A;
static volatile bit	IEX1	@ 0x8B; // renamed to avaoid conflict with interrupt enable register
static 		bit	TR0	@ 0x8C;
static volatile bit	TF0	@ 0x8D;
static 		bit	TR1	@ 0x8E;
static volatile bit	TF1	@ 0x8F;

// definitions for register PORT1
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;

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

// definitions for register PORT2
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	ES	@ 0xAC;
static		bit	ET2	@ 0xAD;
static 		bit	EA	@ 0xAF;

// definitions for register PORT3
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;

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

// definitions for register PORT6
static volatile bit	P60	@ 0xC0;
static volatile bit	P61	@ 0xC1;
static volatile bit	P62	@ 0xC2;
static volatile bit	P63	@ 0xC3;
static volatile bit	P64	@ 0xC4;
static volatile bit	P65	@ 0xC5;
static volatile bit	P66	@ 0xC6;
static volatile bit	P67	@ 0xC7;

// 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 volatile	bit	SM0_1	@ 0xC7;

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

// definitions for register PORT7
static volatile bit	P70	@ 0xD8;
static volatile bit	P71	@ 0xD9;
static volatile bit	P72	@ 0xDA;
static volatile bit	P73	@ 0xDB;
static volatile bit	P74	@ 0xDC;
static volatile bit	P75	@ 0xDD;
static volatile bit	P76	@ 0xDE;
static volatile bit	P77	@ 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 IE1
static 		bit	IE10	@ 0xE8;
static 		bit	IE11	@ 0xE9;
static 		bit 	IE12	@ 0xEA;
static 		bit 	IE13	@ 0xEB;
static 		bit 	IE14	@ 0xEC;
static 		bit 	IE15	@ 0xED;
static 		bit 	IE16	@ 0xEE;
static 		bit 	IE17	@ 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	IP10	@ 0xF8;
static 		bit	IP11	@ 0xF9;
static 		bit 	IP12	@ 0xFA;
static 		bit 	IP13	@ 0xFB;
static 		bit 	IP14	@ 0xFC;
static 		bit 	IP15	@ 0xFD;
static 		bit 	IP16	@ 0xFE;
static 		bit 	IP17	@ 0xFF;


//Interrupt Vectors
#define	RESET	0
#define	EXTINT0	0x03
#define TIMER0	0x0B
#define	EXTINT1	0x13
#define	TIMER1	0x1B
#define	SERIAL	0x23
#define	TIMER45	0x33
#define	TIMER23	0x3B
#define	I2C	0x43
#define	S1	0x4B
#define	ADC	0x53
#define	DAC0	0x5B
#define	DAC1	0x63
#define	EXTINT	0x6B

#endif
