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

/* This is a header file for the Trumpion Microcontroller
	T33520
	
	*** Note that the 64_128M bit (FLCTR.1) is renamed to M64_128 ***
 */

#ifndef __T33520_H
#define __T33520_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 P0CFGA	@ 0x84;
static		unsigned char P0CFGB	@ 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		unsigned char MUTICON3	@ 0x8F;
static volatile unsigned char P1	@ 0x90;
static volatile unsigned char I2SCTRL	@ 0x91;
static		unsigned char I2SFREQ	@ 0x92;
static volatile unsigned char SCON	@ 0x97;
static volatile unsigned char FLCTR	@ 0x98;
static volatile unsigned char SBUF	@ 0x99;
static		unsigned char P1CFGA	@ 0x9E;
static		unsigned char P1CFGB	@ 0x9F;
static volatile unsigned char P2	@ 0xA0;
static		unsigned char P2CFGA	@ 0xA4;
static		unsigned char P2CFGB	@ 0xA5;
static		unsigned char IE	@ 0xA8;
static volatile unsigned char USBIINT	@ 0xA9;
static volatile unsigned char USBIBULK	@ 0xAA;
static volatile unsigned char USBICR	@ 0xAB;
static volatile unsigned char USBICRD1	@ 0xAC;
static volatile unsigned char USBICRD2	@ 0xAD;
static volatile unsigned char USBICRD3	@ 0xAE;
static volatile unsigned char USBICRD4	@ 0xAF;
static volatile unsigned char P3	@ 0xB0;
static volatile unsigned char MUTICON2	@ 0xB1;
static volatile unsigned char PRT_DATA_IN @ 0xB2;
static		unsigned char IP	@ 0xB8;
static volatile unsigned char USBICRD5	@ 0xB9;
static volatile unsigned char USBICRD6	@ 0xBA;
static volatile unsigned char USBICRD7	@ 0xBB;
static volatile unsigned char USBICRD8	@ 0xBC;
static		unsigned char USBICMD	@ 0xBD;
static		unsigned char P3CFGA	@ 0xBE;
static		unsigned char P3CFGB	@ 0xBF;
static volatile unsigned char CFCTR	@ 0xC0;
static volatile unsigned char USBICX	@ 0xC1;
static volatile unsigned char USBIVID1	@ 0xC2;
static volatile unsigned char USBIVID2	@ 0xC3;
static volatile unsigned char USBIPID1	@ 0xC4;
static volatile unsigned char USBIPID2	@ 0xC5;
static volatile unsigned char USBIDIV1	@ 0xC6;
static volatile unsigned char USBIDIV2	@ 0xC7;
static volatile unsigned char SBCTL	@ 0xC8;
static volatile unsigned char PSW	@ 0xD0;
static volatile	unsigned char CFFERR	@ 0xD1;
static volatile unsigned char CFSC	@ 0xD2;
static volatile unsigned char CFSN	@ 0xD3;
static volatile unsigned char CFCYL	@ 0xD4;
static volatile unsigned char CFCYH	@ 0xD5;
static volatile unsigned char CFDRH	@ 0xD6;
static volatile unsigned char CFCMDS	@ 0xD7;
static volatile unsigned char CFRTS	@ 0xD8;
static volatile unsigned char CFDEVS	@ 0xD9;
// alternate functions
static volatile	unsigned char FLMKC	@ 0xD1;
static volatile unsigned char FLDVC	@ 0xD2;
static volatile unsigned char FLSTS	@ 0xD3;
static volatile unsigned char FLCMD	@ 0xD4;
static volatile unsigned char FLA0	@ 0xD5;
static volatile unsigned char FLA1	@ 0xD6;
static volatile unsigned char FLA2	@ 0xD7;
static volatile unsigned char FLTRG	@ 0xD8;
static volatile unsigned char FLA3	@ 0xD9;
static volatile unsigned char CFDAT	@ 0xDA;
static		unsigned char CFATAPI	@ 0xDB;
static volatile unsigned char ACC	@ 0xE0;
static volatile unsigned char P4	@ 0xE1;
static		unsigned char MMCACMD	@ 0xE5;
static volatile unsigned char MCADAT	@ 0xE6;
static volatile unsigned char MMCATRG	@ 0xE7;
static volatile unsigned char MCACTR	@ 0xE8;
static		unsigned char USBIISC	@ 0xE9;
static volatile unsigned char USBIGEN	@ 0xEA;
static		unsigned char USBIINTR	@ 0xEB;
static		unsigned char USBIPWR	@ 0xEC;
static volatile unsigned char USBIMPW	@ 0xED;
static		unsigned char P4CFGA	@ 0xEE;
static		unsigned char P4CFGB	@ 0xEF;
static volatile unsigned char B		@ 0xF0;
static volatile unsigned char P5	@ 0xF1;
static		unsigned char P5CFGA	@ 0xF4;
static		unsigned char P5CFGB	@ 0xF5;
static		unsigned char SB1ENDPTR	@ 0xF6;
static		unsigned char SB2ENDPTR	@ 0xF7;
static		unsigned char SBADHPTR	@ 0xF8;
static volatile unsigned char SBDATA	@ 0xF9;
static		unsigned char XRAMP	@ 0xFA;
static		unsigned char DMA_SBPTR	@ 0xFB;
static		unsigned char C51_SBPTR	@ 0xFC;
static volatile unsigned char MUTICON1	@ 0xFD;
static		unsigned char WDT	@ 0xFF;

