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

/* This is a header file for the Siliconians Microcontroller
	SS8203
*/

#ifndef __SS8203_H
#define __SS8203_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 P1	@ 0x90;
static		unsigned char ADCR	@ 0x91;
static volatile unsigned char ADAT	@ 0x92;
static		unsigned char ADENL	@ 0x93;
static		unsigned char ADENH	@ 0x94;
static		unsigned char SREL	@ 0x96;
static		unsigned char PSCR	@ 0x97;
static		unsigned char PCR	@ 0x9A;
static		unsigned char ZCR	@ 0x9B;
static volatile unsigned char P2	@ 0xA0;
static volatile unsigned char WDCR	@ 0xA1;
static volatile unsigned char WDTR	@ 0xA2;
static volatile unsigned char WBCR	@ 0xA3;
static volatile unsigned char SECCNT	@ 0xA4;
static volatile unsigned char MINCNT	@ 0xA5;
static		unsigned char XICR0	@ 0xA6;
static		unsigned char XICR1	@ 0xA7;
static		unsigned char IE	@ 0xA8;
static		unsigned char P0IO	@ 0xAA;
static		unsigned char P0RD	@ 0xAB;
static volatile unsigned char P3	@ 0xB0;
static volatile unsigned char TBCR	@ 0xB1;
static volatile unsigned char TBCNT	@ 0xB2;
static volatile unsigned char TBDAT	@ 0xB3;
static volatile unsigned char PT1CR	@ 0xB4;
static volatile unsigned char PT1CNT	@ 0xB5;
static volatile unsigned char PT1DAT	@ 0xB6;
static volatile unsigned char P6	@ 0xB7;
static		unsigned char IP	@ 0xB8;
static		unsigned char P1IO	@ 0xBA;
static		unsigned char P1RD	@ 0xBB;
static volatile unsigned char P4	@ 0xC0;
static volatile unsigned char PT2CR	@ 0xC1;
static volatile unsigned char PT2CNT	@ 0xC2;
static volatile unsigned char PT2DAT	@ 0xC3;
static volatile unsigned char PT3CR	@ 0xC4;
static volatile unsigned char PT3CNT	@ 0xC5;
static volatile unsigned char PT3DAT	@ 0xC6;
static volatile unsigned char P7	@ 0xC7;
static volatile unsigned char P5	@ 0xC8;
static		unsigned char P2IO	@ 0xCA;
static		unsigned char P2RD	@ 0xCB;
static volatile unsigned char PSW	@ 0xD0;
static		unsigned char CT1CR	@ 0xD1;
static volatile unsigned char CT1CL	@ 0xD2;
static volatile unsigned char CT1CH	@ 0xD3;
static		unsigned char CT1DL	@ 0xD4;
static		unsigned char CT1DH	@ 0xD5;
static		unsigned char ISE0	@ 0xD7;
static volatile unsigned char INT0	@ 0xD8;
static		unsigned char P3IO	@ 0xDA;
static		unsigned char P3RD	@ 0xDB;
static volatile unsigned char ACC	@ 0xE0;
static		unsigned char CT2CR	@ 0xE1;
static volatile unsigned char CT2CL	@ 0xE2;
static volatile unsigned char CT2CH	@ 0xE3;
static		unsigned char CT2DL	@ 0xE4;
static		unsigned char CT2DH	@ 0xE5;
static		unsigned char ISE1	@ 0xE7;
static volatile unsigned char INT1	@ 0xE8;
static		unsigned char P4IO	@ 0xEA;
static		unsigned char P4RD	@ 0xEB;
static volatile unsigned char B		@ 0xF0;
static volatile unsigned char SIO1CR	@ 0xF1;
static volatile unsigned char SIO1DH	@ 0xF2;
static volatile unsigned char SIO1DL	@ 0xF3;
static volatile unsigned char SIO2CR	@ 0xF4;
static volatile unsigned char SIO2D	@ 0xF5;
static volatile unsigned char ISE2	@ 0xF7;
static volatile unsigned char INT2	@ 0xF8;
static		unsigned char P5IO	@ 0xFA;
static		unsigned char P5RD	@ 0xFB;
static volatile unsigned char MSIZ	@ 0xFF;

