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

/* This is a header file for the Micronas Microcontroller
	SDA55XX
	and the infineon microcontroller of the same name

 *** note that Port 4 bits 2 & 3 have the alternate functions named ENAR & ENAW respectively ***
 *** this differs from ENARW & ENARW that is used in the datasheet ***
 */

#ifndef __SDA55XX_H
#define __SDA55XX_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		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 P1		@ 0x90;
static volatile unsigned char MEX1		@ 0x94;
static volatile unsigned char MEX2		@ 0x95;
static volatile unsigned char MEX3		@ 0x96;
static volatile unsigned char MEXSP		@ 0x97;
static volatile unsigned char SCON		@ 0x98;
static volatile unsigned char SBUF		@ 0x99;
static volatile unsigned char P2		@ 0xA0;
static		unsigned char IEN0		@ 0xA8;
static		unsigned char IEN1		@ 0xA9;
static		unsigned char IEN2		@ 0xAA;
static		unsigned char IEN3		@ 0xAB;
static		unsigned char IP1		@ 0xAC;
static		unsigned char IRCON		@ 0xAD;
static volatile unsigned char P3		@ 0xB0;
static		unsigned char WDT_REL		@ 0xB1;
static volatile unsigned char WDT_CTRL		@ 0xB2;
static volatile unsigned char WDT_REFRESH	@ 0xB3;
static volatile unsigned char WDT_LOW		@ 0xB4;
static volatile unsigned char WDT_HIGH		@ 0xB5;
static		unsigned char CRT_RELL		@ 0xB7;
static		unsigned char IP0		@ 0xB8;
static		unsigned char CRT_RELH		@ 0xB9;
static volatile unsigned char CRT_CAPL		@ 0xBA;
static volatile unsigned char CRT_CAPH		@ 0xBB;
static volatile unsigned char CRT_MINCAPL	@ 0xBC;
static volatile unsigned char CRT_MINCAPH	@ 0xBD;
static volatile unsigned char CRTCON0		@ 0xBE;
static volatile unsigned char CRTCON1		@ 0xBF;
static volatile unsigned char CISR0		@ 0xC0;
static		unsigned char PWM_COMP8_0	@ 0xC1;
static		unsigned char PWM_COMP8_1	@ 0xC2;
static		unsigned char PWM_COMP8_2	@ 0xC3;
static		unsigned char PWM_COMP8_3	@ 0xC4;
static		unsigned char PWM_COMP8_4	@ 0xC5;
static		unsigned char PWM_COMP8_5	@ 0xC6;
static		unsigned char PWM_COMP14_0	@ 0xC7;
static volatile unsigned char CISR1		@ 0xC8;
static		unsigned char PWM_COMP14_1	@ 0xC9;
static		unsigned char PWM_COMPEXT14_0	@ 0xCA;
static		unsigned char PWM_COMPEXT14_1	@ 0xCB;
static volatile unsigned char PWM_CL		@ 0xCC;
// alternative definition
static volatile unsigned char PWCL		@ 0xCC;
static volatile unsigned char PWM_CH		@ 0xCD;
// alternative definition
static volatile unsigned char PWCH	@ 0xCD;
static		unsigned char PWM_EN	@ 0xCE;
static volatile unsigned char PSW	@ 0xD0;
static volatile unsigned char CADC0	@ 0xD1;
static volatile unsigned char CADC1	@ 0xD2;
static volatile unsigned char CADC2	@ 0xD3;
static volatile unsigned char CADC3	@ 0xD4;
static		unsigned char CADCCO	@ 0xD5;
static volatile unsigned char PSAVEX	@ 0xD7;
static volatile unsigned char PSAVE	@ 0xD8;
static volatile unsigned char STRVBI	@ 0xD9;
static		unsigned char PCLK1	@ 0xDA;
static		unsigned char PCLK0	@ 0xDB;
static		unsigned char CSCR0	@ 0xDD;
static volatile unsigned char CSCR1	@ 0xDE;
static		unsigned char SNDCSTL	@ 0xDF;
static volatile unsigned char ACC	@ 0xE0;
static		unsigned char SCR1	@ 0xE1;
static		unsigned char SCR0	@ 0xE2;
static		unsigned char SDV1	@ 0xE3;
static		unsigned char SDV0	@ 0xE4;
static		unsigned char SDH1	@ 0xE5;
static		unsigned char SDH0	@ 0xE6;
static		unsigned char HCR1	@ 0xE7;
static volatile unsigned char P4	@ 0xE8;
static		unsigned char HCR0	@ 0xE9;
static		unsigned char BVCR1	@ 0xEA;
static		unsigned char BVCR0	@ 0xEB;
static		unsigned char EVCR1	@ 0xEC;
static		unsigned char EVCR0	@ 0xED;
static volatile unsigned char VLR1	@ 0xEE;
static		unsigned char VLR0	@ 0xEF;
static volatile unsigned char B		@ 0xF0;
static		unsigned char HPR1	@ 0xF1;
static		unsigned char HPR0	@ 0xF2;
static		unsigned char POINTARRAY1_1	@ 0xF3;
static		unsigned char POINTARRAY1_0	@ 0xF4;
static		unsigned char POINTARRAY0_1	@ 0xF5;
static		unsigned char POINTARRAY0_0	@ 0xF6;
static		unsigned char OSD_CTRL		@ 0xF8;