static volatile SFR_BITS P0_BITS		@ 0x80;
static		SFR_BITS P0CFGA_BITS		@ 0x84;
static		SFR_BITS P0CFGB_BITS		@ 0x86;
static volatile SFR_BITS PCON_BITS		@ 0x87;
static volatile SFR_BITS TCON_BITS		@ 0x88;
static		SFR_BITS TMOD_BITS		@ 0x89;
static		SFR_BITS MUTICON3_BITS		@ 0x8F;
static volatile SFR_BITS P1_BITS		@ 0x90;
static volatile SFR_BITS I2SCTRL_BITS		@ 0x91;
static volatile SFR_BITS SCON_BITS		@ 0x97;
static volatile SFR_BITS FLCTR_BITS		@ 0x98;
static		SFR_BITS P1CFGA_BITS		@ 0x9E;
static		SFR_BITS P1CFGB_BITS		@ 0x9F;
static volatile SFR_BITS P2_BITS		@ 0xA0;
static		SFR_BITS P2CFGA_BITS		@ 0xA4;
static		SFR_BITS P2CFGB_BITS		@ 0xA5;
static		SFR_BITS IE_BITS		@ 0xA8;
static volatile SFR_BITS USBIINT_BITS		@ 0xA9;
static volatile SFR_BITS USBIBULK_BITS		@ 0xAA;
static volatile SFR_BITS P3_BITS		@ 0xB0;
static volatile SFR_BITS MUTICON2_BITS		@ 0xB1;
static		SFR_BITS IP_BITS		@ 0xB8;
static		SFR_BITS P3CFGA_BITS		@ 0xBE;
static		SFR_BITS P3CFGB_BITS		@ 0xBF;
static volatile SFR_BITS CFCTR_BITS		@ 0xC0;
static volatile SFR_BITS USBICX_BITS		@ 0xC1;
static volatile SFR_BITS USBIVID1_BITS		@ 0xC2;
static volatile SFR_BITS USBIVID2_BITS		@ 0xC3;
static volatile SFR_BITS USBIPID1_BITS		@ 0xC4;
static volatile SFR_BITS USBIPID2_BITS		@ 0xC5;
static volatile SFR_BITS USBIDIV1_BITS		@ 0xC6;
static volatile SFR_BITS USBIDIV2_BITS		@ 0xC7;
static volatile SFR_BITS SBCTL_BITS		@ 0xC8;
static volatile SFR_BITS PSW_BITS		@ 0xD0;
static volatile SFR_BITS CFFERR_BITS		@ 0xD1;
static volatile SFR_BITS CFSN_BITS		@ 0xD3;
static volatile SFR_BITS CFCYL_BITS		@ 0xD4;
static volatile SFR_BITS CFCYH_BITS		@ 0xD5;
static volatile SFR_BITS CFDRH_BITS		@ 0xD6;
static volatile SFR_BITS CFCMDS_BITS		@ 0xD7;
static volatile SFR_BITS CFRTS_BITS		@ 0xD8;
static volatile SFR_BITS CFDEVS_BITS		@ 0xD9;
static volatile SFR_BITS FLMKC_BITS		@ 0xD1;
static volatile SFR_BITS FLDVC_BITS		@ 0xD2;
static volatile SFR_BITS FLSTS_BITS		@ 0xD3;
static volatile SFR_BITS FLCMD_BITS		@ 0xD4;
static volatile SFR_BITS FLA0_BITS		@ 0xD5;
static volatile SFR_BITS FLA1_BITS		@ 0xD6;
static volatile SFR_BITS FLA2_BITS		@ 0xD7;
static volatile SFR_BITS FLTRG_BITS		@ 0xD8;
static volatile SFR_BITS FLA3_BITS		@ 0xD9;
static		SFR_BITS CFATAPI_BITS		@ 0xDB;
static volatile SFR_BITS ACC_BITS		@ 0xE0;
static volatile SFR_BITS P4_BITS		@ 0xE1;
static volatile SFR_BITS MCACTR_BITS		@ 0xE8;
static		SFR_BITS USBIISC_BITS		@ 0xE9;
static volatile SFR_BITS USBIGEN_BITS		@ 0xEA;
static		SFR_BITS USBIPWR_BITS		@ 0xEC;
static		SFR_BITS P4CFGA_BITS		@ 0xEE;
static		SFR_BITS P4CFGB_BITS		@ 0xEF;
static volatile SFR_BITS B_BITS			@ 0xF0;
static volatile SFR_BITS P5_BITS		@ 0xF1;
static		SFR_BITS P5CFGA_BITS		@ 0xF4;
static		SFR_BITS P5CFGB_BITS		@ 0xF5;
static		SFR_BITS XRAMP_BITS		@ 0xFA;
static volatile SFR_BITS MUTICON1_BITS		@ 0xFD;

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

