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

/* This is a header file for the Siemens Microcontrollers
	SDA30C263
	SDA30C264
*/

#ifndef __SD30C26X_H
#define __SD30C26X_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 WDTL	@ 0x84;
static volatile unsigned char WDTH	@ 0x85;
static		unsigned char WDTREL	@ 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 P1	@ 0x90;
static volatile unsigned char MEX1	@ 0x94;
static volatile unsigned char MEX2	@ 0x95;
static volatile unsigned char SCON	@ 0x98;
static volatile unsigned char SBUF	@ 0x99;
static volatile unsigned char P2	@ 0xA0;
static		unsigned char DPSEL	@ 0xA2;
static		unsigned char PAGE0	@ 0xA4;
static		unsigned char PAGE1	@ 0xA5;
static		unsigned char AFR	@ 0xA6;
static volatile unsigned char WDCON	@ 0xA7;
static		unsigned char IE	@ 0xA8;
static		unsigned char IP0	@ 0xA9;
static		unsigned char IP1	@ 0xAA;
static		unsigned char IRCON	@ 0xAB;
static volatile unsigned char P3	@ 0xB0;
#if defined(_SDA30C264)
static volatile unsigned char ICCON	@ 0xB8;
static volatile unsigned char ICMOD	@ 0xB9;
static volatile unsigned char ICSHI	@ 0xBA;
static		unsigned char ICADR	@ 0xBB;
static		unsigned char ICBD0	@ 0xBC;
static		unsigned char ICBD1	@ 0xBD;
#endif
static volatile unsigned char PSW	@ 0xD0;
static volatile unsigned char ADCON	@ 0xD8;
static volatile unsigned char ADDAT	@ 0xD9;
static volatile unsigned char DAPR	@ 0xDA;
#if defined(_SDA30C264)
static volatile unsigned char DECON	@ 0xDC;
static		unsigned char DESEL	@ 0xDD;
static		unsigned char DELOW	@ 0xDE;
static		unsigned char DEUP	@ 0xDF;
#endif
static volatile unsigned char ACC	@ 0xE0;
static volatile unsigned char P4	@ 0xE8;
static volatile unsigned char B		@ 0xF0;
static		unsigned char PWCOMP0	@ 0xF1;
static		unsigned char PWCOMP1	@ 0xF2;
static		unsigned char PWCOMP2	@ 0xF3;
static		unsigned char PWCOMP3	@ 0xF4;
static		unsigned char PWCOMP4	@ 0xF5;
static		unsigned char PWCOMP5	@ 0xF6;
static volatile	unsigned char PWCL	@ 0xF7;
static		unsigned char PWME	@ 0xF8;
static volatile unsigned char PWCH	@ 0xF9;
static		unsigned char PWEXT6	@ 0xFA;
static		unsigned char PWCOMP6	@ 0xFB;
static		unsigned char PWEXT7	@ 0xFC;
static		unsigned char PWCOMP7	@ 0xFD;