static volatile SFR_BITS	P0_BITS			@ 0x80;
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	P1_BITS			@ 0x90;
static volatile SFR_BITS	SCON_BITS		@ 0x98;
static volatile SFR_BITS	P2_BITS			@ 0xA0;
static		SFR_BITS	IEN0_BITS		@ 0xA8;
static		SFR_BITS	IEN1_BITS		@ 0xA9;
static		SFR_BITS	IEN2_BITS		@ 0xAA;
static		SFR_BITS	IEN3_BITS		@ 0xAB;
static		SFR_BITS	IP1_BITS		@ 0xAC;
static		SFR_BITS	IRCON_BITS		@ 0xAD;
static volatile SFR_BITS	P3_BITS			@ 0xB0;
static volatile SFR_BITS	WDT_CTRL_BITS		@ 0xB2;
static volatile SFR_BITS	WDT_REFRESH_BITS	@ 0xB3;
static		SFR_BITS	IP0_BITS		@ 0xB8;
static volatile SFR_BITS	CRTCON0_BITS		@ 0xBE;
static volatile SFR_BITS	CRTCON1_BITS		@ 0xBF;
static volatile SFR_BITS	CISR0_BITS		@ 0xC0;
static volatile SFR_BITS	CISR1_BITS		@ 0xC8;
static volatile SFR_BITS	PWM_CH_BITS		@ 0xCD;
static volatile SFR_BITS	PSW_BITS		@ 0xD0;
static		SFR_BITS	CADCCO_BITS		@ 0xD5;
static volatile SFR_BITS	PSAVEX_BITS		@ 0xD7;
static volatile SFR_BITS	PSAVE_BITS		@ 0xD8;
static volatile SFR_BITS	STRVBI_BITS		@ 0xD9;
static		SFR_BITS	CSCR0_BITS		@ 0xDD;
static volatile SFR_BITS	CSCR1_BITS		@ 0xDE;
static		SFR_BITS	SNDCSTL_BITS		@ 0xDF;
static volatile SFR_BITS	ACC_BITS		@ 0xE0;
static		SFR_BITS	SCR1_BITS		@ 0xE1;
static		SFR_BITS	SCR0_BITS		@ 0xE2;
static volatile SFR_BITS	P4_BITS			@ 0xE8;
static volatile SFR_BITS	VLR1_BITS		@ 0xEE;
static volatile SFR_BITS	B_BITS			@ 0xF0;
static		SFR_BITS	OSD_CTRL_BITS		@ 0xF8;

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

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

//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 0 IEN0
static 		bit	EX0	@ 0xA8;
static 		bit	ET0	@ 0xA9;
static 		bit 	EX1	@ 0xAA;
static 		bit 	ET1	@ 0xAB;
static 		bit 	EU	@ 0xAC;
static 		bit 	EAD	@ 0xAD;
static 		bit 	EAL	@ 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	O_E_P3_O	@ 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	RXD	@ 0xB7;

//Interrupt Priority 0 IP0
static 		bit 	G0P1 	@ 0xB8;
static 		bit 	G1P1 	@ 0xB9;
static 		bit 	G2P1 	@ 0xBA;
static 		bit 	G3P1 	@ 0xBB;
static 		bit 	G4P1 	@ 0xBC;
static 		bit 	G5P1 	@ 0xBD;

// Central int service 0 CISR0
static volatile bit	DHS	@ 0xC0;
static volatile bit	AHS	@ 0xC1;
static volatile bit	PWTMR	@ 0xC2;
static volatile bit	DVS	@ 0xC3;
static volatile bit	AVS	@ 0xC4;
static volatile bit	WTMR	@ 0xC5;
static volatile bit	ADC	@ 0xC6;
static volatile bit	L24	@ 0xC7;

// Central int service 1 CISR1
static volatile bit	IEX0	@ 0xC8;
static volatile bit	IEX1	@ 0xC9;
static volatile bit	ADW	@ 0xCE;
static volatile bit	CC	@ 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;

// Power save register PSAVE
static volatile bit	PERI	@ 0xD8;
static volatile bit	DISP	@ 0xD9;
static volatile bit	SLI_ACQ	@ 0xDA;
static volatile bit	WAKUP	@ 0xDB;
static volatile bit	CADC	@ 0xDC;

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

//Port 4
static volatile bit	P40	@ 0xE8;
static volatile bit	P41	@ 0xE9;
static volatile bit	P42	@ 0xEA;
static volatile bit	P43	@ 0xEB;
static volatile bit	P44	@ 0xEC;
static volatile bit	P45	@ 0xED;
static volatile bit	P46	@ 0xEE;
static volatile bit	P47	@ 0xEF;
// alternate functions
static volatile bit	A17	@ 0xE8;
static volatile bit	A18	@ 0xE9;
static volatile bit	ENAR	@ 0xEA;
static volatile bit	ENAW	@ 0xEB;
static volatile bit	A19	@ 0xEC;
static volatile bit	VS_OE	@ 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;

// Display OSD control OSD_CTRL
static		bit	DIS_BLANK	@ 0xF8;
static		bit	DIS_COR		@ 0xF9;
static		bit	EN_DGOUT	@ 0xFA;
static		bit	EN_LD_CUR	@ 0xFB;
static		bit	DISPLAY		@ 0xFF;


//Interrupt Vectors
#define	RESET	0
#define	EXTINT0	0x03
#define TIMER0	0x0B
#define	EXTINT1	0x13
#define	TIMER1	0x1B
#define	SERIAL	0x23
#define	AD	0x2B
#define	EXTINT6	0x33
#define	EXTINTX0 0x3B
#define	WDT	0x43
#define	EXTINTX1 0x4B
#define	AVSYNC	0x53
#define	DVSYNC	0x5B
#define	EXTINT12 0x63
#define	EXTINT13 0x6B
#define	PWMTMR	0x83
#define	CHCHAN	0x8B
#define	AHSYNC	0x93
#define	DHSYNC	0x9B
#define	EXTINT18 0xA3
#define	EXTINT19 0xAB
#define	EXTINT20 0xB3
#define	EXTINT21 0xBB
#define	L24START 0xC3
#define	ADWAKE	0xCB

#endif