//SmartMedia Control Register FLCTR
static volatile bit	R_B	@ 0x98;
static		bit	M64_128	@ 0x99;
static		bit	ERASE	@ 0x9A;
static volatile bit	ECC_DONE @ 0x9B;
static		bit	SDATA8	@ 0x9C;
static		bit	FLWP	@ 0x9D;
static		bit	FLCE	@ 0x9E;
static volatile bit	IRST	@ 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	INT0	@ 0xA8;
static		bit	T0	@ 0xA9;
static		bit	INT1	@ 0xAA;
static		bit	T1	@ 0xAB;
static 		bit	CF_INT	@ 0xAC;
static 		bit	MMCA_INT @ 0xAD;
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	PX0	@ 0xB8;
static 		bit	PT0	@ 0xB9;
static 		bit	PX1	@ 0xBA;
static 		bit	PT1	@ 0xBB;
static 		bit	PCF	@ 0xBC;
static 		bit	PMMCA	@ 0xBD;

//IDE Control Register CFCTR
static volatile bit	CFCTR0	@ 0xC0;
static volatile bit	CFCTR1	@ 0xC1;
static volatile bit	CFCTR2	@ 0xC2;
static volatile bit	CFCTR3	@ 0xC3;
static		bit	CFCTR4	@ 0xC4;
static volatile bit	CFCTR5	@ 0xC5;
static volatile bit	CFCTR6	@ 0xC6;
static volatile bit	CFCTR7	@ 0xC7;

//MMU Control Port SBCTL
static volatile bit	SBCTL0	@ 0xC8;
static volatile bit	SBCTL1	@ 0xC9;
static volatile bit	SBCTL2	@ 0xCA;
static		bit	SBCTL3	@ 0xCB;
static volatile bit	SBCTL4	@ 0xCC;
static volatile bit	SBCTL5	@ 0xCD;
static volatile bit	SBCTL6	@ 0xCE;

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

//Transactio Strat Register CFRTS
static volatile bit	CFRTS0	@ 0xD8;
static volatile bit	CFRTS1	@ 0xD9;
static volatile bit	CFRTS2	@ 0xDA;
static volatile bit	CFRTS3	@ 0xDB;
static volatile bit	CFRTS4	@ 0xDC;
static volatile bit	CFRTS5	@ 0xDD;
static volatile bit	CFRTS6	@ 0xDE;
static volatile bit	CFRTS7	@ 0xDF;

//Flash Auto-Function Trigger Register FLTRG
static		bit	S_RDID	@ 0xD8;
static		bit	S_RDST	@ 0xD9;
static		bit	S_FCMD	@ 0xDA;
static		bit	EVEN_ODD @ 0xDB;
static		bit	S_FACMD	@ 0xDC;
static		bit	S_FDAT	@ 0xDD;
static		bit	ECC_EN	@ 0xDE;
static		bit	DDIR	@ 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;

//MMC Adapter Control Register MCACTR
static		bit	MCA_CSN	@ 0xE8;
static		bit	MCA_CD	@ 0xE9;
static 		bit	MCA_RW	@ 0xEA;
static volatile bit	MCA_STBN @ 0xEB;
static volatile bit	MCA_ACKN @ 0xEC;
static volatile bit	MCA_IRQ	@ 0xED;
static volatile bit	MCA_RDY	@ 0xEE;
static volatile bit	MCA_RD	@ 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 Vectors
#define	RESET	0
#define	EXTINT0	0x03
#define TIMER0	0x0B
#define	EXTINT1	0x13
#define	TIMER1	0x1B
#define	CF	0x23
#define	MMCA	0x2B
#define	FREE	0x33

#endif