static volatile SFR_BITS P0_BITS		@ 0x80;
static volatile SFR_BITS SP_BITS		@ 0x81;
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 MEX1_BITS		@ 0x94;
static volatile SFR_BITS MEX2_BITS		@ 0x95;
static volatile SFR_BITS SCON_BITS		@ 0x98;
static volatile SFR_BITS P2_BITS		@ 0xA0;
static		SFR_BITS DPSEL_BITS		@ 0xA2;
static		SFR_BITS AFR_BITS		@ 0xA6;
static volatile SFR_BITS WDCON_BITS		@ 0xA7;
static		SFR_BITS IE_BITS		@ 0xA8;
static		SFR_BITS IP0_BITS		@ 0xA9;
static		SFR_BITS IP1_BITS		@ 0xAA;
static		SFR_BITS IRCON_BITS		@ 0xAB;
static volatile SFR_BITS P3_BITS		@ 0xB0;
#if defined(_SDA30C264)
static volatile SFR_BITS ICCON_BITS		@ 0xB8;
static volatile SFR_BITS ICMOD_BITS		@ 0xB9;
static		SFR_BITS ICBD0_BITS		@ 0xBC;
static		SFR_BITS ICBD1_BITS		@ 0xBD;
#endif
static volatile SFR_BITS PSW_BITS		@ 0xD0;
static volatile SFR_BITS ADCON_BITS		@ 0xD8;
#if defined(_SDA30C264)
static volatile SFR_BITS DECON_BITS		@ 0xDC;
static		SFR_BITS DESEL_BITS		@ 0xDD;
#endif
static volatile SFR_BITS ACC_BITS		@ 0xE0;
static volatile SFR_BITS P4_BITS		@ 0xE8;
static volatile SFR_BITS B_BITS			@ 0xF0;
static		SFR_BITS PWCOMP0_BITS		@ 0xF1;
static		SFR_BITS PWCOMP1_BITS		@ 0xF2;
static		SFR_BITS PWCOMP2_BITS		@ 0xF3;
static		SFR_BITS PWCOMP3_BITS		@ 0xF4;
static		SFR_BITS PWCOMP4_BITS		@ 0xF5;
static		SFR_BITS PWCOMP5_BITS		@ 0xF6;
static volatile SFR_BITS PWCL_BITS		@ 0xF7;
static		SFR_BITS PWME_BITS		@ 0xF8;
static volatile SFR_BITS PWCH_BITS		@ 0xF9;
static		SFR_BITS PWEXT6_BITS		@ 0xFA;
static		SFR_BITS PWEXT7_BITS		@ 0xFC;

//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	PWM0	@ 0x90;
static volatile bit	PWM1	@ 0x91;
static volatile bit	PWM2	@ 0x92;
static volatile bit	PWM3	@ 0x93;
static volatile bit	PWM4	@ 0x94;
static volatile bit	PWM5	@ 0x95;
static volatile bit	PWM6	@ 0x96;
static volatile bit	PWM7	@ 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 IE
static		bit	EX0	@ 0xA8;
static		bit	ET0	@ 0xA9;
static		bit	EX1	@ 0xAA;
static		bit	ET1	@ 0xAB;
static 		bit	ES	@ 0xAC;
#if defined(_SDA30C264)
static 		bit	EIC	@ 0xAD;
static 		bit	EAD	@ 0xAE;
#endif
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;
static volatile bit	RXD	@ 0xB6;
static volatile bit	TXD	@ 0xB7;

#if defined(_SDA30C264)
// I2C Control Register ICCON
static volatile	bit	BUM	@ 0xB8;
static		bit	ACK	@ 0xB9;
static volatile	bit	LRB	@ 0xBA;
static volatile	bit	AL	@ 0xBB;
static volatile	bit	IIN	@ 0xBC;
static volatile	bit	BB	@ 0xBD;
static		bit	TRX	@ 0xBE;
static volatile	bit	SLA	@ 0xBF;
#endif

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

// AD Control ADCON
static		bit	MX0	@ 0xD8;
static		bit	MX1	@ 0xD9;
static		bit	ADM	@ 0xDB;
static volatile	bit	BSY	@ 0xDC;
static		bit	SAMP	@ 0xDE;
static		bit	PSC	@ 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;

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

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

// PWM Enable Register PWME
static		bit	E0	@ 0xF8;
static		bit	E1	@ 0xF9;
static		bit	E2	@ 0xFA;
static		bit	E3	@ 0xFB;
static		bit	E4	@ 0xFC;
static		bit	E5	@ 0xFD;
static		bit	E6	@ 0xFE;
static		bit	E7	@ 0xFF;


//Interrupt Vectors
#define	RESET	0
#define	EXTINT0	0x03
#define TIMER0	0x0B
#define	EXTINT1	0x13
#define	TIMER1	0x1B
#define	SERIAL	0x23
#if defined(_SDA30C264)
#define	I2C	0x2B
#define	ADC	0x33
#endif

#endif
