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


 /* header file for the Emosyn THESIUS(R) microcontrollers
	PLATINUM130
 */

#ifndef	__PLATNM130_H

#define	__PLATNM130_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 volatile unsigned char SCON	@ 0x98;
static volatile unsigned char SBUF	@ 0x99;
static		unsigned char CBSL	@ 0xA1;
static volatile unsigned char SECSTA	@ 0xB0;
static volatile unsigned char ISOCON	@ 0xB2;
static		unsigned char ISOTMR	@ 0xB4;
static volatile unsigned char PROGIO	@ 0xC0;
static volatile unsigned char PSW	@ 0xD0;
static		unsigned char SPSW	@ 0xD8;
static volatile unsigned char ACC	@ 0xE0;
static volatile unsigned char B		@ 0xF0;
static volatile unsigned char MMUSTA	@ 0xF7;

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	 SCON_BITS	@ 0x98;
static		SFR_BITS	 CBSL_BITS	@ 0xA1;
static volatile SFR_BITS	 SECSTA_BITS	@ 0xB0;
static volatile SFR_BITS	 ISOCON_BITS	@ 0xB2;
static volatile SFR_BITS	 PROGIO_BITS	@ 0xC0;
static volatile SFR_BITS	 PSW_BITS	@ 0xD0;
static		SFR_BITS	 SPSW_BITS	@ 0xD8;
static volatile SFR_BITS	 ACC_BITS	@ 0xE0;
static volatile SFR_BITS	 B_BITS		@ 0xF0;
static volatile SFR_BITS	 MMUSTA_BITS	@ 0xF7;


// Bit Addressable Locations
// Timer Control TCON
static volatile bit	SINT	@ 0x89;
static volatile bit	MFLT	@ 0x8B;
static 		bit	TR0	@ 0x8C;
static volatile bit	TF0	@ 0x8D;
static 		bit	TR1	@ 0x8E;
static volatile bit	TF1	@ 0x8F;

// Serial Control SCON
static volatile bit	RI	@ 0x98;
static volatile bit	TI	@ 0x99;

// definitions for register SECSTA
static volatile bit	OVVOLT	@ 0xB0;
static volatile bit	UNVOLT	@ 0xB1;
static volatile bit	UVDET	@ 0xB2;
static volatile bit	UNFREQ	@ 0xB3;
static volatile bit	TEMPER	@ 0xB4;
static volatile bit	MEMVIO	@ 0xB5;
static volatile bit	PFLT	@ 0xB7;

// definitions for register PROGIO
static		bit	CLKWRE	@ 0xC0;
static volatile bit	CLKWRT	@ 0xC1;
static		bit	DATWRE	@ 0xC2;
static volatile bit	DATWRT	@ 0xC3;
static volatile bit	CLKRD	@ 0xC4;
static volatile bit	DATRD	@ 0xC5;

// Program Status Word PSW
static volatile bit	P	@ 0xD0;
static		bit	M	@ 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;

// definitions for register SPSW
static		bit	SM	@ 0xD9;

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

// 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 Vectors
#define	RESET	0
#define	SWI	0x03
#define TIMER0	0x0B
#define	MEMORY	0x13
#define	TIMER1	0x1B
#define	SERIAL	0x23
#define	PHYSICAL 0x2B

#endif