static volatile SFR_BITS P0_BITS		@ 0x80;
static volatile SFR_BITS SP_BITS		@ 0x81;
static volatile SFR_BITS DPL_BITS		@ 0x82;
static volatile SFR_BITS DPH_BITS		@ 0x83;
static volatile SFR_BITS P1_BITS		@ 0x90;
static		SFR_BITS ADCR_BITS		@ 0x91;
static		SFR_BITS ADENL_BITS		@ 0x93;
static		SFR_BITS ADENH_BITS		@ 0x94;
static		SFR_BITS SREL_BITS		@ 0x96;
static		SFR_BITS PSCR_BITS		@ 0x97;
static		SFR_BITS PCR_BITS		@ 0x9A;
static		SFR_BITS ZCR_BITS		@ 0x9B;
static volatile SFR_BITS P2_BITS		@ 0xA0;
static volatile SFR_BITS WDCR_BITS		@ 0xA1;
static volatile SFR_BITS WBCR_BITS		@ 0xA3;
static		SFR_BITS XICR0_BITS		@ 0xA6;
static		SFR_BITS XICR1_BITS		@ 0xA7;
static		SFR_BITS IE_BITS		@ 0xA8;
static		SFR_BITS P0IO_BITS		@ 0xAA;
static		SFR_BITS P0RD_BITS		@ 0xAB;
static volatile SFR_BITS P3_BITS		@ 0xB0;
static volatile SFR_BITS TBCR_BITS		@ 0xB1;
static volatile SFR_BITS PT1CR_BITS		@ 0xB4;
static volatile SFR_BITS PT1CNT_BITS		@ 0xB5;
static volatile SFR_BITS P6_BITS		@ 0xB7;
static		SFR_BITS IP_BITS		@ 0xB8;
static		SFR_BITS P1IO_BITS		@ 0xBA;
static		SFR_BITS P1RD_BITS		@ 0xBB;
static volatile SFR_BITS P4_BITS		@ 0xC0;
static volatile SFR_BITS PT2CR_BITS		@ 0xC1;
static volatile SFR_BITS PT2CNT_BITS		@ 0xC2;
static volatile SFR_BITS PT3CR_BITS		@ 0xC4;
static volatile SFR_BITS PT3CNT_BITS		@ 0xC5;
static volatile SFR_BITS P7_BITS		@ 0xC7;
static volatile SFR_BITS P5_BITS		@ 0xC8;
static		SFR_BITS P2IO_BITS		@ 0xCA;
static		SFR_BITS P2RD_BITS		@ 0xCB;
static volatile SFR_BITS PSW_BITS		@ 0xD0;
static		SFR_BITS CT1CR_BITS		@ 0xD1;
static		SFR_BITS ISE0_BITS		@ 0xD7;
static volatile SFR_BITS INT0_BITS		@ 0xD8;
static		SFR_BITS P3IO_BITS		@ 0xDA;
static		SFR_BITS P3RD_BITS		@ 0xDB;
static volatile SFR_BITS ACC_BITS		@ 0xE0;
static		SFR_BITS CT2CR_BITS		@ 0xE1;
static		SFR_BITS ISE1_BITS		@ 0xE7;
static volatile SFR_BITS INT1_BITS		@ 0xE8;
static		SFR_BITS P4IO_BITS		@ 0xEA;
static		SFR_BITS P4RD_BITS		@ 0xEB;
static volatile SFR_BITS B_BITS			@ 0xF0;
static volatile SFR_BITS SIO1CR_BITS		@ 0xF1;
static volatile SFR_BITS SIO2CR_BITS		@ 0xF4;
static volatile SFR_BITS ISE2_BITS		@ 0xF7;
static		SFR_BITS P5IO_BITS		@ 0xFA;
static		SFR_BITS P5RD_BITS		@ 0xFB;
static volatile SFR_BITS INT2_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;

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

//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	EGA	@ 0xA8;
static		bit	EGB	@ 0xA9;
static		bit	EGC	@ 0xAA;
static		bit	EGD	@ 0xAB;
static 		bit	EGE	@ 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;

//Interrupt Priority
static 		bit	PGA	@ 0xB8;
static 		bit	PGB	@ 0xB9;
static 		bit	PGC	@ 0xBA;
static 		bit	PGD	@ 0xBB;
static 		bit	PGE	@ 0xBC;

//Port 4
static volatile bit	P40	@ 0xC0;
static volatile bit	P41	@ 0xC1;
static volatile bit	P42	@ 0xC2;
static volatile bit	P43	@ 0xC3;
static volatile bit	P44	@ 0xC4;
static volatile bit	P45	@ 0xC5;
static volatile bit	P46	@ 0xC6;
static volatile bit	P47	@ 0xC7;

//Port 5 P5
static volatile bit	P50	@ 0xC8;
static volatile bit	P51	@ 0xC9;
static volatile bit	P52	@ 0xCA;
static volatile bit	P53	@ 0xCB;
static volatile bit	P54	@ 0xCC;
static volatile bit	P55	@ 0xCD;
static volatile bit	P56	@ 0xCE;
static volatile bit	P57	@ 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;

// Interrupt Request Register 0 INT0
static volatile bit	IRQ0F	@ 0xD8;
static volatile bit	IRQ1F	@ 0xD9;
static volatile bit	IRQ2F	@ 0xDA;
static volatile bit	IRQ3F	@ 0xDB;
static volatile bit	IRQ4F	@ 0xDC;
static volatile bit	IRQ5F	@ 0xDD;

//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 Request Register 1 INT1
static volatile bit	LOCKINT	@ 0xE8;
static volatile bit	WINT	@ 0xE9;
static volatile bit	TBINT	@ 0xEA;
static volatile bit	PT1INT	@ 0xEB;
static volatile bit	PT2INT	@ 0xEC;
static volatile bit	PT3INT	@ 0xED;
static volatile bit	ECT1INT	@ 0xEE;
static volatile bit	ECT2INT	@ 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 Request Register 2 INT2
static volatile bit	ADINT	@ 0xF8;
static volatile bit	S1INT	@ 0xF9;
static volatile bit	S2INT	@ 0xFC;


//Interrupt Vectors
#define	RESET	0
#define	GROUPA	0x03
#define GROUPB	0x0B
#define	GROUPC	0x13
#define	GROUPD	0x1B
#define	GROUPE	0x23

#endif
